From patchwork Mon Sep 30 02:08:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 11165951 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9EC0D17EE for ; Mon, 30 Sep 2019 02:09:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73D2721835 for ; Mon, 30 Sep 2019 02:09:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gpUTBSTD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726360AbfI3CJG (ORCPT ); Sun, 29 Sep 2019 22:09:06 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42312 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729329AbfI3CJG (ORCPT ); Sun, 29 Sep 2019 22:09:06 -0400 Received: by mail-pg1-f195.google.com with SMTP id z12so6474231pgp.9 for ; Sun, 29 Sep 2019 19:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RTVI3ok1pi5ZTGTh8NOoqYXjMZw8tk1g5KZ1fDiav2E=; b=gpUTBSTDbKWiOWTYJr4xGS9Bj5qnm3EyE5j0gG4H9K/ZnkE+SlAcuHsMy7sVUhnXqo b51BzmFSkky79YX+vwzRmvMqGR6awh+5Vs1QFDk78IcVJV4O6nNptZi65o+rMuSRwlxI ZsC3KTRZf2wWRKsYDQoYW39upnSkyZiQ2KGopoKbV5KvwQgRXUMpY+7GKPvFiS6AVuiS qEZabFbSu9pLkd/Wy2wRFQg4YyYzUPzCZnobfq9Rn0xFE52RhH6yj4zTZFZF5il1yE+k xlbZ5cQ1OaKohFslw5EZef6+CIfInNiN/cuLuO7WX23FJeV6/XaKreGdqdSCHGF8nZdY 9QOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RTVI3ok1pi5ZTGTh8NOoqYXjMZw8tk1g5KZ1fDiav2E=; b=GuGZe2fser0NqEBLkcq7xA6SpA18nM7uQTRolVow+SLCPzYePZdsI2fVVtjMF5N/+0 fiUP2gJGe6hrUmFoWxKDBrt3JbZvDp9oS8V6V4rzhPj2T4j1WcYMGASNfORPThsembVR xjzRklUvY55yt3bzy2SPF6Ki0N2UXHKEkQ6KtPJla1H7KrWMUqnr8dQuAFdcMIJ3/Q6H hkVobrrEInD8Cjsyb/iCTaQOoclFJmGfnxehygSzR/SIiYY0RiZPhdYsSSfrjPOH0u9F Oiaqf0SCp9WV6+CymwLEclANAJCVz1M+xSq69vPNXYx5U98HcvhvCXRPWOkBz4QC+gMe dJNQ== X-Gm-Message-State: APjAAAUdtCFNwbSbvYKiZ6iYqzV4ptxJo4jS0fYgMpMSjB06IKXJGa/h XUu7+r1DHxH3fBfAU6XADfo= X-Google-Smtp-Source: APXvYqxBAsZT6i+qBEIPbNaMB+PAMCM4UoHyB6CPxex2iU6SaH7KeuCaRT4XRG0WiyOqC11i7zEvBw== X-Received: by 2002:a63:5947:: with SMTP id j7mr6738157pgm.402.1569809345238; Sun, 29 Sep 2019 19:09:05 -0700 (PDT) Received: from wafer.ozlabs.ibm.com.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id x72sm11450733pfc.89.2019.09.29.19.09.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Sep 2019 19:09:04 -0700 (PDT) From: Oliver O'Halloran To: linuxppc-dev@lists.ozlabs.org Cc: aik@ozlabs.ru, shawn@anastas.io, linux-pci@vger.kernel.org, Oliver O'Halloran Subject: [PATCH 1/3] powernv/iov: Ensure the pdn for VFs always contains a valid PE number Date: Mon, 30 Sep 2019 12:08:46 +1000 Message-Id: <20190930020848.25767-2-oohall@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190930020848.25767-1-oohall@gmail.com> References: <20190930020848.25767-1-oohall@gmail.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On PowerNV we use the pcibios_sriov_enable() hook to do two things: 1. Create a pci_dn structure for each of the VFs, and 2. Configure the PHB's internal BARs that map MMIO ranges to PEs so that each VF has it's own PE. Note that the PE also determines the IOMMU table the HW uses for the device. Currently we do not set the pe_number field of the pci_dn immediately after assigning the PE number for the VF that it represents. Instead, we do that in a fixup (see pnv_pci_dma_dev_setup) which is run inside the pcibios_add_device() hook which is run prior to adding the device to the bus. On PowerNV we add the device to it's IOMMU group using a bus notifier and in order for this to work the PE number needs to be known when the bus notifier is run. This works today since the PE number is set in the fixup which runs before adding the device to the bus. However, if we want to move the fixup to a later stage this will break. We can fix this by setting the pdn->pe_number inside of pcibios_sriov_enable(). There's no good to avoid this since we already have all the required information at that point, so... do that. Moving this earlier does cause two problems: 1. We trip the WARN_ON() in the fixup code, and 2. The EEH core will clear pdn->pe_number while recovering VFs. The only justification for either of these is a comment in eeh_rmv_device() suggesting that pdn->pe_number *must* be set to IODA_INVALID_PE in order for the VF to be scanned. However, this comment appears to have no basis in reality so just delete it. Signed-off-by: Oliver O'Halloran Tested-by: Alexey Kardashevskiy Reviewed-by: Alexey Kardashevskiy --- Can't get rid of the fixup entirely since we need it to set the ioda_pe->pdev back-pointer. I'll look at killing that another time. --- arch/powerpc/kernel/eeh_driver.c | 6 ------ arch/powerpc/platforms/powernv/pci-ioda.c | 19 +++++++++++++++---- arch/powerpc/platforms/powernv/pci.c | 4 ---- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c index d9279d0..7955fba 100644 --- a/arch/powerpc/kernel/eeh_driver.c +++ b/arch/powerpc/kernel/eeh_driver.c @@ -541,12 +541,6 @@ static void eeh_rmv_device(struct eeh_dev *edev, void *userdata) pci_iov_remove_virtfn(edev->physfn, pdn->vf_index); edev->pdev = NULL; - - /* - * We have to set the VF PE number to invalid one, which is - * required to plug the VF successfully. - */ - pdn->pe_number = IODA_INVALID_PE; #endif if (rmv_data) list_add(&edev->rmv_entry, &rmv_data->removed_vf_list); diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 5e3172d..70508b3 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -1558,6 +1558,10 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs) /* Reserve PE for each VF */ for (vf_index = 0; vf_index < num_vfs; vf_index++) { + int vf_devfn = pci_iov_virtfn_devfn(pdev, vf_index); + int vf_bus = pci_iov_virtfn_bus(pdev, vf_index); + struct pci_dn *vf_pdn; + if (pdn->m64_single_mode) pe_num = pdn->pe_num_map[vf_index]; else @@ -1570,13 +1574,11 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs) pe->pbus = NULL; pe->parent_dev = pdev; pe->mve_number = -1; - pe->rid = (pci_iov_virtfn_bus(pdev, vf_index) << 8) | - pci_iov_virtfn_devfn(pdev, vf_index); + pe->rid = (vf_bus << 8) | vf_devfn; pe_info(pe, "VF %04d:%02d:%02d.%d associated with PE#%x\n", hose->global_number, pdev->bus->number, - PCI_SLOT(pci_iov_virtfn_devfn(pdev, vf_index)), - PCI_FUNC(pci_iov_virtfn_devfn(pdev, vf_index)), pe_num); + PCI_SLOT(vf_devfn), PCI_FUNC(vf_devfn), pe_num); if (pnv_ioda_configure_pe(phb, pe)) { /* XXX What do we do here ? */ @@ -1590,6 +1592,15 @@ static void pnv_ioda_setup_vf_PE(struct pci_dev *pdev, u16 num_vfs) list_add_tail(&pe->list, &phb->ioda.pe_list); mutex_unlock(&phb->ioda.pe_list_mutex); + /* associate this pe to it's pdn */ + list_for_each_entry(vf_pdn, &pdn->parent->child_list, list) { + if (vf_pdn->busno == vf_bus && + vf_pdn->devfn == vf_devfn) { + vf_pdn->pe_number = pe_num; + break; + } + } + pnv_pci_ioda2_setup_dma_pe(phb, pe); #ifdef CONFIG_IOMMU_API iommu_register_group(&pe->table_group, diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c index 2825d00..b7761e2 100644 --- a/arch/powerpc/platforms/powernv/pci.c +++ b/arch/powerpc/platforms/powernv/pci.c @@ -816,16 +816,12 @@ void pnv_pci_dma_dev_setup(struct pci_dev *pdev) struct pnv_phb *phb = hose->private_data; #ifdef CONFIG_PCI_IOV struct pnv_ioda_pe *pe; - struct pci_dn *pdn; /* Fix the VF pdn PE number */ if (pdev->is_virtfn) { - pdn = pci_get_pdn(pdev); - WARN_ON(pdn->pe_number != IODA_INVALID_PE); list_for_each_entry(pe, &phb->ioda.pe_list, list) { if (pe->rid == ((pdev->bus->number << 8) | (pdev->devfn & 0xff))) { - pdn->pe_number = pe->pe_number; pe->pdev = pdev; break; } From patchwork Mon Sep 30 02:08:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 11165953 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D414017D4 for ; Mon, 30 Sep 2019 02:09:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A8FEE2086A for ; Mon, 30 Sep 2019 02:09:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Tf6eIchY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729375AbfI3CJI (ORCPT ); Sun, 29 Sep 2019 22:09:08 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:38441 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729372AbfI3CJI (ORCPT ); Sun, 29 Sep 2019 22:09:08 -0400 Received: by mail-pl1-f193.google.com with SMTP id w8so2819266plq.5 for ; Sun, 29 Sep 2019 19:09:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2MQ9C5D2pIjxtgzo4yVQfpILkEUvZWmVx5Oo69HXIq8=; b=Tf6eIchYTJJ6HB8+pDvWoFPPKt6DXO80N10eIjs++8R+5WcAvRpfNxZjm6StUBipWj 7R/Qw9qhqeoUuxUAZTpFKrhuVjFsGyJuPhWPlkX1tGIf6TRudciGXsxHaaPtjjRSIdyO 7Pkr3T/dUl37GYzU8sLMP2NCEQnqGPk3zBHc22vSOykwQSUNIujJeBORffA/cR2Tdbna g5z6Xow/QI72KxWBMs6eNkdLh2oRCcAw62mcwYj/LtTP6UqldwjUgo7thmHXTIfoRoiA SFeEeXM/qOQshMdJbkfCuvBmTFEx6yK1wmHAlWzXige09TX3iucC4P5nY1WfFnyDatg6 fkXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2MQ9C5D2pIjxtgzo4yVQfpILkEUvZWmVx5Oo69HXIq8=; b=sn8OBw+Swt5JDNaB8UQRaLDcrrlamPXeQkd5NVxdZszQaa/cfaRkMClwabRo7t6zLs 0LkL/+1ZK++KdlI/H1jj2kOhSDeCGiCPK0tocOxlNCF7bHmR0z65blAvbRW40cbcvzy1 d7a7ZOegwBcZMpMFL6iAkM5OBsygpqM0tMnPCAeEfM3Q0Zk++NSkNONwowB6obhwjZiG mGa34KqcAex9lBint7f51f3TQmiABCQr5EJ3+yMqL4isSfhywbQj5UQfvNZbErkdlazr WRlboddHmFfrQ8tlonrA5B8Z2mP4bpjHNAS8vqeVK58XaNj03paoUXYJyELZzFCh4/UF McZA== X-Gm-Message-State: APjAAAVJMyFUCkPLZH0dBBWhq2W9edq2SSeiVUQbAHIwyGe27MQbX9Bj aX1av4v7j0/cN8xIysrAtWcep/ir X-Google-Smtp-Source: APXvYqyE9QwN95Qw7WOIU+JPp5GuMXB6QLQNlk86LK1sujLh/uxthmQzCx6Dwxoc0VVF61UdtdkwUQ== X-Received: by 2002:a17:902:b789:: with SMTP id e9mr18178242pls.88.1569809347711; Sun, 29 Sep 2019 19:09:07 -0700 (PDT) Received: from wafer.ozlabs.ibm.com.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id x72sm11450733pfc.89.2019.09.29.19.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Sep 2019 19:09:07 -0700 (PDT) From: Oliver O'Halloran To: linuxppc-dev@lists.ozlabs.org Cc: aik@ozlabs.ru, shawn@anastas.io, linux-pci@vger.kernel.org Subject: [PATCH 2/3] powerpc/pci: Fix pcibios_setup_device() ordering Date: Mon, 30 Sep 2019 12:08:47 +1000 Message-Id: <20190930020848.25767-3-oohall@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190930020848.25767-1-oohall@gmail.com> References: <20190930020848.25767-1-oohall@gmail.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Shawn Anastasio Move PCI device setup from pcibios_add_device() and pcibios_fixup_bus() to pcibios_bus_add_device(). This ensures that platform-specific DMA and IOMMU setup occurs after the device has been registered in sysfs, which is a requirement for IOMMU group assignment to work This fixes IOMMU group assignment for hotplugged devices on pseries, where the existing behavior results in IOMMU assignment before registration. Thanks to Lukas Wunner for the suggestion. Signed-off-by: Shawn Anastasio Tested-by: Alexey Kardashevskiy Reviewed-by: Alexey Kardashevskiy --- arch/powerpc/kernel/pci-common.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 1c448cf..b89925ed 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -261,12 +261,6 @@ int pcibios_sriov_disable(struct pci_dev *pdev) #endif /* CONFIG_PCI_IOV */ -void pcibios_bus_add_device(struct pci_dev *pdev) -{ - if (ppc_md.pcibios_bus_add_device) - ppc_md.pcibios_bus_add_device(pdev); -} - static resource_size_t pcibios_io_size(const struct pci_controller *hose) { #ifdef CONFIG_PPC64 @@ -987,15 +981,17 @@ static void pcibios_setup_device(struct pci_dev *dev) ppc_md.pci_irq_fixup(dev); } -int pcibios_add_device(struct pci_dev *dev) +void pcibios_bus_add_device(struct pci_dev *pdev) { - /* - * We can only call pcibios_setup_device() after bus setup is complete, - * since some of the platform specific DMA setup code depends on it. - */ - if (dev->bus->is_added) - pcibios_setup_device(dev); + /* Perform platform-specific device setup */ + pcibios_setup_device(pdev); + + if (ppc_md.pcibios_bus_add_device) + ppc_md.pcibios_bus_add_device(pdev); +} +int pcibios_add_device(struct pci_dev *dev) +{ #ifdef CONFIG_PCI_IOV if (ppc_md.pcibios_fixup_sriov) ppc_md.pcibios_fixup_sriov(dev); @@ -1037,9 +1033,6 @@ void pcibios_fixup_bus(struct pci_bus *bus) /* Now fixup the bus bus */ pcibios_setup_bus_self(bus); - - /* Now fixup devices on that bus */ - pcibios_setup_bus_devices(bus); } EXPORT_SYMBOL(pcibios_fixup_bus); From patchwork Mon Sep 30 02:08:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 11165955 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BC0E1922 for ; Mon, 30 Sep 2019 02:09:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE4D82086A for ; Mon, 30 Sep 2019 02:09:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uSdLpYVJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729395AbfI3CJM (ORCPT ); Sun, 29 Sep 2019 22:09:12 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:39518 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729329AbfI3CJL (ORCPT ); Sun, 29 Sep 2019 22:09:11 -0400 Received: by mail-pl1-f195.google.com with SMTP id s17so3274482plp.6 for ; Sun, 29 Sep 2019 19:09:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GpdB7/NTd3wtvGApi+SbwzoSWGyyJYFNhOXdPw30ujU=; b=uSdLpYVJI6agqhIuFFc4HJVODoORgxFLSHEYcs3h5PWTlzvNM38KyCuA3zuniy92Gm 0S1yVfu+E3c3jS9CSgQboR+fQEObkxkoQDodLfnczAQVKswxCqEdc84kLOjJb7Y+4gTT hUx2CFIW1GT7FuQZ4bEO+FwWOjlmRvMvy30OEfxtP83zMi5J92mIsTcaT8Yg0iAxDc18 vn7icu7d2alBoSA6xCNEHb+AIOP84KwDeZvnwDByYGITxVyVgUdSN4sOr3NW+9NdjrvI ZoCOp6vVtARf+jf7Df3HZFQ6hfSAgnhCimUws6ZDXA6SkVY/MIaNe0N2kstXVNdxClhv ORSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GpdB7/NTd3wtvGApi+SbwzoSWGyyJYFNhOXdPw30ujU=; b=JGw+4rbUGPrEfNGEn01TSUcoOK9FAYd4MU/SlCi51f/cmRDVvcI0WJsJ78LV8CP881 tpTxoG5dDZwT295+Kc0QdvhLfwVSleVzofTd/5iyimS7/4FgqPYJwXOHjx4oyjWVhgNK 1m8aFFevTutiED6zGBrKyvqM+S3Y5PxD1D36UL53BID0TcQuhhJX+0+BtQp2uIs/jqXR Zk6/th1DyeDzP6dykS4pC39qCjjnID0siG3OR4667mja5GgBWiWVUTlHW0alE/wcsiuy YTet94cM+8pKfZit3jKNBMKU+WrgUCe6jLBW6YiFlUbR+u6ILvkPe7F9b8aob+Rvq/qL ID+A== X-Gm-Message-State: APjAAAUXzfinsCJYoHsADHkFgRBddxAOGwNcTeYuP2PZr64ICqX1vmfN ROEypnaPw7Law19LVgo8OAw= X-Google-Smtp-Source: APXvYqzkHaoeDmSN7IhITXbXlspuHGKFl8/ESO8gCTP8d/M8lRKpa0zl41o5kYYshR3e5JSieRd/sA== X-Received: by 2002:a17:902:bcc4:: with SMTP id o4mr16891124pls.142.1569809350280; Sun, 29 Sep 2019 19:09:10 -0700 (PDT) Received: from wafer.ozlabs.ibm.com.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id x72sm11450733pfc.89.2019.09.29.19.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Sep 2019 19:09:09 -0700 (PDT) From: Oliver O'Halloran To: linuxppc-dev@lists.ozlabs.org Cc: aik@ozlabs.ru, shawn@anastas.io, linux-pci@vger.kernel.org, Oliver O'Halloran Subject: [PATCH 3/3] powerpc/pci: Remove pcibios_setup_bus_devices() Date: Mon, 30 Sep 2019 12:08:48 +1000 Message-Id: <20190930020848.25767-4-oohall@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190930020848.25767-1-oohall@gmail.com> References: <20190930020848.25767-1-oohall@gmail.com> MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org With the previous patch applied pcibios_setup_device() will always be run when pcibios_bus_add_device() is called. There are several code paths where pcibios_setup_bus_device() is still called (the PowerPC specific PCI hotplug support is one) so with just the previous patch applied the setup can be run multiple times on a device, once before the device is added to the bus and once after. There's no need to run the setup in the early case any more so just remove it entirely. Signed-off-by: Oliver O'Halloran Tested-by: Alexey Kardashevskiy Reviewed-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/pci.h | 1 - arch/powerpc/kernel/pci-common.c | 25 ------------------------- arch/powerpc/kernel/pci-hotplug.c | 1 - arch/powerpc/kernel/pci_of_scan.c | 1 - 4 files changed, 28 deletions(-) diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h index 327567b..63ed7e3 100644 --- a/arch/powerpc/include/asm/pci.h +++ b/arch/powerpc/include/asm/pci.h @@ -113,7 +113,6 @@ extern pgprot_t pci_phys_mem_access_prot(struct file *file, pgprot_t prot); extern resource_size_t pcibios_io_space_offset(struct pci_controller *hose); -extern void pcibios_setup_bus_devices(struct pci_bus *bus); extern void pcibios_setup_bus_self(struct pci_bus *bus); extern void pcibios_setup_phb_io_space(struct pci_controller *hose); extern void pcibios_scan_phb(struct pci_controller *hose); diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index b89925ed..f8a59d7 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1000,24 +1000,6 @@ int pcibios_add_device(struct pci_dev *dev) return 0; } -void pcibios_setup_bus_devices(struct pci_bus *bus) -{ - struct pci_dev *dev; - - pr_debug("PCI: Fixup bus devices %d (%s)\n", - bus->number, bus->self ? pci_name(bus->self) : "PHB"); - - list_for_each_entry(dev, &bus->devices, bus_list) { - /* Cardbus can call us to add new devices to a bus, so ignore - * those who are already fully discovered - */ - if (pci_dev_is_added(dev)) - continue; - - pcibios_setup_device(dev); - } -} - void pcibios_set_master(struct pci_dev *dev) { /* No special bus mastering setup handling */ @@ -1036,13 +1018,6 @@ void pcibios_fixup_bus(struct pci_bus *bus) } EXPORT_SYMBOL(pcibios_fixup_bus); -void pci_fixup_cardbus(struct pci_bus *bus) -{ - /* Now fixup devices on that bus */ - pcibios_setup_bus_devices(bus); -} - - static int skip_isa_ioresource_align(struct pci_dev *dev) { if (pci_has_flag(PCI_CAN_SKIP_ISA_ALIGN) && diff --git a/arch/powerpc/kernel/pci-hotplug.c b/arch/powerpc/kernel/pci-hotplug.c index fc62c4b..d6a67f8 100644 --- a/arch/powerpc/kernel/pci-hotplug.c +++ b/arch/powerpc/kernel/pci-hotplug.c @@ -134,7 +134,6 @@ void pci_hp_add_devices(struct pci_bus *bus) */ slotno = PCI_SLOT(PCI_DN(dn->child)->devfn); pci_scan_slot(bus, PCI_DEVFN(slotno, 0)); - pcibios_setup_bus_devices(bus); max = bus->busn_res.start; /* * Scan bridges that are already configured. We don't touch diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c index f91d7e9..c3024f1 100644 --- a/arch/powerpc/kernel/pci_of_scan.c +++ b/arch/powerpc/kernel/pci_of_scan.c @@ -414,7 +414,6 @@ static void __of_scan_bus(struct device_node *node, struct pci_bus *bus, */ if (!rescan_existing) pcibios_setup_bus_self(bus); - pcibios_setup_bus_devices(bus); /* Now scan child busses */ for_each_pci_bridge(dev, bus)