From patchwork Thu Oct 6 15:49:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9365533 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 605E96077E for ; Fri, 7 Oct 2016 00:12:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51F2C2926A for ; Fri, 7 Oct 2016 00:12:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 469032927F; Fri, 7 Oct 2016 00:12:11 +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 C20C72926A for ; Fri, 7 Oct 2016 00:12:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9DB686EAB3; Fri, 7 Oct 2016 00:11:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com [IPv6:2a00:1450:400c:c09::22f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5A1736EA04 for ; Thu, 6 Oct 2016 15:49:43 +0000 (UTC) Received: by mail-wm0-x22f.google.com with SMTP id f193so298196586wmg.0 for ; Thu, 06 Oct 2016 08:49:43 -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=pPShHL+A6D5U6d8F1WH4VDQC5nZgiC4H1tHYtrgqQ9E=; b=GqjQR5FkjEfdicddmDm95LnPv+n3jbs2absUffQJptMXuqnuC6j6KlcHmbFNR4kZ0W m0k72MjGTK0sSDMTZjijJJPMZ3K6TZd39vW1vG0Zo90Hoa7KqGYijNtPgSwMXvXhgjem vTrtypvUeCWo8r7juvGCfSrQQ7e9kbRlNpD3o= 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=pPShHL+A6D5U6d8F1WH4VDQC5nZgiC4H1tHYtrgqQ9E=; b=e/UEoOsmQ+dgdLZ3JytPQjmMRZ6TE4MK7W+0ReY5l2I1vFW2PQHqfEF6XnIYbox7XA y4GMr1eq0R+023sxdyIiS1gNHNj7vJF6B2jwK2YT2yIyunPriB+sZdNizze30xBtLMbi Ui2iI9nLImOOBi4tB+KCyZmjhjgLJtiCr1Nsq9kPslY4paCQHIGrARitLEr0vyz8h7om 0/iW8eU485JLFNpd8B0twJMUjUToO+B6B1PBlmIE1pe+lCa4RHmIA4Rj+/bGHoGoSs1B teWM/2ATBxeMAEspRitZw9LhCxZznPWa8Jcxibd4Lzbtj84FQTNrrzKGeUyOp0jR0Yp2 U3Yg== X-Gm-Message-State: AA6/9RmpMm0eWbNqkKQx7Zof9RPbecY2KS6O5+eGewHOFnYC1RFOuAuP+a56Y5y1t575EIS/ X-Received: by 10.194.95.105 with SMTP id dj9mr14577123wjb.20.1475768981868; Thu, 06 Oct 2016 08:49:41 -0700 (PDT) Received: from localhost.localdomain ([197.128.55.6]) by smtp.gmail.com with ESMTPSA id x124sm36001176wmf.22.2016.10.06.08.49.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Oct 2016 08:49:41 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH v5 2/3] drm/nouveau/fb/gf100: defer DMA mapping of scratch page to oneinit() hook Date: Thu, 6 Oct 2016 16:49:29 +0100 Message-Id: <1475768970-32512-3-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 100c10 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/gf100.c | 31 ++++++++++++-------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gf100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gf100.c index 76433cc66fff..c1995c0024ef 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gf100.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/gf100.c @@ -50,24 +50,39 @@ gf100_fb_intr(struct nvkm_fb *base) } int -gf100_fb_oneinit(struct nvkm_fb *fb) +gf100_fb_oneinit(struct nvkm_fb *base) { - struct nvkm_device *device = fb->subdev.device; + struct gf100_fb *fb = gf100_fb(base); + struct nvkm_device *device = fb->base.subdev.device; int ret, size = 0x1000; size = nvkm_longopt(device->cfgopt, "MmuDebugBufferSize", size); size = min(size, 0x1000); ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST, size, 0x1000, - false, &fb->mmu_rd); + false, &base->mmu_rd); if (ret) return ret; ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST, size, 0x1000, - false, &fb->mmu_wr); + false, &base->mmu_wr); if (ret) return ret; + fb->r100c10_page = alloc_page(GFP_KERNEL | __GFP_ZERO); + if (!fb->r100c10_page) { + nvkm_error(&fb->base.subdev, "failed 100c10 page alloc\n"); + return -ENOMEM; + } + + fb->r100c10 = dma_map_page(device->dev, fb->r100c10_page, 0, PAGE_SIZE, + DMA_BIDIRECTIONAL); + if (dma_mapping_error(device->dev, fb->r100c10)) { + nvkm_error(&fb->base.subdev, "failed to map 100c10 page\n"); + __free_page(fb->r100c10_page); + return -EFAULT; + } + return 0; } @@ -123,14 +138,6 @@ gf100_fb_new_(const struct nvkm_fb_func *func, struct nvkm_device *device, nvkm_fb_ctor(func, device, index, &fb->base); *pfb = &fb->base; - fb->r100c10_page = alloc_page(GFP_KERNEL | __GFP_ZERO); - if (fb->r100c10_page) { - fb->r100c10 = dma_map_page(device->dev, fb->r100c10_page, 0, - PAGE_SIZE, DMA_BIDIRECTIONAL); - if (dma_mapping_error(device->dev, fb->r100c10)) - return -EFAULT; - } - return 0; }