Message ID | 20191120012859.23300-5-oohall@gmail.com (mailing list archive) |
---|---|
State | RFC |
Headers | show |
Series | [Very,RFC,01/46] powerpc/eeh: Don't attempt to restore VF config space after reset | expand |
On 20/11/2019 12:28, Oliver O'Halloran wrote: > These functions are only used from pci-ioda.c. Move them in there and remove > the prototypes from the header files. Make them static then, or am I missing the point? With that fixed, Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru> Also, pci-ioda.c is around 4000 lines long, if anything I'd rather be moving things to a separate new file (pci-ioda-dma.c or whatever). OTOH after everything you've done, pci-ioda.c is 77 lines shorter so I'll shut up now :) > > Signed-off-by: Oliver O'Halloran <oohall@gmail.com> > --- > arch/powerpc/platforms/powernv/pci-ioda.c | 43 +++++++++++++++++++++++ > arch/powerpc/platforms/powernv/pci.c | 43 ----------------------- > arch/powerpc/platforms/powernv/pci.h | 2 -- > 3 files changed, 43 insertions(+), 45 deletions(-) > > diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c > index 099c0bb1a9b9..c2b3a5a13004 100644 > --- a/arch/powerpc/platforms/powernv/pci-ioda.c > +++ b/arch/powerpc/platforms/powernv/pci-ioda.c > @@ -3637,6 +3637,49 @@ static void pnv_pci_ioda_shutdown(struct pci_controller *hose) > OPAL_ASSERT_RESET); > } > > +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); > +} > + > +void pnv_pci_dma_bus_setup(struct pci_bus *bus) > +{ > + struct pci_controller *hose = bus->sysdata; > + struct pnv_phb *phb = hose->private_data; > + struct pnv_ioda_pe *pe; > + > + list_for_each_entry(pe, &phb->ioda.pe_list, list) { > + if (!(pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL))) > + continue; > + > + if (!pe->pbus) > + continue; > + > + if (bus->number == ((pe->rid >> 8) & 0xFF)) { > + pe->pbus = bus; > + break; > + } > + } > +} > + > static const struct pci_controller_ops pnv_pci_ioda_controller_ops = { > .dma_dev_setup = pnv_pci_dma_dev_setup, > .dma_bus_setup = pnv_pci_dma_bus_setup, > diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c > index b7761e2e06f8..8b9058b52575 100644 > --- a/arch/powerpc/platforms/powernv/pci.c > +++ b/arch/powerpc/platforms/powernv/pci.c > @@ -810,49 +810,6 @@ struct iommu_table *pnv_pci_table_alloc(int nid) > return tbl; > } > > -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); > -} > - > -void pnv_pci_dma_bus_setup(struct pci_bus *bus) > -{ > - struct pci_controller *hose = bus->sysdata; > - struct pnv_phb *phb = hose->private_data; > - struct pnv_ioda_pe *pe; > - > - list_for_each_entry(pe, &phb->ioda.pe_list, list) { > - if (!(pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL))) > - continue; > - > - if (!pe->pbus) > - continue; > - > - if (bus->number == ((pe->rid >> 8) & 0xFF)) { > - pe->pbus = bus; > - break; > - } > - } > -} > - > struct device_node *pnv_pci_get_phb_node(struct pci_dev *dev) > { > struct pci_controller *hose = pci_bus_to_host(dev->bus); > diff --git a/arch/powerpc/platforms/powernv/pci.h b/arch/powerpc/platforms/powernv/pci.h > index 01a01739c03e..f23145575048 100644 > --- a/arch/powerpc/platforms/powernv/pci.h > +++ b/arch/powerpc/platforms/powernv/pci.h > @@ -189,8 +189,6 @@ extern void pnv_npu2_map_lpar(struct pnv_ioda_pe *gpe, unsigned long msr); > extern void pnv_pci_reset_secondary_bus(struct pci_dev *dev); > extern int pnv_eeh_phb_reset(struct pci_controller *hose, int option); > > -extern void pnv_pci_dma_dev_setup(struct pci_dev *pdev); > -extern void pnv_pci_dma_bus_setup(struct pci_bus *bus); > extern int pnv_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type); > extern void pnv_teardown_msi_irqs(struct pci_dev *pdev); > extern struct pnv_ioda_pe *__pnv_ioda_get_pe(struct pnv_phb *phb, u16 bdfn); >
On Thu, Nov 21, 2019 at 3:02 PM Alexey Kardashevskiy <aik@ozlabs.ru> wrote: > > > > On 20/11/2019 12:28, Oliver O'Halloran wrote: > > These functions are only used from pci-ioda.c. Move them in there and remove > > the prototypes from the header files. > > > Make them static then, or am I missing the point? I forgot. > > With that fixed, > > > Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru> > > > > Also, pci-ioda.c is around 4000 lines long, if anything I'd rather be > moving things to a separate new file (pci-ioda-dma.c or whatever). OTOH > after everything you've done, pci-ioda.c is 77 lines shorter so I'll > shut up now :) IMO pci-ioda and pci.c should probably be folded together since there's no clear distinction between the two. We might be able to split off the PCI/NPU/OpenCAPI PHB specific functions into separate files to slim things down a bit, but I still need to re-work some of PHB init code and to make that possible. Oliver
> +#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 */ It would be nice to split this into a helper. And I think using IS_ENABLED we might not even need ifdefs: static void pnv_pci_dma_fixup_vfs(struct pci_dev *pdev) { struct pnv_ioda_pe *pe; list_for_each_entry(pe, &phb->ioda.pe_list, list) { if (pe->rid == ((pdev->bus->number << 8) | (pdev->devfn & 0xff))) { pe->pdev = pdev; break; } } ... if (IS_ENABLED(CONFIG_PCI_IOV) && pdev->is_virtfn) pnv_pci_dma_fixup_vfs(pdev);
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 099c0bb1a9b9..c2b3a5a13004 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -3637,6 +3637,49 @@ static void pnv_pci_ioda_shutdown(struct pci_controller *hose) OPAL_ASSERT_RESET); } +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); +} + +void pnv_pci_dma_bus_setup(struct pci_bus *bus) +{ + struct pci_controller *hose = bus->sysdata; + struct pnv_phb *phb = hose->private_data; + struct pnv_ioda_pe *pe; + + list_for_each_entry(pe, &phb->ioda.pe_list, list) { + if (!(pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL))) + continue; + + if (!pe->pbus) + continue; + + if (bus->number == ((pe->rid >> 8) & 0xFF)) { + pe->pbus = bus; + break; + } + } +} + static const struct pci_controller_ops pnv_pci_ioda_controller_ops = { .dma_dev_setup = pnv_pci_dma_dev_setup, .dma_bus_setup = pnv_pci_dma_bus_setup, diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c index b7761e2e06f8..8b9058b52575 100644 --- a/arch/powerpc/platforms/powernv/pci.c +++ b/arch/powerpc/platforms/powernv/pci.c @@ -810,49 +810,6 @@ struct iommu_table *pnv_pci_table_alloc(int nid) return tbl; } -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); -} - -void pnv_pci_dma_bus_setup(struct pci_bus *bus) -{ - struct pci_controller *hose = bus->sysdata; - struct pnv_phb *phb = hose->private_data; - struct pnv_ioda_pe *pe; - - list_for_each_entry(pe, &phb->ioda.pe_list, list) { - if (!(pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL))) - continue; - - if (!pe->pbus) - continue; - - if (bus->number == ((pe->rid >> 8) & 0xFF)) { - pe->pbus = bus; - break; - } - } -} - struct device_node *pnv_pci_get_phb_node(struct pci_dev *dev) { struct pci_controller *hose = pci_bus_to_host(dev->bus); diff --git a/arch/powerpc/platforms/powernv/pci.h b/arch/powerpc/platforms/powernv/pci.h index 01a01739c03e..f23145575048 100644 --- a/arch/powerpc/platforms/powernv/pci.h +++ b/arch/powerpc/platforms/powernv/pci.h @@ -189,8 +189,6 @@ extern void pnv_npu2_map_lpar(struct pnv_ioda_pe *gpe, unsigned long msr); extern void pnv_pci_reset_secondary_bus(struct pci_dev *dev); extern int pnv_eeh_phb_reset(struct pci_controller *hose, int option); -extern void pnv_pci_dma_dev_setup(struct pci_dev *pdev); -extern void pnv_pci_dma_bus_setup(struct pci_bus *bus); extern int pnv_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type); extern void pnv_teardown_msi_irqs(struct pci_dev *pdev); extern struct pnv_ioda_pe *__pnv_ioda_get_pe(struct pnv_phb *phb, u16 bdfn);
These functions are only used from pci-ioda.c. Move them in there and remove the prototypes from the header files. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> --- arch/powerpc/platforms/powernv/pci-ioda.c | 43 +++++++++++++++++++++++ arch/powerpc/platforms/powernv/pci.c | 43 ----------------------- arch/powerpc/platforms/powernv/pci.h | 2 -- 3 files changed, 43 insertions(+), 45 deletions(-)