From patchwork Mon Oct 28 08:54:22 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: 11214995 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 EE4B613B1 for ; Mon, 28 Oct 2019 08:54:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C097120B7C for ; Mon, 28 Oct 2019 08:54:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N5nPdIZ4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733235AbfJ1Iyo (ORCPT ); Mon, 28 Oct 2019 04:54:44 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:41498 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730954AbfJ1Iyn (ORCPT ); Mon, 28 Oct 2019 04:54:43 -0400 Received: by mail-pg1-f195.google.com with SMTP id l3so6460249pgr.8 for ; Mon, 28 Oct 2019 01:54:43 -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:mime-version :content-transfer-encoding; bh=7H6mKTh9zqXvYcy1Ua/XMd20wDfeej2CMStIpNchhTw=; b=N5nPdIZ4q7Aq0XXxne5lc8oSpDsdue75MjJhQbt611aYDKsSLPsg9RDWo6DsU2AcuL QVVGogrCKr9KnK9OCLRYj6xH1DrYh3hSSwNdzGRRSd9hBfD1HEIzopHu4xztvApzhvhb VrQzeJMGLI8oYIE5Zof0T8gbAqQBMmWfpq2agZopq5IrTD89oh91ZHT3vyvqwtFc4j42 dmS1qYkH4g/fo4YZBKmJiovXyOKviT+Gd6nynRLB/Saew38voSvgvByDaitfP1EE7XsD KcFT9imbXVUvcP9UUSI0PByFW1hj/l/fgS2KAGVr/GbCYNEw/ZzovGeP6UcpfugQLoPD a08Q== 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:mime-version :content-transfer-encoding; bh=7H6mKTh9zqXvYcy1Ua/XMd20wDfeej2CMStIpNchhTw=; b=czeP7AgTwbIvPxFmFvLHIgV32U/awfS5BRc/xibUjwinCrHfbc4qmqHd/d/3jcgIFN fWaZXJsS+tZFIelPxKysxFOR+yhbK7sqph154duUqDMVLDdxRYSOdSjd+3xmwyQLprNH IY1bENhzGfUHlgEoRwKzdh/AbyZ/kP+a+KTF76EPdkqH/BaheppIgiTXZZJKDq7ce2C0 U14tytMYPuEguzvbB8ChOI8RYHWD91zxWynBaOvt/Ah7AWtgsjg/NxsibT6Qq47/OPqg z+Rzr5/l2PqJpAwcxstQu601jUvVEtfntx8L/xMrHNa1x5AyRdzRNuI8w8b2+IBj/g+p q8Mw== X-Gm-Message-State: APjAAAUwU/bTRar5QRNV+FCgMp2VEXfFgVRwb+h6KmtsmrgJQHGLULqH EAoIQP+xyqxLGzIZ9Hi+MaFY4XXaVH0= X-Google-Smtp-Source: APXvYqxUV43b7g9mMcqrN31QguLDDNjtEwSPvccNFhr/Ei5Vy6JN7s2fJnlfHWr8ItTacgAdU+8OYg== X-Received: by 2002:a63:2c2:: with SMTP id 185mr17549116pgc.219.1572252882682; Mon, 28 Oct 2019 01:54:42 -0700 (PDT) Received: from wafer.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id l24sm10046115pff.151.2019.10.28.01.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 01:54:41 -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 v2 1/3] powernv/iov: Ensure the pdn for VFs always contains a valid PE number Date: Mon, 28 Oct 2019 19:54:22 +1100 Message-Id: <20191028085424.12006-1-oohall@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On pseries there is a bug with adding hotplugged devices to an IOMMU group. For a number of dumb reasons fixing that bug first requires re-working how VFs are configured on PowerNV. For background, 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 so the MMIO range for each VF maps to a unique PE. Roughly speaking a PE is the hardware counterpart to a Linux IOMMU group since all the devices in a PE share the same IOMMU table. A PE also defines the set of devices that should be isolated in response to a PCI error (i.e. bad DMA, UR/CA, AER events, etc). When isolated all MMIO and DMA traffic to and from devicein the PE is blocked by the root complex until the PE is recovered by the OS. The requirement to block MMIO causes a giant headache because the P8 PHB generally uses a fixed mapping between MMIO addresses and PEs. As a result we need to delay configuring the IOMMU groups for device until after MMIO resources are assigned. For physical devices (i.e. non-VFs) the PE assignment is done in pcibios_setup_bridge() which is called immediately after the MMIO resources for downstream devices (and the bridge's windows) are assigned. For VFs the setup is more complicated because: a) pcibios_setup_bridge() is not called again when VFs are activated, and b) The pci_dev for VFs are created by generic code which runs after pcibios_sriov_enable() is called. The work around for this is a two step process: 1. A fixup in pcibios_add_device() is used to initialised the cached pe_number in pci_dn, then 2. A bus notifier then adds the device to the IOMMU group for the PE specified in pci_dn->pe_number. A side effect fixing the pseries bug mentioned in the first paragraph is moving the fixup out of pcibios_add_device() and into pcibios_bus_add_device(), which is called much later. This results in step 2. failing because pci_dn->pe_number won't be initialised when the bus notifier is run. We can fix this by removing the need for the fixup. The PE for a VF is known before the VF is even scanned so we can initialise pci_dn->pe_number pcibios_sriov_enable() instead. Unfortunately, moving the initialisation causes two problems: 1. We trip the WARN_ON() in the current fixup code, and 2. The EEH core clears pdn->pe_number when recovering a VF and relies on the fixup to correctly re-set it. 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. Both bugs can be fixed by just deleting the code. Tested-by: Alexey Kardashevskiy Reviewed-by: Alexey Kardashevskiy Signed-off-by: Oliver O'Halloran --- v2: Re-wrote commit message, got very depressed about the state of things. The real fix here is to move the IOMMU group setup for both VFs and PFs into pcibios_bus_add_device() and kill the pcibios_setup_bridge() hack and the bus notifier hack, but doing that requires some pretty gnarly changes. The fix here is much less invasive. --- 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 Oct 28 08:54:23 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: 11214997 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 C53391515 for ; Mon, 28 Oct 2019 08:54:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A4517214E0 for ; Mon, 28 Oct 2019 08:54:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Wgxq6MBE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733246AbfJ1Iyq (ORCPT ); Mon, 28 Oct 2019 04:54:46 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:44365 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730954AbfJ1Iyq (ORCPT ); Mon, 28 Oct 2019 04:54:46 -0400 Received: by mail-pg1-f194.google.com with SMTP id e10so6450098pgd.11 for ; Mon, 28 Oct 2019 01:54:45 -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=tz/eLS9GWjuONE2SqgYz3LI8GYDdc5KRtTV4JcWn9cM=; b=Wgxq6MBEIWzvIM5FQYlmEILX9B4hTz8Lq5H0AZEGCC3df+NSklJRlKh7ikkgdg2hDn JdlFmC/500vMuLjZP7BSjT/B6+dkLjiSDamfs68neMQFck1GBqYtiBynf/N02j4IcUsD 0b9X0RsxoSmP21mZWUvjLxU86H3qjpz6LidqepRp5pCZ6RrUsl3sJ/snGLq3lpmzvLxa zEa7HUcgAKEoEZRSB23bri46zw4ymywIoT4V4agEqRS6IMiXTgVJohr9z/k1kzudAe0S j4kBQjlqdLWsAJmz3ohTfNKuS3M8aU0bMgDTFMQMsMFxDwNgXVUTDRv9ducssDBwp235 eMsQ== 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=tz/eLS9GWjuONE2SqgYz3LI8GYDdc5KRtTV4JcWn9cM=; b=GES3QlWe8y0gd7iYUe6gRZ5klM2b5FdEnSQWc+WEj425OkS86ZYPdFVjZSzHfnYpVJ 9VBLoRerZ5yB+VTQHW6BEVmKemm4HbGkTTcE9KklQoMLc5AvMoDampKsdtgMNr45ph9E amFrOX3WkwD/+BDgQeu4y/wZ3/wqv6/P6jOo3uM7Uy/Dv6aZWWypBW4IkNc7NO1JClrV AcWB2oOf1YWrhp3bSz5IpKd/8wrNficOmuPwZO7yd5vMY2aF944+oL7epnfHa43lMCe+ k8zj63b9YeyYQxsjWcDxqCSNsV4ScPlspU49dhFf6UsoQWGs0gbVxovm8QlMIUdm5sPP t+tg== X-Gm-Message-State: APjAAAW+bcX1c4yIZQUKkZfO6I59vy/NYY96sk/49gL2tPBuL29a8/7m +IYNzeWky3a9aJ4sp8Uj3pN3WawwtRI= X-Google-Smtp-Source: APXvYqzs5kotA0RconlUqusn0ksFnt4u5f65QNQXt+doD15LRKJ87F1+51WeR3xnNdC7u12LuIQJGg== X-Received: by 2002:a63:d50c:: with SMTP id c12mr18190381pgg.199.1572252885260; Mon, 28 Oct 2019 01:54:45 -0700 (PDT) Received: from wafer.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id l24sm10046115pff.151.2019.10.28.01.54.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 01:54:44 -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 v2 2/3] powerpc/pci: Fix pcibios_setup_device() ordering Date: Mon, 28 Oct 2019 19:54:23 +1100 Message-Id: <20191028085424.12006-2-oohall@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191028085424.12006-1-oohall@gmail.com> References: <20191028085424.12006-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 Oct 28 08:54:24 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: 11214999 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 9F55713B1 for ; Mon, 28 Oct 2019 08:54:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E089214E0 for ; Mon, 28 Oct 2019 08:54:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jPPkZL9o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733262AbfJ1Iyt (ORCPT ); Mon, 28 Oct 2019 04:54:49 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:34684 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730954AbfJ1Iys (ORCPT ); Mon, 28 Oct 2019 04:54:48 -0400 Received: by mail-pf1-f195.google.com with SMTP id b128so6488901pfa.1 for ; Mon, 28 Oct 2019 01:54:48 -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=r0Avz0Tu7xGXTMueLduwreUTtk3OeBAu9BGY0062r5s=; b=jPPkZL9oZ+4BBGtNUSParTCdoxGMTcmV/DOHFtVKBM3djJukwwTI4vexOF3xR0d2HK AfzmuPuaeriVHEIOcl2ZkiSMIqu3aynaAXfTOm0LnATEdO5e8ZzX5weS/CRzuCjhc+3j CID7lxWP5wEiNXC86dNOf5HflyUqUNc4THfshMLo5c17+U+glm1wrCe7bEVa15xpYppP UjmbSMBNaoAuOC9q+Y1tqdZGzIKAeupnhs1dfjmIBBaVNCqI+nXU7L05EaPtfsTY7zIB 2zzVKtE8EvYEcg22LyTe0hAHXw67J2dFe+4AuT1ACeZR4KW8ACdq8g1egfTJHgvBB/H+ alEg== 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=r0Avz0Tu7xGXTMueLduwreUTtk3OeBAu9BGY0062r5s=; b=PBt8Hlqyb12RgBs4+7GWsK/B9kr2Rjbk8CENef6SBmCCtQLq5hLwOJsFW420vovRxb ZnHI7akEU5UUrOIEx0gbTwwaXurDl2cOAL4wydob9WVy2aZwZebFX7pF2afb+B46xn/5 n/HKMP67WtYHbFjqDSYkIh1VP2sAcANihlc+3k7D4FvTqgJYcf4cKh7UXjsfe6OzkoJi fX3A5yIDUMFnQVFRFEnBmiw5Z/6Cqb5r0lP7y1zVz1gms0JdhYf9T+JYk2hQLOvkQ8wQ 9KAfts2ymGKOqJDB7YLquBs+JSXHruYKlBaBc4/3dVIEmiT67kHMaFw/+iT+YwNafOEY jbHw== X-Gm-Message-State: APjAAAWJWubxsgcy2n7PkVi64e0berb6ALQLqKZr85tg/XJGaOWuAY4I Y73EwZCWUxQwUSOAIffMlSw= X-Google-Smtp-Source: APXvYqxwWQ+V7hAAVr6qKOUlkaphE8bJSOrJP3OgpvivebAwlApw//DL8Q8ukOBbelij4/ESEo60Tg== X-Received: by 2002:a65:628e:: with SMTP id f14mr19910357pgv.114.1572252888010; Mon, 28 Oct 2019 01:54:48 -0700 (PDT) Received: from wafer.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id l24sm10046115pff.151.2019.10.28.01.54.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 01:54:47 -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 v2 3/3] powerpc/pci: Remove pcibios_setup_bus_devices() Date: Mon, 28 Oct 2019 19:54:24 +1100 Message-Id: <20191028085424.12006-3-oohall@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191028085424.12006-1-oohall@gmail.com> References: <20191028085424.12006-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)