From patchwork Thu Oct 6 15:49:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 77310 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp45410qge; Thu, 6 Oct 2016 08:51:01 -0700 (PDT) X-Received: by 10.66.26.49 with SMTP id i17mr22705113pag.145.1475769060962; Thu, 06 Oct 2016 08:51:00 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cw3si12271662pad.246.2016.10.06.08.51.00; Thu, 06 Oct 2016 08:51:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964814AbcJFPuy (ORCPT + 27 others); Thu, 6 Oct 2016 11:50:54 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:38284 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755763AbcJFPul (ORCPT ); Thu, 6 Oct 2016 11:50:41 -0400 Received: by mail-wm0-f48.google.com with SMTP id i130so12588498wmg.1 for ; Thu, 06 Oct 2016 08:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Qiy7cIKSwgmNypjd8Xi59gpmLg/1EGmJPouO8Te2wSw=; b=inW4fMMpIUwH6FPG0FVgvKg6F48RNEKXdximxis2sRVBCr7nXCkU9mEXIDZEzZAV8J 8yImn0zpb8STch4W6fl3CIQwIKdfqndKXqTf7Gw25VHtcEwQyVrAfG3qtUzxbAOd9cpo qf3zj1FEctkGL+QbI8t8fF5GzmtX1gfly1HEY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Qiy7cIKSwgmNypjd8Xi59gpmLg/1EGmJPouO8Te2wSw=; b=AQpSWoH15LeR5FvjhJovuMaUHvDMeW5mwzIXeGCNUpuycA+qlls6qDtmGbktIG2CP5 ju6dpRk5mSkrf0HWMdjzjCRW4Sx6V+9gZcUdmn5B6oujzSk8GC6riA+9cFfA/Zn5GJln 6jRRp/qPsF9yxQa3Dgedl17j7AabAAUlPz+9V2cJiU34sTvUJY5kMDbIkoNpjTgq5plf p9A+KFSfiVG+e4sELkpi/cQFxF06t7ZCoVxsTdvZdYmPkBlwR5tedXNiecE7vxxjZzLm a/Xk4W+RxUwytzK8ckQY3NQH0P560yuxxNZ0fJ3iSs2OkNKI6AriyjWtnJrRlSU9Gx90 d/YQ== X-Gm-Message-State: AA6/9RmkdN+TjgHZJQa15Re2wVawF/RHz5/T9fQPa082YamaFiZSg4eZMv/9AdATP9SR3dJP X-Received: by 10.194.192.195 with SMTP id hi3mr12384708wjc.108.1475768983830; Thu, 06 Oct 2016 08:49:43 -0700 (PDT) Received: from localhost.localdomain ([197.128.55.6]) by smtp.gmail.com with ESMTPSA id x124sm36001176wmf.22.2016.10.06.08.49.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Oct 2016 08:49:43 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: airlied@linux.ie, bskeggs@redhat.com, gnurou@gmail.com, Ard Biesheuvel Subject: [PATCH v5 3/3] drm/nouveau/fb/nv50: defer DMA mapping of scratch page to oneinit() hook Date: Thu, 6 Oct 2016 16:49:30 +0100 Message-Id: <1475768970-32512-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1475768970-32512-1-git-send-email-ard.biesheuvel@linaro.org> References: <1475768970-32512-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The 100c08 scratch page is mapped using dma_map_page() before the TTM layer has had a chance to set the DMA mask. This means we are still running with the default of 32 when this code executes, and this causes problems for platforms with no memory below 4 GB (such as AMD Seattle) So move the dma_map_page() to the .oneinit hook, which executes after the DMA mask has been set. Signed-off-by: Ard Biesheuvel --- drivers/gpu/drm/nouveau/nvkm/subdev/fb/nv50.c | 33 ++++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) -- 2.7.4 diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/nv50.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/nv50.c index 1b5fb02eab2a..d9bc4d11f145 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/nv50.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/nv50.c @@ -210,6 +210,28 @@ nv50_fb_intr(struct nvkm_fb *base) nvkm_fifo_chan_put(fifo, flags, &chan); } +static int +nv50_fb_oneinit(struct nvkm_fb *base) +{ + struct nv50_fb *fb = nv50_fb(base); + + fb->r100c08_page = alloc_page(GFP_KERNEL | __GFP_ZERO); + if (!fb->r100c08_page) { + nvkm_error(&fb->base.subdev, "failed 100c08 page alloc\n"); + return -ENOMEM; + } + + fb->r100c08 = dma_map_page(device->dev, fb->r100c08_page, 0, PAGE_SIZE, + DMA_BIDIRECTIONAL); + if (dma_mapping_error(device->dev, fb->r100c08)) { + nvkm_error(&fb->base.subdev, "failed to map 100c08 page\n"); + __free_page(fb->r100c08_page); + return -EFAULT; + } + + return 0; +} + static void nv50_fb_init(struct nvkm_fb *base) { @@ -245,6 +267,7 @@ nv50_fb_dtor(struct nvkm_fb *base) static const struct nvkm_fb_func nv50_fb_ = { .dtor = nv50_fb_dtor, + .oneinit = nv50_fb_oneinit, .init = nv50_fb_init, .intr = nv50_fb_intr, .ram_new = nv50_fb_ram_new, @@ -263,16 +286,6 @@ nv50_fb_new_(const struct nv50_fb_func *func, struct nvkm_device *device, fb->func = func; *pfb = &fb->base; - fb->r100c08_page = alloc_page(GFP_KERNEL | __GFP_ZERO); - if (fb->r100c08_page) { - fb->r100c08 = dma_map_page(device->dev, fb->r100c08_page, 0, - PAGE_SIZE, DMA_BIDIRECTIONAL); - if (dma_mapping_error(device->dev, fb->r100c08)) - return -EFAULT; - } else { - nvkm_warn(&fb->base.subdev, "failed 100c08 page alloc\n"); - } - return 0; }