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: 77032 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1151653qgf; Mon, 26 Sep 2016 05:33:20 -0700 (PDT) X-Received: by 10.98.149.149 with SMTP id c21mr38288017pfk.33.1474893200635; Mon, 26 Sep 2016 05:33:20 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si20588366pfk.243.2016.09.26.05.33.20; Mon, 26 Sep 2016 05:33:20 -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 S1034799AbcIZMdI (ORCPT + 27 others); Mon, 26 Sep 2016 08:33:08 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:34308 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1034674AbcIZMcv (ORCPT ); Mon, 26 Sep 2016 08:32:51 -0400 Received: by mail-pa0-f48.google.com with SMTP id gp7so5557535pac.1 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=NUrZUJTX2nhInq2fflO0DD0QzsfXNkw64WH7OawZfAEZYVrL+Of9Cmr86XeKk/nI9E AV5817jx5LBkOooQS91Ml1uId/c/Ed5eNlZkTaETfkkazWZxgCVF9A8RM5PnWplm8nXu KUCcg3DLyZCAs7KnjFdDBVNC3aS9KpLpAIVQ9Tsyx3uTlWHEaeTAhhpPH2wuUY6HpQIa jRoUKhUotweiyTF791kb5ubAYNMHp62LKnGAv0F5r9f3mIZ+5JQJ88tADt3G27nC9MHT 7C+51JTtB+eSZiAFPlnxl6dvx0frQEQ3+4rXN1Z1VayqteJ3xjBmIl5BJuYJy7tD5gGB q/Gw== X-Gm-Message-State: AE9vXwOxHKvgLrj4D/lPhlGNpDE//2+iCEieE/er2lDyXY+/nR2VyKubP3Eh8ggEP0rn6KfS 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 Cc: Ard Biesheuvel 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> 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 .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(-) -- 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..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;