From patchwork Mon Sep 26 12:32:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9350813 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 AB57F6077A for ; Mon, 26 Sep 2016 15:02:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A63028B02 for ; Mon, 26 Sep 2016 15:02:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DA0D28B14; Mon, 26 Sep 2016 15:02:38 +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 2CA1728B02 for ; Mon, 26 Sep 2016 15:02:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 96BA06E50B; Mon, 26 Sep 2016 15:02:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-x230.google.com (mail-pa0-x230.google.com [IPv6:2607:f8b0:400e:c03::230]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7748D6E4B9 for ; Mon, 26 Sep 2016 12:32:51 +0000 (UTC) Received: by mail-pa0-x230.google.com with SMTP id qn7so45277467pac.3 for ; Mon, 26 Sep 2016 05:32:51 -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=uHOk9XtoxPoEtKQ0yEz5lBCJr0sU4QURv6Kg+7TquCg=; b=DiQUDOG0f0yPdsg5RQBdwlJCl5igyFakBjPEffh+DRrsKlNyO4ZGi5QAEyRQdEcl3y 9i2Lcrp0SB+Kep2QZ8cJrICfp0hiVMkLvpI5H9/dxWePURg6zo3Falo+BDVdo7OXBfrt PeKZ6GqJRN6y3y693R4dYK+4cDwltTin9kg4k= 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=uHOk9XtoxPoEtKQ0yEz5lBCJr0sU4QURv6Kg+7TquCg=; b=Uv/6I9IMcWt91C1Z5w5Um7PFIEF9/P/UcwTHTshMzreygk75svgx0xjFb7bCZqvxNq Gdx+CrxQK3YBrpCJMFUphYQnKGYMGPbM1pdpqfY2rZeBXeUaCDAqobKCtvdpNuibao1K Fm2gn43NWMnZ8YLvU1SoiMHOkD1iuOEKHHEDD8MaBhvmNgWARUDi3NSeILrbJQZSOrVP Y6dl1PhbLosvk7by30jNhBg1T1dBfkiCWZ2nJjMeORbgQmfn4pKUQXFZHqOaoRWz26t5 6NuKdHSvz3J+xypuCPwnuIw1AIw0Bjz+QWh0c7+TfyAip5KHHXwLZkh7XdJU/e/I7g96 vsvg== X-Gm-Message-State: AE9vXwNVh0Gk52MreZ5v6+6RQnkirGXb+ac+NaT27TqALHoDVyqrCylFfYs+sFfbDhYO5qR4 X-Received: by 10.66.246.227 with SMTP id xz3mr37575307pac.24.1474893171006; Mon, 26 Sep 2016 05:32:51 -0700 (PDT) Received: from localhost.localdomain ([67.238.99.186]) by smtp.gmail.com with ESMTPSA id c15sm10893809pfl.25.2016.09.26.05.32.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Sep 2016 05:32:50 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, bskeggs@redhat.com, airlied@linux.ie, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org Subject: [PATCH v4 3/3] drm/nouveau/fb/nv50: defer DMA mapping of scratch page to init() hook Date: Mon, 26 Sep 2016 05:32:40 -0700 Message-Id: <1474893160-12321-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474893160-12321-1-git-send-email-ard.biesheuvel@linaro.org> References: <1474893160-12321-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailman-Approved-At: Mon, 26 Sep 2016 15:01:57 +0000 Cc: 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 .init hook, which executes after the DMA mask has been set. Signed-off-by: Ard Biesheuvel --- drivers/gpu/drm/nouveau/nvkm/subdev/fb/nv50.c | 30 +++++++++++++------- 1 file changed, 19 insertions(+), 11 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..f029aaf01831 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/nv50.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/nv50.c @@ -216,11 +216,23 @@ nv50_fb_init(struct nvkm_fb *base) struct nv50_fb *fb = nv50_fb(base); struct nvkm_device *device = fb->base.subdev.device; + if (!fb->r100c08) { + dma_addr_t addr = dma_map_page(device->dev, fb->r100c08_page, 0, + PAGE_SIZE, DMA_BIDIRECTIONAL); + if (!dma_mapping_error(device->dev, addr)) { + fb->r100c08 = addr; + } else { + nvkm_warn(&fb->base.subdev, + "dma_map_page() failed on 100c08 page\n"); + } + } + /* Not a clue what this is exactly. Without pointing it at a * scratch page, VRAM->GART blits with M2MF (as in DDX DFS) * cause IOMMU "read from address 0" errors (rh#561267) */ - nvkm_wr32(device, 0x100c08, fb->r100c08 >> 8); + if (fb->r100c08) + nvkm_wr32(device, 0x100c08, fb->r100c08 >> 8); /* This is needed to get meaningful information from 100c90 * on traps. No idea what these values mean exactly. */ @@ -233,11 +245,11 @@ nv50_fb_dtor(struct nvkm_fb *base) struct nv50_fb *fb = nv50_fb(base); struct nvkm_device *device = fb->base.subdev.device; - if (fb->r100c08_page) { + if (fb->r100c08) dma_unmap_page(device->dev, fb->r100c08, PAGE_SIZE, DMA_BIDIRECTIONAL); - __free_page(fb->r100c08_page); - } + + __free_page(fb->r100c08_page); return fb; } @@ -264,13 +276,9 @@ nv50_fb_new_(const struct nv50_fb_func *func, struct nvkm_device *device, *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"); + if (!fb->r100c08_page) { + nvkm_error(&fb->base.subdev, "failed 100c08 page alloc\n"); + return -ENOMEM; } return 0;