From patchwork Thu Oct 6 15:49:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9365551 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 94A1D6077E for ; Fri, 7 Oct 2016 00:12:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86AA12926A for ; Fri, 7 Oct 2016 00:12:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B3F12927F; Fri, 7 Oct 2016 00:12:26 +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 33F612926A for ; Fri, 7 Oct 2016 00:12:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1AF4E6EAC0; Fri, 7 Oct 2016 00:12:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x233.google.com (mail-wm0-x233.google.com [IPv6:2a00:1450:400c:c09::233]) by gabe.freedesktop.org (Postfix) with ESMTPS id B5F976EA06 for ; Thu, 6 Oct 2016 15:49:41 +0000 (UTC) Received: by mail-wm0-x233.google.com with SMTP id i130so12584550wmg.1 for ; Thu, 06 Oct 2016 08:49:41 -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=NHo+AG3DCe8I4B3ZQeOtz7rXXnNkeWIPm9SADh8jacg=; b=GUJRcW7GflAIB4Ce3mo2vqHWKFOnP/LBvDzmCcYl9VbbMLY6n85HpGgUPftNo8528c Wb92lJNDyriPs0fzQVdx53NT4Gm/pmgNVmEmbOahYO/cgKygEPbVuiZ24c9nnoexSAmG 7OixRlHJp7wrfQYt/G44VyWHL17HZ5HUeUQLY= 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=NHo+AG3DCe8I4B3ZQeOtz7rXXnNkeWIPm9SADh8jacg=; b=kjeBmzkydsQ3wbCXFOp4zHeeqCK0HIKd9p7EQskTxhYbKazJYbxSzg6SUzvywaeY+M aoNeh3quN0Z48OnZBVIDPYCmK0qcC5g+msfTbTrQYfuhkau6mvGlZ7F7bE5Wmpp1iq6Z vnha6CCeQt1/5uG5FTTgN7mzZDoKqFP9pWxFxT3D+P9c/dEYkvSAmeaCqYjwoMblHEm+ fXLILJGnImH0eXiZ3N6lla5c+w3eGDsZPQtojFTkVdYr+50Cwt3HBsXHvQ1j3Sga7/hq 9+J2l9mrdWfqzKuTC4QMNddHcZpPRs9aEGc9cXL7M2mV0i4b4Nph5X4WTaHspc62Tuit qPzA== X-Gm-Message-State: AA6/9RkFBxaPGbIfFzyvFKbITJd4yuBKpW95vYUvDrWW6vYeZMZdW5HK1dMCIHUpluX2yEr0 X-Received: by 10.194.83.166 with SMTP id r6mr12903445wjy.186.1475768979961; Thu, 06 Oct 2016 08:49:39 -0700 (PDT) Received: from localhost.localdomain ([197.128.55.6]) by smtp.gmail.com with ESMTPSA id x124sm36001176wmf.22.2016.10.06.08.49.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Oct 2016 08:49:39 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH v5 1/3] drm/nouveau: set streaming DMA mask early Date: Thu, 6 Oct 2016 16:49:28 +0100 Message-Id: <1475768970-32512-2-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 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/nvkm/engine/device/pci.c | 37 ++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c index 62ad0300cfa5..0030cd9543b2 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c @@ -1665,14 +1665,31 @@ nvkm_device_pci_new(struct pci_dev *pci_dev, const char *cfg, const char *dbg, *pdevice = &pdev->device; pdev->pdev = pci_dev; - return nvkm_device_ctor(&nvkm_device_pci_func, quirk, &pci_dev->dev, - pci_is_pcie(pci_dev) ? NVKM_DEVICE_PCIE : - pci_find_capability(pci_dev, PCI_CAP_ID_AGP) ? - NVKM_DEVICE_AGP : NVKM_DEVICE_PCI, - (u64)pci_domain_nr(pci_dev->bus) << 32 | - pci_dev->bus->number << 16 | - PCI_SLOT(pci_dev->devfn) << 8 | - PCI_FUNC(pci_dev->devfn), name, - cfg, dbg, detect, mmio, subdev_mask, - &pdev->device); + ret = nvkm_device_ctor(&nvkm_device_pci_func, quirk, &pci_dev->dev, + pci_is_pcie(pci_dev) ? NVKM_DEVICE_PCIE : + pci_find_capability(pci_dev, PCI_CAP_ID_AGP) ? + NVKM_DEVICE_AGP : NVKM_DEVICE_PCI, + (u64)pci_domain_nr(pci_dev->bus) << 32 | + pci_dev->bus->number << 16 | + PCI_SLOT(pci_dev->devfn) << 8 | + PCI_FUNC(pci_dev->devfn), name, + cfg, dbg, detect, mmio, subdev_mask, + &pdev->device); + + if (ret) + return ret; + + /* + * 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() or oneinit() methods, which may be 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. + */ + if (subdev_mask & BIT(NVKM_SUBDEV_MMU)) + dma_set_mask_and_coherent(&pci_dev->dev, + DMA_BIT_MASK(pdev->device.mmu->dma_bits)); + + return 0; }