powerpc/powernv: move dma_get_required_mask from pnv_phb to pci_controller_ops
authorAndrew Donnellan <andrew.donnellan@au1.ibm.com>
Fri, 7 Aug 2015 03:45:54 +0000 (13:45 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 18 Aug 2015 09:32:11 +0000 (19:32 +1000)
Simplify the dma_get_required_mask call chain by moving it from pnv_phb to
pci_controller_ops, similar to commit 763d2d8df1ee ("powerpc/powernv:
Move dma_set_mask from pnv_phb to pci_controller_ops").

Previous call chain:

  0) call dma_get_required_mask() (kernel/dma.c)
  1) call ppc_md.dma_get_required_mask, if it exists. On powernv, that
     points to pnv_dma_get_required_mask() (platforms/powernv/setup.c)
  2) device is PCI, therefore call pnv_pci_dma_get_required_mask()
     (platforms/powernv/pci.c)
  3) call phb->dma_get_required_mask if it exists
  4) it only exists in the ioda case, where it points to
       pnv_pci_ioda_dma_get_required_mask() (platforms/powernv/pci-ioda.c)

New call chain:

  0) call dma_get_required_mask() (kernel/dma.c)
  1) device is PCI, therefore call pci_controller_ops.dma_get_required_mask
     if it exists
  2) in the ioda case, that points to pnv_pci_ioda_dma_get_required_mask()
     (platforms/powernv/pci-ioda.c)

In the p5ioc2 case, the call chain remains the same -
dma_get_required_mask() does not find either a ppc_md call or
pci_controller_ops call, so it calls __dma_get_required_mask().

Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/pci-bridge.h
arch/powerpc/kernel/dma.c
arch/powerpc/platforms/powernv/pci-ioda.c
arch/powerpc/platforms/powernv/pci.c
arch/powerpc/platforms/powernv/pci.h
arch/powerpc/platforms/powernv/powernv.h
arch/powerpc/platforms/powernv/setup.c

index 712add5..37fc535 100644 (file)
@@ -42,6 +42,7 @@ struct pci_controller_ops {
 #endif
 
        int             (*dma_set_mask)(struct pci_dev *dev, u64 dma_mask);
+       u64             (*dma_get_required_mask)(struct pci_dev *dev);
 
        void            (*shutdown)(struct pci_controller *);
 };
index 1558f81..59503ed 100644 (file)
@@ -353,6 +353,13 @@ u64 dma_get_required_mask(struct device *dev)
        if (ppc_md.dma_get_required_mask)
                return ppc_md.dma_get_required_mask(dev);
 
+       if (dev_is_pci(dev)) {
+               struct pci_dev *pdev = to_pci_dev(dev);
+               struct pci_controller *phb = pci_bus_to_host(pdev->bus);
+               if (phb->controller_ops.dma_get_required_mask)
+                       return phb->controller_ops.dma_get_required_mask(pdev);
+       }
+
        return __dma_get_required_mask(dev);
 }
 EXPORT_SYMBOL_GPL(dma_get_required_mask);
index fdafbac..528cd1e 100644 (file)
@@ -1597,9 +1597,10 @@ static int pnv_pci_ioda_dma_set_mask(struct pci_dev *pdev, u64 dma_mask)
        return 0;
 }
 
-static u64 pnv_pci_ioda_dma_get_required_mask(struct pnv_phb *phb,
-                                             struct pci_dev *pdev)
+static u64 pnv_pci_ioda_dma_get_required_mask(struct pci_dev *pdev)
 {
+       struct pci_controller *hose = pci_bus_to_host(pdev->bus);
+       struct pnv_phb *phb = hose->private_data;
        struct pci_dn *pdn = pci_get_pdn(pdev);
        struct pnv_ioda_pe *pe;
        u64 end, mask;
@@ -3024,6 +3025,7 @@ static const struct pci_controller_ops pnv_pci_ioda_controller_ops = {
        .window_alignment = pnv_pci_window_alignment,
        .reset_secondary_bus = pnv_pci_reset_secondary_bus,
        .dma_set_mask = pnv_pci_ioda_dma_set_mask,
+       .dma_get_required_mask = pnv_pci_ioda_dma_get_required_mask,
        .shutdown = pnv_pci_ioda_shutdown,
 };
 
@@ -3170,7 +3172,6 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,
 
        /* Setup TCEs */
        phb->dma_dev_setup = pnv_pci_ioda_dma_dev_setup;
-       phb->dma_get_required_mask = pnv_pci_ioda_dma_get_required_mask;
 
        /* Setup MSI support */
        pnv_pci_init_ioda_msis(phb);
index 765d8ed..3e7f6fd 100644 (file)
@@ -761,17 +761,6 @@ void pnv_pci_dma_dev_setup(struct pci_dev *pdev)
                phb->dma_dev_setup(phb, pdev);
 }
 
-u64 pnv_pci_dma_get_required_mask(struct pci_dev *pdev)
-{
-       struct pci_controller *hose = pci_bus_to_host(pdev->bus);
-       struct pnv_phb *phb = hose->private_data;
-
-       if (phb && phb->dma_get_required_mask)
-               return phb->dma_get_required_mask(phb, pdev);
-
-       return __dma_get_required_mask(&pdev->dev);
-}
-
 void pnv_pci_shutdown(void)
 {
        struct pci_controller *hose;
index e891ff4..c8ff50e 100644 (file)
@@ -105,8 +105,6 @@ struct pnv_phb {
                         unsigned int hwirq, unsigned int virq,
                         unsigned int is_64, struct msi_msg *msg);
        void (*dma_dev_setup)(struct pnv_phb *phb, struct pci_dev *pdev);
-       u64 (*dma_get_required_mask)(struct pnv_phb *phb,
-                                    struct pci_dev *pdev);
        void (*fixup_phb)(struct pci_controller *hose);
        u32 (*bdfn_to_pe)(struct pnv_phb *phb, struct pci_bus *bus, u32 devfn);
        int (*init_m64)(struct pnv_phb *phb);
index 9269e30..6dbc0a1 100644 (file)
@@ -12,15 +12,9 @@ struct pci_dev;
 #ifdef CONFIG_PCI
 extern void pnv_pci_init(void);
 extern void pnv_pci_shutdown(void);
-extern u64 pnv_pci_dma_get_required_mask(struct pci_dev *pdev);
 #else
 static inline void pnv_pci_init(void) { }
 static inline void pnv_pci_shutdown(void) { }
-
-static inline u64 pnv_pci_dma_get_required_mask(struct pci_dev *pdev)
-{
-       return 0;
-}
 #endif
 
 extern u32 pnv_get_supported_cpuidle_states(void);
index 53737e0..77a31c1 100644 (file)
@@ -165,14 +165,6 @@ static void pnv_progress(char *s, unsigned short hex)
 {
 }
 
-static u64 pnv_dma_get_required_mask(struct device *dev)
-{
-       if (dev_is_pci(dev))
-               return pnv_pci_dma_get_required_mask(to_pci_dev(dev));
-
-       return __dma_get_required_mask(dev);
-}
-
 static void pnv_shutdown(void)
 {
        /* Let the PCI code clear up IODA tables */
@@ -314,7 +306,6 @@ define_machine(powernv) {
        .machine_shutdown       = pnv_shutdown,
        .power_save             = power7_idle,
        .calibrate_decr         = generic_calibrate_decr,
-       .dma_get_required_mask  = pnv_dma_get_required_mask,
 #ifdef CONFIG_KEXEC
        .kexec_cpu_down         = pnv_kexec_cpu_down,
 #endif