Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/powernv: move dma_get_required_mask from pnv_phb to pci_controller_ops

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>

authored by

Andrew Donnellan and committed by
Michael Ellerman
53522982 73b341ef

+12 -31
+1
arch/powerpc/include/asm/pci-bridge.h
··· 42 42 #endif 43 43 44 44 int (*dma_set_mask)(struct pci_dev *dev, u64 dma_mask); 45 + u64 (*dma_get_required_mask)(struct pci_dev *dev); 45 46 46 47 void (*shutdown)(struct pci_controller *); 47 48 };
+7
arch/powerpc/kernel/dma.c
··· 353 353 if (ppc_md.dma_get_required_mask) 354 354 return ppc_md.dma_get_required_mask(dev); 355 355 356 + if (dev_is_pci(dev)) { 357 + struct pci_dev *pdev = to_pci_dev(dev); 358 + struct pci_controller *phb = pci_bus_to_host(pdev->bus); 359 + if (phb->controller_ops.dma_get_required_mask) 360 + return phb->controller_ops.dma_get_required_mask(pdev); 361 + } 362 + 356 363 return __dma_get_required_mask(dev); 357 364 } 358 365 EXPORT_SYMBOL_GPL(dma_get_required_mask);
+4 -3
arch/powerpc/platforms/powernv/pci-ioda.c
··· 1597 1597 return 0; 1598 1598 } 1599 1599 1600 - static u64 pnv_pci_ioda_dma_get_required_mask(struct pnv_phb *phb, 1601 - struct pci_dev *pdev) 1600 + static u64 pnv_pci_ioda_dma_get_required_mask(struct pci_dev *pdev) 1602 1601 { 1602 + struct pci_controller *hose = pci_bus_to_host(pdev->bus); 1603 + struct pnv_phb *phb = hose->private_data; 1603 1604 struct pci_dn *pdn = pci_get_pdn(pdev); 1604 1605 struct pnv_ioda_pe *pe; 1605 1606 u64 end, mask; ··· 3025 3024 .window_alignment = pnv_pci_window_alignment, 3026 3025 .reset_secondary_bus = pnv_pci_reset_secondary_bus, 3027 3026 .dma_set_mask = pnv_pci_ioda_dma_set_mask, 3027 + .dma_get_required_mask = pnv_pci_ioda_dma_get_required_mask, 3028 3028 .shutdown = pnv_pci_ioda_shutdown, 3029 3029 }; 3030 3030 ··· 3172 3170 3173 3171 /* Setup TCEs */ 3174 3172 phb->dma_dev_setup = pnv_pci_ioda_dma_dev_setup; 3175 - phb->dma_get_required_mask = pnv_pci_ioda_dma_get_required_mask; 3176 3173 3177 3174 /* Setup MSI support */ 3178 3175 pnv_pci_init_ioda_msis(phb);
-11
arch/powerpc/platforms/powernv/pci.c
··· 761 761 phb->dma_dev_setup(phb, pdev); 762 762 } 763 763 764 - u64 pnv_pci_dma_get_required_mask(struct pci_dev *pdev) 765 - { 766 - struct pci_controller *hose = pci_bus_to_host(pdev->bus); 767 - struct pnv_phb *phb = hose->private_data; 768 - 769 - if (phb && phb->dma_get_required_mask) 770 - return phb->dma_get_required_mask(phb, pdev); 771 - 772 - return __dma_get_required_mask(&pdev->dev); 773 - } 774 - 775 764 void pnv_pci_shutdown(void) 776 765 { 777 766 struct pci_controller *hose;
-2
arch/powerpc/platforms/powernv/pci.h
··· 105 105 unsigned int hwirq, unsigned int virq, 106 106 unsigned int is_64, struct msi_msg *msg); 107 107 void (*dma_dev_setup)(struct pnv_phb *phb, struct pci_dev *pdev); 108 - u64 (*dma_get_required_mask)(struct pnv_phb *phb, 109 - struct pci_dev *pdev); 110 108 void (*fixup_phb)(struct pci_controller *hose); 111 109 u32 (*bdfn_to_pe)(struct pnv_phb *phb, struct pci_bus *bus, u32 devfn); 112 110 int (*init_m64)(struct pnv_phb *phb);
-6
arch/powerpc/platforms/powernv/powernv.h
··· 12 12 #ifdef CONFIG_PCI 13 13 extern void pnv_pci_init(void); 14 14 extern void pnv_pci_shutdown(void); 15 - extern u64 pnv_pci_dma_get_required_mask(struct pci_dev *pdev); 16 15 #else 17 16 static inline void pnv_pci_init(void) { } 18 17 static inline void pnv_pci_shutdown(void) { } 19 - 20 - static inline u64 pnv_pci_dma_get_required_mask(struct pci_dev *pdev) 21 - { 22 - return 0; 23 - } 24 18 #endif 25 19 26 20 extern u32 pnv_get_supported_cpuidle_states(void);
-9
arch/powerpc/platforms/powernv/setup.c
··· 165 165 { 166 166 } 167 167 168 - static u64 pnv_dma_get_required_mask(struct device *dev) 169 - { 170 - if (dev_is_pci(dev)) 171 - return pnv_pci_dma_get_required_mask(to_pci_dev(dev)); 172 - 173 - return __dma_get_required_mask(dev); 174 - } 175 - 176 168 static void pnv_shutdown(void) 177 169 { 178 170 /* Let the PCI code clear up IODA tables */ ··· 306 314 .machine_shutdown = pnv_shutdown, 307 315 .power_save = power7_idle, 308 316 .calibrate_decr = generic_calibrate_decr, 309 - .dma_get_required_mask = pnv_dma_get_required_mask, 310 317 #ifdef CONFIG_KEXEC 311 318 .kexec_cpu_down = pnv_kexec_cpu_down, 312 319 #endif