From patchwork Wed Nov 22 22:49:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10071711 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 4B6A760353 for ; Wed, 22 Nov 2017 22:53:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3974B29BA5 for ; Wed, 22 Nov 2017 22:53:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E43829E33; Wed, 22 Nov 2017 22:53:56 +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.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 91A5D29BA5 for ; Wed, 22 Nov 2017 22:53:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=aTsCzZSkF9PRtG9EUAoehuzDJlXi4EztMsKGZ2dSGMs=; b=tJK6UxkHHjngVQbkiEwFb7D1tV QI0fNnEhj242QUgSkZ9BfGG8WTB0NLieK1fWeBaNZV2uT6N/lLBPuP9xFnFIRaT35OGnAtfXiOz+T lKGmYGulh4ZO1l67icPi5e/ko6rN+zaucXpGpg4G88UIudZ6gbRBMEwzxn70Ezq4nfadfaukMQnyh 07stkuhHCyhoAFpAmXL9S/Uzpc9jYiQ9ZoBiD/Blo2/CF9Py8CYgVzz5YCAkc7dTwG66FIstlRmqJ LcOPOvHrd8oVuo8sGJntJk7yqA5tLDF6/UjPdP2VeaZ2XJe1nefrVe2JqMXTs/L1yWxKozcMzWGRb gLvsnKxQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eHdty-0001V4-AI; Wed, 22 Nov 2017 22:53:54 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eHdqs-00079w-0c for linux-arm-kernel@bombadil.infradead.org; Wed, 22 Nov 2017 22:50:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=p2pvcx+qm6WPngKQS+L/Uf20JSRVWY/W1ylQwfEMZbc=; b=kncM9Ze1rDPrThdC0Z9HupIlD EKM9YasvsDoDmw8IC/btpsbsRHY10zQACsiPHZrqbk8ey9Jhj4UmX4Uib5Bk1x9bElhz8eWqgrFTP fEYWSpMFKvBXWb/LoMD8fS2nmpKU7Lj/n6YTs2x+2j5fCKSn/chicTxuEFWpHDlX35H27KhPoEKH9 n22kZQJEAExTFbdRnP45U2Q4q3VB8ufQ4AC4U+nflnAUxel6HAbv2IM/MsrsLzrdHNllSCKHQyj+G E0aKGIHcvfVLoClp4FT6BKzngnMXmzBgyeFOxGP6ycOoQsTRP5IoilufLrwrqMhMhoFj/dqwygT19 +CSmHUqDA==; Received: from smtp.codeaurora.org ([198.145.29.96]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eHdqo-0001zQ-EY for linux-arm-kernel@lists.infradead.org; Wed, 22 Nov 2017 22:50:40 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 2F5B0609BD; Wed, 22 Nov 2017 22:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1511391014; bh=0+L2VpFfd1Fwd19QRasAq7BCvfHJSkN8vpE0idzA2Eg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QUNNXGQO+hHYQBz1WSWGiZA0ooxXi9ggoekul63twuA9MWBObuNW+Vn0YR91fMtTy v0xTIOPJg+54Lu0VOYF3YqrbftyRegFCirTPFOnFIE+tXSDq6XRoGnuC4vxCT5q8PM vvurrFNQJ7WQAbD1Jrvxloka7d9fyiOWAHcSrOnA= Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 507D7609A8; Wed, 22 Nov 2017 22:50:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1511391002; bh=0+L2VpFfd1Fwd19QRasAq7BCvfHJSkN8vpE0idzA2Eg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZoY494Y0hOBGBzklBRh1ICoe6PaCD/D5b8X7EoXuEVCM44z5c4X2CqVU2yhemB+ki S1ly/AIE+C1CDrZlqrEJKWX307tsWtUKnI03h3X/NvbQDlBgvDRNewqTJoStG5sCOQ kw3rvMZywJC+iVMhCuhteMMdkLpfi+q+kUObqQuk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 507D7609A8 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: linux-pci@vger.kernel.org, timur@codeaurora.org Subject: [PATCH V2 10/29] drm/nouveau: deprecate pci_get_bus_and_slot() Date: Wed, 22 Nov 2017 17:49:05 -0500 Message-Id: <1511390964-9979-11-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1511390964-9979-1-git-send-email-okaya@codeaurora.org> References: <1511390964-9979-1-git-send-email-okaya@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171122_225038_772606_E708A8E8 X-CRM114-Status: GOOD ( 17.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, David Airlie , linux-arm-msm@vger.kernel.org, open list , "open list:DRM DRIVER FOR NVIDIA GEFORCE/QUADRO GPUS" , Sinan Kaya , Ben Skeggs , "open list:DRM DRIVER FOR NVIDIA GEFORCE/QUADRO GPUS" , Ilia Mirkin MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP pci_get_bus_and_slot() is restrictive such that it assumes domain=0 as where a PCI device is present. This restricts the device drivers to be reused for other domain numbers. Getting ready to remove pci_get_bus_and_slot() function in favor of pci_get_domain_bus_and_slot(). Replace pci_get_bus_and_slot() with pci_get_domain_bus_and_slot() and extract the domain number from 1. struct pci_dev 2. struct pci_dev through drm_device->pdev 3. struct pci_dev through fb->subdev->drm_device->pdev Signed-off-by: Sinan Kaya --- drivers/gpu/drm/nouveau/dispnv04/arb.c | 4 +++- drivers/gpu/drm/nouveau/dispnv04/hw.c | 10 +++++++--- drivers/gpu/drm/nouveau/nouveau_drm.c | 3 ++- drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c | 10 +++++++++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/nouveau/dispnv04/arb.c b/drivers/gpu/drm/nouveau/dispnv04/arb.c index 90075b6..e7455f7 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/arb.c +++ b/drivers/gpu/drm/nouveau/dispnv04/arb.c @@ -213,8 +213,10 @@ struct nv_sim_state { if ((dev->pdev->device & 0xffff) == 0x01a0 /*CHIPSET_NFORCE*/ || (dev->pdev->device & 0xffff) == 0x01f0 /*CHIPSET_NFORCE2*/) { uint32_t type; + u32 domain = pci_domain_nr(dev->pdev->bus); - pci_read_config_dword(pci_get_bus_and_slot(0, 1), 0x7c, &type); + pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 1), + 0x7c, &type); sim_data.memory_type = (type >> 12) & 1; sim_data.memory_width = 64; diff --git a/drivers/gpu/drm/nouveau/dispnv04/hw.c b/drivers/gpu/drm/nouveau/dispnv04/hw.c index b985990..8806b1b 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/hw.c +++ b/drivers/gpu/drm/nouveau/dispnv04/hw.c @@ -216,12 +216,15 @@ { struct nvkm_pll_vals pllvals; int ret; + u32 domain; + + domain = pci_domain_nr(dev->pdev->bus); if (plltype == PLL_MEMORY && (dev->pdev->device & 0x0ff0) == CHIPSET_NFORCE) { uint32_t mpllP; - - pci_read_config_dword(pci_get_bus_and_slot(0, 3), 0x6c, &mpllP); + pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 3), + 0x6c, &mpllP); mpllP = (mpllP >> 8) & 0xf; if (!mpllP) mpllP = 4; @@ -232,7 +235,8 @@ (dev->pdev->device & 0xff0) == CHIPSET_NFORCE2) { uint32_t clock; - pci_read_config_dword(pci_get_bus_and_slot(0, 5), 0x4c, &clock); + pci_read_config_dword(pci_get_domain_bus_and_slot(domain, 0, 5), + 0x4c, &clock); return clock / 1000; } diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 595630d..0b6c639 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -406,7 +406,8 @@ static int nouveau_drm_probe(struct pci_dev *pdev, } /* subfunction one is a hdmi audio device? */ - drm->hdmi_device = pci_get_bus_and_slot((unsigned int)pdev->bus->number, + drm->hdmi_device = pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus), + (unsigned int)pdev->bus->number, PCI_DEVFN(PCI_SLOT(pdev->devfn), 1)); if (!drm->hdmi_device) { diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c index 3c6a871..273a632 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c @@ -28,8 +28,16 @@ { struct pci_dev *bridge; u32 mem, mib; + u32 domain = 0; + struct pci_dev *pdev = NULL; - bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 1)); + if (dev_is_pci(fb->subdev.device->dev)) + pdev = to_pci_dev(fb->subdev.device->dev); + + if (pdev) + domain = pci_domain_nr(pdev->bus); + + bridge = pci_get_domain_bus_and_slot(domain, 0, PCI_DEVFN(0, 1)); if (!bridge) { nvkm_error(&fb->subdev, "no bridge device\n"); return -ENODEV;