From patchwork Mon Sep 26 12:32:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9350805 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 4B44F6077A for ; Mon, 26 Sep 2016 15:02:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CF5E28B14 for ; Mon, 26 Sep 2016 15:02:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31F9C28B19; Mon, 26 Sep 2016 15:02: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 BA1C228B14 for ; Mon, 26 Sep 2016 15:02:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CC2F06E505; Mon, 26 Sep 2016 15:01:58 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-x236.google.com (mail-pa0-x236.google.com [IPv6:2607:f8b0:400e:c03::236]) by gabe.freedesktop.org (Postfix) with ESMTPS id E637C6E45D for ; Mon, 26 Sep 2016 12:32:48 +0000 (UTC) Received: by mail-pa0-x236.google.com with SMTP id oz2so62732489pac.2 for ; Mon, 26 Sep 2016 05:32:48 -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=Sp073HDQbDI3K6X+VWyR2X/rDvt5anoYpDdGVWsitLM=; b=JOUKGPpRBeNZnhDJYRbHpy9Q427eiTZdKhIFH6vNiCIGwP7HYbPeywbz5HRNKrNa7L 2BZB86WUTkij5UN77QGtKTtGUmMyghIUAjVhnSms/fOJH0zdS+oAruth3ZEoxqpVHVqj r0rt+V0cpJ4ksOd1Typ5WjV9WoQvXt9F9Gw9A= 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=Sp073HDQbDI3K6X+VWyR2X/rDvt5anoYpDdGVWsitLM=; b=edh1fqjsxoxn4pLdgs+nXdZ0h/8UMbi8teM7DMtdIjpj9xQr4dS+BqgFrO71P1hAwV jtgea2SeAc4aNsmg+tG5AGQSEbiW6nAcAIpX6nW2mRaRDslnB+zfodUz9BJt3JUAF8hk ae3ifu/HrKLwJ7vzPT+VrqiWKNoB9otSzlpYA/C35VFYTowaWTUg6X8GUnikrxbvVgSq 1pkN77a4EHbAQjKl7HhtzMbYB7H2/nB9PFPQzCsKUvumlzO/5JDgQiyOU7btv0G12v7w dMKTHy5hqrmQds7033NjdCZaiAoKpllZwKttjGhII8FbDv8D6XUsSy6iRFbJ0OSaYCgB 9FZA== X-Gm-Message-State: AE9vXwOhfxoGxD3FWAQQsJCj1pyJXK/CTNXlKMZZzKy+l1uejkCG6Qt2QYJ6H74UWxipQNas X-Received: by 10.66.188.202 with SMTP id gc10mr37377454pac.104.1474893168559; Mon, 26 Sep 2016 05:32:48 -0700 (PDT) Received: from localhost.localdomain ([67.238.99.186]) by smtp.gmail.com with ESMTPSA id c15sm10893809pfl.25.2016.09.26.05.32.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Sep 2016 05:32:47 -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 1/3] drm/nouveau: set streaming DMA mask early Date: Mon, 26 Sep 2016 05:32:38 -0700 Message-Id: <1474893160-12321-2-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 Some subdevices (i.e., fb/nv50.c and fb/gf100.c) map a scratch page using dma_map_page() way before the TTM layer has had a chance to set the DMA mask. This may prevent the driver from loading at all on platforms whose system memory is not covered by the default DMA mask of 32-bit (i.e., when all RAM is above 4 GB). So set a preliminary DMA mask right after constructing the PCI device, and base it on the .dma_bits member of the MMU subdevice, which is what the TTM layer will base the DMA mask on as well. Signed-off-by: Ard Biesheuvel --- drivers/gpu/drm/nouveau/nouveau_drm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 652ab111dd74..e61e9a0adb51 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -361,6 +361,17 @@ static int nouveau_drm_probe(struct pci_dev *pdev, pci_set_master(pdev); + /* + * Set a preliminary DMA mask based on the .dma_bits member of the + * MMU subdevice. This allows other subdevices to create DMA mappings + * in their init() function, which are called before the TTM layer sets + * the DMA mask definitively. + * This is necessary for platforms where the default DMA mask of 32 + * does not cover any system memory, i.e., when all RAM is > 4 GB. + */ + dma_set_mask_and_coherent(device->dev, + DMA_BIT_MASK(device->mmu->dma_bits)); + ret = drm_get_pci_dev(pdev, pent, &driver_pci); if (ret) { nvkm_device_del(&device);