]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
powerpc/iov: Move VF pdev fixup into pcibios_fixup_iov()
authorOliver O'Halloran <oohall@gmail.com>
Fri, 10 Jan 2020 07:02:05 +0000 (18:02 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Feb 2020 07:38:07 +0000 (08:38 +0100)
[ Upstream commit 965c94f309be58fbcc6c8d3e4f123376c5970d79 ]

An ioda_pe for each VF is allocated in pnv_pci_sriov_enable() before
the pci_dev for the VF is created. We need to set the pe->pdev pointer
at some point after the pci_dev is created. Currently we do that in:

pcibios_bus_add_device()
pnv_pci_dma_dev_setup() (via phb->ops.dma_dev_setup)
/* fixup is done here */
pnv_pci_ioda_dma_dev_setup() (via pnv_phb->dma_dev_setup)

The fixup needs to be done before setting up DMA for for the VF's PE,
but there's no real reason to delay it until this point. Move the
fixup into pnv_pci_ioda_fixup_iov() so the ordering is:

pcibios_add_device()
pnv_pci_ioda_fixup_iov() (via ppc_md.pcibios_fixup_sriov)

pcibios_bus_add_device()
...

This isn't strictly required, but it's a slightly more logical place
to do the fixup and it simplifies pnv_pci_dma_dev_setup().

Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200110070207.439-4-oohall@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/powerpc/platforms/powernv/pci-ioda.c
arch/powerpc/platforms/powernv/pci.c

index 4374836b033b40020d8c1585b93e8b250b972041..67e4628dd5274e840a9c0bbd50f9541dfa81359f 100644 (file)
@@ -2900,9 +2900,6 @@ static void pnv_pci_ioda_fixup_iov_resources(struct pci_dev *pdev)
        struct pci_dn *pdn;
        int mul, total_vfs;
 
-       if (!pdev->is_physfn || pci_dev_is_added(pdev))
-               return;
-
        pdn = pci_get_pdn(pdev);
        pdn->vfs_expanded = 0;
        pdn->m64_single_mode = false;
@@ -2977,6 +2974,30 @@ truncate_iov:
                res->end = res->start - 1;
        }
 }
+
+static void pnv_pci_ioda_fixup_iov(struct pci_dev *pdev)
+{
+       if (WARN_ON(pci_dev_is_added(pdev)))
+               return;
+
+       if (pdev->is_virtfn) {
+               struct pnv_ioda_pe *pe = pnv_ioda_get_pe(pdev);
+
+               /*
+                * VF PEs are single-device PEs so their pdev pointer needs to
+                * be set. The pdev doesn't exist when the PE is allocated (in
+                * (pcibios_sriov_enable()) so we fix it up here.
+                */
+               pe->pdev = pdev;
+               WARN_ON(!(pe->flags & PNV_IODA_PE_VF));
+       } else if (pdev->is_physfn) {
+               /*
+                * For PFs adjust their allocated IOV resources to match what
+                * the PHB can support using it's M64 BAR table.
+                */
+               pnv_pci_ioda_fixup_iov_resources(pdev);
+       }
+}
 #endif /* CONFIG_PCI_IOV */
 
 static void pnv_ioda_setup_pe_res(struct pnv_ioda_pe *pe,
@@ -3873,7 +3894,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
        ppc_md.pcibios_default_alignment = pnv_pci_default_alignment;
 
 #ifdef CONFIG_PCI_IOV
-       ppc_md.pcibios_fixup_sriov = pnv_pci_ioda_fixup_iov_resources;
+       ppc_md.pcibios_fixup_sriov = pnv_pci_ioda_fixup_iov;
        ppc_md.pcibios_iov_resource_alignment = pnv_pci_iov_resource_alignment;
        ppc_md.pcibios_sriov_enable = pnv_pcibios_sriov_enable;
        ppc_md.pcibios_sriov_disable = pnv_pcibios_sriov_disable;
index e8e58a2cccddf7e3296eedf6dc0450c99272f71b..8307e1f4086cb3fc3bb9b5c5660605a6ab0f5cdb 100644 (file)
@@ -814,20 +814,6 @@ void pnv_pci_dma_dev_setup(struct pci_dev *pdev)
 {
        struct pci_controller *hose = pci_bus_to_host(pdev->bus);
        struct pnv_phb *phb = hose->private_data;
-#ifdef CONFIG_PCI_IOV
-       struct pnv_ioda_pe *pe;
-
-       /* Fix the VF pdn PE number */
-       if (pdev->is_virtfn) {
-               list_for_each_entry(pe, &phb->ioda.pe_list, list) {
-                       if (pe->rid == ((pdev->bus->number << 8) |
-                           (pdev->devfn & 0xff))) {
-                               pe->pdev = pdev;
-                               break;
-                       }
-               }
-       }
-#endif /* CONFIG_PCI_IOV */
 
        if (phb && phb->dma_dev_setup)
                phb->dma_dev_setup(phb, pdev);