[Very RFC 04/46] powernv/pci: Move dma_{dev|bus}_setup into pci-ioda.c

Alexey Kardashevskiy aik at ozlabs.ru
Thu Nov 21 15:02:32 AEDT 2019



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 at 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 at 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);
> 

-- 
Alexey


More information about the Linuxppc-dev mailing list