From: Daniel Axtens <hidden> Date: 2015-03-31 05:01:22
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
--
2.1.4
From: Daniel Axtens <hidden> Date: 2015-03-31 05:01:24
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.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
@@ -23,8 +23,6 @@ extern void pci_setup_phb_io_dynamic(struct pci_controller *hose, int primary);externstructlist_headhose_list;-externvoidfind_and_init_phbs(void);-externstructpci_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 */
@@ -277,50 +277,3 @@ int rtas_setup_phb(struct pci_controller *phb)return0;}--void__initfind_and_init_phbs(void)-{-structdevice_node*node;-structpci_controller*phb;-structdevice_node*root=of_find_node_by_path("/");--for_each_child_of_node(root,node){-if(node->type==NULL||(strcmp(node->type,"pci")!=0&&-strcmp(node->type,"pciex")!=0))-continue;--phb=pcibios_alloc_controller(node);-if(!phb)-continue;-rtas_setup_phb(phb);-pci_process_bridge_OF_ranges(phb,node,0);-isa_bridge_find_early(phb);-}--of_node_put(root);-pci_devs_phb_init();--/*-*PCI_PROBE_ONLYandPCI_REASSIGN_ALL_BUScanbesetviaproperties-*inchosen.-*/-if(of_chosen){-constint*prop;--prop=of_get_property(of_chosen,-"linux,pci-probe-only",NULL);-if(prop){-if(*prop)-pci_add_flags(PCI_PROBE_ONLY);-else-pci_clear_flags(PCI_PROBE_ONLY);-}--#ifdef CONFIG_PPC32 /* Will be made generic soon */-prop=of_get_property(of_chosen,-"linux,pci-assign-all-buses",NULL);-if(prop&&*prop)-pci_add_flags(PCI_REASSIGN_ALL_BUS);-#endif /* CONFIG_PPC32 */-}-}
@@ -461,6 +461,53 @@ static long pseries_little_endian_exceptions(void)}#endif+staticvoid__initfind_and_init_phbs(void)+{+structdevice_node*node;+structpci_controller*phb;+structdevice_node*root=of_find_node_by_path("/");++for_each_child_of_node(root,node){+if(node->type==NULL||(strcmp(node->type,"pci")!=0&&+strcmp(node->type,"pciex")!=0))+continue;++phb=pcibios_alloc_controller(node);+if(!phb)+continue;+rtas_setup_phb(phb);+pci_process_bridge_OF_ranges(phb,node,0);+isa_bridge_find_early(phb);+}++of_node_put(root);+pci_devs_phb_init();++/*+*PCI_PROBE_ONLYandPCI_REASSIGN_ALL_BUScanbesetviaproperties+*inchosen.+*/+if(of_chosen){+constint*prop;++prop=of_get_property(of_chosen,+"linux,pci-probe-only",NULL);+if(prop){+if(*prop)+pci_add_flags(PCI_PROBE_ONLY);+else+pci_clear_flags(PCI_PROBE_ONLY);+}++#ifdef CONFIG_PPC32 /* Will be made generic soon */+prop=of_get_property(of_chosen,+"linux,pci-assign-all-buses",NULL);+if(prop&&*prop)+pci_add_flags(PCI_REASSIGN_ALL_BUS);+#endif /* CONFIG_PPC32 */+}+}+staticvoid__initpSeries_setup_arch(void){set_arch_panic_timeout(10,ARCH_PANIC_TIMEOUT);
@@ -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+intpmac_pci_probe_mode(structpci_bus*bus)+{+structdevice_node*node=pci_bus_to_OF_node(bus);++/* We need to use normal PCI probing for the AGP bus,+*sincethedevicefortheAGPbridgeisn'tinthetree.+*SameforthePCIehostonU4andtheHThostbridge.+*/+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")))+returnPCI_PROBE_NORMAL;+returnPCI_PROBE_DEVTREE;+}+#endif /* CONFIG_PPC64 */
@@ -637,24 +637,6 @@ static int __init pmac_probe(void)return1;}-#ifdef CONFIG_PPC64-/* Move that to pci.c */-staticintpmac_pci_probe_mode(structpci_bus*bus)-{-structdevice_node*node=pci_bus_to_OF_node(bus);--/* We need to use normal PCI probing for the AGP bus,-*sincethedevicefortheAGPbridgeisn'tinthetree.-*SameforthePCIehostonU4andtheHThostbridge.-*/-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")))-returnPCI_PROBE_NORMAL;-returnPCI_PROBE_DEVTREE;-}-#endif /* CONFIG_PPC64 */-define_machine(powermac){.name="PowerMac",.probe=pmac_probe,
From: Daniel Axtens <hidden> Date: 2015-03-31 05:01:30
pcibios_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.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
@@ -237,9 +237,9 @@ struct machdep_calls {/* Called for each PCI bus in the system when it's probed */void(*pcibios_fixup_bus)(structpci_bus*);-/* Called when pci_enable_device() is called. Returns 0 to+/* Called when pci_enable_device() is called. Returns true to*allowassignment/enablingofthedevice.*/-int(*pcibios_enable_device_hook)(structpci_dev*);+bool(*pcibios_enable_device_hook)(structpci_dev*);/* Called after scan and before resource survey */void(*pcibios_fixup_phb)(structpci_controller*hose);
@@ -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;+returnfalse;}if(!node)-return0;+returntrue;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);}-return0;+returntrue;}voidpmac_pci_fixup_ohci(structpci_dev*dev)
From: Daniel Axtens <hidden> Date: 2015-03-31 05:01:33
Introduces 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.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
From: Daniel Axtens <hidden> Date: 2015-03-31 05:01:35
Add pci_controller_ops.dma_bus_setup, shadowing ppc_md.pci_dma_bus_setup.
Add a shim, and changes the callsites to use the shim.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
From: Daniel Axtens <hidden> Date: 2015-03-31 05:01:38
Add 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.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
@@ -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 */+structdevice_node;/*
@@ -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
From: Daniel Axtens <hidden> Date: 2015-03-31 05:01:41
Add pci_controller_ops.enable_device_hook,
shadowing ppc_md.pcibios_enable_device_hook.
Add a shim, and changes the callsites to use the shim.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
@@ -27,6 +27,10 @@ struct pci_controller_ops {void(*dma_bus_setup)(structpci_bus*bus);int(*probe_mode)(structpci_bus*);++/* Called when pci_enable_device() is called. Returns true to+*allowassignment/enablingofthedevice.*/+bool(*enable_device_hook)(structpci_dev*);};/*
From: Daniel Axtens <hidden> Date: 2015-03-31 05:01:44
Add 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.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
@@ -31,6 +31,9 @@ struct pci_controller_ops {/* Called when pci_enable_device() is called. Returns true to*allowassignment/enablingofthedevice.*/bool(*enable_device_hook)(structpci_dev*);++/* Called during PCI resource reassignment */+resource_size_t(*window_alignment)(structpci_bus*,unsignedlongtype);};/*
From: Daniel Axtens <hidden> Date: 2015-03-31 05:01:47
Add 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.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
From: Daniel Axtens <hidden> Date: 2015-03-31 05:01:49
If 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.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
@@ -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
From: Daniel Axtens <hidden> Date: 2015-03-31 05:01:52
This moves the Power Mac platform to use the pci_controller_ops
structure rather than ppc_md for PCI controller operations.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
@@ -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
From: Daniel Axtens <hidden> Date: 2015-03-31 05:01:56
This moves the pSeries platform to use the pci_controller_ops structure,
rather than ppc_md for PCI controller operations.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
From: Daniel Axtens <hidden> Date: 2015-03-31 05:01:58
This moves the PowerNV platform to use the pci_controller_ops
structure rather than ppc_md for PCI controller operations.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
From: Daniel Axtens <hidden> Date: 2015-03-31 05:02:01
This moves the PaSemi platform to use the pci_controller_ops
structure rather than ppc_md for PCI controller operations.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
From: Daniel Axtens <hidden> Date: 2015-03-31 05:02:04
This moves the Maple platform to use the pci_controller_ops
structure rather than ppc_md for PCI controller operations.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
From: Daniel Axtens <hidden> Date: 2015-03-31 05:02:07
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.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
@@ -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);+return0;no_bridge:
From: Daniel Axtens <hidden> Date: 2015-03-31 05:02:11
This moves the Cell platform to use the pci_controller_ops
structure rather than ppc_md for PCI controller operations.
Signed-off-by: Daniel Axtens <redacted>
---
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
@@ -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)gotobail;-/* 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;
@@ -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)(structpci_bus*);void(*pci_irq_fixup)(structpci_dev*dev);int(*pcibios_root_bridge_prepare)(structpci_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)(structpci_bus*);-/* Called when pci_enable_device() is called. Returns true to-*allowassignment/enablingofthedevice.*/-bool(*pcibios_enable_device_hook)(structpci_dev*);-/* Called after scan and before resource survey */void(*pcibios_fixup_phb)(structpci_controller*hose);-/* Called during PCI resource reassignment */-resource_size_t(*pcibios_window_alignment)(structpci_bus*,unsignedlongtype);--/* Reset the secondary bus of bridge */-void(*pcibios_reset_secondary_bus)(structpci_dev*dev);-/* Called to shutdown machine specific hardware not already controlled*byotherdrivers.*/
@@ -12,11 +12,6 @@#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 */-structdevice_node;/*
@@ -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
@@ -929,6 +946,8 @@ static void pcibios_fixup_bridge(struct pci_bus *bus)voidpcibios_setup_bus_self(structpci_bus*bus){+structpci_controller*phb;+/* Fix up the bus resources for P2P bridges */if(bus->self!=NULL)pcibios_fixup_bridge(bus);
@@ -940,11 +959,14 @@ void pcibios_setup_bus_self(struct pci_bus *bus)ppc_md.pcibios_fixup_bus(bus);/* Setup bus DMA mappings */-pci_dma_bus_setup(bus);+phb=pci_bus_to_host(bus);+if(phb->controller_ops.dma_bus_setup)+phb->controller_ops.dma_bus_setup(bus);}staticvoidpcibios_setup_device(structpci_dev*dev){+structpci_controller*phb;/* Fixup NUMA node as it may not be setup yet by the generic*codeandisneededbytheDMAinit*/
From: Daniel Axtens <hidden> Date: 2015-03-31 05:02:15
Now 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.
Signed-off-by: Daniel Axtens <redacted>
---
arch/powerpc/sysdev/dart_iommu.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
From: Daniel Axtens <hidden> Date: 2015-04-02 03:22:13
This moves the pSeries platform to use the pci_controller_ops structure,
rather than ppc_md for PCI controller operations.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
On Tuesday 31 March 2015 16:00:42 Daniel Axtens wrote:
quoted hunk
Introduces 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.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
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
I'm familiar with that patch series - I've been helping Yijing get it up
to speed on PowerPC.
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
I'm familiar with that patch series - I've been helping Yijing get it up
to speed on PowerPC.
quoted
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.
Ok, fair enough. Let's do this one first then.
Arnd
On Tuesday 31 March 2015 16:00:38 Daniel Axtens wrote:
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.
I looked over the whole series again now, and with my previous concern
withdrawn, everything looks good to me. Nice work!
Arnd
I'm familiar with that patch series - I've been helping Yijing get it up
to speed on PowerPC.
quoted
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.
From: Daniel Axtens <hidden> Date: 2015-04-10 00:12:19
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.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
@@ -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);+return0;no_bridge:
From: Scott Wood <hidden> Date: 2015-04-10 01:29:04
On Fri, 2015-04-10 at 10:11 +1000, Daniel Axtens wrote:
Moves the setup out of swiotlb's subsys init call, and into an new
structure.
"a new"
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.
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
From: Daniel Axtens <hidden> Date: 2015-04-10 02:36:46
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 and
fsl_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
On Thu, 2015-04-09 at 20:28 -0500, Scott Wood wrote:
On Fri, 2015-04-10 at 10:11 +1000, Daniel Axtens wrote:
quoted
Moves the setup out of swiotlb's subsys init call, and into an new
structure.
"a new"
quoted
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.
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
From: Daniel Axtens <hidden> Date: 2015-04-10 03:16:01
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 and
fsl_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.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)
@@ -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);+return0;no_bridge:
From: Scott Wood <hidden> Date: 2015-04-10 03:18:34
On Fri, 2015-04-10 at 13:15 +1000, Daniel Axtens wrote:
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 and
fsl_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.
Signed-off-by: Daniel Axtens <redacted>
---
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(-)