From patchwork Sat Dec 7 16:42:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilia Mirkin X-Patchwork-Id: 3305111 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 753D69F37A for ; Sat, 7 Dec 2013 16:42:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4615A2034A for ; Sat, 7 Dec 2013 16:42:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 36FDD202B4 for ; Sat, 7 Dec 2013 16:42:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B7152FA9C2; Sat, 7 Dec 2013 08:42:42 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qe0-f46.google.com (mail-qe0-f46.google.com [209.85.128.46]) by gabe.freedesktop.org (Postfix) with ESMTP id 0E1E1FA9C2; Sat, 7 Dec 2013 08:42:40 -0800 (PST) Received: by mail-qe0-f46.google.com with SMTP id a11so1489112qen.5 for ; Sat, 07 Dec 2013 08:42:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=kmd9y8knQVXlS2SwteAVR+qlv6LYlbzFWAd921dNkZ4=; b=0o4YqspNw/vlRruG/r9yBYJaUmxzjbq98YdQeiKd5ClmvtCAdlvU7512sv9pbVGT9z MLkzsWHm2cY4jFgBR0uxDcQM9tWIuPbUT/jDRppHiAojoFW7DN2keFt9wwPl7kX6/D7C SFZt9qP7hrNS1fjrIa+fcPKcjgfs9Yqi2scsBU1PsHBiV0IC6OGbmK2CqJY6Cg3ypIfv yIdZQ70yzc5RLbQEGrk+PQVltYbep7W0oO2rCRgba0uxlaU2lHKiwRIc6QlaMEzcU1nH 2BqqAiR5DHiK+hwBBtp+iQtv2TNIGejeThbLp/Mj2Zdt+GrdmR9yC+Be/cHM1HcgOy6U O1oA== X-Received: by 10.49.94.212 with SMTP id de20mr25426647qeb.51.1386434559472; Sat, 07 Dec 2013 08:42:39 -0800 (PST) Received: from localhost.localdomain (cpe-74-71-31-84.nyc.res.rr.com. [74.71.31.84]) by mx.google.com with ESMTPSA id a5sm7780671qae.2.2013.12.07.08.42.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 07 Dec 2013 08:42:39 -0800 (PST) From: Ilia Mirkin To: Ben Skeggs Subject: [PATCH] drm/nouveau/falcon: use vmalloc to create firwmare copies Date: Sat, 7 Dec 2013 11:42:19 -0500 Message-Id: <1386434539-29188-1-git-send-email-imirkin@alum.mit.edu> X-Mailer: git-send-email 1.8.3.2 Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some firmware images may be large (64K), so using kmalloc memory is inappropriate for them. Use vmalloc instead, to avoid high-order allocation failures. Signed-off-by: Ilia Mirkin Cc: stable@vger.kernel.org --- Couldn't get video decoding started on a long-running system due to high-order allocation failures. This seems like a fine use-case for vmalloc. drivers/gpu/drm/nouveau/core/engine/falcon.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/nouveau/core/engine/falcon.c b/drivers/gpu/drm/nouveau/core/engine/falcon.c index e03fc8e..5e077e4 100644 --- a/drivers/gpu/drm/nouveau/core/engine/falcon.c +++ b/drivers/gpu/drm/nouveau/core/engine/falcon.c @@ -56,6 +56,16 @@ _nouveau_falcon_wr32(struct nouveau_object *object, u64 addr, u32 data) nv_wr32(falcon, falcon->addr + addr, data); } +static void * +vmemdup(const void *src, size_t len) +{ + void *p = vmalloc(len); + + if (p) + memcpy(p, src, len); + return p; +} + int _nouveau_falcon_init(struct nouveau_object *object) { @@ -111,7 +121,7 @@ _nouveau_falcon_init(struct nouveau_object *object) ret = request_firmware(&fw, name, &device->pdev->dev); if (ret == 0) { - falcon->code.data = kmemdup(fw->data, fw->size, GFP_KERNEL); + falcon->code.data = vmemdup(fw->data, fw->size); falcon->code.size = fw->size; falcon->data.data = NULL; falcon->data.size = 0; @@ -134,7 +144,7 @@ _nouveau_falcon_init(struct nouveau_object *object) return ret; } - falcon->data.data = kmemdup(fw->data, fw->size, GFP_KERNEL); + falcon->data.data = vmemdup(fw->data, fw->size); falcon->data.size = fw->size; release_firmware(fw); if (!falcon->data.data) @@ -149,7 +159,7 @@ _nouveau_falcon_init(struct nouveau_object *object) return ret; } - falcon->code.data = kmemdup(fw->data, fw->size, GFP_KERNEL); + falcon->code.data = vmemdup(fw->data, fw->size); falcon->code.size = fw->size; release_firmware(fw); if (!falcon->code.data) @@ -235,8 +245,8 @@ _nouveau_falcon_fini(struct nouveau_object *object, bool suspend) if (!suspend) { nouveau_gpuobj_ref(NULL, &falcon->core); if (falcon->external) { - kfree(falcon->data.data); - kfree(falcon->code.data); + vfree(falcon->data.data); + vfree(falcon->code.data); falcon->code.data = NULL; } }