powerpc/fsl-pci: Unify pci/pcie initialization code
Subsystems (4)
PATCH v3 1/5 powerpc/fsl-pci: Unify pci/pcie initialization code
We unified the Freescale pci/pcie initialization by changing the fsl_pci to a platform driver. In previous PCI code architecture the initialization routine is called at board_setup_arch stage. Now the initialization is done in probe function which is architectural better. Also It's convenient for adding PM support for PCI controller in later patch.
One issue introduced by this architecture is the timing of swiotlb_init. During PCI initialization the need of swiotlb is determined and this should be done before swiotlb_init. So a new function to determine swiotlb by parsing pci ranges is made. This function is called at board_setup_arch stage which is earlier than swiotlb_init.
---
Changed for V3:
- Rebase the patch set on the latest tree
- merge PCI unify and swiotlb patch into one
arch/powerpc/sysdev/fsl_pci.c | 155 ++++++++++++++++++++++++++++++++--------- arch/powerpc/sysdev/fsl_pci.h | 9 +-- 2 files changed, 125 insertions(+), 39 deletions(-)
arch/powerpc/sysdev/fsl_pci.c +121 -34
@@ -823,56 +823,143 @@ static const struct of_device_id pci_ids[] = { {}, }; -struct device_node *fsl_pci_primary; - -void __devinit fsl_pci_init (void ) +#ifdef CONFIG_SWIOTLB +void pci_determine_swiotlb (void ) { +const u32 *ranges; +int rlen; +int pna; +int np;struct device_node *node; -struct pci_controller *hose; -dma_addr_t max =0xffffffff ; - -/* Callers can specify the primary bus using other means. */ -if (!fsl_pci_primary) { -/* If a PCI host bridge contains an ISA node, it's primary. */ - node =of_find_node_by_type (NULL ,"isa" ); -while ((fsl_pci_primary =of_get_parent (node))) { -of_node_put (node); - node = fsl_pci_primary; - -if (of_match_node (pci_ids, node)) -break ; - } - } +int memno; +u32 pci_space; +unsigned long long pci_addr, cpu_addr, pci_next, cpu_next, size; +unsigned long long pci_addr_lo =ULLONG_MAX ; +unsigned long long pci_addr_hi =0x0 ; +dma_addr_t pci_dma_sz; - node =NULL ;for_each_node_by_type (node,"pci" ) {if (of_match_node (pci_ids, node)) { -/* -* If there's no PCI host bridge with ISA, arbitrarily -* designate one as primary. This can go away once -* various bugs with primary-less systems are fixed. -*/ -if (!fsl_pci_primary) - fsl_pci_primary = node; - -fsl_add_bridge (node, fsl_pci_primary == node); - hose =pci_find_hose_for_OF_device (node); - max =min (max, hose->dma_window_base_cur + - hose->dma_window_size); + memno =0 ; + pna =of_n_addr_cells (node); + np = pna +5 ; +/* Get ranges property */ + ranges =of_get_property (node,"ranges" , &rlen); +if (ranges ==NULL ) +return ; + +/* Parse outbound MEM window range */ +while ((rlen -= np *4 ) >=0 ) { +/* Read next ranges element */ + pci_space = ranges[0 ]; +if (!((pci_space >>24 ) &0x2 )) { + ranges += np; +break ; + } + pci_addr =of_read_number (ranges +1 ,2 ); + cpu_addr =of_translate_address ( + node, ranges +3 ); + size =of_read_number (ranges + pna +3 ,2 ); + ranges += np; + +/* +* If we failed translation or got a zero-sized +* region (some FW try to feed us with non +* sensical zero sized regions such as power3 +* which look like some kind of attempt at +* exposing the VGA memory hole) +*/ +if (cpu_addr ==OF_BAD_ADDR || size ==0 ) +continue ; + +/* +* Now consume following elements while they +* are contiguous +*/ +for (; rlen >= np *sizeof (u32); + ranges += np, rlen -= np *4 ) { +if (ranges[0 ] != pci_space) +break ; + pci_next =of_read_number (ranges +1 , +2 ); + cpu_next =of_translate_address (node, + ranges +3 ); +if (pci_next != pci_addr + size || + cpu_next != cpu_addr + size) +break ; + size +=of_read_number ( + ranges + pna +3 ,2 ); + } + +/* We support only 3 memory ranges */ +if (memno >=3 ) { +printk (KERN_INFO +" \\--> Skipped (too many) !\n" ); +continue ; + } + + pci_addr_lo =min (pci_addr, pci_addr_lo); + pci_addr_hi =max (pci_addr + size, pci_addr_hi); + memno++; + } } } -#ifdef CONFIG_SWIOTLB +/* Get PEXCSRBAR size (equal to CCSR size) */ + node =of_find_node_by_type (NULL ,"soc" ); + ranges =of_get_property (node,"ranges" , &rlen); +if (ranges ==NULL ) +return ; + + size =of_read_number (ranges +3 ,1 ); +of_node_put (node); + +if (pci_addr_hi < (0x100000000ull - size)) + pci_dma_sz = pci_addr_lo; +else + pci_dma_sz = pci_addr_lo - size; +/* * if we couldn't map all of DRAM via the dma windows * we need SWIOTLB to handle buffers located outside of * dma capable memory region */ -if (memblock_end_of_DRAM () -1 > max) { +if (memblock_end_of_DRAM () > pci_dma_sz) { ppc_swiotlb_enable =1 ;set_pci_dma_ops (&swiotlb_dma_ops); - ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; + ppc_md.pci_dma_dev_setup = + pci_dma_dev_setup_swiotlb; } +}#endif + +int primary_phb_addr; +static int __devinit fsl_pci_probe (struct platform_device *pdev) +{ +struct pci_controller *hose; +bool is_primary; + +if (of_match_node (pci_ids, pdev->dev.of_node)) { +struct resource rsrc; +of_address_to_resource (pdev->dev.of_node,0 , &rsrc); + is_primary = ((rsrc.start &0xfffff ) == primary_phb_addr); +fsl_add_bridge (pdev->dev.of_node, is_primary); + } + +return 0 ; +} + +static struct platform_driver fsl_pci_driver = { + .driver = { + .name ="fsl-pci" , + .of_match_table = pci_ids, + }, + .probe = fsl_pci_probe, +}; + +static int __init fsl_pci_init (void ) +{ +return platform_driver_register (&fsl_pci_driver); } +arch_initcall (fsl_pci_init);#endif
arch/powerpc/sysdev/fsl_pci.h +4 -5
@@ -88,17 +88,16 @@ struct ccsr_pci { __be32 pex_err_cap_r3; /* 0x.e34 - PCIE error capture register 0 */ }; +extern int primary_phb_addr;extern int fsl_add_bridge (struct device_node *dev,int is_primary);extern void fsl_pcibios_fixup_bus (struct pci_bus *bus);extern int mpc83xx_add_bridge (struct device_node *dev);u64 fsl_pci_immrbar_base (struct pci_controller *hose); -extern struct device_node *fsl_pci_primary; - -#ifdef CONFIG_FSL_PCI -void fsl_pci_init (void ); +#ifdef CONFIG_SWIOTLB +extern void pci_determine_swiotlb (void );#else -static inline void fsl_pci_init (void ) {} +static inline void pci_determine_swiotlb (void ) {}#endif #endif /* __POWERPC_FSL_PCI_H */
Signature · 1 line
1.7.5.1
PATCH v3 2/5 powerpc/fsl-pci: Determine primary bus by looking for ISA node
PCI host bridge is primary bus if it contains an ISA node. But not all boards fit this rule. Device tree should be updated for all these boards.
---
Changed for V3:
- Using non-recursive function to find ISA under PCI
arch/powerpc/include/asm/pci-bridge.h | 1 + arch/powerpc/sysdev/fsl_pci.c | 31 ++++++++++++++++++++++++------- arch/powerpc/sysdev/fsl_pci.h | 12 +++++++++++- 3 files changed, 36 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +1 -0
@@ -20,6 +20,7 @@ struct device_node;struct pci_controller {struct pci_bus *bus;char is_dynamic; +int is_primary;#ifdef CONFIG_PPC64 int node;#endif
arch/powerpc/sysdev/fsl_pci.c +24 -7
@@ -453,6 +453,7 @@ int __init fsl_add_bridge(struct device_node *dev, int is_primary) hose->first_busno = bus_range ? bus_range[0 ] :0x0 ; hose->last_busno = bus_range ? bus_range[1 ] :0xff ; + hose->is_primary = is_primary;setup_indirect_pci (hose, rsrc.start, rsrc.start +0x4 ,PPC_INDIRECT_TYPE_BIG_ENDIAN );
@@ -933,18 +934,34 @@ void pci_determine_swiotlb(void) }#endif -int primary_phb_addr; +/* Checkout if PCI contains ISA node (Only scan the children of PCI) */ +static int of_pci_has_isa (struct device_node *pci_node) +{ +struct device_node *np; + +read_lock (&devtree_lock); +if (!pci_node) +return 0 ; + np = pci_node->allnext; +for (; np != pci_node->sibling; np = np->allnext) { +if (np->type && (of_node_cmp (np->type,"isa" ) ==0 ) + &&of_node_get (np)) { +of_node_put (pci_node); +return 1 ; + } + } +of_node_put (pci_node); +read_unlock (&devtree_lock); +return 0 ; +} +static int __devinit fsl_pci_probe (struct platform_device *pdev) { -struct pci_controller *hose;bool is_primary; + is_primary =of_pci_has_isa (pdev->dev.of_node); -if (of_match_node (pci_ids, pdev->dev.of_node)) { -struct resource rsrc; -of_address_to_resource (pdev->dev.of_node,0 , &rsrc); - is_primary = ((rsrc.start &0xfffff ) == primary_phb_addr); +if (of_match_node (pci_ids, pdev->dev.of_node))fsl_add_bridge (pdev->dev.of_node, is_primary); - }return 0 ; }
arch/powerpc/sysdev/fsl_pci.h +11 -1
@@ -88,7 +88,17 @@ struct ccsr_pci {__be32 pex_err_cap_r3;/* 0x.e34 - PCIE error capture register 0 */ }; -extern int primary_phb_addr; + +#ifdef CONFIG_SUSPEND +struct fsl_pci_private_data { +int inbound_num; +struct pci_outbound_window_regs __iomem *pci_pow; +struct pci_inbound_window_regs __iomem *pci_piw; +void *saved_regs; +}; +#endif + +extern int is_has_isa_node (struct device_node *parent);extern int fsl_add_bridge (struct device_node *dev,int is_primary);extern void fsl_pcibios_fixup_bus (struct pci_bus *bus);extern int mpc83xx_add_bridge (struct device_node *dev);
Signature · 1 line
1.7.5.1
Re: [PATCH V3 2/5] powerpc/fsl-pci: Determine primary bus by looking for ISA node
Quoted 1 line · Jia Hongtao
PCI host bridge is primary bus if it contains an ISA node. But not all =
boards
Quoted 1 line
fit this rule. Device tree should be updated for all these boards.
I don't really seen any reason for this patch. We can just use the code = as Scott wrote it that sets fsl_pci_primary based on search for the isa = node.
Quoted 9 lines
=20
Signed-off-by Jia Hongtao <[email protected]>Signed-off-by Li Yang <[email protected]>---
Changed for V3:
- Using non-recursive function to find ISA under PCI =20arch/powerpc/include/asm/pci-bridge.h| 1 +arch/powerpc/sysdev/fsl_pci.c| 31 =
++++++++++++++++++++++++-------
=
Quoted 4 lines
arch/powerpc/sysdev/fsl_pci.h| 12 +++++++++++-3 files changed, 36 insertions(+), 8 deletions(-)=20
= renamed from arch/powerpc/include/asm/pci-bridge.h +0
-0
b/arch/powerpc/include/asm/pci-bridge.h
=
Quoted 12 lines
index ac39e6a..b48fa7f 100644
arch/powerpc/include/asm/pci-bridge.h +1
-0@@ -20,6 +20,7 @@ struct device_node;struct pci_controller {struct pci_bus *bus;char is_dynamic; +int is_primary;#ifdef CONFIG_PPC64 int node;#endif = renamed from arch/powerpc/sysdev/fsl_pci.c +0
-0
b/arch/powerpc/sysdev/fsl_pci.c
arch/powerpc/sysdev/fsl_pci.c int __init fsl_add_bridge(struct device_node *dev, =
Quoted 4 lines
index 5228b6b..97557c5 100644
arch/powerpc/sysdev/fsl_pci.c +0
-0@@ -453,6 +453,7 @@ int __init fsl_add_bridge(struct device_node *dev, =
int is_primary)
arch/powerpc/sysdev/fsl_pci.c
Quoted 13 lines
=20
hose->first_busno =3D bus_range ? bus_range[0] : 0x0; hose->last_busno =3D bus_range ? bus_range[1] : 0xff;arch/powerpc/sysdev/fsl_pci.c +1
-0+ hose->is_primary =3D is_primary;=20
setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4, PPC_INDIRECT_TYPE_BIG_ENDIAN);arch/powerpc/sysdev/fsl_pci.c +0
-0@@ -933,18 +934,34 @@ void pci_determine_swiotlb(void) }#endif =20
arch/powerpc/sysdev/fsl_pci.c +1
-1-int primary_phb_addr; +/* Checkout if PCI contains ISA node (Only scan the children of PCI) =
*/
Quoted 26 lines
arch/powerpc/sysdev/fsl_pci.c +20
-0+static int of_pci_has_isa (struct device_node *pci_node) +{ +struct device_node *np; + +read_lock (&devtree_lock); +if (!pci_node) +return 0 ; + np =3D pci_node->allnext; + for (; np !=3D pci_node->sibling; np =3D np->allnext) { + if (np->type && (of_node_cmp(np->type, "isa") =3D=3D 0) + && of_node_get(np)) { +of_node_put (pci_node); +return 1 ; + } + } +of_node_put (pci_node); +read_unlock (&devtree_lock); +return 0 ; +} +static int
__devinitfsl_pci_probe(struct platform_device *pdev){arch/powerpc/sysdev/fsl_pci.c +0
-1-struct pci_controller *hose;bool is_primary;arch/powerpc/sysdev/fsl_pci.c +1
-0+ is_primary =3D of_pci_has_isa(pdev->dev.of_node);=20
arch/powerpc/sysdev/fsl_pci.c void pci_determine_swiotlb(void)
Quoted 4 lines
arch/powerpc/sysdev/fsl_pci.c +0
-4-if (of_match_node (pci_ids, pdev->dev.of_node)) { -struct resource rsrc; -of_address_to_resource (pdev->dev.of_node,0 , &rsrc); - is_primary =3D ((rsrc.start & 0xfffff) =3D=3D =
primary_phb_addr);
=
Quoted 7 lines
arch/powerpc/sysdev/fsl_pci.c +1
-0+if (of_match_node (pci_ids, pdev->dev.of_node))fsl_add_bridge(pdev->dev.of_node, is_primary);arch/powerpc/sysdev/fsl_pci.c +0
-1- }=20
return 0; }= renamed from arch/powerpc/sysdev/fsl_pci.h +0
-0
b/arch/powerpc/sysdev/fsl_pci.h
arch/powerpc/sysdev/fsl_pci.h struct ccsr_pci { · line 88
Quoted 5 lines
index 095392d..c884e06 100644
arch/powerpc/sysdev/fsl_pci.h +0
-0@@ -88,7 +88,17 @@ struct ccsr_pci {__be32 pex_err_cap_r3;/* 0x.e34 - PCIE error capture =
register 0 */
arch/powerpc/sysdev/fsl_pci.h struct ccsr_pci { · line 100
Quoted 13 lines
arch/powerpc/sysdev/fsl_pci.h +0
-0};=20
arch/powerpc/sysdev/fsl_pci.h +10
-1-extern int primary_phb_addr; + +#ifdef CONFIG_SUSPEND +struct fsl_pci_private_data { +int inbound_num; +struct pci_outbound_window_regs __iomem *pci_pow; +struct pci_inbound_window_regs __iomem *pci_piw; +void *saved_regs; +}; +#endif +
This struct has nothing to do with this patch
Quoted 1 line
+extern int
is_has_isa_node(struct device_node *parent);
Where is is_has_isa_node() defined or used?
Quoted 6 lines
extern int
fsl_add_bridge(struct device_node *dev, int is_primary); extern voidfsl_pcibios_fixup_bus(struct pci_bus *bus); extern intmpc83xx_add_bridge(struct device_node *dev); --=20
1.7.5.1
=20
RE: [PATCH V3 2/5] powerpc/fsl-pci: Determine primary bus by looking for ISA node
Thanks for all your comments.
Sorry for the mistakes in this patchset. I am just so eager to push them to upstream. I will work on the comments very carfully.
Thanks.
-Hongtao.
Quoted 137 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Friday, July 27, 2012 2:22 AM
To: Jia Hongtao-B38951
Cc: [email protected]; Wood Scott-B07421; Li Yang-R58472
Subject: Re: [PATCH V3 2/5] powerpc/fsl-pci: Determine primary bus by looking for ISA node
=20
=20
On Jul 26, 2012, at 7:30 AM, Jia Hongtao wrote:
=20Quoted 1 line
PCI host bridge is primary bus if it contains an ISA node. But not all
boards
Quoted 1 line
fit this rule. Device tree should be updated for all these boards.
=20
I don't really seen any reason for this patch. We can just use the code as Scott wrote it that setsfsl_pci_primarybased on search for the isa node.
=20Quoted 9 lines
Signed-off-by Jia Hongtao <[email protected]>Signed-off-by Li Yang <[email protected]>---
Changed for V3:
- Using non-recursive function to find ISA under PCI
arch/powerpc/include/asm/pci-bridge.h| 1 +arch/powerpc/sysdev/fsl_pci.c| 31 ++++++++++++++++++++++++-------
Review
Quoted 4 lines
arch/powerpc/sysdev/fsl_pci.h| 12 +++++++++++-3 files changed, 36 insertions(+), 8 deletions(-)(quoted diff) +0
-0
b/arch/powerpc/include/asm/pci-bridge.hReview
Quoted 12 lines
index ac39e6a..b48fa7f 100644
arch/powerpc/include/asm/pci-bridge.h +1
-0@@ -20,6 +20,7 @@ struct device_node;struct pci_controller {struct pci_bus *bus;char is_dynamic; +int is_primary;#ifdef CONFIG_PPC64 int node;#endif (quoted diff) +0
-0
b/arch/powerpc/sysdev/fsl_pci.carch/powerpc/sysdev/fsl_pci.c int __init fsl_add_bridge(struct device_node *dev,
Quoted 4 lines
index 5228b6b..97557c5 100644
arch/powerpc/sysdev/fsl_pci.c +0
-0@@ -453,6 +453,7 @@ int __init fsl_add_bridge(struct device_node *dev,int
is_primary)arch/powerpc/sysdev/fsl_pci.c void pci_determine_swiotlb(void) · line 937
Quoted 13 lines
arch/powerpc/sysdev/fsl_pci.c +2
-1hose->first_busno =3D bus_range ? bus_range[0] : 0x0; hose->last_busno =3D bus_range ? bus_range[1] : 0xff; + hose->is_primary =3D is_primary;setup_indirect_pci (hose, rsrc.start, rsrc.start +0x4 ,PPC_INDIRECT_TYPE_BIG_ENDIAN );@@ -933,18 +934,34 @@ void pci_determine_swiotlb(void) }#endif -int primary_phb_addr; +/* Checkout if PCI contains ISA node (Only scan the children of PCI) */
Review
Quoted 37 lines
arch/powerpc/sysdev/fsl_pci.c +22
-6+static int of_pci_has_isa (struct device_node *pci_node) +{ +struct device_node *np; + +read_lock (&devtree_lock); +if (!pci_node) +return 0 ; + np =3D pci_node->allnext; + for (; np !=3D pci_node->sibling; np =3D np->allnext) { + if (np->type && (of_node_cmp(np->type, "isa") =3D=3D 0) + && of_node_get(np)) { +of_node_put (pci_node); +return 1 ; + } + } +of_node_put (pci_node); +read_unlock (&devtree_lock); +return 0 ; +} +static int __devinit fsl_pci_probe (struct platform_device *pdev) { -struct pci_controller *hose;bool is_primary; + is_primary =3D of_pci_has_isa(pdev->dev.of_node); -if (of_match_node (pci_ids, pdev->dev.of_node)) { -struct resource rsrc; -of_address_to_resource (pdev->dev.of_node,0 , &rsrc); - is_primary =3D ((rsrc.start & 0xfffff) =3D=3D primary_phb_addr); +if (of_match_node (pci_ids, pdev->dev.of_node))fsl_add_bridge (pdev->dev.of_node, is_primary); - }return 0 ; }(quoted diff) +0
-0
b/arch/powerpc/sysdev/fsl_pci.harch/powerpc/sysdev/fsl_pci.h struct ccsr_pci { · line 88
Quoted 5 lines
index 095392d..c884e06 100644
arch/powerpc/sysdev/fsl_pci.h +0
-0@@ -88,7 +88,17 @@ struct ccsr_pci {__be32 pex_err_cap_r3;/* 0x.e34 - PCIE error capture register 0 */
arch/powerpc/sysdev/fsl_pci.h struct ccsr_pci { · line 100
Quoted 13 lines
arch/powerpc/sysdev/fsl_pci.h +10
-1}; -extern int primary_phb_addr; + +#ifdef CONFIG_SUSPEND +struct fsl_pci_private_data { +int inbound_num; +struct pci_outbound_window_regs __iomem *pci_pow; +struct pci_inbound_window_regs __iomem *pci_piw; +void *saved_regs; +}; +#endif +=20
This struct has nothing to do with this patch
=20arch/powerpc/sysdev/fsl_pci.h struct ccsr_pci { · line 101
Quoted 1 line
arch/powerpc/sysdev/fsl_pci.h +1
-0+extern int is_has_isa_node (struct device_node *parent);=20
Where isis_has_isa_node()defined or used?
=20Quoted 6 lines
arch/powerpc/sysdev/fsl_pci.h +0
-1extern int fsl_add_bridge (struct device_node *dev,int is_primary);extern void fsl_pcibios_fixup_bus (struct pci_bus *bus);extern int mpc83xx_add_bridge (struct device_node *dev); --1.7.5.1
=20
RE: [PATCH V3 2/5] powerpc/fsl-pci: Determine primary bus by looking for ISA node
In reply to Kumar GalaQuoted 11 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Friday, July 27, 2012 2:22 AM
To: Jia Hongtao-B38951
Cc: [email protected]; Wood Scott-B07421; Li Yang-R58472
Subject: Re: [PATCH V3 2/5] powerpc/fsl-pci: Determine primary bus by looking for ISA node
=20
=20
On Jul 26, 2012, at 7:30 AM, Jia Hongtao wrote:
=20
Quoted 8 lines
Quoted 1 line
PCI host bridge is primary bus if it contains an ISA node. But not all
boards
Quoted 1 line
fit this rule. Device tree should be updated for all these boards.
=20
I don't really seen any reason for this patch. We can just use the code as Scott wrote it that setsfsl_pci_primarybased on search for the isa node.
=20
I change the way of searching ISA node just because the platform driver mechanism. Probe function of this driver will be called for each PCI controller which means more than once. I think the Scott's way is not perfectly match this situation. Anyway I will find a better way to solve this by refactoring the Scott's method or using my own way.
Thanks.
-Hongtao.
PATCH v3 3/5 powerpc/mpc85xx: convert to unified PCI init
In reply to Jia HongtaoPCI initialization is now done by PCI controller driver. In board_setup_arch stage we don't need PCI init any more but swiotlb should be determined at this stage.
---
We now just apply this for mpc85xx_ds and qemu
arch/powerpc/kernel/iommu.c.rej | 22 ----------------- arch/powerpc/platforms/85xx/common.c | 9 +++++++ arch/powerpc/platforms/85xx/mpc85xx_ds.c | 38 +++++++---------------------- arch/powerpc/platforms/85xx/qemu_e500.c | 5 +++- 4 files changed, 22 insertions(+), 52 deletions(-) delete mode 100644 arch/powerpc/kernel/iommu.c.rej
arch/powerpc/kernel/iommu.c.rej deleted +0 -22
@@ -1,22 +0,0 @@ ---- arch/powerpc/kernel/iommu.c 2012-06-08 09:01:02.785709100 +1000 -+++ arch/powerpc/kernel/iommu.c 2012-06-08 09:01:07.489784856 +1000 -@@ -33,7 +33,9 @@ - #include <linux/bitmap.h> - #include <linux/iommu-helper.h> - #include <linux/crash_dump.h> -+#include <linux/fault-inject.h> - #include <asm/io.h> -+#include <asm/vio.h> - #include <asm/prom.h> - #include <asm/iommu.h> - #include <asm/pci-bridge.h> -@@ -171,6 +261,9 @@ - return DMA_ERROR_CODE; - } - -+ if (should_fail_iommu(dev)) -+ return DMA_ERROR_CODE; -+ - if (handle && *handle) - start = *handle; - else
arch/powerpc/platforms/85xx/common.c +9 -0
@@ -27,6 +27,15 @@ static struct of_device_id __initdata mpc85xx_common_ids[] = { { .compatible = "fsl,mpc8548-guts", }, /* Probably unnecessary? */ { .compatible = "gpio-leds", }, + /* For all PCI controllers */ + { .compatible = "fsl,mpc8540-pci", }, + { .compatible = "fsl,mpc8548-pcie", }, + { .compatible = "fsl,p1022-pcie", }, + { .compatible = "fsl,p1010-pcie", }, + { .compatible = "fsl,p1023-pcie", }, + { .compatible = "fsl,p4080-pcie", }, + { .compatible = "fsl,qoriq-pcie-v2.3", }, + { .compatible = "fsl,qoriq-pcie-v2.2", }, {}, };
arch/powerpc/platforms/85xx/mpc85xx_ds.c +9 -29
@@ -117,40 +117,16 @@ void __init mpc85xx_ds_pic_init(void)extern int uli_exclude_device (struct pci_controller *hose,u_char bus,u_char devfn); -static struct device_node *pci_with_uli; -static int mpc85xx_exclude_device (struct pci_controller *hose,u_char bus,u_char devfn) { -if (hose->dn == pci_with_uli) +if (hose->is_primary)return uli_exclude_device (hose, bus, devfn);return PCIBIOS_SUCCESSFUL ; }#endif /* CONFIG_PCI */ -static void __init mpc85xx_ds_pci_init (void ) -{ -#ifdef CONFIG_PCI -struct device_node *node; - -fsl_pci_init (); - -/* See if we have a ULI under the primary */ - - node =of_find_node_by_name (NULL ,"uli1575" ); -while ((pci_with_uli =of_get_parent (node))) { -of_node_put (node); - node = pci_with_uli; - -if (pci_with_uli == fsl_pci_primary) { - ppc_md.pci_exclude_device = mpc85xx_exclude_device; -break ; - } - } -#endif -} -/* * Setup the architecture */
@@ -159,7 +135,11 @@ static void __init mpc85xx_ds_setup_arch(void)if (ppc_md.progress) ppc_md.progress ("mpc85xx_ds_setup_arch()" ,0 ); -mpc85xx_ds_pci_init (); +#ifdef CONFIG_PCI +pci_determine_swiotlb (); + ppc_md.pci_exclude_device = mpc85xx_exclude_device; +#endif +mpc85xx_smp_init ();printk ("MPC85xx DS board from Freescale Semiconductor\n" );
@@ -175,9 +155,9 @@ static int __init mpc8544_ds_probe(void)return !!of_flat_dt_is_compatible (root,"MPC8544DS" ); } -machine_device_initcall (mpc8544_ds, mpc85xx_common_publish_devices); -machine_device_initcall (mpc8572_ds, mpc85xx_common_publish_devices); -machine_device_initcall (p2020_ds, mpc85xx_common_publish_devices); +machine_arch_initcall (mpc8544_ds, mpc85xx_common_publish_devices); +machine_arch_initcall (mpc8572_ds, mpc85xx_common_publish_devices); +machine_arch_initcall (p2020_ds, mpc85xx_common_publish_devices);machine_arch_initcall (mpc8544_ds, swiotlb_setup_bus_notifier);machine_arch_initcall (mpc8572_ds, swiotlb_setup_bus_notifier);
arch/powerpc/platforms/85xx/qemu_e500.c +4 -1
@@ -41,7 +41,10 @@ static void __init qemu_e500_setup_arch(void) { ppc_md.progress ("qemu_e500_setup_arch()" ,0 ); -fsl_pci_init (); +#ifdef CONFIG_PCI +pci_determine_swiotlb (); +#endif +mpc85xx_smp_init (); }
Signature · 1 line
1.7.5.1
Re: [PATCH V3 3/5] powerpc/mpc85xx: convert to unified PCI init
Quoted 1 line · Jia Hongtao
PCI initialization is now done by PCI controller driver. In =
board_setup_arch
Quoted 1 line
stage we don't need PCI init any more but swiotlb should be determined =
at this
Quoted 10 lines
stage.
=20Signed-off-by Jia Hongtao <[email protected]>Signed-off-by Li Yang <[email protected]>---
We now just apply this formpc85xx_dsand qemu
=20arch/powerpc/kernel/iommu.c.rej | 22 ----------------- arch/powerpc/platforms/85xx/common.c | 9 +++++++ arch/powerpc/platforms/85xx/mpc85xx_ds.c | 38 =
+++++++----------------------
Quoted 3 lines
arch/powerpc/platforms/85xx/qemu_e500.c| 5 +++-4 files changed, 22 insertions(+), 52 deletions(-)delete mode 100644
arch/powerpc/kernel/iommu.c.rej
removal of iommu.c.rej is handled by:
commit 668fcb6972177489bdc01a66d697c3b494aa8a24
Author: Benjamin Herrenschmidt <[email protected]> Date: Mon Jul 23 09:38:53 2012 +1000
Remove stale .rej file
- k=
Re: [PATCH V3 3/5] powerpc/mpc85xx: convert to unified PCI init
In reply to Jia HongtaoQuoted 1 line · Jia Hongtao
PCI initialization is now done by PCI controller driver. In =
board_setup_arch
Quoted 1 line
stage we don't need PCI init any more but swiotlb should be determined =
at this
Quoted 10 lines
stage.
=20Signed-off-by Jia Hongtao <[email protected]>Signed-off-by Li Yang <[email protected]>---
We now just apply this formpc85xx_dsand qemu
=20arch/powerpc/kernel/iommu.c.rej | 22 ----------------- arch/powerpc/platforms/85xx/common.c | 9 +++++++ arch/powerpc/platforms/85xx/mpc85xx_ds.c | 38 =
+++++++----------------------
=
Quoted 5 lines
arch/powerpc/platforms/85xx/qemu_e500.c| 5 +++-4 files changed, 22 insertions(+), 52 deletions(-)delete mode 100644
arch/powerpc/kernel/iommu.c.rej=20= renamed from arch/powerpc/kernel/iommu.c.rej +0
-0
b/arch/powerpc/kernel/iommu.c.rej
arch/powerpc/kernel/iommu.c.rej line 1
Quoted 6 lines
deleted file mode 100644
index 9d10d34..0000000arch/powerpc/kernel/iommu.c.rej deleted +0
-1@@ -1,22 +0,0 @@ ---- arch/powerpc/kernel/iommu.c 2012-06-08 09:01:02.785709100 =
+1000
arch/powerpc/kernel/iommu.c.rej line 2
Quoted 1 line
arch/powerpc/kernel/iommu.c.rej deleted +0
-1-+++ arch/powerpc/kernel/iommu.c 2012-06-08 09:01:07.489784856 =
+1000
=
Quoted 21 lines
arch/powerpc/kernel/iommu.c.rej deleted +0
-20-@@ -33,7 +33,9 @@ - #include <linux/bitmap.h> - #include <linux/iommu-helper.h> - #include <linux/crash_dump.h> -+#include <linux/fault-inject.h> - #include <asm/io.h> -+#include <asm/vio.h> - #include <asm/prom.h> - #include <asm/iommu.h> - #include <asm/pci-bridge.h> -@@ -171,6 +261,9 @@ - return DMA_ERROR_CODE; - } -=20 -+ if (should_fail_iommu(dev)) -+ return DMA_ERROR_CODE; -+ - if (handle && *handle) - start =3D *handle; - else= renamed from arch/powerpc/platforms/85xx/common.c +0
-0
b/arch/powerpc/platforms/85xx/common.c
arch/powerpc/platforms/85xx/common.c static struct of_device_id __initdata =
Quoted 4 lines
index 67dac22..303fedb 100644
arch/powerpc/platforms/85xx/common.c +0
-0@@ -27,6 +27,15 @@ static struct of_device_id __initdata =
mpc85xx_common_ids[] =3D {
arch/powerpc/platforms/85xx/common.c static struct of_device_id __initdata = · line 36
Quoted 10 lines
arch/powerpc/platforms/85xx/common.c +7
-0{ .compatible =3D "fsl,mpc8548-guts", }, /* Probably unnecessary? */ { .compatible =3D "gpio-leds", }, + /* For all PCI controllers */ + { .compatible =3D "fsl,mpc8540-pci", }, + { .compatible =3D "fsl,mpc8548-pcie", }, + { .compatible =3D "fsl,p1022-pcie", }, + { .compatible =3D "fsl,p1010-pcie", }, + { .compatible =3D "fsl,p1023-pcie", }, + { .compatible =3D "fsl,p4080-pcie", },
Add:
{ .compatible =3D "fsl,qoriq-pcie-v2.4", },Quoted 6 lines
arch/powerpc/platforms/85xx/common.c +2
-0+ { .compatible =3D "fsl,qoriq-pcie-v2.3", }, + { .compatible =3D "fsl,qoriq-pcie-v2.2", }, {},};
- k=
PATCH v3 4/5 powerpc/fsl-pci: Add pci inbound/outbound PM support
In reply to Jia HongtaoPower supply for PCI inbound/outbound window registers is off when system go to deep-sleep state. We save the values of registers before suspend and restore to registers after resume.
--- arch/powerpc/include/asm/pci-bridge.h | 2 +- arch/powerpc/sysdev/fsl_pci.c | 121 +++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 1 deletions(-)
arch/powerpc/include/asm/pci-bridge.h +1 -1
@@ -90,9 +90,9 @@ struct pci_controller {#ifdef CONFIG_PPC64 unsigned long buid; +#endif /* CONFIG_PPC64 */ void *private_data; -#endif /* CONFIG_PPC64 */ };/* These are used for config access before all the PCI probing
arch/powerpc/sysdev/fsl_pci.c +121 -0
133 lines not on this page · raw message
Signature · 1 line
1.7.5.1
PATCH v3 5/5 Edac/85xx: Register mpc85xx_pci_err_driver by fsl_pci_driver
In reply to Jia HongtaoFrom: Chunhe Lan <[email protected]>
Now we registered pci controllers as platform devices. It will make edac driver failed to register pci nodes as platform devices too. So we combine two initialization code as one platform driver.
--- arch/powerpc/sysdev/fsl_pci.c | 4 +++ arch/powerpc/sysdev/fsl_pci.h | 4 +++ drivers/edac/mpc85xx_edac.c | 43 +++++++++++----------------------------- 3 files changed, 20 insertions(+), 31 deletions(-)
arch/powerpc/sysdev/fsl_pci.c +4 -0
@@ -963,6 +963,10 @@ static int __devinit fsl_pci_probe(struct platform_device *pdev)if (of_match_node (pci_ids, pdev->dev.of_node))fsl_add_bridge (pdev->dev.of_node, is_primary); +#ifdef CONFIG_EDAC_MPC85XX +mpc85xx_pci_err_probe (pdev); +#endif +return 0 ; }
arch/powerpc/sysdev/fsl_pci.h +4 -0
@@ -110,5 +110,9 @@ extern void pci_determine_swiotlb(void);static inline void pci_determine_swiotlb (void ) {}#endif +#ifdef CONFIG_EDAC_MPC85XX +extern int mpc85xx_pci_err_probe (struct platform_device *op); +#endif +#endif /* __POWERPC_FSL_PCI_H */ #endif /* __KERNEL__ */
drivers/edac/mpc85xx_edac.c +12 -31
79 lines not on this page · raw message
Signature · 1 line
1.7.5.1
Quoted 1 line · Jia Hongtao
We unified the Freescale pci/pcie initialization by changing the =
fsl_pci
Quoted 1 line
to a platform driver. In previous PCI code architecture the =
initialization
Quoted 1 line
routine is called at
board_setup_archstage. Now the initialization is =
done
Quoted 1 line
in probe function which is architectural better. Also It's convenient =
for
Quoted 3 lines
adding PM support for PCI controller in later patch. =20
One issue introduced by this architecture is the timing of =
swiotlb_init.
Quoted 1 line
During PCI initialization the need of swiotlb is determined and this =
should
Quoted 2 lines
be done before
swiotlb_init. So a new function to determine swiotlb by parsing pci ranges is made. This function is called at =
board_setup_arch
Quoted 10 lines
stage which is earlier than
swiotlb_init.
=20Signed-off-by Jia Hongtao <[email protected]>Signed-off-by Li Yang <[email protected]>---
Changed for V3:
- Rebase the patch set on the latest tree
- merge PCI unify and swiotlb patch into one
=20arch/powerpc/sysdev/fsl_pci.c| 155 =
++++++++++++++++++++++++++++++++---------
=
Quoted 4 lines
arch/powerpc/sysdev/fsl_pci.h| 9 +--2 files changed, 125 insertions(+), 39 deletions(-)=20
= renamed from arch/powerpc/sysdev/fsl_pci.c +0
-0
b/arch/powerpc/sysdev/fsl_pci.c
arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] =3D =
Quoted 4 lines
index a7b2a60..5228b6b 100644
arch/powerpc/sysdev/fsl_pci.c +0
-0@@ -823,56 +823,143 @@ static const struct of_device_id pci_ids[] =3D =
{
Quoted 14 lines
arch/powerpc/sysdev/fsl_pci.c +0
-0{}, };=20
arch/powerpc/sysdev/fsl_pci.c +2
-3-struct device_node *fsl_pci_primary; - -void __devinit fsl_pci_init (void ) +#ifdef CONFIG_SWIOTLB +void pci_determine_swiotlb (void ){
arch/powerpc/sysdev/fsl_pci.c +4
-0+const u32 *ranges; +int rlen; +int pna; +int np;struct device_node *node;
arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] = {
Quoted 6 lines
arch/powerpc/sysdev/fsl_pci.c +0
-6-struct pci_controller *hose; - dma_addr_t max =3D 0xffffffff; - -/* Callers can specify the primary bus using other means. */ -if (!fsl_pci_primary) { -/* If a PCI host bridge contains an ISA node, it's =
primary. */
Quoted 19 lines
arch/powerpc/sysdev/fsl_pci.c +6
-9- node =3D of_find_node_by_type(NULL, "isa"); - while ((fsl_pci_primary =3D of_get_parent(node))) { -of_node_put (node); - node =3D fsl_pci_primary; - -if (of_match_node (pci_ids, node)) -break ; - } - } +int memno; +u32 pci_space; +unsigned long long pci_addr, cpu_addr, pci_next, cpu_next, size; + unsigned long long pci_addr_lo =3D ULLONG_MAX; + unsigned long long pci_addr_hi =3D 0x0; +dma_addr_t pci_dma_sz;=20
arch/powerpc/sysdev/fsl_pci.c +0
-1- node =3D NULL;for_each_node_by_type(node, "pci") { if (of_match_node(pci_ids, node)) {
arch/powerpc/sysdev/fsl_pci.c
Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.c +0
-2-/* -* If there's no PCI host bridge with ISA, =
arbitrarily
arch/powerpc/sysdev/fsl_pci.c
Quoted 1 line
arch/powerpc/sysdev/fsl_pci.c +0
-1-* designate one as primary. This can go away =
once
arch/powerpc/sysdev/fsl_pci.c
Quoted 1 line
arch/powerpc/sysdev/fsl_pci.c +0
-1-* various bugs with primary-less systems are =
fixed.
arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] = {
Quoted 5 lines
arch/powerpc/sysdev/fsl_pci.c +0
-5-*/ -if (!fsl_pci_primary) - fsl_pci_primary =3D node; - - fsl_add_bridge(node, fsl_pci_primary =3D=3D =
node);
arch/powerpc/sysdev/fsl_pci.c
Quoted 6 lines
arch/powerpc/sysdev/fsl_pci.c +3
-3- hose =3D pci_find_hose_for_OF_device(node); - max =3D min(max, hose->dma_window_base_cur + - hose->dma_window_size); + memno =3D 0; + pna =3D of_n_addr_cells(node); + np =3D pna + 5;
Don't duplicate code from pci_process_bridge_OF_ranges(), refactor the = code to have a shared function:
arch/powerpc/sysdev/fsl_pci.c
Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.c +2
-0+/* Get ranges property */ + ranges =3D of_get_property(node, "ranges", =
&rlen);
arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] = {
Quoted 12 lines
arch/powerpc/sysdev/fsl_pci.c +12
-0+ if (ranges =3D=3D NULL) +return ; + +/* Parse outbound MEM window range */ + while ((rlen -=3D np * 4) >=3D 0) { +/* Read next ranges element */ + pci_space =3D ranges[0]; +if (!((pci_space >>24 ) &0x2 )) { + ranges +=3D np; +break ; + } + pci_addr =3D of_read_number(ranges + 1, =
2);
arch/powerpc/sysdev/fsl_pci.c
Quoted 3 lines
arch/powerpc/sysdev/fsl_pci.c +3
-0+ cpu_addr =3D of_translate_address( + node, ranges +3 ); + size =3D of_read_number(ranges + pna + =
3, 2);
arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] = {
Quoted 4 lines
arch/powerpc/sysdev/fsl_pci.c +4
-0+ ranges +=3D np; + +/* +* If we failed translation or got a =
zero-sized
arch/powerpc/sysdev/fsl_pci.c
Quoted 1 line
arch/powerpc/sysdev/fsl_pci.c +1
-0+* region (some FW try to feed us with =
non
arch/powerpc/sysdev/fsl_pci.c
Quoted 1 line
arch/powerpc/sysdev/fsl_pci.c +1
-0+* sensical zero sized regions such as =
power3
arch/powerpc/sysdev/fsl_pci.c
Quoted 1 line
arch/powerpc/sysdev/fsl_pci.c +1
-0+* which look like some kind of attempt =
at
arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] = {
Quoted 3 lines
arch/powerpc/sysdev/fsl_pci.c +3
-0+* exposing the VGA memory hole) +*/ + if (cpu_addr =3D=3D OF_BAD_ADDR || size =
=3D=3D 0)
arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] = {
Quoted 4 lines
arch/powerpc/sysdev/fsl_pci.c +4
-0+continue ; + +/* +* Now consume following elements while =
they
arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] = {
Quoted 4 lines
arch/powerpc/sysdev/fsl_pci.c +4
-0+* are contiguous +*/ + for (; rlen >=3D np * sizeof(u32); + ranges +=3D np, rlen -=3D =
np * 4) {
arch/powerpc/sysdev/fsl_pci.c
Quoted 3 lines
arch/powerpc/sysdev/fsl_pci.c +3
-0+ if (ranges[0] !=3D pci_space) +break ; + pci_next =3D =
of_read_number(ranges + 1,
arch/powerpc/sysdev/fsl_pci.c
Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.c +2
-0+ 2); + cpu_next =3D =
of_translate_address(node,
arch/powerpc/sysdev/fsl_pci.c
Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.c +2
-0+ ranges + 3); + if (pci_next !=3D pci_addr + =
size ||
arch/powerpc/sysdev/fsl_pci.c
Quoted 1 line
arch/powerpc/sysdev/fsl_pci.c +1
-0+ cpu_next !=3D cpu_addr + =
size)
arch/powerpc/sysdev/fsl_pci.c
Quoted 3 lines
arch/powerpc/sysdev/fsl_pci.c +3
-0+break ; + size +=3D of_read_number( + ranges + pna + =
3, 2);
arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] = {
Quoted 6 lines
arch/powerpc/sysdev/fsl_pci.c +6
-0+ } + +/* We support only 3 memory ranges */ + if (memno >=3D 3) { + printk(KERN_INFO + " \\--> Skipped =
(too many) !\n");
arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] = {
Quoted 4 lines
arch/powerpc/sysdev/fsl_pci.c +4
-0+continue ; + } + + pci_addr_lo =3D min(pci_addr, =
pci_addr_lo);
arch/powerpc/sysdev/fsl_pci.c
Quoted 1 line
arch/powerpc/sysdev/fsl_pci.c +1
-0+ pci_addr_hi =3D max(pci_addr + size, =
pci_addr_hi);
Quoted 29 lines
arch/powerpc/sysdev/fsl_pci.c +2
-0+ memno++; + }} }=20
arch/powerpc/sysdev/fsl_pci.c +14
-1-#ifdef CONFIG_SWIOTLB +/* Get PEXCSRBAR size (equal to CCSR size) */ + node =3D of_find_node_by_type(NULL, "soc"); + ranges =3D of_get_property(node, "ranges", &rlen); + if (ranges =3D=3D NULL) +return ; + + size =3D of_read_number(ranges + 3, 1); +of_node_put (node); + +if (pci_addr_hi < (0x100000000ull - size)) + pci_dma_sz =3D pci_addr_lo; +else + pci_dma_sz =3D pci_addr_lo - size; +/*
* if we couldn't map all of DRAM via the dma windows
* we need SWIOTLB to handle buffers located outside of
* dma capable memory region
*/arch/powerpc/sysdev/fsl_pci.c +1
-1-if (memblock_end_of_DRAM () -1 > max) { +if (memblock_end_of_DRAM () > pci_dma_sz) {ppc_swiotlb_enable =3D 1; set_pci_dma_ops(&swiotlb_dma_ops);
arch/powerpc/sysdev/fsl_pci.c
Quoted 3 lines
arch/powerpc/sysdev/fsl_pci.c +2
-1- ppc_md.pci_dma_dev_setup =3D pci_dma_dev_setup_swiotlb; + ppc_md.pci_dma_dev_setup =3D + pci_dma_dev_setup_swiotlb;
why the line wrap change?
Quoted 4 lines
}+}
#endifarch/powerpc/sysdev/fsl_pci.c +1
-0+
arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] = {
Quoted 10 lines
arch/powerpc/sysdev/fsl_pci.c +10
-0+int primary_phb_addr; +static int __devinit fsl_pci_probe (struct platform_device *pdev) +{ +struct pci_controller *hose; +bool is_primary; + +if (of_match_node (pci_ids, pdev->dev.of_node)) { +struct resource rsrc; +of_address_to_resource (pdev->dev.of_node,0 , &rsrc); + is_primary =3D ((rsrc.start & 0xfffff) =3D=3D =
primary_phb_addr);
Quoted 20 lines
arch/powerpc/sysdev/fsl_pci.c +17
-0+fsl_add_bridge (pdev->dev.of_node, is_primary); + } + +return 0 ; +} + +static struct platform_driver fsl_pci_driver =3D { + .driver =3D { + .name =3D "fsl-pci", + .of_match_table =3D pci_ids, + }, + .probe =3D fsl_pci_probe, +}; + +static int __init fsl_pci_init (void ) +{ +return platform_driver_register (&fsl_pci_driver);}
+arch_initcall(fsl_pci_init);
#endif
Hi kumar,
I know "duplicate code from pci_process_bridge_OF_ranges()" is hard to accept but "refactor the code to have a shared function" is knotty. Actually this is the reason I didn't do the refactor.
Here is the situation:
First, pci_process_bridge_OF_ranges() is a common code using by so many pci client.
Second, the contents of pci_process_bridge_OF_ranges() twisted together. It's hard to decouple the function I need for determining swiotlb with other contents. I tried and found a way to do this but the shared function need so many parameters which is also unacceptable.=20
Third, my function to determine swiotlb should know the start and the end of pci mem space address for all the controllers. Note that the end of address is for determining where to map PEXCSRBAR.
If you have any idea for this please let me know.
Thanks.
-Hongtao.
Quoted 11 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Friday, July 27, 2012 1:53 AM
To: Jia Hongtao-B38951
Cc: [email protected]; Wood Scott-B07421; Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization code
=20
=20
On Jul 26, 2012, at 7:30 AM, Jia Hongtao wrote:
=20
Quoted 11 lines
Quoted 1 line
We unified the Freescale pci/pcie initialization by changing the
fsl_pciQuoted 1 line
to a platform driver. In previous PCI code architecture the
initialization
Quoted 1 line
routine is called at
board_setup_archstage. Now the initialization isdone
Quoted 1 line
in probe function which is architectural better. Also It's convenient
for
Quoted 3 lines
adding PM support for PCI controller in later patch.
One issue introduced by this architecture is the timing of swiotlb_init=
.
Quoted 212 lines
Quoted 1 line
During PCI initialization the need of swiotlb is determined and this
should
Quoted 4 lines
be done before
swiotlb_init. So a new function to determine swiotlb by parsing pci ranges is made. This function is called atboard_setup_archstage which is earlier thanswiotlb_init.Quoted 8 lines
Signed-off-by Jia Hongtao <[email protected]>Signed-off-by Li Yang <[email protected]>---
Changed for V3:
- Rebase the patch set on the latest tree
- merge PCI unify and swiotlb patch into one
arch/powerpc/sysdev/fsl_pci.c| 155 ++++++++++++++++++++++++++++++++---------
Review
Quoted 4 lines
arch/powerpc/sysdev/fsl_pci.h| 9 +--2 files changed, 125 insertions(+), 39 deletions(-)(quoted diff) +0
-0
b/arch/powerpc/sysdev/fsl_pci.cQuoted 14 lines
index a7b2a60..5228b6b 100644
arch/powerpc/sysdev/fsl_pci.c +3
-3@@ -823,56 +823,143 @@ static const struct of_device_id pci_ids[] =3D { {}, }; -struct device_node *fsl_pci_primary; - -void __devinit fsl_pci_init (void ) +#ifdef CONFIG_SWIOTLB +void pci_determine_swiotlb (void ) { +const u32 *ranges;arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] =3D { · line 836
Quoted 10 lines
arch/powerpc/sysdev/fsl_pci.c +3
-6+int rlen; +int pna; +int np;struct device_node *node; -struct pci_controller *hose; - dma_addr_t max =3D 0xffffffff; - -/* Callers can specify the primary bus using other means. */ -if (!fsl_pci_primary) { -/* If a PCI host bridge contains an ISA node, it's primary. */
Quoted 24 lines
arch/powerpc/sysdev/fsl_pci.c +6
-15- node =3D of_find_node_by_type(NULL, "isa"); - while ((fsl_pci_primary =3D of_get_parent(node))) { -of_node_put (node); - node =3D fsl_pci_primary; - -if (of_match_node (pci_ids, node)) -break ; - } - } +int memno; +u32 pci_space; +unsigned long long pci_addr, cpu_addr, pci_next, cpu_next, size; + unsigned long long pci_addr_lo =3D ULLONG_MAX; + unsigned long long pci_addr_hi =3D 0x0; +dma_addr_t pci_dma_sz; - node =3D NULL;for_each_node_by_type (node,"pci" ) {if (of_match_node (pci_ids, node)) { -/* -* If there's no PCI host bridge with ISA, arbitrarily -* designate one as primary. This can go away once -* various bugs with primary-less systems are fixed. -*/ arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] = {
Quoted 10 lines
arch/powerpc/sysdev/fsl_pci.c +3
-7-if (!fsl_pci_primary) - fsl_pci_primary =3D node; - - fsl_add_bridge(node, fsl_pci_primary =3D=3D node); - hose =3D pci_find_hose_for_OF_device(node); - max =3D min(max, hose->dma_window_base_cur + - hose->dma_window_size); + memno =3D 0; + pna =3D of_n_addr_cells(node); + np =3D pna + 5;=20
Don't duplicate code frompci_process_bridge_OF_ranges(), refactor the code to have a shared function:
=20Quoted 42 lines
arch/powerpc/sysdev/fsl_pci.c +42
-0+/* Get ranges property */ + ranges =3D of_get_property(node, "ranges", &rlen); + if (ranges =3D=3D NULL) +return ; + +/* Parse outbound MEM window range */ + while ((rlen -=3D np * 4) >=3D 0) { +/* Read next ranges element */ + pci_space =3D ranges[0]; +if (!((pci_space >>24 ) &0x2 )) { + ranges +=3D np; +break ; + } + pci_addr =3D of_read_number(ranges + 1, 2); + cpu_addr =3D of_translate_address( + node, ranges +3 ); + size =3D of_read_number(ranges + pna + 3, 2); + ranges +=3D np; + +/* +* If we failed translation or got a zero-sized +* region (some FW try to feed us with non +* sensical zero sized regions such as power3 +* which look like some kind of attempt at +* exposing the VGA memory hole) +*/ + if (cpu_addr =3D=3D OF_BAD_ADDR || size =3D=3D 0) +continue ; + +/* +* Now consume following elements while they +* are contiguous +*/ + for (; rlen >=3D np * sizeof(u32); + ranges +=3D np, rlen -=3D np * 4) { + if (ranges[0] !=3D pci_space) +break ; + pci_next =3D of_read_number(ranges + 1, +2 ); + cpu_next =3D of_translate_address(node, + ranges +3 ); + if (pci_next !=3D pci_addr + size ||arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] = {
Quoted 10 lines
arch/powerpc/sysdev/fsl_pci.c +10
-0+ cpu_next !=3D cpu_addr + size) +break ; + size +=3D of_read_number( + ranges + pna +3 ,2 ); + } + +/* We support only 3 memory ranges */ + if (memno >=3D 3) { + printk(KERN_INFO + " \\--> Skipped (toomany) !\n");
Quoted 27 lines
arch/powerpc/sysdev/fsl_pci.c +21
-1+continue ; + } + + pci_addr_lo =3D min(pci_addr, pci_addr_lo); + pci_addr_hi =3D max(pci_addr + size, pci_addr_hi); + memno++; + } } } -#ifdef CONFIG_SWIOTLB +/* Get PEXCSRBAR size (equal to CCSR size) */ + node =3D of_find_node_by_type(NULL, "soc"); + ranges =3D of_get_property(node, "ranges", &rlen); + if (ranges =3D=3D NULL) +return ; + + size =3D of_read_number(ranges + 3, 1); +of_node_put (node); + +if (pci_addr_hi < (0x100000000ull - size)) + pci_dma_sz =3D pci_addr_lo; +else + pci_dma_sz =3D pci_addr_lo - size; +/* * if we couldn't map all of DRAM via the dma windows arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] = { · line 931
Quoted 10 lines
arch/powerpc/sysdev/fsl_pci.c +3
-2* we need SWIOTLB to handle buffers located outside of * dma capable memory region */ -if (memblock_end_of_DRAM () -1 > max) { +if (memblock_end_of_DRAM () > pci_dma_sz) { ppc_swiotlb_enable =3D 1;set_pci_dma_ops (&swiotlb_dma_ops); - ppc_md.pci_dma_dev_setup =3D pci_dma_dev_setup_swiotlb; + ppc_md.pci_dma_dev_setup =3D + pci_dma_dev_setup_swiotlb;=20
why the line wrap change?
=20Quoted 24 lines
arch/powerpc/sysdev/fsl_pci.c +22
-0} +}#endif + +int primary_phb_addr; +static int __devinit fsl_pci_probe (struct platform_device *pdev) +{ +struct pci_controller *hose; +bool is_primary; + +if (of_match_node (pci_ids, pdev->dev.of_node)) { +struct resource rsrc; +of_address_to_resource (pdev->dev.of_node,0 , &rsrc); + is_primary =3D ((rsrc.start & 0xfffff) =3D=3D primary_phb_addr); +fsl_add_bridge (pdev->dev.of_node, is_primary); + } + +return 0 ; +} + +static struct platform_driver fsl_pci_driver =3D { + .driver =3D { + .name =3D "fsl-pci", + .of_match_table =3D pci_ids,arch/powerpc/sysdev/fsl_pci.c static const struct of_device_id pci_ids[] = { · line 965
Quoted 10 lines
arch/powerpc/sysdev/fsl_pci.c +8
-0+ }, + .probe =3D fsl_pci_probe, +}; + +static int __init fsl_pci_init (void ) +{ +return platform_driver_register (&fsl_pci_driver); } +arch_initcall (fsl_pci_init);#endif =20
=20
Quoted 5 lines · On 07/27/2012 05:10 AM, Jia Hongtao-B38951 wrote:
Hi kumar,
I know "duplicate code from
pci_process_bridge_OF_ranges()" is hard to accept but "refactor the code to have a shared function" is knotty. Actually this is the reason I didn't do the refactor.
Maybe we should keep doing the init early? We could still have a platform device for the PM stuff, but some init would be done before probe.
Another possibility is to try to handle swiotlb init later -- possibly by reserving memory for it if the platform indicates it's a possibility that it will be needed, then freeing the memory if it's not needed.
-Scott
Quoted 9 lines · Scott Wood
Quoted 5 lines · On 07/27/2012 05:10 AM, Jia Hongtao-B38951 wrote:
Hi kumar,
=20
I know "duplicate code frompci_process_bridge_OF_ranges()" is hard to accept but "refactor the code to have a shared function" is knotty. Actually this is the reason I didn't do the refactor.=20
Maybe we should keep doing the init early? We could still have a platform device for the PM stuff, but some init would be done before =
probe.
Quoted 3 lines
=20
Another possibility is to try to handle swiotlb init later -- possibly by reserving memory for it if the platform indicates it's a =
possibility
Quoted 3 lines
that it will be needed, then freeing the memory if it's not needed. =20
-Scott
I think the first option seems reasonable. Can we leave fsl_pci_init() = as we now have it and just have the platform driver deal with PM restore = via calling setup_pci_atmu() [probably need to update setup_pci_atmu to = handle restore case, but seems like minor changes]
- k
Quoted 30 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Saturday, July 28, 2012 5:17 AM
To: Wood Scott-B07421
Cc: Jia Hongtao-B38951; [email protected]; Wood Scott-B07421; Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization code
=20
=20
On Jul 27, 2012, at 3:24 PM, Scott Wood wrote:
=20Quoted 9 lines · On 07/27/2012 05:10 AM, Jia Hongtao-B38951 wrote:
Quoted 5 lines
Hi kumar,
I know "duplicate code from
pci_process_bridge_OF_ranges()" is hard to accept but "refactor the code to have a shared function" is knotty. Actually this is the reason I didn't do the refactor.Maybe we should keep doing the init early? We could still have a platform device for the PM stuff, but some init would be done before
probe.
Quoted 6 lines
Another possibility is to try to handle swiotlb init later -- possibly by reserving memory for it if the platform indicates it's a possibility that it will be needed, then freeing the memory if it's not needed.
-Scott
Quoted 8 lines
=20
I think the first option seems reasonable. Can we leavefsl_pci_init()as we now have it and just have the platform driver deal with PM restore via callingsetup_pci_atmu()[probably need to updatesetup_pci_atmuto handle restore case, but seems like minor changes]
=20
- k
=20
I think the second option is better if it's hard to decouple swiotlb determination from pci init. I believe the better architecture that PCI init in probe function of platform driver will bring us considerable advantage. I really like to keep the completion of pci controller platform driver not only for PM support but also for pci init.
-Hongtao.=20
Quoted 7 lines · On Jul 30, 2012, at 3:26 AM, Jia Hongtao-B38951 wrote:
=20
=20Quoted 5 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Saturday, July 28, 2012 5:17 AM
To: Wood Scott-B07421
Cc: Jia Hongtao-B38951; [email protected]; Wood =
Scott-B07421;
Quoted 13 lines
Quoted 13 lines
Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization code
=20
=20
On Jul 27, 2012, at 3:24 PM, Scott Wood wrote:
=20Quoted 6 lines · On 07/27/2012 05:10 AM, Jia Hongtao-B38951 wrote:
Quoted 5 lines
Hi kumar,
=20
I know "duplicate code frompci_process_bridge_OF_ranges()" is hard to accept but "refactor the code to have a shared function" is knotty. Actually this is the reason I didn't do the refactor.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
=20
Maybe we should keep doing the init early? We could still have a platform device for the PM stuff, but some init would be done beforeprobe.
Quoted 2 lines
=20
Another possibility is to try to handle swiotlb init later -- =
possibly
Quoted 1 line
Quoted 1 line
Quoted 1 line
by reserving memory for it if the platform indicates it's a =
possibility
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
that it will be needed, then freeing the memory if it's not needed. =20
-Scott=20
I think the first option seems reasonable. Can we leave =
fsl_pci_init()
Quoted 1 line
Quoted 1 line
as we now have it and just have the platform driver deal with PM =
restore
Quoted 1 line
Quoted 1 line
via calling
setup_pci_atmu()[probably need to updatesetup_pci_atmu=
to
Quoted 9 lines
Quoted 4 lines
handle restore case, but seems like minor changes] =20
- k
=20=20
=20
I think the second option is better if it's hard to decouple swiotlb determination from pci init. I believe the better architecture that PCI init in probe function of platform driver will bring us =
considerable
Quoted 5 lines
advantage. I really like to keep the completion of pci controller platform driver not only for PM support but also for pci init. =20
-Hongtao.=20
=20
Shifting of swiotlb init has a lot more issues. Why do we need to do = the PCI init in probe?
- k=
Quoted 35 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Monday, July 30, 2012 10:47 PM
To: Jia Hongtao-B38951
Cc: Wood Scott-B07421; [email protected]; Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization code
=20
=20
On Jul 30, 2012, at 3:26 AM, Jia Hongtao-B38951 wrote:
=20Quoted 7 lines
Quoted 7 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Saturday, July 28, 2012 5:17 AM
To: Wood Scott-B07421
Cc: Jia Hongtao-B38951; [email protected]; Wood Scott-B07421;
Quoted 14 lines
Quoted 14 lines
Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization codeQuoted 7 lines · Scott Wood
Quoted 5 lines · On 07/27/2012 05:10 AM, Jia Hongtao-B38951 wrote:
Hi kumar,
I know "duplicate code from
pci_process_bridge_OF_ranges()" is hard to accept but "refactor the code to have a shared function" is knotty. Actually this is the reason I didn't do the refactor.
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Maybe we should keep doing the init early? We could still have a platform device for the PM stuff, but some init would be done before
probe.
Quoted 2 lines
Another possibility is to try to handle swiotlb init later --
possibly
Quoted 1 line
Quoted 1 line
Quoted 1 line
by reserving memory for it if the platform indicates it's a
possibility
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
that it will be needed, then freeing the memory if it's not needed.
-Scott
I think the first option seems reasonable. Can we leave fsl_pci_init(=
)
Quoted 17 lines
Quoted 1 line
Quoted 1 line
as we now have it and just have the platform driver deal with PM
restore
Quoted 1 line
Quoted 1 line
via calling
setup_pci_atmu()[probably need to updatesetup_pci_atmuto
Quoted 9 lines
Quoted 4 lines
handle restore case, but seems like minor changes]
- k
I think the second option is better if it's hard to decouple swiotlb determination from pci init. I believe the better architecture that PCI init in probe function of platform driver will bring us
considerable
Quoted 3 lines
advantage. I really like to keep the completion of pci controller platform driver not only for PM support but also for pci init.
Quoted 7 lines
Quoted 2 lines
-Hongtao.
=20
Shifting of swiotlb init has a lot more issues. Why do we need to do the PCI init in probe?
=20
- k
I investigated the swiotlb init thing and found that in x86 swiotlb init is done first and free if we don't need it.
-Hongtao.
Quoted 49 lines · Kumar Gala
Quoted 46 lines · On Jul 30, 2012, at 3:26 AM, Jia Hongtao-B38951 wrote:
Quoted 29 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Saturday, July 28, 2012 5:17 AM
To: Wood Scott-B07421
Cc: Jia Hongtao-B38951; [email protected]; Wood Scott-B07421; Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization codeQuoted 9 lines · Scott Wood
Quoted 5 lines · On 07/27/2012 05:10 AM, Jia Hongtao-B38951 wrote:
Hi kumar,
I know "duplicate code from
pci_process_bridge_OF_ranges()" is hard to accept but "refactor the code to have a shared function" is knotty. Actually this is the reason I didn't do the refactor.Maybe we should keep doing the init early? We could still have a platform device for the PM stuff, but some init would be done before
probe.
Quoted 5 lines
Another possibility is to try to handle swiotlb init later -- possibly by reserving memory for it if the platform indicates it's a possibility that it will be needed, then freeing the memory if it's not needed.
Quoted 9 lines
Quoted 1 line
-Scott
I think the first option seems reasonable. Can we leave
fsl_pci_init()as we now have it and just have the platform driver deal with PM restore via callingsetup_pci_atmu()[probably need to updatesetup_pci_atmuto handle restore case, but seems like minor changes]- k
I think the second option is better if it's hard to decouple swiotlb determination from pci init. I believe the better architecture that PCI init in probe function of platform driver will bring us considerable advantage. I really like to keep the completion of pci controller platform driver not only for PM support but also for pci init.
Quoted 4 lines
Quoted 2 lines
-Hongtao.
Shifting of swiotlb init has a lot more issues. Why do we need to do the PCI init in probe?
The ordering issues are introduced by swiotlb. And the ideal way is to solve the problem within swiotlb instead of changing PCI to workaround it. Take the implementation of x86 as reference it's possible to be addressed bu allocating first and free later approach.
It is common sense that the initialization of a device is in the probe function of the driver of the device. And the change will provide better unification of PCI controller code. The PCI controller is generic enough not to be taken care of at the platform area.
Leo
Quoted 1 line · Li Yang
On Mon, Jul 30, 2012 at 10:46 PM, Kumar Gala =
Quoted 10 lines · <[email protected]> wrote:
Quoted 10 lines
=20
On Jul 30, 2012, at 3:26 AM, Jia Hongtao-B38951 wrote:
=20Quoted 7 lines
=20
=20Quoted 5 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Saturday, July 28, 2012 5:17 AM
To: Wood Scott-B07421
Cc: Jia Hongtao-B38951; [email protected]; Wood =
Scott-B07421;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization code
=20
=20
On Jul 27, 2012, at 3:24 PM, Scott Wood wrote:
=20Quoted 1 line · On 07/27/2012 05:10 AM, Jia Hongtao-B38951 wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Hi kumar,
=20
I know "duplicate code frompci_process_bridge_OF_ranges()" is hard to accept but "refactor the code to have a shared function" is knotty. Actually this is the reason I didn't do the refactor.=20
Maybe we should keep doing the init early? We could still have a platform device for the PM stuff, but some init would be done =
before
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
probe.
Quoted 2 lines
=20
Another possibility is to try to handle swiotlb init later -- =
possibly
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
by reserving memory for it if the platform indicates it's a =
possibility
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
that it will be needed, then freeing the memory if it's not =
needed.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
=20
-Scott=20
I think the first option seems reasonable. Can we leave =
fsl_pci_init()
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
as we now have it and just have the platform driver deal with PM =
restore
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
via calling
setup_pci_atmu()[probably need to update =
setup_pci_atmu to
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
handle restore case, but seems like minor changes] =20
- k
=20=20
=20
I think the second option is better if it's hard to decouple swiotlb determination from pci init. I believe the better architecture that PCI init in probe function of platform driver will bring us =
considerable
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
advantage. I really like to keep the completion of pci controller platform driver not only for PM support but also for pci init. =20
-Hongtao.
=20=20
Shifting of swiotlb init has a lot more issues. Why do we need to do =
the PCI init in probe?
Quoted 4 lines
=20
The ordering issues are introduced by swiotlb. And the ideal way is to solve the problem within swiotlb instead of changing PCI to workaround it. Take the implementation of x86 as reference it's
Quoted 8 lines
possible to be addressed bu allocating first and free later approach. =20
It is common sense that the initialization of a device is in the probe function of the driver of the device. And the change will provide better unification of PCI controller code. The PCI controller is generic enough not to be taken care of at the platform area. =20
Leo
Than lets look at going with that approach.. Be careful with impact on = other users of swiotlb on PPC, I believe one 44x board uses swiotlb.
- k=
Quoted 90 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Tuesday, July 31, 2012 9:38 PM
To: Li Yang-R58472
Cc: Jia Hongtao-B38951; Wood Scott-B07421; [email protected]; Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization code
=20
=20
On Jul 31, 2012, at 2:21 AM, Li Yang wrote:
=20Quoted 1 line
On Mon, Jul 30, 2012 at 10:46 PM, Kumar Gala <[email protected]=
Quoted 10 lines · wrote:
Quoted 10 lines · On Jul 30, 2012, at 3:26 AM, Jia Hongtao-B38951 wrote:
Quoted 8 lines
Quoted 8 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Saturday, July 28, 2012 5:17 AM
To: Wood Scott-B07421
Cc: Jia Hongtao-B38951; [email protected]; Wood Scott-B07421;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization codeQuoted 1 line · Scott Wood
On 07/27/2012 05:10 AM, Jia Hongtao-B38951 wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Hi kumar,
I know "duplicate code from
pci_process_bridge_OF_ranges()" is hard to accept but "refactor the code to have a shared function" is knotty. Actually this is the reason I didn't do the refactor.Maybe we should keep doing the init early? We could still have a platform device for the PM stuff, but some init would be done
before
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
probe.
Quoted 2 lines
Another possibility is to try to handle swiotlb init later --
possibly
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
by reserving memory for it if the platform indicates it's a
possibility
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
that it will be needed, then freeing the memory if it's not needed.
-Scott
I think the first option seems reasonable. Can we leave
fsl_pci_init()Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
as we now have it and just have the platform driver deal with PM
restore
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
via calling
setup_pci_atmu()[probably need to updatesetup_pci_atmuto
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
handle restore case, but seems like minor changes]
- k
I think the second option is better if it's hard to decouple swiotlb determination from pci init. I believe the better architecture that PCI init in probe function of platform driver will bring us
considerable
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
advantage. I really like to keep the completion of pci controller platform driver not only for PM support but also for pci init.
-Hongtao.
Shifting of swiotlb init has a lot more issues. Why do we need to do
the PCI init in probe?
Quoted 11 lines
The ordering issues are introduced by swiotlb. And the ideal way is to solve the problem within swiotlb instead of changing PCI to workaround it. Take the implementation of x86 as reference it's possible to be addressed bu allocating first and free later approach.
It is common sense that the initialization of a device is in the probe function of the driver of the device. And the change will provide better unification of PCI controller code. The PCI controller is generic enough not to be taken care of at the platform area.
Quoted 6 lines
Quoted 1 line
Leo
=20
Than lets look at going with that approach.. Be careful with impact on other users of swiotlb on PPC, I believe one 44x board uses swiotlb. =20
- k
I will be careful with this approach.
I have already noticed 44x. Thank you all the same.
-Hongtao.
Quoted 1 line · Jia Hongtao
We unified the Freescale pci/pcie initialization by changing the =
fsl_pci
Quoted 1 line
to a platform driver. In previous PCI code architecture the =
initialization
Quoted 1 line
routine is called at
board_setup_archstage. Now the initialization is =
done
Quoted 1 line
in probe function which is architectural better. Also It's convenient =
for
Quoted 3 lines
adding PM support for PCI controller in later patch. =20
One issue introduced by this architecture is the timing of =
swiotlb_init.
Quoted 1 line
During PCI initialization the need of swiotlb is determined and this =
should
Quoted 2 lines
be done before
swiotlb_init. So a new function to determine swiotlb by parsing pci ranges is made. This function is called at =
board_setup_arch
Quoted 10 lines
stage which is earlier than
swiotlb_init.
=20Signed-off-by Jia Hongtao <[email protected]>Signed-off-by Li Yang <[email protected]>---
Changed for V3:
- Rebase the patch set on the latest tree
- merge PCI unify and swiotlb patch into one
=20arch/powerpc/sysdev/fsl_pci.c| 155 =
++++++++++++++++++++++++++++++++---------
Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.h| 9 +--2 files changed, 125 insertions(+), 39 deletions(-)
I'd like the SWIOTLB refactoring as a separate patch. Additionally, the = order of patches should be as follows:
1. refactor PCI node parsing code
2. add pci_determine_swiotlb (should rename to = fsl_pci_determine_swiotlb)
3. Determine primary bus by looking for ISA node
4. convert all boards over to fsl_pci_init
5. convert fsl pci to platform driver (edac and other fixes should be = merged in here)
6. PM support
- k=
Quoted 13 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Friday, July 27, 2012 2:15 AM
To: Jia Hongtao-B38951
Cc: [email protected]; Wood Scott-B07421; Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization code
=20
=20
On Jul 26, 2012, at 7:30 AM, Jia Hongtao wrote:
=20
Quoted 11 lines
Quoted 1 line
We unified the Freescale pci/pcie initialization by changing the
fsl_pciQuoted 1 line
to a platform driver. In previous PCI code architecture the
initialization
Quoted 1 line
routine is called at
board_setup_archstage. Now the initialization isdone
Quoted 1 line
in probe function which is architectural better. Also It's convenient
for
Quoted 3 lines
adding PM support for PCI controller in later patch.
One issue introduced by this architecture is the timing of swiotlb_init=
.
Quoted 17 lines
Quoted 1 line
During PCI initialization the need of swiotlb is determined and this
should
Quoted 4 lines
be done before
swiotlb_init. So a new function to determine swiotlb by parsing pci ranges is made. This function is called atboard_setup_archstage which is earlier thanswiotlb_init.Quoted 8 lines
Signed-off-by Jia Hongtao <[email protected]>Signed-off-by Li Yang <[email protected]>---
Changed for V3:
- Rebase the patch set on the latest tree
- merge PCI unify and swiotlb patch into one
arch/powerpc/sysdev/fsl_pci.c| 155 ++++++++++++++++++++++++++++++++---------
Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.h| 9 +--2 files changed, 125 insertions(+), 39 deletions(-)
Quoted 13 lines
=20
I'd like the SWIOTLB refactoring as a separate patch. Additionally, the order of patches should be as follows:
=20
1. refactor PCI node parsing code
2. addpci_determine_swiotlb(should rename tofsl_pci_determine_swiotlb)
3. Determine primary bus by looking for ISA node
4. convert all boards over tofsl_pci_init
5. convert fsl pci to platform driver (edac and other fixes should be merged in here)
6. PM support
=20
- k
Should I convert all boards over to fsl_pci_init first and then convert the= m
over to platform driver again or just convert them direct to platform drive= r?
Thanks.
-Hongtao.
Quoted 18 lines · On Jul 27, 2012, at 3:35 AM, Jia Hongtao-B38951 wrote:
=20
=20Quoted 16 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Friday, July 27, 2012 2:15 AM
To: Jia Hongtao-B38951
Cc: [email protected]; Wood Scott-B07421; Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization code
=20
=20
On Jul 26, 2012, at 7:30 AM, Jia Hongtao wrote:
=20Quoted 1 line
We unified the Freescale pci/pcie initialization by changing the
fsl_pciQuoted 1 line
to a platform driver. In previous PCI code architecture the
initialization
Quoted 1 line
routine is called at
board_setup_archstage. Now the initialization =
is
Quoted 2 lines
Quoted 2 lines
done
Quoted 1 line
in probe function which is architectural better. Also It's =
convenient
Quoted 4 lines
Quoted 4 lines
for
Quoted 3 lines
adding PM support for PCI controller in later patch. =20
One issue introduced by this architecture is the timing of =
swiotlb_init.
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
During PCI initialization the need of swiotlb is determined and this
should
Quoted 1 line
be done before
swiotlb_init. So a new function to determine swiotlb =
by
Quoted 1 line
Quoted 1 line
Quoted 1 line
parsing pci ranges is made. This function is called at =
board_setup_arch
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
stage which is earlier than
swiotlb_init.
=20Signed-off-by Jia Hongtao <[email protected]>Signed-off-by Li Yang <[email protected]>---
Changed for V3:
- Rebase the patch set on the latest tree
- merge PCI unify and swiotlb patch into one
=20arch/powerpc/sysdev/fsl_pci.c| 155 =
++++++++++++++++++++++++++++++++--
Quoted 5 lines
Quoted 5 lines
-------
Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.h| 9 +--2 files changed, 125 insertions(+), 39 deletions(-)=20
I'd like the SWIOTLB refactoring as a separate patch. Additionally, =
the
Quoted 4 lines
Quoted 4 lines
order of patches should be as follows:
=20
1. refactor PCI node parsing code
2. addpci_determine_swiotlb(should rename to =
fsl_pci_determine_swiotlb)
Quoted 9 lines
Quoted 7 lines
3. Determine primary bus by looking for ISA node
4. convert all boards over tofsl_pci_init
5. convert fsl pci to platform driver (edac and other fixes should be merged in here)
6. PM support
=20
- k=20
Should I convert all boards over tofsl_pci_initfirst and then =
convert them
Quoted 1 line
over to platform driver again or just convert them direct to platform =
driver?
Yes do the fsl_pci_init conversion first. The reason is we should NOT = break functionality from one patch to another.
- k=
Quoted 74 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Friday, July 27, 2012 8:47 PM
To: Jia Hongtao-B38951
Cc: [email protected]; Wood Scott-B07421; Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization code
=20
=20
On Jul 27, 2012, at 3:35 AM, Jia Hongtao-B38951 wrote:
=20Quoted 11 lines
Quoted 11 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Friday, July 27, 2012 2:15 AM
To: Jia Hongtao-B38951
Cc: [email protected]; Wood Scott-B07421; Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization codeQuoted 7 lines
Quoted 7 lines · Jia Hongtao
Quoted 2 lines
We unified the Freescale pci/pcie initialization by changing the
fsl_pciQuoted 1 line
to a platform driver. In previous PCI code architecture the
initialization
Quoted 1 line
routine is called at
board_setup_archstage. Now the initializationis
Quoted 6 lines
Quoted 6 lines
done
Quoted 1 line
in probe function which is architectural better. Also It's convenient
for
Quoted 3 lines
adding PM support for PCI controller in later patch.
One issue introduced by this architecture is the timing of
swiotlb_init.Quoted 3 lines
Quoted 3 lines
Quoted 1 line
During PCI initialization the need of swiotlb is determined and this
should
Quoted 1 line
be done before
swiotlb_init. So a new function to determine swiotlbby
Quoted 1 line
Quoted 1 line
Quoted 1 line
parsing pci ranges is made. This function is called at
board_setup_archQuoted 10 lines
Quoted 10 lines
Quoted 10 lines
stage which is earlier than
swiotlb_init.Signed-off-by Jia Hongtao <[email protected]>Signed-off-by Li Yang <[email protected]>---
Changed for V3:
- Rebase the patch set on the latest tree
- merge PCI unify and swiotlb patch into one
arch/powerpc/sysdev/fsl_pci.c| 155++++++++++++++++++++++++++++++++--
Quoted 5 lines
Quoted 5 lines
-------
Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.h| 9 +--2 files changed, 125 insertions(+), 39 deletions(-)I'd like the SWIOTLB refactoring as a separate patch. Additionally,
the
Quoted 4 lines
Quoted 4 lines
order of patches should be as follows:
1. refactor PCI node parsing code
2. addpci_determine_swiotlb(should rename to
fsl_pci_determine_swiotlb)Quoted 9 lines
Quoted 7 lines
3. Determine primary bus by looking for ISA node
4. convert all boards over tofsl_pci_init
5. convert fsl pci to platform driver (edac and other fixes should be merged in here)
6. PM support- k
Should I convert all boards over to
fsl_pci_initfirst and then convert
Quoted 8 lines
them
Quoted 1 line
over to platform driver again or just convert them direct to platform
driver?
=20
Yes do thefsl_pci_initconversion first. The reason is we should NOT break functionality from one patch to another.
=20
- k
Actually, the functionality is not broken, other boards just use the old Way to init pci controller and it still works.
-Hongtao.
Quoted 11 lines · On Jul 30, 2012, at 3:07 AM, Jia Hongtao-B38951 wrote:
Quoted 11 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Friday, July 27, 2012 8:47 PM
To: Jia Hongtao-B38951
Cc: [email protected]; Wood Scott-B07421; Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization code
=20
=20
On Jul 27, 2012, at 3:35 AM, Jia Hongtao-B38951 wrote:
=20
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
=20
=20Quoted 5 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Friday, July 27, 2012 2:15 AM
To: Jia Hongtao-B38951
Cc: [email protected]; Wood Scott-B07421; Li =
Yang-R58472
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization code
=20
=20
On Jul 26, 2012, at 7:30 AM, Jia Hongtao wrote:
=20Quoted 1 line
We unified the Freescale pci/pcie initialization by changing the
fsl_pciQuoted 1 line
to a platform driver. In previous PCI code architecture the
initialization
Quoted 1 line
routine is called at
board_setup_archstage. Now the =
initialization
Quoted 3 lines
Quoted 3 lines
is
Quoted 2 lines
Quoted 2 lines
done
Quoted 1 line
in probe function which is architectural better. Also It's =
convenient
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
for
Quoted 3 lines
adding PM support for PCI controller in later patch. =20
One issue introduced by this architecture is the timing of
swiotlb_init.Quoted 1 line
Quoted 1 line
Quoted 1 line
During PCI initialization the need of swiotlb is determined and =
this
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
should
Quoted 1 line
be done before
swiotlb_init. So a new function to determine =
swiotlb
Quoted 13 lines
Quoted 13 lines
by
Quoted 1 line
Quoted 1 line
Quoted 1 line
parsing pci ranges is made. This function is called at
board_setup_archQuoted 10 lines
Quoted 10 lines
Quoted 10 lines
stage which is earlier than
swiotlb_init.
=20Signed-off-by Jia Hongtao <[email protected]>Signed-off-by Li Yang <[email protected]>---
Changed for V3:
- Rebase the patch set on the latest tree
- merge PCI unify and swiotlb patch into one
=20arch/powerpc/sysdev/fsl_pci.c| 155
Quoted 6 lines
Quoted 6 lines
++++++++++++++++++++++++++++++++--
Quoted 5 lines
Quoted 5 lines
-------
Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.h| 9 +--2 files changed, 125 insertions(+), 39 deletions(-)=20
I'd like the SWIOTLB refactoring as a separate patch. =
Additionally,
Quoted 9 lines
Quoted 9 lines
the
Quoted 4 lines
Quoted 4 lines
order of patches should be as follows:
=20
1. refactor PCI node parsing code
2. addpci_determine_swiotlb(should rename to
fsl_pci_determine_swiotlb)Quoted 3 lines
Quoted 3 lines
3. Determine primary bus by looking for ISA node
4. convert all boards over tofsl_pci_init
5. convert fsl pci to platform driver (edac and other fixes should =
be
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
merged in here)
6. PM support
=20
- k=20
Should I convert all boards over tofsl_pci_initfirst and then =
convert
Quoted 2 lines
Quoted 2 lines
them
Quoted 1 line
over to platform driver again or just convert them direct to =
platform
Quoted 3 lines
Quoted 3 lines
driver?
=20
Yes do thefsl_pci_initconversion first. The reason is we should =
NOT
Quoted 6 lines
Quoted 3 lines
break functionality from one patch to another.
=20
- k=20
=20
Actually, the functionality is not broken, other boards just use the =
old
Quoted 1 line
Way to init pci controller and it still works.
How do you figure? The platform driver is going to get called on boards = not yet converted. So than you will get 2 different inits of PCI going = on.
- k=
Quoted 102 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Monday, July 30, 2012 10:47 PM
To: Jia Hongtao-B38951
Cc: [email protected]; Wood Scott-B07421; Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization code
=20
=20
On Jul 30, 2012, at 3:07 AM, Jia Hongtao-B38951 wrote:
=20Quoted 24 lines
Quoted 24 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Friday, July 27, 2012 8:47 PM
To: Jia Hongtao-B38951
Cc: [email protected]; Wood Scott-B07421; Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization codeQuoted 13 lines · On Jul 27, 2012, at 3:35 AM, Jia Hongtao-B38951 wrote:
Quoted 13 lines
-----Original Message-----
From: Kumar Gala [mailto:[email protected]]
Sent: Friday, July 27, 2012 2:15 AM
To: Jia Hongtao-B38951
Cc: [email protected]; Wood Scott-B07421; Li Yang-R58472
Subject: Re: [PATCH V3 1/5] powerpc/fsl-pci: Unify pci/pcie initialization codeOn Jul 26, 2012, at 7:30 AM, Jia Hongtao wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
We unified the Freescale pci/pcie initialization by changing the
fsl_pciQuoted 1 line
to a platform driver. In previous PCI code architecture the
initialization
Quoted 1 line
routine is called at
board_setup_archstage. Now the initializationis
Quoted 2 lines
Quoted 2 lines
done
Quoted 1 line
in probe function which is architectural better. Also It's
convenient
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
for
Quoted 3 lines
adding PM support for PCI controller in later patch.
One issue introduced by this architecture is the timing of
swiotlb_init.Quoted 1 line
Quoted 1 line
Quoted 1 line
During PCI initialization the need of swiotlb is determined and
this
Quoted 22 lines
Quoted 22 lines
Quoted 2 lines
Quoted 2 lines
should
Quoted 1 line
be done before
swiotlb_init. So a new function to determine swiotlbby
Quoted 1 line
Quoted 1 line
Quoted 1 line
parsing pci ranges is made. This function is called at
board_setup_archQuoted 10 lines
Quoted 10 lines
Quoted 10 lines
stage which is earlier than
swiotlb_init.Signed-off-by Jia Hongtao <[email protected]>Signed-off-by Li Yang <[email protected]>---
Changed for V3:
- Rebase the patch set on the latest tree
- merge PCI unify and swiotlb patch into one
arch/powerpc/sysdev/fsl_pci.c| 155++++++++++++++++++++++++++++++++--
Quoted 5 lines
Quoted 5 lines
-------
Quoted 2 lines
arch/powerpc/sysdev/fsl_pci.h| 9 +--2 files changed, 125 insertions(+), 39 deletions(-)I'd like the SWIOTLB refactoring as a separate patch. Additionally,
the
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
order of patches should be as follows:
1. refactor PCI node parsing code
2. addpci_determine_swiotlb(should rename to
fsl_pci_determine_swiotlb)Quoted 3 lines
Quoted 3 lines
3. Determine primary bus by looking for ISA node
4. convert all boards over tofsl_pci_init
5. convert fsl pci to platform driver (edac and other fixes shouldbe
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
merged in here)
6. PM support- k
Should I convert all boards over to
fsl_pci_initfirst and thenconvert
Quoted 11 lines
Quoted 8 lines
them
Quoted 1 line
over to platform driver again or just convert them direct to platform
driver?
Yes do the
fsl_pci_initconversion first. The reason is we should NOT break functionality from one patch to another.- k
Actually, the functionality is not broken, other boards just use the
Quoted 8 lines
old
Quoted 1 line
Way to init pci controller and it still works.
=20
How do you figure? The platform driver is going to get called on boards not yet converted. So than you will get 2 different inits of PCI going on.
=20
- k
In Scott's patch set no platform driver used. fsl_pci_init is just a unifie= d
routine function for all boards to call. Now other boards in which fsl_pci_= init
is not called just use the old way to init.
-Hongtao.
Quoted 27 lines · Jia Hongtao
Quoted 15 lines
We unified the Freescale pci/pcie initialization by changing the
fsl_pcito a platform driver. In previous PCI code architecture the initialization routine is called atboard_setup_archstage. Now the initialization is done in probe function which is architectural better. Also It's convenient for adding PM support for PCI controller in later patch.One issue introduced by this architecture is the timing of
swiotlb_init. During PCI initialization the need of swiotlb is determined and this should be done beforeswiotlb_init. So a new function to determine swiotlb by parsing pci ranges is made. This function is called atboard_setup_archstage which is earlier thanswiotlb_init.Signed-off-by Jia Hongtao <[email protected]>Signed-off-by Li Yang <[email protected]>Quoted 8 lines
---
Changed for V3:
- Rebase the patch set on the latest tree
- merge PCI unify and swiotlb patch into one
arch/powerpc/sysdev/fsl_pci.c| 155 ++++++++++++++++++++++++++++++++---------arch/powerpc/sysdev/fsl_pci.h| 9 +--2 files changed, 125 insertions(+), 39 deletions(-)
Quoted 8 lines
I'd like the SWIOTLB refactoring as a separate patch. Additionally, the order of patches should be as follows:
1. refactor PCI node parsing code
2. addpci_determine_swiotlb(should rename tofsl_pci_determine_swiotlb)
3. Determine primary bus by looking for ISA node
4. convert all boards over tofsl_pci_init
5. convert fsl pci to platform driver (edac and other fixes should be merged in here)
6. PM support
Could you add:
7. Fix PPC_INDIRECT_TYPE_NO_PCIE_LINK issue. The link is only probed at init and a subsequent pci/rescan does not change that. See mail thread titled:
mpc8xxx PCIe hotplug needs fixing, some clues ..
Jocke