Refactor PCI controller operations
v2 cover Refactor PCI controller operations
This patch set moves some PCI controller operations out of ppc_md and into a new pci_controller_ops struct.
This is desirable for systems with more than one type of PCI controller. In particular, it's intended that this new interface will be used by the CXL (aka CAPI) driver.
The design tries to balance a desire to avoid having yet another abstraction layer with a desire to make it easy for vendor kernels to pull in as little or as much as they are comfortable with.
To this end, it's in 3 main parts:
1) Set up the pci_controller_ops structure. For each function we add to the structure, set up a shim that calls the controller_ops function if it exists, or the ppc_md function otherwise. Modify callsites to use the shims.
2) Move each affected platform over from using ppc_md to using the controller_ops structure.
3) Take out the shims and the ppc_md entries. Modify the callsites to use the controller_ops calls.
MSI and some legacy functions have been deliberately deferred, and will be to be tackled at a later point.
The set has been build tested for PowerNV, pSeries, Power Mac, Maple, Cell, PaSemi and Corenet 64 (for fsl_pci). It builds at every point in the series.
The set depends on mpe's two recent cleanup patches to remove powernv RTAS support [1] and drop celleb [2].
Thanks for feedback from mpe, there is one functional change since v1, and a number of cosmetic ones.
Functionally:
- A mistake was made regarding in fsl_pci/swiotlb. I though that setting ppc_swiotlb_enable in fsl_pci.c couldn't have an effect, and removed it in patch #4. This was wrong. Drop the offending patch. In the patch that ports fsl_pci/swiotlb to the new structure, move the hook around so that it always has the correct value.
Cosmetically:
- Prefer "phb" over "hose" whenever possible.
- Drop an unnecessary renaming patch. (prev #3)
- Squash all the shim removal.
- Squash the creation of the struct with the addition of the first member.
- Better commit messages. (Thanks sfr & mpe)
- Shims now have names that (where possible) match the ppc_md names, rather than the new, non-namespaced names.
The series has also been rebased onto -rc6; no changes were necessary.
The full breakdown of the patches is as follows:
Patches 1 - 3: minor necessary cleanups
Patches 4 - 9: Introduce struct and shims
Patches 10 - 17: Platform specific migrations
Patch 18: Remove shims
Patch 19: Final cleanup
Daniel Axtens (19):
powerpc: move find_and_init_phbs() to pSeries specific code powerpc/powermac: move pmac_pci_probe_mode from setup.c to pci.c
powerpc: pcibios_enable_device_hook: return bool rather than int
powerpc: Create pci_controller_ops.dma_dev_setup and shims
powerpc: Create pci_controller_ops.dma_bus_setup and shim
powerpc: Create pci_controller_ops.probe_mode and shim
powerpc: Create pci_controller_ops.enable_device_hook and shim
powerpc: Create pci_controller_ops.window_alignment and shim
powerpc: Create pci_controller_ops.reset_secondary_bus and shim
powerpc: dart_iommu: optionally populate controller_ops on init powerpc/powermac: Move controller ops from ppc_md to controller_ops powerpc/pseries: Move controller ops from ppc_md to controller_ops powerpc/powernv: Move controller ops from ppc_md to controller_ops powerpc/pasemi: Move controller ops from ppc_md to controller_ops powerpc/maple: Move controller ops from ppc_md to controller_ops
powerpc: fsl_pci, swiotlb: Move controller ops from ppc_md to
controller_ops
powerpc/cell: Move controller ops from ppc_md to controller_ops
powerpc: Remove shims for pci_controller_ops operations
powerpc: dart_iommu: Remove check for controller_ops == NULL case
arch/powerpc/include/asm/iommu.h | 3 +- arch/powerpc/include/asm/machdep.h | 14 -------- arch/powerpc/include/asm/pci-bridge.h | 19 +++++++++++ arch/powerpc/include/asm/pci.h | 2 +- arch/powerpc/include/asm/ppc-pci.h | 3 -- arch/powerpc/kernel/dma-swiotlb.c | 11 +++--- arch/powerpc/kernel/pci-common.c | 35 ++++++++++++------- arch/powerpc/kernel/pci-hotplug.c | 7 ++-- arch/powerpc/kernel/pci_of_scan.c | 7 ++-- arch/powerpc/kernel/rtas_pci.c | 47 ------------------------- arch/powerpc/platforms/cell/cell.h | 24 +++++++++++++ arch/powerpc/platforms/cell/iommu.c | 7 ++-- arch/powerpc/platforms/cell/setup.c | 5 +++ arch/powerpc/platforms/maple/maple.h | 2 ++ arch/powerpc/platforms/maple/pci.c | 4 +++ arch/powerpc/platforms/maple/setup.c | 2 +- arch/powerpc/platforms/pasemi/iommu.c | 6 ++-- arch/powerpc/platforms/pasemi/pasemi.h | 1 + arch/powerpc/platforms/pasemi/pci.c | 5 +++ arch/powerpc/platforms/powermac/pci.c | 38 ++++++++++++++++++--- arch/powerpc/platforms/powermac/pmac.h | 3 +- arch/powerpc/platforms/powermac/setup.c | 22 +----------- arch/powerpc/platforms/powernv/pci-ioda.c | 15 ++++---- arch/powerpc/platforms/powernv/pci-p5ioc2.c | 1 + arch/powerpc/platforms/powernv/pci.c | 5 ++- arch/powerpc/platforms/powernv/powernv.h | 2 ++ arch/powerpc/platforms/pseries/iommu.c | 9 ++--- arch/powerpc/platforms/pseries/pseries.h | 2 ++ arch/powerpc/platforms/pseries/setup.c | 53 ++++++++++++++++++++++++++++- arch/powerpc/sysdev/dart_iommu.c | 10 +++--- arch/powerpc/sysdev/fsl_pci.c | 19 +++++++++++ 31 files changed, 244 insertions(+), 139 deletions(-) create mode 100644 arch/powerpc/platforms/cell/cell.h
Signature · 1 line
2.1.4
PATCH v2 1/19 powerpc: move find_and_init_phbs() to pSeries specific code
Previously, find_and_init_phbs() was used in both PowerNV and pSeries setup. However, since RTAS support has been dropped from PowerNV, we can move it into a platform-specific file.
---
This patch depends on the patch to drop RTAS support from PowerNV:
http://patchwork.ozlabs.org/patch/449316/
--- arch/powerpc/include/asm/ppc-pci.h | 3 --- arch/powerpc/kernel/rtas_pci.c | 47 ---------------------------------- arch/powerpc/platforms/pseries/setup.c | 47 ++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 50 deletions(-)
arch/powerpc/include/asm/ppc-pci.h +0 -3
@@ -23,8 +23,6 @@ extern void pci_setup_phb_io_dynamic(struct pci_controller *hose, int primary);extern struct list_head hose_list; -extern void find_and_init_phbs (void ); -extern struct pci_dev *isa_bridge_pcidev;/* may be NULL if no ISA bus */ /** Bus Unit ID macros; get low and hi 32-bits of the 64-bit BUID */
@@ -76,7 +74,6 @@ static inline const char *eeh_driver_name(struct pci_dev *pdev)#endif /* CONFIG_EEH */ #else /* CONFIG_PCI */ -static inline void find_and_init_phbs (void ) { }static inline void init_pci_config_tokens (void ) { }#endif /* !CONFIG_PCI */
arch/powerpc/kernel/rtas_pci.c +0 -47
50 lines not on this page · raw message
arch/powerpc/platforms/pseries/setup.c +47 -0
53 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 2/19 powerpc/powermac: move pmac_pci_probe_mode from setup.c to pci.c
In reply to Daniel Axtens--- arch/powerpc/platforms/powermac/pci.c | 17 +++++++++++++++++ arch/powerpc/platforms/powermac/pmac.h | 4 ++++ arch/powerpc/platforms/powermac/setup.c | 18 ------------------ 3 files changed, 21 insertions(+), 18 deletions(-)
arch/powerpc/platforms/powermac/pci.c +17 -0
@@ -1223,3 +1223,20 @@ static void fixup_u4_pcie(struct pci_dev* dev)pci_write_config_dword (dev,PCI_PREF_MEMORY_BASE ,0 ); }DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_APPLE ,PCI_DEVICE_ID_APPLE_U4_PCIE , fixup_u4_pcie); + +#ifdef CONFIG_PPC64 +int pmac_pci_probe_mode (struct pci_bus *bus) +{ +struct device_node *node =pci_bus_to_OF_node (bus); + +/* We need to use normal PCI probing for the AGP bus, +* since the device for the AGP bridge isn't in the tree. +* Same for the PCIe host on U4 and the HT host bridge. +*/ +if (bus->self ==NULL && (of_device_is_compatible (node,"u3-agp" ) || +of_device_is_compatible (node,"u4-pcie" ) || +of_device_is_compatible (node,"u3-ht" ))) +return PCI_PROBE_NORMAL ; +return PCI_PROBE_DEVTREE ; +} +#endif /* CONFIG_PPC64 */
arch/powerpc/platforms/powermac/pmac.h +4 -0
@@ -39,4 +39,8 @@ extern void low_cpu_die(void) __attribute__((noreturn));extern int pmac_nvram_init (void );extern void pmac_pic_init (void ); +#ifdef CONFIG_PPC64 +extern int pmac_pci_probe_mode (struct pci_bus *bus); +#endif +#endif /* __PMAC_H__ */
arch/powerpc/platforms/powermac/setup.c +0 -18
@@ -637,24 +637,6 @@ static int __init pmac_probe(void)return 1 ; } -#ifdef CONFIG_PPC64 -/* Move that to pci.c */ -static int pmac_pci_probe_mode (struct pci_bus *bus) -{ -struct device_node *node =pci_bus_to_OF_node (bus); - -/* We need to use normal PCI probing for the AGP bus, -* since the device for the AGP bridge isn't in the tree. -* Same for the PCIe host on U4 and the HT host bridge. -*/ -if (bus->self ==NULL && (of_device_is_compatible (node,"u3-agp" ) || -of_device_is_compatible (node,"u4-pcie" ) || -of_device_is_compatible (node,"u3-ht" ))) -return PCI_PROBE_NORMAL ; -return PCI_PROBE_DEVTREE ; -} -#endif /* CONFIG_PPC64 */ -define_machine (powermac) { .name = "PowerMac", .probe = pmac_probe,
Signature · 1 line
2.1.4
PATCH v2 3/19 powerpc: pcibios_enable_device_hook: return bool rather than int
In reply to Daniel Axtenspcibios_enable_device_hook returned an int. Every implementation returned either -EINVAL or 0. The return value wasn't propagated by the caller: any non-zero return value caused pcibios_enable_device to return -EINVAL itself. Therefore, make the hook return a bool.
--- arch/powerpc/include/asm/machdep.h | 4 ++-- arch/powerpc/kernel/pci-common.c | 2 +- arch/powerpc/platforms/powermac/pci.c | 8 ++++---- arch/powerpc/platforms/powermac/pmac.h | 2 +- arch/powerpc/platforms/powernv/pci-ioda.c | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-)
arch/powerpc/include/asm/machdep.h +2 -2
@@ -237,9 +237,9 @@ struct machdep_calls {/* Called for each PCI bus in the system when it's probed */ void (*pcibios_fixup_bus)(struct pci_bus *); -/* Called when pci_enable_device() is called. Returns 0 to +/* Called when pci_enable_device() is called. Returns true to * allow assignment/enabling of the device. */ -int (*pcibios_enable_device_hook)(struct pci_dev *); +bool (*pcibios_enable_device_hook)(struct pci_dev *);/* Called after scan and before resource survey */ void (*pcibios_fixup_phb)(struct pci_controller *hose);
arch/powerpc/kernel/pci-common.c +1 -1
@@ -1451,7 +1451,7 @@ EXPORT_SYMBOL_GPL(pcibios_finish_adding_to_bus);int pcibios_enable_device (struct pci_dev *dev,int mask) {if (ppc_md.pcibios_enable_device_hook) -if (ppc_md.pcibios_enable_device_hook (dev)) +if (!ppc_md.pcibios_enable_device_hook (dev))return -EINVAL ;return pci_enable_resources (dev, mask);
arch/powerpc/platforms/powermac/pci.c +4 -4
@@ -942,7 +942,7 @@ void __init pmac_pci_init(void) }#ifdef CONFIG_PPC32 -int pmac_pci_enable_device_hook (struct pci_dev *dev) +bool pmac_pci_enable_device_hook (struct pci_dev *dev) {struct device_node * node;int updatecfg =0 ;
@@ -958,11 +958,11 @@ int pmac_pci_enable_device_hook(struct pci_dev *dev) && !node) {printk (KERN_INFO "Apple USB OHCI %s disabled by firmware\n" ,pci_name (dev)); -return -EINVAL ; +return false; }if (!node) -return 0 ; +return true; uninorth_child = node->parent &&of_device_is_compatible (node->parent,"uni-north" );
@@ -1003,7 +1003,7 @@ int pmac_pci_enable_device_hook(struct pci_dev *dev) L1_CACHE_BYTES >> 2); } -return 0 ; +return true; }void pmac_pci_fixup_ohci (struct pci_dev *dev)
arch/powerpc/platforms/powermac/pmac.h +1 -1
@@ -25,7 +25,7 @@ extern void pmac_pci_init(void);extern void pmac_nvram_update (void );extern unsigned char pmac_nvram_read_byte (int addr);extern void pmac_nvram_write_byte (int addr,unsigned char val); -extern int pmac_pci_enable_device_hook (struct pci_dev *dev); +extern bool pmac_pci_enable_device_hook (struct pci_dev *dev);extern void pmac_pcibios_after_init (void );extern int of_show_percpuinfo (struct seq_file *m,int i);
arch/powerpc/platforms/powernv/pci-ioda.c +4 -4
@@ -1910,7 +1910,7 @@ static resource_size_t pnv_pci_window_alignment(struct pci_bus *bus,/* Prevent enabling devices for which we couldn't properly * assign a PE */ -static int pnv_pci_enable_device_hook (struct pci_dev *dev) +static bool pnv_pci_enable_device_hook (struct pci_dev *dev) {struct pci_controller *hose =pci_bus_to_host (dev->bus);struct pnv_phb *phb = hose->private_data;
@@ -1922,13 +1922,13 @@ static int pnv_pci_enable_device_hook(struct pci_dev *dev)* PEs isn't ready. */ if (!phb->initialized) -return 0 ; +return true; pdn =pci_get_pdn (dev);if (!pdn || pdn->pe_number ==IODA_INVALID_PE ) -return -EINVAL ; +return false; -return 0 ; +return true; } static u32 pnv_ioda_bdfn_to_pe(struct pnv_phb *phb, struct pci_bus *bus,
Signature · 1 line
2.1.4
PATCH v2 4/19 powerpc: Create pci_controller_ops.dma_dev_setup and shim
In reply to Daniel AxtensIntroduces the pci_controller_ops structure.
Add pci_controller_ops.dma_dev_setup, shadowing ppc_md.pci_dma_dev_setup. Add a shim, and change the callsites to use the shim.
---
v1 --> v2:
- Better commit message
- Use phb in favour of hose
- Make shim name match ppc_md name, not pci_controller_ops name.
--- arch/powerpc/include/asm/pci-bridge.h | 21 +++++++++++++++++++++ arch/powerpc/kernel/pci-common.c | 3 +-- 2 files changed, 22 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +21 -0
@@ -15,6 +15,13 @@struct device_node ;/* +* PCI controller operations +*/ +struct pci_controller_ops { +void (*dma_dev_setup)(struct pci_dev *dev); +}; + +/* * Structure of a PCI controller (host bridge) */ struct pci_controller {
@@ -46,6 +53,7 @@ struct pci_controller {resource_size_t isa_mem_phys;resource_size_t isa_mem_size; +struct pci_controller_ops controller_ops;struct pci_ops *ops;unsigned int __iomem *cfg_addr;void __iomem *cfg_data;
@@ -258,5 +266,18 @@ static inline int pcibios_vaddr_is_ioport(void __iomem *address) }#endif /* CONFIG_PCI */ +/* +* Shims to prefer pci_controller version over ppc_md where available. +*/ +static inline void pci_dma_dev_setup (struct pci_dev *dev) +{ +struct pci_controller *phb =pci_bus_to_host (dev->bus); + +if (phb->controller_ops.dma_dev_setup) + phb->controller_ops.dma_dev_setup (dev); +else if (ppc_md.pci_dma_dev_setup) + ppc_md.pci_dma_dev_setup (dev); +} +#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_PCI_BRIDGE_H */
arch/powerpc/kernel/pci-common.c +1 -2
@@ -969,8 +969,7 @@ static void pcibios_setup_device(struct pci_dev *dev)set_dma_offset (&dev->dev,PCI_DRAM_OFFSET );/* Additional platform DMA/iommu setup */ -if (ppc_md.pci_dma_dev_setup) - ppc_md.pci_dma_dev_setup (dev); +pci_dma_dev_setup (dev);/* Read default IRQs and fixup if necessary */ pci_read_irq_line (dev);
Signature · 1 line
2.1.4
Re: [PATCH v2 04/19] powerpc: Create pci_controller_ops.dma_dev_setup and shim
Quoted 22 lines · On Tuesday 31 March 2015 16:00:42 Daniel Axtens wrote:
Introduces the
pci_controller_opsstructure.
Add pci_controller_ops.dma_dev_setup, shadowing ppc_md.pci_dma_dev_setup. Add a shim, and change the callsites to use the shim.Signed-off-by Daniel Axtens <[email protected]>---
v1 --> v2:
- Better commit message
- Use phb in favour of hose
- Make shim name matchppc_mdname, notpci_controller_opsname.--- arch/powerpc/include/asm/pci-bridge.h | 21 +++++++++++++++++++++ arch/powerpc/kernel/pci-common.c | 3 +-- 2 files changed, 22 insertions(+), 2 deletions(-)arch/powerpc/include/asm/pci-bridge.h +0
-0
arch/powerpc/include/asm/pci-bridge.h line 24
Quoted 10 lines
arch/powerpc/include/asm/pci-bridge.h +7
-0@@ -15,6 +15,13 @@struct device_node ;/* +* PCI controller operations +*/ +struct pci_controller_ops { +void (*dma_dev_setup)(struct pci_dev *dev); +}; + +/*
Please see https://patchwork.ozlabs.org/patch/431333/ for related work.
I think it would be better not to introduce another architecture-specific pci host bridge operations structure, but instead consolidate into the one that is already there. We are also adding a generic way to set up PCI DMA, so it would seems reasonable to hook into that place.
Arnd
Re: [PATCH v2 04/19] powerpc: Create pci_controller_ops.dma_dev_setup and shim
Quoted 2 lines
Please see https://patchwork.ozlabs.org/patch/431333/ for related work.
I'm familiar with that patch series - I've been helping Yijing get it up to speed on PowerPC.
Quoted 4 lines
I think it would be better not to introduce another architecture-specific pci host bridge operations structure, but instead consolidate into the one that is already there. We are also adding a generic way to set up PCI DMA, so it would seems reasonable to hook into that place.
I see what you're getting at, and I agree that we want to move towards generic operations.
However, I think this should go in as is at this point, for two main reasons:
1) This is a good midpoint that makes it easier to move to a generic structure. Our arch specific stuff is quirky and difficult. This patch series does a lot to reduce the complexity, and would make it very easy to move these ops into a generic structure at some future point.
2) Trying to go generic at this point risks making the change set so complex and wide ranging that it will really struggle to get in. For example, Yijing's patch set, despite not changing any of the quirky stuff in PowerPC, is already quite long, and will require agreement from a lot of people before it can go in.
Much as I would like to have everything as generic as possible, if we were to try to do the whole job in one go, it'd become a big, difficult, messy patch set, and would be less likely to happen than if we were to do it in two steps.
Regards,
Daniel
Re: [PATCH v2 04/19] powerpc: Create pci_controller_ops.dma_dev_setup and shim
Quoted 27 lines · On Tuesday 07 April 2015 10:31:36 Daniel Axtens wrote:
Quoted 2 lines
Please see https://patchwork.ozlabs.org/patch/431333/ for related work.
I'm familiar with that patch series - I've been helping Yijing get it up to speed on PowerPC.
Quoted 4 lines
I think it would be better not to introduce another architecture-specific pci host bridge operations structure, but instead consolidate into the one that is already there. We are also adding a generic way to set up PCI DMA, so it would seems reasonable to hook into that place.
I see what you're getting at, and I agree that we want to move towards generic operations.
However, I think this should go in as is at this point, for two main reasons:
1) This is a good midpoint that makes it easier to move to a generic structure. Our arch specific stuff is quirky and difficult. This patch series does a lot to reduce the complexity, and would make it very easy to move these ops into a generic structure at some future point.
2) Trying to go generic at this point risks making the change set so complex and wide ranging that it will really struggle to get in. For example, Yijing's patch set, despite not changing any of the quirky stuff in PowerPC, is already quite long, and will require agreement from a lot of people before it can go in.
Quoted 4 lines
Much as I would like to have everything as generic as possible, if we were to try to do the whole job in one go, it'd become a big, difficult, messy patch set, and would be less likely to happen than if we were to do it in two steps.
Ok, fair enough. Let's do this one first then.
Arnd
Michael Ellerman
reviewerRe: [PATCH v2 04/19] powerpc: Create pci_controller_ops.dma_dev_setup and shim
Quoted 28 lines · Arnd Bergmann
Quoted 27 lines · On Tuesday 07 April 2015 10:31:36 Daniel Axtens wrote:
Quoted 2 lines
Please see https://patchwork.ozlabs.org/patch/431333/ for related work.
I'm familiar with that patch series - I've been helping Yijing get it up to speed on PowerPC.
Quoted 4 lines
I think it would be better not to introduce another architecture-specific pci host bridge operations structure, but instead consolidate into the one that is already there. We are also adding a generic way to set up PCI DMA, so it would seems reasonable to hook into that place.
I see what you're getting at, and I agree that we want to move towards generic operations.
However, I think this should go in as is at this point, for two main reasons:
1) This is a good midpoint that makes it easier to move to a generic structure. Our arch specific stuff is quirky and difficult. This patch series does a lot to reduce the complexity, and would make it very easy to move these ops into a generic structure at some future point.
2) Trying to go generic at this point risks making the change set so complex and wide ranging that it will really struggle to get in. For example, Yijing's patch set, despite not changing any of the quirky stuff in PowerPC, is already quite long, and will require agreement from a lot of people before it can go in.
Quoted 6 lines
Quoted 4 lines
Much as I would like to have everything as generic as possible, if we were to try to do the whole job in one go, it'd become a big, difficult, messy patch set, and would be less likely to happen than if we were to do it in two steps.
Ok, fair enough. Let's do this one first then.
Thanks Arnd.
cheers
PATCH v2 5/19 powerpc: Create pci_controller_ops.dma_bus_setup and shim
In reply to Daniel AxtensAdd pci_controller_ops.dma_bus_setup, shadowing ppc_md.pci_dma_bus_setup. Add a shim, and changes the callsites to use the shim.
---
v1 --> v2:
- Better commit message
- Use phb in favour of hose
- Make shim name match ppc_md name, not pci_controller_ops name.
--- arch/powerpc/include/asm/pci-bridge.h | 11 +++++++++++ arch/powerpc/kernel/pci-common.c | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +11 -0
@@ -19,6 +19,7 @@ struct device_node;*/ struct pci_controller_ops {void (*dma_dev_setup)(struct pci_dev *dev); +void (*dma_bus_setup)(struct pci_bus *bus); };/*
@@ -279,5 +280,15 @@ static inline void pci_dma_dev_setup(struct pci_dev *dev) ppc_md.pci_dma_dev_setup (dev); } +static inline void pci_dma_bus_setup (struct pci_bus *bus) +{ +struct pci_controller *phb =pci_bus_to_host (bus); + +if (phb->controller_ops.dma_bus_setup) + phb->controller_ops.dma_bus_setup (bus); +else if (ppc_md.pci_dma_bus_setup) + ppc_md.pci_dma_bus_setup (bus); +} +#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_PCI_BRIDGE_H */
arch/powerpc/kernel/pci-common.c +1 -2
@@ -953,8 +953,7 @@ void pcibios_setup_bus_self(struct pci_bus *bus) ppc_md.pcibios_fixup_bus (bus);/* Setup bus DMA mappings */ -if (ppc_md.pci_dma_bus_setup) - ppc_md.pci_dma_bus_setup (bus); +pci_dma_bus_setup (bus); }static void pcibios_setup_device (struct pci_dev *dev)
Signature · 1 line
2.1.4
PATCH v2 6/19 powerpc: Create pci_controller_ops.probe_mode and shim
In reply to Daniel AxtensAdd pci_controller_ops.probe_mode, shadowing ppc_md.pci_probe_mode. Add a shim, and changes the callsites to use the shim.
We also need to move the probe mode defines to pci-bridge.h from pci.h. They are required by the shim in order to return a sensible default. Previously, the were defined in pci.h, but pci.h includes pci-bridge.h before the relevant #defines. This means the definitions are absent if pci.h is included before pci-bridge.h. This occurs in some drivers. So, move the definitons now, and move them back when we remove the shim.
Anything that wants the defines would have had to include pci.h, and since pci.h includes pci-bridge.h, nothing will lose access to the defines.
---
v1 --> v2:
- Better commit message
- Use phb in favour of hose
- Make shim name match ppc_md name, not pci_controller_ops name.
--- arch/powerpc/include/asm/pci-bridge.h | 18 ++++++++++++++++++ arch/powerpc/include/asm/pci.h | 5 ----- arch/powerpc/kernel/pci-common.c | 4 ++-- arch/powerpc/kernel/pci-hotplug.c | 3 +-- arch/powerpc/kernel/pci_of_scan.c | 3 +-- 5 files changed, 22 insertions(+), 11 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +18 -0
@@ -12,6 +12,11 @@#include <linux/ioport.h> #include <asm-generic/pci-bridge.h> +/* Return values for pci_controller_ops.probe_mode function */ +#define PCI_PROBE_NONE -1/* Don't look at this bus at all */ +#define PCI_PROBE_NORMAL 0/* Do normal PCI probing */ +#define PCI_PROBE_DEVTREE 1/* Instantiate from device tree */ +struct device_node ;/*
@@ -20,6 +25,8 @@ struct device_node;struct pci_controller_ops {void (*dma_dev_setup)(struct pci_dev *dev);void (*dma_bus_setup)(struct pci_bus *bus); + +int (*probe_mode)(struct pci_bus *); };/*
@@ -290,5 +297,16 @@ static inline void pci_dma_bus_setup(struct pci_bus *bus) ppc_md.pci_dma_bus_setup (bus); } +static inline int pci_probe_mode (struct pci_bus *bus) +{ +struct pci_controller *phb =pci_bus_to_host (bus); + +if (phb->controller_ops.probe_mode) +return phb->controller_ops.probe_mode (bus); +if (ppc_md.pci_probe_mode) +return ppc_md.pci_probe_mode (bus); +return PCI_PROBE_NORMAL ; +} +#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_PCI_BRIDGE_H */
arch/powerpc/include/asm/pci.h +0 -5
@@ -22,11 +22,6 @@#include <asm-generic/pci-dma-compat.h> -/* Return values for ppc_md.pci_probe_mode function */ -#define PCI_PROBE_NONE -1/* Don't look at this bus at all */ -#define PCI_PROBE_NORMAL 0/* Do normal PCI probing */ -#define PCI_PROBE_DEVTREE 1/* Instantiate from device tree */ -#define PCIBIOS_MIN_IO 0x1000#define PCIBIOS_MIN_MEM 0x10000000
arch/powerpc/kernel/pci-common.c +2 -2
@@ -1622,8 +1622,8 @@ void pcibios_scan_phb(struct pci_controller *hose)/* Get probe mode and perform scan */ mode =PCI_PROBE_NORMAL ; -if (node && ppc_md.pci_probe_mode) - mode = ppc_md.pci_probe_mode (bus); +if (node) + mode =pci_probe_mode (bus);pr_debug (" probe mode: %d\n" , mode);if (mode ==PCI_PROBE_DEVTREE )of_scan_bus (node, bus);
arch/powerpc/kernel/pci-hotplug.c +1 -2
@@ -78,8 +78,7 @@ void pcibios_add_pci_devices(struct pci_bus * bus)eeh_add_device_tree_early (dn); mode =PCI_PROBE_NORMAL ; -if (ppc_md.pci_probe_mode) - mode = ppc_md.pci_probe_mode (bus); + mode =pci_probe_mode (bus);if (mode ==PCI_PROBE_DEVTREE ) {/* use ofdt-based probe */
arch/powerpc/kernel/pci_of_scan.c +1 -2
@@ -287,8 +287,7 @@ void of_scan_pci_bridge(struct pci_dev *dev)pr_debug (" bus name: %s\n" , bus->name); mode =PCI_PROBE_NORMAL ; -if (ppc_md.pci_probe_mode) - mode = ppc_md.pci_probe_mode (bus); + mode =pci_probe_mode (bus);pr_debug (" probe mode: %d\n" , mode);if (mode ==PCI_PROBE_DEVTREE )
Signature · 1 line
2.1.4
PATCH v2 7/19 powerpc: Create pci_controller_ops.enable_device_hook and shim
In reply to Daniel AxtensAdd pci_controller_ops.enable_device_hook, shadowing ppc_md.pcibios_enable_device_hook. Add a shim, and changes the callsites to use the shim.
---
v1 --> v2:
- Better commit message
- Use phb in favour of hose
- Make shim name match ppc_md name, not pci_controller_ops name.
--- arch/powerpc/include/asm/pci-bridge.h | 15 +++++++++++++++ arch/powerpc/kernel/pci-common.c | 5 ++--- 2 files changed, 17 insertions(+), 3 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +15 -0
@@ -27,6 +27,10 @@ struct pci_controller_ops {void (*dma_bus_setup)(struct pci_bus *bus);int (*probe_mode)(struct pci_bus *); + +/* Called when pci_enable_device() is called. Returns true to +* allow assignment/enabling of the device. */ +bool (*enable_device_hook)(struct pci_dev *); };/*
@@ -308,5 +312,16 @@ static inline int pci_probe_mode(struct pci_bus *bus)return PCI_PROBE_NORMAL ; } +static inline bool pcibios_enable_device_hook (struct pci_dev *dev) +{ +struct pci_controller *phb =pci_bus_to_host (dev->bus); + +if (phb->controller_ops.enable_device_hook) +return phb->controller_ops.enable_device_hook (dev); +if (ppc_md.pcibios_enable_device_hook) +return ppc_md.pcibios_enable_device_hook (dev); +return true; +} +#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_PCI_BRIDGE_H */
arch/powerpc/kernel/pci-common.c +2 -3
@@ -1448,9 +1448,8 @@ EXPORT_SYMBOL_GPL(pcibios_finish_adding_to_bus);int pcibios_enable_device (struct pci_dev *dev,int mask) { -if (ppc_md.pcibios_enable_device_hook) -if (!ppc_md.pcibios_enable_device_hook (dev)) -return -EINVAL ; +if (!pcibios_enable_device_hook (dev)) +return -EINVAL ;return pci_enable_resources (dev, mask); }
Signature · 1 line
2.1.4
PATCH v2 8/19 powerpc: Create pci_controller_ops.window_alignment and shim
In reply to Daniel AxtensAdd pci_controller_ops.window_alignment, shadowing ppc_md.pcibios_window_alignment. Add a shim, and changes the callsites to use the shim.
Here, we use pci_window_alignment, as pcibios_window_alignment is already taken.
---
v1 --> v2:
- Better commit message
- Use phb in favour of hose
--- arch/powerpc/include/asm/pci-bridge.h | 21 +++++++++++++++++++++ arch/powerpc/kernel/pci-common.c | 10 +--------- 2 files changed, 22 insertions(+), 9 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +21 -0
@@ -31,6 +31,9 @@ struct pci_controller_ops {/* Called when pci_enable_device() is called. Returns true to * allow assignment/enabling of the device. */ bool (*enable_device_hook)(struct pci_dev *); + +/* Called during PCI resource reassignment */ +resource_size_t (*window_alignment)(struct pci_bus *,unsigned long type); };/*
@@ -323,5 +326,23 @@ static inline bool pcibios_enable_device_hook(struct pci_dev *dev)return true; } +static inline resource_size_t pci_window_alignment (struct pci_bus *bus, +unsigned long type) +{ +struct pci_controller *phb =pci_bus_to_host (bus); + +if (phb->controller_ops.window_alignment) +return phb->controller_ops.window_alignment (bus, type); +if (ppc_md.pcibios_window_alignment) +return ppc_md.pcibios_window_alignment (bus, type); + +/* +* PCI core will figure out the default +* alignment: 4KiB for I/O and 1MiB for +* memory window. +*/ +return 1 ; +} +#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_PCI_BRIDGE_H */
arch/powerpc/kernel/pci-common.c +1 -9
@@ -109,15 +109,7 @@ void pcibios_free_controller(struct pci_controller *phb)resource_size_t pcibios_window_alignment (struct pci_bus *bus,unsigned long type) { -if (ppc_md.pcibios_window_alignment) -return ppc_md.pcibios_window_alignment (bus, type); - -/* -* PCI core will figure out the default -* alignment: 4KiB for I/O and 1MiB for -* memory window. -*/ -return 1 ; +return pci_window_alignment (bus, type); }void pcibios_reset_secondary_bus (struct pci_dev *dev)
Signature · 1 line
2.1.4
PATCH v2 9/19 powerpc: Create pci_controller_ops.reset_secondary_bus and shim
In reply to Daniel AxtensAdd pci_controller_ops.reset_secondary_bus, shadowing ppc_md.pcibios_reset_secondary_bus. Add a shim, and changes the callsites to use the shim.
Use pcibios_reset_secondary_bus_shim, as both pcibios_reset_secondary_bus and pci_reset_secondary_bus are already taken.
---
v1 --> v2:
- Better commit message
- Use phb in favour of hose
- Make shim name namespaced, not the raw pci_controller_ops name.
--- arch/powerpc/include/asm/pci-bridge.h | 17 +++++++++++++++++ arch/powerpc/kernel/pci-common.c | 7 +------ 2 files changed, 18 insertions(+), 6 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +17 -0
@@ -34,6 +34,7 @@ struct pci_controller_ops {/* Called during PCI resource reassignment */ resource_size_t (*window_alignment)(struct pci_bus *,unsigned long type); +void (*reset_secondary_bus)(struct pci_dev *dev); };/*
@@ -344,5 +345,21 @@ static inline resource_size_t pci_window_alignment(struct pci_bus *bus,return 1 ; } +static inline void pcibios_reset_secondary_bus_shim (struct pci_dev *dev) +{ +struct pci_controller *phb =pci_bus_to_host (dev->bus); + +if (phb->controller_ops.reset_secondary_bus) + phb->controller_ops.reset_secondary_bus (dev); +else if (ppc_md.pcibios_reset_secondary_bus) + ppc_md.pcibios_reset_secondary_bus (dev); +else +/* +* Fallback to the generic function if no +* platform-specific one is provided +*/ +pci_reset_secondary_bus (dev); +} +#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_PCI_BRIDGE_H */
arch/powerpc/kernel/pci-common.c +1 -6
@@ -114,12 +114,7 @@ resource_size_t pcibios_window_alignment(struct pci_bus *bus,void pcibios_reset_secondary_bus (struct pci_dev *dev) { -if (ppc_md.pcibios_reset_secondary_bus) { - ppc_md.pcibios_reset_secondary_bus (dev); -return ; - } - -pci_reset_secondary_bus (dev); +pcibios_reset_secondary_bus_shim (dev); }static resource_size_t pcibios_io_size (const struct pci_controller *hose)
Signature · 1 line
2.1.4
PATCH v2 10/19 powerpc: dart_iommu: optionally populate controller_ops on init
In reply to Daniel AxtensIf a pci_controller_ops struct is provided to iommu_init_early_dart, populate that with the DMA setup ops, rather than ppc_md. If NULL is provided, populate ppc_md as before.
This also patches the call sites for Maple and Power Mac to pass NULL, so existing behaviour is preserved.
The benefit of making this optional is that it means we don't have to change dart, Maple and Power Mac over to the controller_ops system in one fell swoop.
--- arch/powerpc/include/asm/iommu.h | 3 ++- arch/powerpc/platforms/maple/setup.c | 2 +- arch/powerpc/platforms/powermac/setup.c | 2 +- arch/powerpc/sysdev/dart_iommu.c | 16 ++++++++++++---- 4 files changed, 16 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/iommu.h +2 -1
@@ -29,6 +29,7 @@#include <linux/bitops.h> #include <asm/machdep.h> #include <asm/types.h> +#include <asm/pci-bridge.h> #define IOMMU_PAGE_SHIFT_4K 12#define IOMMU_PAGE_SIZE_4K (ASM_CONST(1) << IOMMU_PAGE_SHIFT_4K)
@@ -169,7 +170,7 @@ extern void iommu_unmap_page(struct iommu_table *tbl, dma_addr_t dma_handle, struct dma_attrs *attrs);extern void iommu_init_early_pSeries (void ); -extern void iommu_init_early_dart (void ); +extern void iommu_init_early_dart (struct pci_controller_ops *controller_ops);extern void iommu_init_early_pasemi (void );extern void alloc_dart_table (void );
arch/powerpc/platforms/maple/setup.c +1 -1
@@ -203,7 +203,7 @@ static void __init maple_init_early(void) {DBG (" -> maple_init_early\n" ); -iommu_init_early_dart (); +iommu_init_early_dart (NULL );DBG (" <- maple_init_early\n" ); }
arch/powerpc/platforms/powermac/setup.c +1 -1
@@ -473,7 +473,7 @@ static void __init pmac_init_early(void)udbg_adb_init (!!strstr (boot_command_line,"btextdbg" ));#ifdef CONFIG_PPC64 -iommu_init_early_dart (); +iommu_init_early_dart (NULL );#endif /* SMP Init has to be done early as we need to patch up
arch/powerpc/sysdev/dart_iommu.c +12 -4
@@ -369,7 +369,7 @@ static int dart_dma_set_mask(struct device *dev, u64 dma_mask)return 0 ; } -void __init iommu_init_early_dart (void ) +void __init iommu_init_early_dart (struct pci_controller_ops *controller_ops) {struct device_node *dn;
@@ -395,15 +395,23 @@ void __init iommu_init_early_dart(void)if (dart_is_u4) ppc_md.dma_set_mask = dart_dma_set_mask; - ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_dart; - ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_dart; - +if (controller_ops) { + controller_ops->dma_dev_setup = pci_dma_dev_setup_dart; + controller_ops->dma_bus_setup = pci_dma_bus_setup_dart; + }else { + ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_dart; + ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_dart; + }/* Setup pci_dma ops */ set_pci_dma_ops (&dma_iommu_ops);return ; bail:/* If init failed, use direct iommu and null setup functions */ +if (controller_ops) { + controller_ops->dma_dev_setup =NULL ; + controller_ops->dma_bus_setup =NULL ; + } ppc_md.pci_dma_dev_setup =NULL ; ppc_md.pci_dma_bus_setup =NULL ;
Signature · 1 line
2.1.4
PATCH v2 11/19 powerpc/powermac: Move controller ops from ppc_md to controller_ops
In reply to Daniel AxtensThis moves the Power Mac platform to use the pci_controller_ops structure rather than ppc_md for PCI controller operations.
--- arch/powerpc/platforms/powermac/pci.c | 17 +++++++++++++++-- arch/powerpc/platforms/powermac/pmac.h | 5 +---- arch/powerpc/platforms/powermac/setup.c | 4 +--- 3 files changed, 17 insertions(+), 9 deletions(-)
arch/powerpc/platforms/powermac/pci.c +15 -2
@@ -27,6 +27,8 @@#include <asm/grackle.h> #include <asm/ppc-pci.h> +#include "pmac.h" +#undef DEBUG#ifdef DEBUG
@@ -798,6 +800,7 @@ static int __init pmac_add_bridge(struct device_node *dev)return -ENOMEM ; hose->first_busno = bus_range ? bus_range[0 ] :0 ; hose->last_busno = bus_range ? bus_range[1 ] :0xff ; + hose->controller_ops = pmac_pci_controller_ops; disp_name =NULL ;
@@ -942,7 +945,7 @@ void __init pmac_pci_init(void) }#ifdef CONFIG_PPC32 -bool pmac_pci_enable_device_hook (struct pci_dev *dev) +static bool pmac_pci_enable_device_hook (struct pci_dev *dev) {struct device_node * node;int updatecfg =0 ;
@@ -1225,7 +1228,7 @@ static void fixup_u4_pcie(struct pci_dev* dev)DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_APPLE ,PCI_DEVICE_ID_APPLE_U4_PCIE , fixup_u4_pcie);#ifdef CONFIG_PPC64 -int pmac_pci_probe_mode (struct pci_bus *bus) +static int pmac_pci_probe_mode (struct pci_bus *bus) {struct device_node *node =pci_bus_to_OF_node (bus);
@@ -1240,3 +1243,13 @@ int pmac_pci_probe_mode(struct pci_bus *bus)return PCI_PROBE_DEVTREE ; }#endif /* CONFIG_PPC64 */ + +struct pci_controller_ops pmac_pci_controller_ops = { +#ifdef CONFIG_PPC64 + .probe_mode = pmac_pci_probe_mode, +#endif +#ifdef CONFIG_PPC32 + .enable_device_hook = pmac_pci_enable_device_hook, +#endif +}; +
arch/powerpc/platforms/powermac/pmac.h +1 -4
@@ -25,7 +25,6 @@ extern void pmac_pci_init(void);extern void pmac_nvram_update (void );extern unsigned char pmac_nvram_read_byte (int addr);extern void pmac_nvram_write_byte (int addr,unsigned char val); -extern bool pmac_pci_enable_device_hook (struct pci_dev *dev);extern void pmac_pcibios_after_init (void );extern int of_show_percpuinfo (struct seq_file *m,int i);
@@ -39,8 +38,6 @@ extern void low_cpu_die(void) __attribute__((noreturn));extern int pmac_nvram_init (void );extern void pmac_pic_init (void ); -#ifdef CONFIG_PPC64 -extern int pmac_pci_probe_mode (struct pci_bus *bus); -#endif +extern struct pci_controller_ops pmac_pci_controller_ops;#endif /* __PMAC_H__ */
arch/powerpc/platforms/powermac/setup.c +1 -3
@@ -473,7 +473,7 @@ static void __init pmac_init_early(void)udbg_adb_init (!!strstr (boot_command_line,"btextdbg" ));#ifdef CONFIG_PPC64 -iommu_init_early_dart (NULL ); +iommu_init_early_dart (&pmac_pci_controller_ops);#endif /* SMP Init has to be done early as we need to patch up
@@ -656,12 +656,10 @@ define_machine(powermac) { .feature_call = pmac_do_feature_call, .progress = udbg_progress,#ifdef CONFIG_PPC64 - .pci_probe_mode = pmac_pci_probe_mode, .power_save = power4_idle, .enable_pmcs = power4_enable_pmcs,#endif /* CONFIG_PPC64 */ #ifdef CONFIG_PPC32 - .pcibios_enable_device_hook = pmac_pci_enable_device_hook, .pcibios_after_init = pmac_pcibios_after_init, .phys_mem_access_prot = pci_phys_mem_access_prot,#endif
Signature · 1 line
2.1.4
PATCH v2 12/19 powerpc/pseries: Move controller ops from ppc_md to controller_ops
In reply to Daniel AxtensThis moves the pSeries platform to use the pci_controller_ops structure, rather than ppc_md for PCI controller operations.
--- arch/powerpc/platforms/pseries/iommu.c | 9 +++++---- arch/powerpc/platforms/pseries/pseries.h | 2 ++ arch/powerpc/platforms/pseries/setup.c | 6 +++++- 3 files changed, 12 insertions(+), 5 deletions(-)
arch/powerpc/platforms/pseries/iommu.c +5 -4
@@ -49,6 +49,7 @@#include <asm/mmzone.h> #include <asm/plpar_wrappers.h> +#include "pseries.h" static void tce_invalidate_pSeries_sw (struct iommu_table *tbl,__be64 *startp,__be64 *endp)
@@ -1307,16 +1308,16 @@ void iommu_init_early_pSeries(void) ppc_md.tce_free = tce_free_pSeriesLP; } ppc_md.tce_get = tce_get_pSeriesLP; - ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_pSeriesLP; - ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_pSeriesLP; + pseries_pci_controller_ops.dma_bus_setup = pci_dma_bus_setup_pSeriesLP; + pseries_pci_controller_ops.dma_dev_setup = pci_dma_dev_setup_pSeriesLP; ppc_md.dma_set_mask = dma_set_mask_pSeriesLP; ppc_md.dma_get_required_mask = dma_get_required_mask_pSeriesLP; }else { ppc_md.tce_build = tce_build_pSeries; ppc_md.tce_free = tce_free_pSeries; ppc_md.tce_get = tce_get_pseries; - ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_pSeries; - ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_pSeries; + pseries_pci_controller_ops.dma_bus_setup = pci_dma_bus_setup_pSeries; + pseries_pci_controller_ops.dma_dev_setup = pci_dma_dev_setup_pSeries; }
arch/powerpc/platforms/pseries/pseries.h +2 -0
@@ -65,6 +65,8 @@ extern int dlpar_detach_node(struct device_node *);struct pci_host_bridge ;int pseries_root_bridge_prepare (struct pci_host_bridge *bridge); +extern struct pci_controller_ops pseries_pci_controller_ops; +unsigned long pseries_memory_block_size (void );#endif /* _PSERIES_PSERIES_H */
arch/powerpc/platforms/pseries/setup.c +5 -1
@@ -478,6 +478,7 @@ static void __init find_and_init_phbs(void)rtas_setup_phb (phb);pci_process_bridge_OF_ranges (phb, node,0 );isa_bridge_find_early (phb); + phb->controller_ops = pseries_pci_controller_ops; }of_node_put (root);
@@ -840,6 +841,10 @@ static int pSeries_pci_probe_mode(struct pci_bus *bus)void pSeries_final_fixup (void ) { }#endif +struct pci_controller_ops pseries_pci_controller_ops = { + .probe_mode = pSeries_pci_probe_mode, +}; +define_machine (pseries) { .name = "pSeries", .probe = pSeries_probe,
@@ -848,7 +853,6 @@ define_machine(pseries) { .show_cpuinfo = pSeries_show_cpuinfo, .log_error = pSeries_log_error, .pcibios_fixup = pSeries_final_fixup, - .pci_probe_mode = pSeries_pci_probe_mode, .restart = rtas_restart, .halt = rtas_halt, .panic = rtas_os_term,
Signature · 1 line
2.1.4
PATCH v3 12/19 powerpc/pseries: Move controller ops from ppc_md to controller_ops
This moves the pSeries platform to use the pci_controller_ops structure, rather than ppc_md for PCI controller operations.
---
v2 --> v3: Add a hotplug case in pci_dlpar.c
--- arch/powerpc/platforms/pseries/iommu.c | 9 +++++---- arch/powerpc/platforms/pseries/pci_dlpar.c | 3 +++ arch/powerpc/platforms/pseries/pseries.h | 2 ++ arch/powerpc/platforms/pseries/setup.c | 6 +++++- 4 files changed, 15 insertions(+), 5 deletions(-)
arch/powerpc/platforms/pseries/iommu.c +5 -4
@@ -49,6 +49,7 @@#include <asm/mmzone.h> #include <asm/plpar_wrappers.h> +#include "pseries.h" static void tce_invalidate_pSeries_sw (struct iommu_table *tbl,__be64 *startp,__be64 *endp)
@@ -1307,16 +1308,16 @@ void iommu_init_early_pSeries(void) ppc_md.tce_free = tce_free_pSeriesLP; } ppc_md.tce_get = tce_get_pSeriesLP; - ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_pSeriesLP; - ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_pSeriesLP; + pseries_pci_controller_ops.dma_bus_setup = pci_dma_bus_setup_pSeriesLP; + pseries_pci_controller_ops.dma_dev_setup = pci_dma_dev_setup_pSeriesLP; ppc_md.dma_set_mask = dma_set_mask_pSeriesLP; ppc_md.dma_get_required_mask = dma_get_required_mask_pSeriesLP; }else { ppc_md.tce_build = tce_build_pSeries; ppc_md.tce_free = tce_free_pSeries; ppc_md.tce_get = tce_get_pseries; - ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_pSeries; - ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_pSeries; + pseries_pci_controller_ops.dma_bus_setup = pci_dma_bus_setup_pSeries; + pseries_pci_controller_ops.dma_dev_setup = pci_dma_dev_setup_pSeries; }
arch/powerpc/platforms/pseries/pci_dlpar.c +3 -0
@@ -32,6 +32,8 @@#include <asm/firmware.h> #include <asm/eeh.h> +#include "pseries.h" +static struct pci_bus *find_bus_among_children (struct pci_bus *bus,struct device_node *dn)
@@ -75,6 +77,7 @@ struct pci_controller *init_phb_dynamic(struct device_node *dn)return NULL ;rtas_setup_phb (phb);pci_process_bridge_OF_ranges (phb, dn,0 ); + phb->controller_ops = pseries_pci_controller_ops;pci_devs_phb_init_dynamic (phb);
arch/powerpc/platforms/pseries/pseries.h +2 -0
@@ -65,6 +65,8 @@ extern int dlpar_detach_node(struct device_node *);struct pci_host_bridge ;int pseries_root_bridge_prepare (struct pci_host_bridge *bridge); +extern struct pci_controller_ops pseries_pci_controller_ops; +unsigned long pseries_memory_block_size (void );#endif /* _PSERIES_PSERIES_H */
arch/powerpc/platforms/pseries/setup.c +5 -1
@@ -478,6 +478,7 @@ static void __init find_and_init_phbs(void)rtas_setup_phb (phb);pci_process_bridge_OF_ranges (phb, node,0 );isa_bridge_find_early (phb); + phb->controller_ops = pseries_pci_controller_ops; }of_node_put (root);
@@ -840,6 +841,10 @@ static int pSeries_pci_probe_mode(struct pci_bus *bus)void pSeries_final_fixup (void ) { }#endif +struct pci_controller_ops pseries_pci_controller_ops = { + .probe_mode = pSeries_pci_probe_mode, +}; +define_machine (pseries) { .name = "pSeries", .probe = pSeries_probe,
@@ -848,7 +853,6 @@ define_machine(pseries) { .show_cpuinfo = pSeries_show_cpuinfo, .log_error = pSeries_log_error, .pcibios_fixup = pSeries_final_fixup, - .pci_probe_mode = pSeries_pci_probe_mode, .restart = rtas_restart, .halt = rtas_halt, .panic = rtas_os_term,
Signature · 1 line
2.1.4
PATCH v2 13/19 powerpc/powernv: Move controller ops from ppc_md to controller_ops
In reply to Daniel AxtensThis moves the PowerNV platform to use the pci_controller_ops structure rather than ppc_md for PCI controller operations.
--- arch/powerpc/platforms/powernv/pci-ioda.c | 7 ++++--- arch/powerpc/platforms/powernv/pci-p5ioc2.c | 1 + arch/powerpc/platforms/powernv/pci.c | 5 ++++- arch/powerpc/platforms/powernv/powernv.h | 2 ++ 4 files changed, 11 insertions(+), 4 deletions(-)
arch/powerpc/platforms/powernv/pci-ioda.c +4 -3
@@ -1988,6 +1988,7 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np, hose->last_busno =0xff ; } hose->private_data = phb; + hose->controller_ops = pnv_pci_controller_ops; phb->hub_id = hub_id; phb->opal_id = phb_id; phb->type = ioda_type;
@@ -2104,9 +2105,9 @@ static void __init pnv_pci_init_ioda_phb(struct device_node *np,* the child P2P bridges) can form individual PE. */ ppc_md.pcibios_fixup = pnv_pci_ioda_fixup; - ppc_md.pcibios_enable_device_hook = pnv_pci_enable_device_hook; - ppc_md.pcibios_window_alignment = pnv_pci_window_alignment; - ppc_md.pcibios_reset_secondary_bus = pnv_pci_reset_secondary_bus; + pnv_pci_controller_ops.enable_device_hook = pnv_pci_enable_device_hook; + pnv_pci_controller_ops.window_alignment = pnv_pci_window_alignment; + pnv_pci_controller_ops.reset_secondary_bus = pnv_pci_reset_secondary_bus;pci_add_flags (PCI_REASSIGN_ALL_RSRC );/* Reset IODA tables to a clean state */
arch/powerpc/platforms/powernv/pci-p5ioc2.c +1 -0
@@ -133,6 +133,7 @@ static void __init pnv_pci_init_p5ioc2_phb(struct device_node *np, u64 hub_id, phb->hose->first_busno =0 ; phb->hose->last_busno =0xff ; phb->hose->private_data = phb; + phb->hose->controller_ops = pnv_pci_controller_ops; phb->hub_id = hub_id; phb->opal_id = phb_id; phb->type =PNV_PHB_P5IOC2 ;
arch/powerpc/platforms/powernv/pci.c +4 -1
@@ -761,7 +761,6 @@ void __init pnv_pci_init(void)pci_devs_phb_init ();/* Configure IOMMU DMA hooks */ - ppc_md.pci_dma_dev_setup = pnv_pci_dma_dev_setup; ppc_md.tce_build = pnv_tce_build_vm; ppc_md.tce_free = pnv_tce_free_vm; ppc_md.tce_build_rm = pnv_tce_build_rm;
@@ -777,3 +776,7 @@ void __init pnv_pci_init(void) }machine_subsys_initcall_sync (powernv, tce_iommu_bus_notifier_init); + +struct pci_controller_ops pnv_pci_controller_ops = { + .dma_dev_setup = pnv_pci_dma_dev_setup, +};
arch/powerpc/platforms/powernv/powernv.h +2 -0
@@ -29,6 +29,8 @@ static inline u64 pnv_pci_dma_get_required_mask(struct pci_dev *pdev) }#endif +extern struct pci_controller_ops pnv_pci_controller_ops; +extern u32 pnv_get_supported_cpuidle_states (void );extern void pnv_lpc_init (void );
Signature · 1 line
2.1.4
PATCH v2 14/19 powerpc/pasemi: Move controller ops from ppc_md to controller_ops
In reply to Daniel AxtensThis moves the PaSemi platform to use the pci_controller_ops structure rather than ppc_md for PCI controller operations.
--- arch/powerpc/platforms/pasemi/iommu.c | 6 ++++-- arch/powerpc/platforms/pasemi/pasemi.h | 1 + arch/powerpc/platforms/pasemi/pci.c | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pasemi/iommu.c +4 -2
@@ -27,6 +27,8 @@#include <asm/machdep.h> #include <asm/firmware.h> +#include "pasemi.h" +#define IOBMAP_PAGE_SHIFT 12#define IOBMAP_PAGE_SIZE (1 << IOBMAP_PAGE_SHIFT)#define IOBMAP_PAGE_MASK (IOBMAP_PAGE_SIZE - 1)
@@ -248,8 +250,8 @@ void __init iommu_init_early_pasemi(void)iob_init (NULL ); - ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_pasemi; - ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_pasemi; + pasemi_pci_controller_ops.dma_dev_setup = pci_dma_dev_setup_pasemi; + pasemi_pci_controller_ops.dma_bus_setup = pci_dma_bus_setup_pasemi; ppc_md.tce_build = iobmap_build; ppc_md.tce_free = iobmap_free;set_pci_dma_ops (&dma_iommu_ops);
arch/powerpc/platforms/pasemi/pasemi.h +1 -0
@@ -30,5 +30,6 @@ static inline void restore_astate(int cpu) }#endif +extern struct pci_controller_ops pasemi_pci_controller_ops;#endif /* _PASEMI_PASEMI_H */
arch/powerpc/platforms/pasemi/pci.c +5 -0
@@ -31,6 +31,8 @@#include <asm/ppc-pci.h> +#include "pasemi.h" +#define PA_PXP_CFA (bus, devfn, off) (((bus) << 20) | ((devfn) << 12) | (off))static inline int pa_pxp_offset_valid (u8 bus,u8 devfn,int offset)
@@ -199,6 +201,7 @@ static int __init pas_add_bridge(struct device_node *dev) hose->first_busno =0 ; hose->last_busno =0xff ; + hose->controller_ops = pasemi_pci_controller_ops;setup_pa_pxp (hose);
@@ -239,3 +242,5 @@ void __iomem *pasemi_pci_getcfgaddr(struct pci_dev *dev, int offset)return (void __iomem *)pa_pxp_cfg_addr (hose, dev->bus->number, dev->devfn, offset); } + +struct pci_controller_ops pasemi_pci_controller_ops;
Signature · 1 line
2.1.4
PATCH v2 15/19 powerpc/maple: Move controller ops from ppc_md to controller_ops
In reply to Daniel AxtensThis moves the Maple platform to use the pci_controller_ops structure rather than ppc_md for PCI controller operations.
--- arch/powerpc/platforms/maple/maple.h | 2 ++ arch/powerpc/platforms/maple/pci.c | 4 ++++ arch/powerpc/platforms/maple/setup.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-)
arch/powerpc/platforms/maple/maple.h +2 -0
@@ -10,3 +10,5 @@ extern void maple_calibrate_decr(void);extern void maple_pci_init (void );extern void maple_pci_irq_fixup (struct pci_dev *dev);extern int maple_pci_get_legacy_ide_irq (struct pci_dev *dev,int channel); + +extern struct pci_controller_ops maple_pci_controller_ops;
arch/powerpc/platforms/maple/pci.c +4 -0
@@ -510,6 +510,7 @@ static int __init maple_add_bridge(struct device_node *dev)return -ENOMEM ; hose->first_busno = bus_range ? bus_range[0 ] :0 ; hose->last_busno = bus_range ? bus_range[1 ] :0xff ; + hose->controller_ops = maple_pci_controller_ops; disp_name =NULL ;if (of_device_is_compatible (dev,"u3-agp" )) {
@@ -660,3 +661,6 @@ static void quirk_ipr_msi(struct pci_dev *dev) }DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_IBM ,PCI_DEVICE_ID_IBM_OBSIDIAN , quirk_ipr_msi); + +struct pci_controller_ops maple_pci_controller_ops = { +};
arch/powerpc/platforms/maple/setup.c +1 -1
@@ -203,7 +203,7 @@ static void __init maple_init_early(void) {DBG (" -> maple_init_early\n" ); -iommu_init_early_dart (NULL ); +iommu_init_early_dart (&maple_pci_controller_ops);DBG (" <- maple_init_early\n" ); }
Signature · 1 line
2.1.4
PATCH v2 16/19 powerpc: fsl_pci, swiotlb: Move controller ops from ppc_md to controller_ops
In reply to Daniel AxtensMoves the setup out of swiotlb's subsys init call, and into an new structure.
fsl_pci.c is the only thing that checks the ppc_swiotlb_enable global, so we can be confident that patching it will cover all the PCI implementations affected by the changes to dma-swiotlb.c.
We do have to make sure we do the changes late in the function, after setup_pci_atmu, because that can change ppc_swiotlb_enable.
---
v1 --> v2:
- Move the setup call to after setup_pci_atmu().
--- arch/powerpc/kernel/dma-swiotlb.c | 11 ++++------- arch/powerpc/sysdev/fsl_pci.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-)
arch/powerpc/kernel/dma-swiotlb.c +4 -7
@@ -116,16 +116,13 @@ void __init swiotlb_detect_4g(void) } } -static int __init swiotlb_late_init (void ) +static int __init check_swiotlb_enabled (void ) { -if (ppc_swiotlb_enable) { +if (ppc_swiotlb_enable)swiotlb_print_info (); -set_pci_dma_ops (&swiotlb_dma_ops); - ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; - }else { +else swiotlb_free (); - }return 0 ; } -subsys_initcall (swiotlb_late_init); +subsys_initcall (check_swiotlb_enabled);
arch/powerpc/sysdev/fsl_pci.c +19 -0
@@ -111,6 +111,22 @@ static struct pci_ops fsl_indirect_pcie_ops =#define MAX_PHYS_ADDR_BITS 40static u64 pci64_dma_offset =1ull <<MAX_PHYS_ADDR_BITS ; +#ifdef CONFIG_SWIOTLB +static struct pci_controller_ops swiotlb_pci_controller_ops = { + .dma_dev_setup = pci_dma_dev_setup_swiotlb, +}; + +static void setup_swiotlb_ops (struct pci_controller *hose) +{ +if (ppc_swiotlb_enable) { + hose->controller_ops = swiotlb_pci_controller_ops; +set_pci_dma_ops (&swiotlb_dma_ops); + } +} +#else +static inline void setup_swiotlb_ops (struct pci_controller *hose) {} +#endif +static int fsl_pci_dma_set_mask (struct device *dev,u64 dma_mask) {if (!dev->dma_mask || !dma_supported (dev, dma_mask))
@@ -548,6 +564,9 @@ int fsl_add_bridge(struct platform_device *pdev, int is_primary)/* Setup PEX window registers */ setup_pci_atmu (hose); +/* Set up controller operations */ +setup_swiotlb_ops (hose); +return 0 ; no_bridge:
Signature · 1 line
2.1.4
PATCH v3 16/19 powerpc: fsl_pci, swiotlb: Move controller ops from ppc_md to controller_ops
Moves the setup out of swiotlb's subsys init call, and into an new structure.
fsl_pci.c is the only thing that checks the ppc_swiotlb_enable global, so we can be confident that patching it will cover all the PCI implementations affected by the changes to dma-swiotlb.c.
We do have to make sure we do the changes late in the function, after setup_pci_atmu, because that can change ppc_swiotlb_enable.
---
v1 --> v2:
- Move the setup call to after setup_pci_atmu().
v2 --> v3:
- Only set the affected op, not the entire structure. Thanks mpe.
--- arch/powerpc/kernel/dma-swiotlb.c | 11 ++++------- arch/powerpc/sysdev/fsl_pci.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-)
arch/powerpc/kernel/dma-swiotlb.c +4 -7
@@ -116,16 +116,13 @@ void __init swiotlb_detect_4g(void) } } -static int __init swiotlb_late_init (void ) +static int __init check_swiotlb_enabled (void ) { -if (ppc_swiotlb_enable) { +if (ppc_swiotlb_enable)swiotlb_print_info (); -set_pci_dma_ops (&swiotlb_dma_ops); - ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; - }else { +else swiotlb_free (); - }return 0 ; } -subsys_initcall (swiotlb_late_init); +subsys_initcall (check_swiotlb_enabled);
arch/powerpc/sysdev/fsl_pci.c +15 -0
@@ -111,6 +111,18 @@ static struct pci_ops fsl_indirect_pcie_ops =#define MAX_PHYS_ADDR_BITS 40static u64 pci64_dma_offset =1ull <<MAX_PHYS_ADDR_BITS ; +#ifdef CONFIG_SWIOTLB +static void setup_swiotlb_ops (struct pci_controller *hose) +{ +if (ppc_swiotlb_enable) { + hose->controller_ops.dma_dev_setup = pci_dma_dev_setup_swiotlb; +set_pci_dma_ops (&swiotlb_dma_ops); + } +} +#else +static inline void setup_swiotlb_ops (struct pci_controller *hose) {} +#endif +static int fsl_pci_dma_set_mask (struct device *dev,u64 dma_mask) {if (!dev->dma_mask || !dma_supported (dev, dma_mask))
@@ -548,6 +560,9 @@ int fsl_add_bridge(struct platform_device *pdev, int is_primary)/* Setup PEX window registers */ setup_pci_atmu (hose); +/* Set up controller operations */ +setup_swiotlb_ops (hose); +return 0 ; no_bridge:
Signature · 1 line
2.1.4
Re: [PATCH v3 16/19] powerpc: fsl_pci, swiotlb: Move controller ops from ppc_md to controller_ops
Quoted 2 lines · Daniel Axtens
Moves the setup out of swiotlb's subsys init call, and into an new structure.
"a new"
Quoted 3 lines
fsl_pci.cis the only thing that checks theppc_swiotlb_enableglobal, so we can be confident that patching it will cover all the PCI implementations affected by the changes todma-swiotlb.c.
Do you mean the only thing that sets ppc_swiotlb_enable (fsl_pci.c doesn't check it)? It's also set by swiotlb_detect_4g().
Where is the rest of this patchset? What is the problem being solved?
-Scott
Re: [PATCH v3 16/19] powerpc: fsl_pci, swiotlb: Move controller ops from ppc_md to controller_ops
Hi Scott,
This is part of the larger set to move controller ops into a generic structure. The original cover letter is at
https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-March/126837.html
The commit message should have been reworded when I sent out version 2. Apologies. Here's a more accurate summary, which will appear in v4.
powerpc: fsl_pci, swiotlb: Move controller ops from ppc_md to controller_ops
Move the installation of DMA operations out of swiotlb's subsys initcall, and into the generic PCI controller operations struct.
These ops are installed conditionally, based on the ppc_swiotlb_enable global. The global can be set in two places:
- swiotlb_detect_4g, which is always called at the arch initcall level
- setup_pci_atmu, which is called as part of the fsl_add_bridge andfsl_pci_syscore_do_resume. fsl_pci_syscore_do_resume is called late enough that any changes as a result of that call will have no effect.
As such, if we test the global and set the operations as part of fsl_add_bridge, after the call to setup_pci_atmu, we can be confident that it will cover all the PCI implementations affected by the changes to dma-swiotlb.c.
Regards,
Daniel
Quoted 18 lines · Scott Wood
Quoted 2 lines · Daniel Axtens
Moves the setup out of swiotlb's subsys init call, and into an new structure.
"a new"
Quoted 3 lines
fsl_pci.cis the only thing that checks theppc_swiotlb_enableglobal, so we can be confident that patching it will cover all the PCI implementations affected by the changes todma-swiotlb.c.Do you mean the only thing that sets
ppc_swiotlb_enable(fsl_pci.cdoesn't check it)? It's also set byswiotlb_detect_4g().Where is the rest of this patchset? What is the problem being solved?
-Scott
PATCH v4 16/19 powerpc: fsl_pci, swiotlb: Move controller ops from ppc_md to controller_ops
In reply to Daniel AxtensMove the installation of DMA operations out of swiotlb's subsys initcall, and into the generic PCI controller operations struct.
These ops are installed conditionally, based on the ppc_swiotlb_enable global. The global can be set in two places:
- swiotlb_detect_4g, which is always called at the arch initcall level
- setup_pci_atmu, which is called as part of the fsl_add_bridge andfsl_pci_syscore_do_resume.
fsl_pci_syscore_do_resume is called late enough that any changes as a result of that call will have no effect.
As such, if we test the global and set the operations as part of fsl_add_bridge, after the call to setup_pci_atmu, we can be confident that it will cover all the PCI implementations affected by the changes to dma-swiotlb.c.
---
v1 --> v2:
- Move the setup call to after setup_pci_atmu().
v2 --> v3:
- Only set the affected op, not the entire structure. Thanks mpe.
v3 --> v4:
- Improved commit message, thanks Scott Wood.
--- arch/powerpc/kernel/dma-swiotlb.c | 11 ++++------- arch/powerpc/sysdev/fsl_pci.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-)
arch/powerpc/kernel/dma-swiotlb.c +4 -7
@@ -116,16 +116,13 @@ void __init swiotlb_detect_4g(void) } } -static int __init swiotlb_late_init (void ) +static int __init check_swiotlb_enabled (void ) { -if (ppc_swiotlb_enable) { +if (ppc_swiotlb_enable)swiotlb_print_info (); -set_pci_dma_ops (&swiotlb_dma_ops); - ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; - }else { +else swiotlb_free (); - }return 0 ; } -subsys_initcall (swiotlb_late_init); +subsys_initcall (check_swiotlb_enabled);
arch/powerpc/sysdev/fsl_pci.c +15 -0
@@ -111,6 +111,18 @@ static struct pci_ops fsl_indirect_pcie_ops =#define MAX_PHYS_ADDR_BITS 40static u64 pci64_dma_offset =1ull <<MAX_PHYS_ADDR_BITS ; +#ifdef CONFIG_SWIOTLB +static void setup_swiotlb_ops (struct pci_controller *hose) +{ +if (ppc_swiotlb_enable) { + hose->controller_ops.dma_dev_setup = pci_dma_dev_setup_swiotlb; +set_pci_dma_ops (&swiotlb_dma_ops); + } +} +#else +static inline void setup_swiotlb_ops (struct pci_controller *hose) {} +#endif +static int fsl_pci_dma_set_mask (struct device *dev,u64 dma_mask) {if (!dev->dma_mask || !dma_supported (dev, dma_mask))
@@ -548,6 +560,9 @@ int fsl_add_bridge(struct platform_device *pdev, int is_primary)/* Setup PEX window registers */ setup_pci_atmu (hose); +/* Set up controller operations */ +setup_swiotlb_ops (hose); +return 0 ; no_bridge:
Signature · 1 line
2.1.4
Re: [PATCH v4 16/19] powerpc: fsl_pci, swiotlb: Move controller ops from ppc_md to controller_ops
Quoted 27 lines · Daniel Axtens
Move the installation of DMA operations out of swiotlb's subsys initcall, and into the generic PCI controller operations struct.
These ops are installed conditionally, based on the
ppc_swiotlb_enableglobal. The global can be set in two places:
-swiotlb_detect_4g, which is always called at the arch initcall level
-setup_pci_atmu, which is called as part of thefsl_add_bridgeandfsl_pci_syscore_do_resume.
fsl_pci_syscore_do_resumeis called late enough that any changes as a result of that call will have no effect.As such, if we test the global and set the operations as part of
fsl_add_bridge, after the call tosetup_pci_atmu, we can be confident that it will cover all the PCI implementations affected by the changes todma-swiotlb.c.Signed-off-by Daniel Axtens <[email protected]>---
v1 --> v2:
- Move the setup call to aftersetup_pci_atmu().v2 --> v3:
- Only set the affected op, not the entire structure. Thanks mpe.
Quoted 6 lines
v3 --> v4:
- Improved commit message, thanks Scott Wood.--- arch/powerpc/kernel/dma-swiotlb.c | 11 ++++------- arch/powerpc/sysdev/fsl_pci.c | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-)
-Scott
PATCH v2 17/19 powerpc/cell: Move controller ops from ppc_md to controller_ops
In reply to Daniel AxtensThis moves the Cell platform to use the pci_controller_ops structure rather than ppc_md for PCI controller operations.
---
This depends on the patch to drop celleb support:
http://patchwork.ozlabs.org/patch/451730/
--- arch/powerpc/platforms/cell/cell.h | 24 ++++++++++++++++++++++++ arch/powerpc/platforms/cell/iommu.c | 7 ++++--- arch/powerpc/platforms/cell/setup.c | 5 +++++ 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 arch/powerpc/platforms/cell/cell.h
arch/powerpc/platforms/cell/cell.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Cell Platform common data structures +* +* Copyright 2015, Daniel Axtens, IBM Corporation +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2, or (at your option) +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#ifndef CELL_H +#define CELL_H + +#include <asm/pci-bridge.h> + +extern struct pci_controller_ops cell_pci_controller_ops; + +#endif
arch/powerpc/platforms/cell/iommu.c +4 -3
@@ -39,6 +39,7 @@#include <asm/firmware.h> #include <asm/cell-regs.h> +#include "cell.h" #include "interrupt.h" /* Define CELL_IOMMU_REAL_UNMAP to actually unmap non-used pages
@@ -857,7 +858,7 @@ static int __init cell_iommu_init_disabled(void) cell_dma_direct_offset += base;if (cell_dma_direct_offset !=0 ) - ppc_md.pci_dma_dev_setup = cell_pci_dma_dev_setup; + cell_pci_controller_ops.dma_dev_setup = cell_pci_dma_dev_setup;printk ("iommu: disabled, direct DMA offset is 0x%lx\n" , cell_dma_direct_offset);
@@ -1197,8 +1198,8 @@ static int __init cell_iommu_init(void)if (cell_iommu_init_disabled () ==0 ) goto bail; -/* Setup various ppc_md. callbacks */ - ppc_md.pci_dma_dev_setup = cell_pci_dma_dev_setup; +/* Setup various callbacks */ + cell_pci_controller_ops.dma_dev_setup = cell_pci_dma_dev_setup; ppc_md.dma_get_required_mask = cell_dma_get_required_mask; ppc_md.tce_build = tce_build_cell; ppc_md.tce_free = tce_free_cell;
arch/powerpc/platforms/cell/setup.c +5 -0
@@ -54,6 +54,7 @@#include <asm/cell-regs.h> #include <asm/io-workarounds.h> +#include "cell.h" #include "interrupt.h" #include "pervasive.h" #include "ras.h"
@@ -131,6 +132,8 @@ static int cell_setup_phb(struct pci_controller *phb)if (model ==NULL ||strcmp (np->name,"pci" ))return 0 ; + phb->controller_ops = cell_pci_controller_ops; +/* Setup workarounds for spider */ if (strcmp (model,"Spider" ))return 0 ;
@@ -279,3 +282,5 @@ define_machine(cell) { .init_IRQ = cell_init_irq, .pci_setup_phb = cell_setup_phb, }; + +struct pci_controller_ops cell_pci_controller_ops;
Signature · 1 line
2.1.4
PATCH v2 18/19 powerpc: Remove shims for pci_controller_ops operations
In reply to Daniel AxtensRemove shims, patch callsites to use pci_controller_ops versions instead.
Also move back the probe mode defines, as explained in the patch for pci_probe_mode.
---
v1 --> v2:
- Squash all the shim removal.
- Prefer phb to hose.
--- arch/powerpc/include/asm/machdep.h | 14 ------ arch/powerpc/include/asm/pci-bridge.h | 84 ----------------------------------- arch/powerpc/include/asm/pci.h | 5 +++ arch/powerpc/kernel/pci-common.c | 43 ++++++++++++++---- arch/powerpc/kernel/pci-hotplug.c | 6 ++- arch/powerpc/kernel/pci_of_scan.c | 6 ++- arch/powerpc/sysdev/dart_iommu.c | 5 --- 7 files changed, 50 insertions(+), 113 deletions(-)
arch/powerpc/include/asm/machdep.h +0 -14
@@ -103,9 +103,6 @@ struct machdep_calls {#endif #endif /* CONFIG_PPC64 */ -void (*pci_dma_dev_setup)(struct pci_dev *dev); -void (*pci_dma_bus_setup)(struct pci_bus *bus); -/* Platform set_dma_mask and dma_get_required_mask overrides */ int (*dma_set_mask)(struct device *dev,u64 dma_mask);u64 (*dma_get_required_mask)(struct device *dev);
@@ -127,7 +124,6 @@ struct machdep_calls {/* PCI stuff */ /* Called after scanning the bus, before allocating resources */ void (*pcibios_fixup)(void ); -int (*pci_probe_mode)(struct pci_bus *);void (*pci_irq_fixup)(struct pci_dev *dev);int (*pcibios_root_bridge_prepare)(struct pci_host_bridge *bridge);
@@ -237,19 +233,9 @@ struct machdep_calls {/* Called for each PCI bus in the system when it's probed */ void (*pcibios_fixup_bus)(struct pci_bus *); -/* Called when pci_enable_device() is called. Returns true to -* allow assignment/enabling of the device. */ -bool (*pcibios_enable_device_hook)(struct pci_dev *); -/* Called after scan and before resource survey */ void (*pcibios_fixup_phb)(struct pci_controller *hose); -/* Called during PCI resource reassignment */ -resource_size_t (*pcibios_window_alignment)(struct pci_bus *,unsigned long type); - -/* Reset the secondary bus of bridge */ -void (*pcibios_reset_secondary_bus)(struct pci_dev *dev); -/* Called to shutdown machine specific hardware not already controlled * by other drivers. */
arch/powerpc/include/asm/pci-bridge.h +0 -84
95 lines not on this page · raw message
arch/powerpc/include/asm/pci.h +5 -0
@@ -22,6 +22,11 @@#include <asm-generic/pci-dma-compat.h> +/* Return values for pci_controller_ops.probe_mode function */ +#define PCI_PROBE_NONE -1/* Don't look at this bus at all */ +#define PCI_PROBE_NORMAL 0/* Do normal PCI probing */ +#define PCI_PROBE_DEVTREE 1/* Instantiate from device tree */ +#define PCIBIOS_MIN_IO 0x1000#define PCIBIOS_MIN_MEM 0x10000000
arch/powerpc/kernel/pci-common.c +35 -8
87 lines not on this page · raw message
arch/powerpc/kernel/pci-hotplug.c +5 -1
@@ -73,12 +73,16 @@ void pcibios_add_pci_devices(struct pci_bus * bus) {int slotno, mode, pass, max;struct pci_dev *dev; +struct pci_controller *phb;struct device_node *dn =pci_bus_to_OF_node (bus);eeh_add_device_tree_early (dn); + phb =pci_bus_to_host (bus); + mode =PCI_PROBE_NORMAL ; - mode =pci_probe_mode (bus); +if (phb->controller_ops.probe_mode) + mode = phb->controller_ops.probe_mode (bus);if (mode ==PCI_PROBE_DEVTREE ) {/* use ofdt-based probe */
arch/powerpc/kernel/pci_of_scan.c +5 -1
@@ -207,6 +207,7 @@ void of_scan_pci_bridge(struct pci_dev *dev) {struct device_node *node = dev->dev.of_node;struct pci_bus *bus; +struct pci_controller *phb;const __be32 *busrange, *ranges;int len, i, mode;struct pci_bus_region region;
@@ -286,8 +287,11 @@ void of_scan_pci_bridge(struct pci_dev *dev) bus->number);pr_debug (" bus name: %s\n" , bus->name); + phb =pci_bus_to_host (bus); + mode =PCI_PROBE_NORMAL ; - mode =pci_probe_mode (bus); +if (phb->controller_ops.probe_mode) + mode = phb->controller_ops.probe_mode (bus);pr_debug (" probe mode: %d\n" , mode);if (mode ==PCI_PROBE_DEVTREE )
arch/powerpc/sysdev/dart_iommu.c +0 -5
@@ -398,9 +398,6 @@ void __init iommu_init_early_dart(struct pci_controller_ops *controller_ops)if (controller_ops) { controller_ops->dma_dev_setup = pci_dma_dev_setup_dart; controller_ops->dma_bus_setup = pci_dma_bus_setup_dart; - }else { - ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_dart; - ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_dart; }/* Setup pci_dma ops */ set_pci_dma_ops (&dma_iommu_ops);
@@ -412,8 +409,6 @@ void __init iommu_init_early_dart(struct pci_controller_ops *controller_ops) controller_ops->dma_dev_setup =NULL ; controller_ops->dma_bus_setup =NULL ; } - ppc_md.pci_dma_dev_setup =NULL ; - ppc_md.pci_dma_bus_setup =NULL ;/* Setup pci_dma ops */ set_pci_dma_ops (&dma_direct_ops);
Signature · 1 line
2.1.4
PATCH v2 19/19 powerpc: dart_iommu: Remove check for controller_ops == NULL case
In reply to Daniel AxtensNow that we have ported the calls to iommu_init_early_dart to always supply a pci_controller_ops struct, we can safely drop the check.
--- arch/powerpc/sysdev/dart_iommu.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
arch/powerpc/sysdev/dart_iommu.c +5 -8
@@ -395,20 +395,17 @@ void __init iommu_init_early_dart(struct pci_controller_ops *controller_ops)if (dart_is_u4) ppc_md.dma_set_mask = dart_dma_set_mask; -if (controller_ops) { - controller_ops->dma_dev_setup = pci_dma_dev_setup_dart; - controller_ops->dma_bus_setup = pci_dma_bus_setup_dart; - } + controller_ops->dma_dev_setup = pci_dma_dev_setup_dart; + controller_ops->dma_bus_setup = pci_dma_bus_setup_dart; +/* Setup pci_dma ops */ set_pci_dma_ops (&dma_iommu_ops);return ; bail:/* If init failed, use direct iommu and null setup functions */ -if (controller_ops) { - controller_ops->dma_dev_setup =NULL ; - controller_ops->dma_bus_setup =NULL ; - } + controller_ops->dma_dev_setup =NULL ; + controller_ops->dma_bus_setup =NULL ;/* Setup pci_dma ops */ set_pci_dma_ops (&dma_direct_ops);
Signature · 1 line
2.1.4
Quoted 10 lines · On Tuesday 31 March 2015 16:00:38 Daniel Axtens wrote:
This patch set moves some PCI controller operations out of
ppc_mdand into a newpci_controller_opsstruct.This is desirable for systems with more than one type of PCI controller. In particular, it's intended that this new interface will be used by the CXL (aka CAPI) driver.
The design tries to balance a desire to avoid having yet another abstraction layer with a desire to make it easy for vendor kernels to pull in as little or as much as they are comfortable with.
I looked over the whole series again now, and with my previous concern withdrawn, everything looks good to me. Nice work!
Arnd