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: 9365543 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 651016077E for ; Fri, 7 Oct 2016 00:12:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54E4D2926A for ; Fri, 7 Oct 2016 00:12:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 495792927F; Fri, 7 Oct 2016 00:12:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 27E6429278 for ; Fri, 7 Oct 2016 00:12:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 294106EAB9; Fri, 7 Oct 2016 00:12:03 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x22d.google.com (mail-wm0-x22d.google.com [IPv6:2a00:1450:400c:c09::22d]) by gabe.freedesktop.org (Postfix) with ESMTPS id 52C6C6EA06 for ; Thu, 6 Oct 2016 15:49:45 +0000 (UTC) Received: by mail-wm0-x22d.google.com with SMTP id f193so298198333wmg.0 for ; Thu, 06 Oct 2016 08:49:45 -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=aaITaZCmtrzmbgW/sbtkHxx9u9SaOQ3CnEyTFUkyocgdZ6ytwoK0JBo7Fwyr53Folu qhRzD8vwDoDWVn53xUACQBgvwz+lxt/6OyNvrWC9BQR0ThQ+b4tbJwU6oBFTdp0zh2af Ayo5iJjfKLPrfbMjToDr7gfEgr4KwQSwIyzeufAxWjkkd79yORSO4uYzPbbyEL1q6ZPG XuFqS9x0FhBhqqld28otps6dY98u3PuQR7SUkKvV8W2Eom0Bz1fxkxGUxiphxinrCItX 9sHwYXXIQ4sEE2NeDW+mgKjVNSWv8SmlF+xjm9fwx8b3SraVmx2b4WMIiXpsemn7ob9s jIWQ== X-Gm-Message-State: AA6/9RnHVC7eYskYaeUgLuBXyevYlJAoV+67DkhI4kSdGwY0MAFXQy56xJq1IzJQDV1CWfRR 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 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> X-Mailman-Approved-At: Fri, 07 Oct 2016 00:11:52 +0000 Cc: gnurou@gmail.com, bskeggs@redhat.com, Ard Biesheuvel X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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; }