Refine PCI scan interfaces and make generic pci host bridge
v4 cover Refine PCI scan interfaces and make generic pci host bridge
v3->v4:
Fix the rebase issue.v2->v3:
Rebase this series on v4.0-rc1.v1->v2:
Split pci_host_bridge_list into a new patch, remove .phb_probe_mode and rework powerpc .phb_of_scan_bus() for simpilicty suggested by Arnd. Refresh some patch description log, and add a new patch to fix build warning in ia64.
This series is based on Bjorn's pci-next branch.
Patch 1-4 ripped out pci_bus_add_devices() from pci scan interfaces for better pci scan flow.
Patch 5-11 make a generic pci_host_bridge to hold pci_host_bridge related informations, and introduce a pci_host_bridge_ops to support platform host drivers provide its own pci_host_bridge related operations to setup pci_host_bridge during pci enumeration.
Patch 12-28 apply the new pci scan interfaces to platform pci host bridge drivers.
Now in kernel, we scan pci bus use the following ways:
1. pci_scan_bus.
parent = NULL, default io/mem/bus resources call pci_bus_add_devices()
2. pci_scan_bus_parented() + pci_bus_add_devices() default io/mem/bus resources, only used by xen
3. pci_scan_root_bus() + pci_bus_add_devices()
4. pci_create_root_bus() + pci_scan_child_bus() + pci_bus_add_devices()
5. pci_create_root_bus() + xx_of_scan_bus() + pci_bus_add_devices()
And we have a lot of arch specific pci_domain_nr() and other platform specific weak function like pcibios_root_bridge_prepare().
After applied this series, we have following scan interfaces:
1. pci_scan_bus_legacy()
parent = NULL, default io/mem/bus resources. for legacy pci scan
2. pci_scan_root_bus()
for callers provide its own parent and io/mem/bus resources but no platform specific pci_host_bridge operations
3. pci_scan_root_bridge()
for callers provide its own parent and io/mem/bus resources
Arnd Bergmann (1):
xen/PCI: Don't use deprecated function pci_scan_bus_parented()
Yijing Wang (29):
PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
PCI: Remove deprecated pci_scan_bus_parented()
PCI: Rename pci_scan_bus() to pci_scan_bus_legacy()
PCI: Combine PCI domain and bus number in u32 arg
PCI: Pass PCI domain number combined with root bus number
PCI: Introduce pci_host_assign_domain_nr() to assign domain
PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
PCI: Introduce pci_host_bridge_list to manage host bridges
PCI: Save sysdata in pci_host_bridge drvdata
PCI: Introduce pci_host_bridge_ops to support host specific
operations
PCI: Introduce new scan function pci_scan_root_bridge() PCI/x86: Refine pci_acpi_scan_root() with generic pci_host_bridge PCI/IA64: Refine pci_acpi_scan_root() with generic pci_host_bridge PCI/IA64: Fix the build warning about pci_domain_nr() PCI/powerpc: Rename pcibios_root_bridge_prepare() PCI/powerpc: Use pci_scan_root_bridge() for simplicity
PCI: Remove weak pcibios_root_bridge_prepare() PCI/sparc: Use pci_scan_root_bridge() for simplicity
PCI: Introduce pci_bus_child_max_busnr()
PCI/Parisc: Use pci_scan_root_bus() for simplicity PCI/mvebu: Use pci_common_init_dev() to simplify code PCI/tegra: Remove redundant tegra_pcie_scan_bus() PCI/designware: Use pci_scan_root_bus() for simplicity PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
PCI: Export find_pci_host_bridge()
PCI: Remove platform specific pci_domain_nr()
PCI: Remove pci_bus_assign_domain_nr()
arch/alpha/include/asm/pci.h | 2 - arch/alpha/kernel/pci.c | 7 +- arch/alpha/kernel/sys_nautilus.c | 4 +- arch/frv/mb93090-mb00/pci-vdk.c | 6 +- arch/ia64/include/asm/pci.h | 1 - arch/ia64/pci/pci.c | 34 +++--- arch/ia64/sn/kernel/io_acpi_init.c | 6 +- arch/ia64/sn/kernel/io_init.c | 8 +- arch/m68k/coldfire/pci.c | 3 +- arch/microblaze/pci/pci-common.c | 17 +-- arch/mips/include/asm/pci.h | 2 - arch/mips/pci/pci.c | 5 +- arch/mn10300/unit-asb2305/pci.c | 5 +- arch/powerpc/include/asm/machdep.h | 2 +- arch/powerpc/kernel/pci-common.c | 77 ++++++------ arch/powerpc/platforms/pseries/pci.c | 8 +- arch/powerpc/platforms/pseries/pseries.h | 2 +- arch/powerpc/platforms/pseries/setup.c | 2 +- arch/s390/pci/pci.c | 13 +-- arch/sh/drivers/pci/pci.c | 6 +- arch/sh/include/asm/pci.h | 2 - arch/sparc/kernel/leon_pci.c | 1 + arch/sparc/kernel/pci.c | 50 ++++---- arch/sparc/kernel/pcic.c | 4 +- arch/tile/include/asm/pci.h | 2 - arch/tile/kernel/pci.c | 6 +- arch/tile/kernel/pci_gx.c | 7 +- arch/unicore32/kernel/pci.c | 13 +-- arch/x86/include/asm/pci.h | 6 - arch/x86/pci/acpi.c | 38 +++--- arch/x86/pci/common.c | 4 +- arch/xtensa/kernel/pci.c | 2 + drivers/parisc/dino.c | 11 +-- drivers/parisc/lba_pci.c | 7 +- drivers/pci/host-bridge.c | 90 ++++++++++++++- drivers/pci/host/pci-mvebu.c | 18 +--- drivers/pci/host/pci-tegra.c | 16 --- drivers/pci/host/pci-xgene.c | 3 +- drivers/pci/host/pcie-designware.c | 4 +- drivers/pci/hotplug/acpiphp_glue.c | 29 +----- drivers/pci/hotplug/ibmphp_core.c | 6 +- drivers/pci/pci.c | 42 ++++++- drivers/pci/probe.c | 195 ++++++++++++------------------ drivers/pci/xen-pcifront.c | 11 ++- include/linux/pci.h | 47 +++++--- include/uapi/linux/pci.h | 3 + 46 files changed, 423 insertions(+), 404 deletions(-)
PATCH v4 1/30 PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
Pci_bus_add_devices() should not be placed in pci_scan_bus(). Now pci device will be added to driver core once its creation. All things left in pci_bus_add_devices() are driver attachment and other trivial sysfs things. Pci_scan_bus() should be the function responsible for scanning PCI devices, not including driver attachment. Other, some callers(m68k,unicore32,alpha) of pci_scan_bus() will call pci_bus_size_bridges() and pci_bus_assign_resources() after pci_scan_bus().
E.g.
In m68kmcf_pci_init()
pci_scan_bus() ... pci_bus_add_devices() --- try to attach driver pci_fixup_irqs() pci_bus_size_bridges() pci_bus_assign_resources()
Above code flow make pci scan logic obscure, resources should be assigned correctly before attaching driver. Because pci_scan_bus() mostly be called in system boot path, when before drivers are loaded(in module_init), so no pci scan issues will occur. Most pci_scan_bus() callers additionally call pci_bus_size_bridges() and pci_bus_assign_resources() after pci_scan_bus(), we could rip out pci_bus_add_devices() for better code readability. After applied this patch, pci_scan_bus() should be used like:
pci_scan_bus() (mandatory)pci_fixup_irqs() (optional)pci_bus_size_bridges() (optional)pci_pci_bus_assign_resources() (optional)pci_bus_add_devices() (mandatory)
--- arch/alpha/kernel/sys_nautilus.c | 1 + arch/m68k/coldfire/pci.c | 1 + arch/sparc/kernel/pcic.c | 2 ++ arch/unicore32/kernel/pci.c | 11 +++-------- drivers/pci/hotplug/ibmphp_core.c | 6 ++++-- drivers/pci/probe.c | 1 - 6 files changed, 11 insertions(+), 11 deletions(-)
arch/alpha/kernel/sys_nautilus.c +1 -0
@@ -253,6 +253,7 @@ nautilus_init_pci(void)for the root bus, so just clear it. */ bus->self =NULL ;pci_fixup_irqs (alpha_mv.pci_swizzle, alpha_mv.pci_map_irq); +pci_bus_add_devices (bus); }/*
arch/m68k/coldfire/pci.c +1 -0
@@ -319,6 +319,7 @@ static int __init mcf_pci_init(void)pci_fixup_irqs (pci_common_swizzle, mcf_pci_map_irq);pci_bus_size_bridges (rootbus);pci_bus_assign_resources (rootbus); +pci_bus_add_devices (rootbus);return 0 ; }
arch/sparc/kernel/pcic.c +2 -0
@@ -391,6 +391,8 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic)struct linux_pbm_info *pbm = &pcic->pbm; pbm->pci_bus =pci_scan_bus (pbm->pci_first_busno, &pcic_ops, pbm); +if (pbm->pci_bus) +pci_bus_add_devices (pbm->pci_bus);#if 0 /* deadwood transplanted from sparc64 */ pci_fill_in_pbm_cookies (pbm->pci_bus, pbm, pbm->prom_node);pci_record_assignments (pbm, pbm->pci_bus);
arch/unicore32/kernel/pci.c +3 -8
@@ -266,17 +266,12 @@ static int __init pci_common_init(void)pci_fixup_irqs (pci_common_swizzle, pci_puv3_map_irq);if (!pci_has_flag (PCI_PROBE_ONLY )) { -/* -* Size the bridge windows. -*/ +/* Size the bridge windows. */ pci_bus_size_bridges (puv3_bus); - -/* -* Assign resources. -*/ +/* Assign resources. */ pci_bus_assign_resources (puv3_bus); } - +pci_bus_add_devices (puv3_bus);return 0 ; }subsys_initcall (pci_common_init);
drivers/pci/hotplug/ibmphp_core.c +4 -2
@@ -738,7 +738,7 @@ static void ibm_unconfigure_device(struct pci_func *func)*/ static u8 bus_structure_fixup (u8 busno) { -struct pci_bus *bus; +struct pci_bus *bus, *b;struct pci_dev *dev;u16 l;
@@ -765,7 +765,9 @@ static u8 bus_structure_fixup(u8 busno) (l != 0x0000) && (l != 0xffff)) {debug ("%s - Inside bus_structure_fixup()\n" , __func__); -pci_scan_bus (busno, ibmphp_pci_bus->ops,NULL ); + b =pci_scan_bus (busno, ibmphp_pci_bus->ops,NULL ); +if (b) +pci_bus_add_devices (b);break ; } }
drivers/pci/probe.c +0 -1
@@ -2123,7 +2123,6 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, b =pci_create_root_bus (NULL , bus, ops, sysdata, &resources);if (b) {pci_scan_child_bus (b); -pci_bus_add_devices (b); }else {pci_free_resource_list (&resources); }
Signature · 1 line
1.7.1
Bjorn Helgaas
maintainerRe: [PATCH v4 01/30] PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
Quoted 84 lines · Yijing Wang
Pci_bus_add_devices()should not be placed inpci_scan_bus(). Now pci device will be added to driver core once its creation. All things left inpci_bus_add_devices()are driver attachment and other trivial sysfs things.Pci_scan_bus()should be the function responsible for scanning PCI devices, not including driver attachment. Other, somecallers(m68k,unicore32,alpha)ofpci_scan_bus()will callpci_bus_size_bridges()andpci_bus_assign_resources()afterpci_scan_bus().E.g.
In m68kmcf_pci_init()pci_scan_bus() ... pci_bus_add_devices() --- try to attach driver pci_fixup_irqs() pci_bus_size_bridges() pci_bus_assign_resources()Above code flow make pci scan logic obscure, resources should be assigned correctly before attaching driver. Because
pci_scan_bus()mostly be called in system boot path, when before drivers areloaded(in module_init), so no pci scan issues will occur. Mostpci_scan_bus()callers additionally callpci_bus_size_bridges()andpci_bus_assign_resources()afterpci_scan_bus(), we could rip outpci_bus_add_devices()for better code readability. After applied this patch,pci_scan_bus()should be used like:
pci_scan_bus()(mandatory)pci_fixup_irqs()(optional)pci_bus_size_bridges()(optional)pci_pci_bus_assign_resources()(optional)pci_bus_add_devices()(mandatory)Signed-off-by Yijing Wang <[email protected]>CC "David S. Miller" <[email protected]>CC Geert Uytterhoeven <[email protected]>CC Guan Xuetao <[email protected]>CC Richard Henderson <[email protected]>CC Ivan Kokshaysky <[email protected]>CC Matt Turner <[email protected]>--- arch/alpha/kernel/sys_nautilus.c | 1 + arch/m68k/coldfire/pci.c | 1 + arch/sparc/kernel/pcic.c | 2 ++ arch/unicore32/kernel/pci.c | 11 +++-------- drivers/pci/hotplug/ibmphp_core.c | 6 ++++-- drivers/pci/probe.c | 1 - 6 files changed, 11 insertions(+), 11 deletions(-)arch/alpha/kernel/sys_nautilus.c +1
-0@@ -253,6 +253,7 @@ nautilus_init_pci(void)for the root bus, so just clear it. */ bus->self =NULL ;pci_fixup_irqs (alpha_mv.pci_swizzle, alpha_mv.pci_map_irq); +pci_bus_add_devices (bus); }/* arch/m68k/coldfire/pci.c +1
-0@@ -319,6 +319,7 @@ static int __init mcf_pci_init(void)pci_fixup_irqs (pci_common_swizzle, mcf_pci_map_irq);pci_bus_size_bridges (rootbus);pci_bus_assign_resources (rootbus); +pci_bus_add_devices (rootbus);return 0 ; }arch/sparc/kernel/pcic.c +0
-0
arch/sparc/kernel/pcic.c static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic) · line 398
Quoted 8 lines
arch/sparc/kernel/pcic.c +2
-0@@ -391,6 +391,8 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic)struct linux_pbm_info *pbm = &pcic->pbm; pbm->pci_bus =pci_scan_bus (pbm->pci_first_busno, &pcic_ops, pbm); +if (pbm->pci_bus) +pci_bus_add_devices (pbm->pci_bus);#if 0 /* deadwood transplanted from sparc64 */ pci_fill_in_pbm_cookies (pbm->pci_bus, pbm, pbm->prom_node);pci_record_assignments (pbm, pbm->pci_bus);
This is correct, but it should look like this instead:
if (!pbm->pci_bus)
return;
#if 0 /* deadwood ... */
...
#endif
pci_bus_add_devices(pbm->pci_bus);}
That way the mainline code is the normal path, and pci_bus_add_devices() is in the correct place even if the "deadwood" code is resurrected.
Quoted 39 lines
arch/unicore32/kernel/pci.c +3
-8@@ -266,17 +266,12 @@ static int __init pci_common_init(void)pci_fixup_irqs (pci_common_swizzle, pci_puv3_map_irq);if (!pci_has_flag (PCI_PROBE_ONLY )) { -/* -* Size the bridge windows. -*/ +/* Size the bridge windows. */ pci_bus_size_bridges (puv3_bus); - -/* -* Assign resources. -*/ +/* Assign resources. */ pci_bus_assign_resources (puv3_bus); } - +pci_bus_add_devices (puv3_bus);return 0 ; }subsys_initcall (pci_common_init);drivers/pci/hotplug/ibmphp_core.c +1
-1@@ -738,7 +738,7 @@ static void ibm_unconfigure_device(struct pci_func *func)*/ static u8 bus_structure_fixup (u8 busno) { -struct pci_bus *bus; +struct pci_bus *bus, *b;struct pci_dev *dev;u16 l;
drivers/pci/hotplug/ibmphp_core.c static u8 bus_structure_fixup(u8 busno) · line 770
Quoted 7 lines
drivers/pci/hotplug/ibmphp_core.c +3
-1@@ -765,7 +765,9 @@ static u8 bus_structure_fixup(u8 busno) (l != 0x0000) && (l != 0xffff)) {debug ("%s - Inside bus_structure_fixup()\n" , __func__); -pci_scan_bus (busno, ibmphp_pci_bus->ops,NULL ); + b =pci_scan_bus (busno, ibmphp_pci_bus->ops,NULL ); +if (b) +pci_bus_add_devices (b);
Use this:
if (!b)
continue;
pci_bus_add_devices(b);for the same reason as above.
Quoted 18 lines
drivers/pci/hotplug/ibmphp_core.c +0
-0break ; } }drivers/pci/probe.c +0
-1@@ -2123,7 +2123,6 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, b =pci_create_root_bus (NULL , bus, ops, sysdata, &resources);if (b) {pci_scan_child_bus (b); -pci_bus_add_devices (b); }else {pci_free_resource_list (&resources); }Signature · 1 line
1.7.1
Re: [PATCH v4 01/30] PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
Quoted 15 lines
arch/sparc/kernel/pcic.c static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic) · line 398
Quoted 6 lines
arch/sparc/kernel/pcic.c +2
-0pbm->pci_bus =pci_scan_bus (pbm->pci_first_busno, &pcic_ops, pbm); +if (pbm->pci_bus) +pci_bus_add_devices (pbm->pci_bus);#if 0 /* deadwood transplanted from sparc64 */ pci_fill_in_pbm_cookies (pbm->pci_bus, pbm, pbm->prom_node);pci_record_assignments (pbm, pbm->pci_bus);This is correct, but it should look like this instead:
if (!pbm->pci_bus) return; #if 0 /* deadwood ... */ ... #endif pci_bus_add_devices(pbm->pci_bus);
Quoted 5 lines
}
That way the mainline code is the normal path, and
pci_bus_add_devices()is in the correct place even if the "deadwood" code is resurrected.
Yes, you are right, thanks!
Quoted 50 lines
Quoted 40 lines
arch/unicore32/kernel/pci.c +3
-8@@ -266,17 +266,12 @@ static int __init pci_common_init(void)pci_fixup_irqs (pci_common_swizzle, pci_puv3_map_irq);if (!pci_has_flag (PCI_PROBE_ONLY )) { -/* -* Size the bridge windows. -*/ +/* Size the bridge windows. */ pci_bus_size_bridges (puv3_bus); - -/* -* Assign resources. -*/ +/* Assign resources. */ pci_bus_assign_resources (puv3_bus); } - +pci_bus_add_devices (puv3_bus);return 0 ; }subsys_initcall (pci_common_init);drivers/pci/hotplug/ibmphp_core.c +1
-1@@ -738,7 +738,7 @@ static void ibm_unconfigure_device(struct pci_func *func)*/ static u8 bus_structure_fixup (u8 busno) { -struct pci_bus *bus; +struct pci_bus *bus, *b;struct pci_dev *dev;u16 l;drivers/pci/hotplug/ibmphp_core.c static u8 bus_structure_fixup(u8 busno) · line 770
Quoted 7 lines
drivers/pci/hotplug/ibmphp_core.c +3
-1@@ -765,7 +765,9 @@ static u8 bus_structure_fixup(u8 busno) (l != 0x0000) && (l != 0xffff)) {debug ("%s - Inside bus_structure_fixup()\n" , __func__); -pci_scan_bus (busno, ibmphp_pci_bus->ops,NULL ); + b =pci_scan_bus (busno, ibmphp_pci_bus->ops,NULL ); +if (b) +pci_bus_add_devices (b);Use this:
Quoted 5 lines
if (!b) continue; pci_bus_add_devices(b);for the same reason as above.
Will update, thanks!
Thanks!
Yijing.
Quoted 22 lines
Quoted 19 lines
drivers/pci/hotplug/ibmphp_core.c +0
-0break ; } }drivers/pci/probe.c +0
-1@@ -2123,7 +2123,6 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, b =pci_create_root_bus (NULL , bus, ops, sysdata, &resources);if (b) {pci_scan_child_bus (b); -pci_bus_add_devices (b); }else {pci_free_resource_list (&resources); }Signature · 1 line
1.7.1.
Signature · 2 lines
Thanks! Yijing
Re: [PATCH v4 01/30] PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
In reply to Bjorn HelgaasQuoted 15 lines
arch/sparc/kernel/pcic.c static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic) · line 398
Quoted 6 lines
arch/sparc/kernel/pcic.c +2
-0pbm->pci_bus =pci_scan_bus (pbm->pci_first_busno, &pcic_ops, pbm); +if (pbm->pci_bus) +pci_bus_add_devices (pbm->pci_bus);#if 0 /* deadwood transplanted from sparc64 */ pci_fill_in_pbm_cookies (pbm->pci_bus, pbm, pbm->prom_node);pci_record_assignments (pbm, pbm->pci_bus);This is correct, but it should look like this instead:
if (!pbm->pci_bus) return; #if 0 /* deadwood ... */ ... #endif pci_bus_add_devices(pbm->pci_bus);
Quoted 5 lines
}
That way the mainline code is the normal path, and
pci_bus_add_devices()is in the correct place even if the "deadwood" code is resurrected.
Yes, you are right, thanks!
Quoted 50 lines
Quoted 40 lines
arch/unicore32/kernel/pci.c +3
-8@@ -266,17 +266,12 @@ static int __init pci_common_init(void)pci_fixup_irqs (pci_common_swizzle, pci_puv3_map_irq);if (!pci_has_flag (PCI_PROBE_ONLY )) { -/* -* Size the bridge windows. -*/ +/* Size the bridge windows. */ pci_bus_size_bridges (puv3_bus); - -/* -* Assign resources. -*/ +/* Assign resources. */ pci_bus_assign_resources (puv3_bus); } - +pci_bus_add_devices (puv3_bus);return 0 ; }subsys_initcall (pci_common_init);drivers/pci/hotplug/ibmphp_core.c +1
-1@@ -738,7 +738,7 @@ static void ibm_unconfigure_device(struct pci_func *func)*/ static u8 bus_structure_fixup (u8 busno) { -struct pci_bus *bus; +struct pci_bus *bus, *b;struct pci_dev *dev;u16 l;drivers/pci/hotplug/ibmphp_core.c static u8 bus_structure_fixup(u8 busno) · line 770
Quoted 7 lines
drivers/pci/hotplug/ibmphp_core.c +3
-1@@ -765,7 +765,9 @@ static u8 bus_structure_fixup(u8 busno) (l != 0x0000) && (l != 0xffff)) {debug ("%s - Inside bus_structure_fixup()\n" , __func__); -pci_scan_bus (busno, ibmphp_pci_bus->ops,NULL ); + b =pci_scan_bus (busno, ibmphp_pci_bus->ops,NULL ); +if (b) +pci_bus_add_devices (b);Use this:
Quoted 5 lines
if (!b) continue; pci_bus_add_devices(b);for the same reason as above.
Will update, thanks!
Thanks!
Yijing.
Quoted 22 lines
Quoted 19 lines
drivers/pci/hotplug/ibmphp_core.c +0
-0break ; } }drivers/pci/probe.c +0
-1@@ -2123,7 +2123,6 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, b =pci_create_root_bus (NULL , bus, ops, sysdata, &resources);if (b) {pci_scan_child_bus (b); -pci_bus_add_devices (b); }else {pci_free_resource_list (&resources); }Signature · 1 line
1.7.1.
Signature · 2 lines
Thanks! Yijing
PATCH v4 1/30 PCI: Rip out pci_bus_add_devices() from pci_scan_bus()
In reply to Yijing WangPci_bus_add_devices() should not be placed in pci_scan_bus(). Now pci device will be added to driver core once its creation. All things left in pci_bus_add_devices() are driver attachment and other trivial sysfs things. Pci_scan_bus() should be the function responsible for scanning PCI devices, not including driver attachment. Other, some callers(m68k,unicore32,alpha) of pci_scan_bus() will call pci_bus_size_bridges() and pci_bus_assign_resources() after pci_scan_bus().
E.g.
In m68kmcf_pci_init()
pci_scan_bus() ... pci_bus_add_devices() --- try to attach driver pci_fixup_irqs() pci_bus_size_bridges() pci_bus_assign_resources()
Above code flow make pci scan logic obscure, resources should be assigned correctly before attaching driver. Because pci_scan_bus() mostly be called in system boot path, when before drivers are loaded(in module_init), so no pci scan issues will occur. Most pci_scan_bus() callers additionally call pci_bus_size_bridges() and pci_bus_assign_resources() after pci_scan_bus(), we could rip out pci_bus_add_devices() for better code readability. After applied this patch, pci_scan_bus() should be used like:
pci_scan_bus() (mandatory)pci_fixup_irqs() (optional)pci_bus_size_bridges() (optional)pci_pci_bus_assign_resources() (optional)pci_bus_add_devices() (mandatory)
--- arch/alpha/kernel/sys_nautilus.c | 1 + arch/m68k/coldfire/pci.c | 1 + arch/sparc/kernel/pcic.c | 2 ++ arch/unicore32/kernel/pci.c | 11 +++-------- drivers/pci/hotplug/ibmphp_core.c | 6 ++++-- drivers/pci/probe.c | 1 - 6 files changed, 11 insertions(+), 11 deletions(-)
arch/alpha/kernel/sys_nautilus.c +1 -0
@@ -253,6 +253,7 @@ nautilus_init_pci(void)for the root bus, so just clear it. */ bus->self =NULL ;pci_fixup_irqs (alpha_mv.pci_swizzle, alpha_mv.pci_map_irq); +pci_bus_add_devices (bus); }/*
arch/m68k/coldfire/pci.c +1 -0
@@ -319,6 +319,7 @@ static int __init mcf_pci_init(void)pci_fixup_irqs (pci_common_swizzle, mcf_pci_map_irq);pci_bus_size_bridges (rootbus);pci_bus_assign_resources (rootbus); +pci_bus_add_devices (rootbus);return 0 ; }
arch/sparc/kernel/pcic.c +2 -0
@@ -391,6 +391,8 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic)struct linux_pbm_info *pbm = &pcic->pbm; pbm->pci_bus =pci_scan_bus (pbm->pci_first_busno, &pcic_ops, pbm); +if (pbm->pci_bus) +pci_bus_add_devices (pbm->pci_bus);#if 0 /* deadwood transplanted from sparc64 */ pci_fill_in_pbm_cookies (pbm->pci_bus, pbm, pbm->prom_node);pci_record_assignments (pbm, pbm->pci_bus);
arch/unicore32/kernel/pci.c +3 -8
@@ -266,17 +266,12 @@ static int __init pci_common_init(void)pci_fixup_irqs (pci_common_swizzle, pci_puv3_map_irq);if (!pci_has_flag (PCI_PROBE_ONLY )) { -/* -* Size the bridge windows. -*/ +/* Size the bridge windows. */ pci_bus_size_bridges (puv3_bus); - -/* -* Assign resources. -*/ +/* Assign resources. */ pci_bus_assign_resources (puv3_bus); } - +pci_bus_add_devices (puv3_bus);return 0 ; }subsys_initcall (pci_common_init);
drivers/pci/hotplug/ibmphp_core.c +4 -2
@@ -738,7 +738,7 @@ static void ibm_unconfigure_device(struct pci_func *func)*/ static u8 bus_structure_fixup (u8 busno) { -struct pci_bus *bus; +struct pci_bus *bus, *b;struct pci_dev *dev;u16 l;
@@ -765,7 +765,9 @@ static u8 bus_structure_fixup(u8 busno) (l != 0x0000) && (l != 0xffff)) {debug ("%s - Inside bus_structure_fixup()\n" , __func__); -pci_scan_bus (busno, ibmphp_pci_bus->ops,NULL ); + b =pci_scan_bus (busno, ibmphp_pci_bus->ops,NULL ); +if (b) +pci_bus_add_devices (b);break ; } }
drivers/pci/probe.c +0 -1
@@ -2123,7 +2123,6 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, b =pci_create_root_bus (NULL , bus, ops, sysdata, &resources);if (b) {pci_scan_child_bus (b); -pci_bus_add_devices (b); }else {pci_free_resource_list (&resources); }
Signature · 1 line
1.7.1
PATCH v4 2/30 PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
In reply to Yijing WangJust like pci_scan_bus(), we also should rip out pci_bus_add_devices() from pci_scan_root_bus(). Lots platforms first call pci_scan_root_bus(), but after that, they call pci_bus_size_bridges() and pci_bus_assign_resources(). Place pci_bus_add_devices() in pci_scan_root_bus() hurts PCI scan logic. For arm hw_pci->scan() functions which call pci_scan_root_bus(), it's no need to change anything, because pci_bus_add_devices() will be called later in pci_common_init_dev().
--- arch/alpha/kernel/pci.c | 2 ++ arch/frv/mb93090-mb00/pci-vdk.c | 6 ++++-- arch/ia64/sn/kernel/io_init.c | 1 + arch/microblaze/pci/pci-common.c | 1 + arch/mips/pci/pci.c | 1 + arch/mn10300/unit-asb2305/pci.c | 5 ++++- arch/s390/pci/pci.c | 2 +- arch/sh/drivers/pci/pci.c | 1 + arch/sparc/kernel/leon_pci.c | 1 + arch/tile/kernel/pci.c | 2 ++ arch/tile/kernel/pci_gx.c | 2 ++ arch/x86/pci/common.c | 1 + arch/xtensa/kernel/pci.c | 2 ++ drivers/pci/probe.c | 1 - 14 files changed, 23 insertions(+), 5 deletions(-)
arch/alpha/kernel/pci.c +2 -0
@@ -338,6 +338,8 @@ common_init_pci(void) bus =pci_scan_root_bus (NULL , next_busno, alpha_mv.pci_ops, hose, &resources); +if (bus) +pci_bus_add_devices (bus); hose->bus = bus; hose->need_domain_info = need_domain_info; next_busno = bus->busn_res.end +1 ;
arch/frv/mb93090-mb00/pci-vdk.c +4 -2
@@ -316,6 +316,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)int __init pcibios_init (void ) { +struct pci_bus *bus;struct pci_ops *dir =NULL ;LIST_HEAD (resources);
@@ -383,12 +384,13 @@ int __init pcibios_init(void)printk ("PCI: Probing PCI hardware\n" );pci_add_resource (&resources, &pci_ioport_resource);pci_add_resource (&resources, &pci_iomem_resource); -pci_scan_root_bus (NULL ,0 , pci_root_ops,NULL , &resources); + bus =pci_scan_root_bus (NULL ,0 , pci_root_ops,NULL , &resources);pcibios_irq_init ();pcibios_fixup_irqs ();pcibios_resource_survey (); - +if (bus) +pci_bus_add_devices (bus);return 0 ; }
arch/ia64/sn/kernel/io_init.c +1 -0
@@ -272,6 +272,7 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)kfree (res);kfree (controller); } +pci_bus_add_devices (bus); }/*
arch/microblaze/pci/pci-common.c +1 -0
@@ -1362,6 +1362,7 @@ static void pcibios_scan_phb(struct pci_controller *hose) hose->bus = bus; hose->last_busno = bus->busn_res.end; +pci_bus_add_devices (bus); }static int __init pcibios_init (void )
arch/mips/pci/pci.c +1 -0
@@ -114,6 +114,7 @@ static void pcibios_scanbus(struct pci_controller *hose)pci_bus_size_bridges (bus);pci_bus_assign_resources (bus); } +pci_bus_add_devices (bus); } }
arch/mn10300/unit-asb2305/pci.c +4 -1
@@ -340,6 +340,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)*/ static int __init pcibios_init (void ) { +struct pci_bus *bus;resource_size_t io_offset, mem_offset;LIST_HEAD (resources);
@@ -371,11 +372,13 @@ static int __init pcibios_init(void)pci_add_resource_offset (&resources, &pci_ioport_resource, io_offset);pci_add_resource_offset (&resources, &pci_iomem_resource, mem_offset); -pci_scan_root_bus (NULL ,0 , &pci_direct_ampci,NULL , &resources); + bus =pci_scan_root_bus (NULL ,0 , &pci_direct_ampci,NULL , &resources);pcibios_irq_init ();pcibios_fixup_irqs ();pcibios_resource_survey (); +if (bus) +pci_bus_add_devices (bus);return 0 ; }
arch/s390/pci/pci.c +1 -1
@@ -776,7 +776,7 @@ static int zpci_scan_bus(struct zpci_dev *zdev)zpci_cleanup_bus_resources (zdev);return -EIO ; } - +pci_bus_add_devices (zdev->bus); zdev->bus->max_bus_speed = zdev->max_bus_speed;return 0 ; }
arch/sh/drivers/pci/pci.c +1 -0
@@ -69,6 +69,7 @@ static void pcibios_scanbus(struct pci_channel *hose)pci_bus_size_bridges (bus);pci_bus_assign_resources (bus); +pci_bus_add_devices (bus); }else {pci_free_resource_list (&resources); }
arch/sparc/kernel/leon_pci.c +1 -0
@@ -40,6 +40,7 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)/* Assign devices with resources */ pci_assign_unassigned_resources (); +pci_bus_add_devices (root_bus); }else {pci_free_resource_list (&resources); }
arch/tile/kernel/pci.c +2 -0
@@ -339,6 +339,8 @@ int __init pcibios_init(void)struct pci_bus *next_bus;struct pci_dev *dev; +pci_bus_add_devices (root_bus); +list_for_each_entry (dev, &root_bus->devices, bus_list) {/* * Find the PCI host controller, ie. the 1st
arch/tile/kernel/pci_gx.c +2 -0
@@ -916,6 +916,8 @@ int __init pcibios_init(void)/* Configure the max_payload_size values for this domain. */ fixup_read_and_payload_sizes (controller); +pci_bus_add_devices (root_bus); +/* Alloc a PIO region for PCI memory access for each RC port. */ ret =gxio_trio_alloc_pio_regions (trio_context,1 ,0 ,0 );if (ret <0 ) {
arch/x86/pci/common.c +1 -0
@@ -491,6 +491,7 @@ void pcibios_scan_root(int busnum)pci_free_resource_list (&resources);kfree (sd); } +pci_bus_add_devices (bus); }void __init pcibios_set_cache_line_size (void )
arch/xtensa/kernel/pci.c +2 -0
@@ -185,6 +185,8 @@ static int __init pcibios_init(void)pci_controller_apertures (pci_ctrl, &resources); bus =pci_scan_root_bus (NULL , pci_ctrl->first_busno, pci_ctrl->ops, pci_ctrl, &resources); +if (bus) +pci_bus_add_devices (bus); pci_ctrl->bus = bus; pci_ctrl->last_busno = bus->busn_res.end;if (next_busno <= pci_ctrl->last_busno)
drivers/pci/probe.c +0 -1
@@ -2087,7 +2087,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,if (!found)pci_bus_update_busn_res_end (b, max); -pci_bus_add_devices (b);return b; }EXPORT_SYMBOL (pci_scan_root_bus);
Signature · 1 line
1.7.1
Bjorn Helgaas
maintainerRe: [PATCH v4 02/30] PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
Quoted 56 lines · Yijing Wang
Just like
pci_scan_bus(), we also should rip outpci_bus_add_devices()frompci_scan_root_bus(). Lots platforms first callpci_scan_root_bus(), but after that, they callpci_bus_size_bridges()andpci_bus_assign_resources(). Placepci_bus_add_devices()inpci_scan_root_bus()hurts PCI scan logic. For armhw_pci->scan()functions which callpci_scan_root_bus(), it's no need to change anything, becausepci_bus_add_devices()will be called later inpci_common_init_dev().Signed-off-by Yijing Wang <[email protected]>CC Richard Henderson <[email protected]>CC Ivan Kokshaysky <[email protected]>CC Matt Turner <[email protected]>CC David Howells <[email protected]>CC Tony Luck <[email protected]>CC Michal Simek <[email protected]>CC Ralf Baechle <[email protected]>CC Koichi Yasutake <[email protected]>CC Sebastian Ott <[email protected]>CC "David S. Miller" <[email protected]>CC Chris Metcalf <[email protected]>CC Chris Zankel <[email protected]>CC Max Filippov <[email protected]>CC Thomas Gleixner <[email protected]>--- arch/alpha/kernel/pci.c | 2 ++ arch/frv/mb93090-mb00/pci-vdk.c | 6 ++++-- arch/ia64/sn/kernel/io_init.c | 1 + arch/microblaze/pci/pci-common.c | 1 + arch/mips/pci/pci.c | 1 + arch/mn10300/unit-asb2305/pci.c | 5 ++++- arch/s390/pci/pci.c | 2 +- arch/sh/drivers/pci/pci.c | 1 + arch/sparc/kernel/leon_pci.c | 1 + arch/tile/kernel/pci.c | 2 ++ arch/tile/kernel/pci_gx.c | 2 ++ arch/x86/pci/common.c | 1 + arch/xtensa/kernel/pci.c | 2 ++ drivers/pci/probe.c | 1 - 14 files changed, 23 insertions(+), 5 deletions(-)arch/alpha/kernel/pci.c +0
-0
arch/alpha/kernel/pci.c common_init_pci(void) · line 345
Quoted 8 lines
arch/alpha/kernel/pci.c +2
-0@@ -338,6 +338,8 @@ common_init_pci(void) bus =pci_scan_root_bus (NULL , next_busno, alpha_mv.pci_ops, hose, &resources); +if (bus) +pci_bus_add_devices (bus); hose->bus = bus; hose->need_domain_info = need_domain_info; next_busno = bus->busn_res.end +1 ;
This doesn't look right. The code above is inside a loop, and just after the loop we have:
pci_assign_unassigned_resources();
pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);I think the pci_bus_add_devices() needs to go inside another loop after the assign and fixup_irqs code.
You didn't fix arm, but I think it has the same problem:
pci_common_init_dev
pcibios_init_hw
pci_scan_root_bus
pci_fixup_irqs
pci_bus_size_bridges
pci_bus_assign_resources
Quoted 15 lines
arch/frv/mb93090-mb00/pci-vdk.c +1
-0@@ -316,6 +316,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)int __init pcibios_init (void ) { +struct pci_bus *bus;struct pci_ops *dir =NULL ;LIST_HEAD (resources);@@ -383,12 +384,13 @@ int __init pcibios_init(void)printk ("PCI: Probing PCI hardware\n" );pci_add_resource (&resources, &pci_ioport_resource);
arch/frv/mb93090-mb00/pci-vdk.c int __init pcibios_init(void) · line 393
Quoted 10 lines
arch/frv/mb93090-mb00/pci-vdk.c +3
-2pci_add_resource (&resources, &pci_iomem_resource); -pci_scan_root_bus (NULL ,0 , pci_root_ops,NULL , &resources); + bus =pci_scan_root_bus (NULL ,0 , pci_root_ops,NULL , &resources);pcibios_irq_init ();pcibios_fixup_irqs ();pcibios_resource_survey (); - +if (bus) +pci_bus_add_devices (bus);
It's one more line of code, but personally I would write:
if (!bus)
return 0;
pci_bus_add_devices(bus);
return 0;arch/ia64/sn/kernel/io_init.c sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus) · line 273
Quoted 10 lines
arch/frv/mb93090-mb00/pci-vdk.c +0
-0return 0 ; }arch/ia64/sn/kernel/io_init.c +0
-0@@ -272,6 +272,7 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)kfree (res);kfree (controller);
This needs a "return;" right here. Otherwise we'll call pci_bus_add_devices(NULL) below.
Quoted 10 lines
arch/ia64/sn/kernel/io_init.c +1
-0} +pci_bus_add_devices (bus); }/* arch/microblaze/pci/pci-common.c +0
-0
arch/microblaze/pci/pci-common.c static void pcibios_scan_phb(struct pci_controller *hose) · line 1366
Quoted 5 lines
arch/microblaze/pci/pci-common.c +1
-0@@ -1362,6 +1362,7 @@ static void pcibios_scan_phb(struct pci_controller *hose) hose->bus = bus; hose->last_busno = bus->busn_res.end; +pci_bus_add_devices (bus); }
I think this is still wrong:
pcibios_init
pcibios_scan_phb
pci_scan_root_bus
pci_bus_add_devices
pcibios_resource_survey <-- oops
arch/mips/pci/pci.c static void pcibios_scanbus(struct pci_controller *hose) · line 118
Quoted 12 lines
arch/microblaze/pci/pci-common.c +0
-0static int __init pcibios_init (void )arch/mips/pci/pci.c +1
-0@@ -114,6 +114,7 @@ static void pcibios_scanbus(struct pci_controller *hose)pci_bus_size_bridges (bus);pci_bus_assign_resources (bus); } +pci_bus_add_devices (bus); }
I would add a new patch at the end of your series to cosmetically restructure this as:
if (!bus)
return;
next_busno = bus->busn_res.end + 1;
...
pci_bus_add_devices(bus);Quoted 16 lines
arch/mips/pci/pci.c +0
-0}arch/mn10300/unit-asb2305/pci.c +1
-0@@ -340,6 +340,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)*/ static int __init pcibios_init (void ) { +struct pci_bus *bus;resource_size_t io_offset, mem_offset;LIST_HEAD (resources);@@ -371,11 +372,13 @@ static int __init pcibios_init(void)
arch/mn10300/unit-asb2305/pci.c static int __init pcibios_init(void) · line 381
Quoted 10 lines
arch/mn10300/unit-asb2305/pci.c +3
-1pci_add_resource_offset (&resources, &pci_ioport_resource, io_offset);pci_add_resource_offset (&resources, &pci_iomem_resource, mem_offset); -pci_scan_root_bus (NULL ,0 , &pci_direct_ampci,NULL , &resources); + bus =pci_scan_root_bus (NULL ,0 , &pci_direct_ampci,NULL , &resources);pcibios_irq_init ();pcibios_fixup_irqs ();pcibios_resource_survey (); +if (bus) +pci_bus_add_devices (bus);
if (!bus)
return 0;
pci_bus_add_devices(bus);Quoted 8 lines
arch/mn10300/unit-asb2305/pci.c +0
-0return 0 ; }arch/s390/pci/pci.c +0
-0
arch/s390/pci/pci.c static int zpci_scan_bus(struct zpci_dev *zdev) · line 780
Quoted 6 lines
arch/s390/pci/pci.c +1
-1@@ -776,7 +776,7 @@ static int zpci_scan_bus(struct zpci_dev *zdev)zpci_cleanup_bus_resources (zdev);return -EIO ; } - +pci_bus_add_devices (zdev->bus); zdev->bus->max_bus_speed = zdev->max_bus_speed;
We should set zdev->bus->max_bus_speed before calling pci_bus_add_devices(). Some drivers look at max_bus_speed.
Quoted 7 lines
arch/s390/pci/pci.c +0
-0return 0 ; }arch/sh/drivers/pci/pci.c +0
-0
arch/sh/drivers/pci/pci.c static void pcibios_scanbus(struct pci_channel *hose) · line 75
Quoted 7 lines
arch/sh/drivers/pci/pci.c +1
-0@@ -69,6 +69,7 @@ static void pcibios_scanbus(struct pci_channel *hose)pci_bus_size_bridges (bus);pci_bus_assign_resources (bus); +pci_bus_add_devices (bus); }else {pci_free_resource_list (&resources); }
Cosmetic restructure (new patch at end of series):
if (!bus) {
pci_free_resource_list(&resources);
return;
}
next_busno = bus->busn_res.end + 1;
...
pci_bus_add_devices(bus);arch/sparc/kernel/leon_pci.c void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) · line 46
Quoted 12 lines
arch/sparc/kernel/leon_pci.c +1
-0@@ -40,6 +40,7 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)/* Assign devices with resources */ pci_assign_unassigned_resources (); +pci_bus_add_devices (root_bus); }else {pci_free_resource_list (&resources); }
Restructure this with the same pattern (in a new patch).
Quoted 18 lines
arch/tile/kernel/pci.c +2
-0@@ -339,6 +339,8 @@ int __init pcibios_init(void)struct pci_bus *next_bus;struct pci_dev *dev; +pci_bus_add_devices (root_bus); +list_for_each_entry (dev, &root_bus->devices, bus_list) {/* * Find the PCI host controller, ie. the 1st arch/tile/kernel/pci_gx.c +0
-0
arch/tile/kernel/pci_gx.c int __init pcibios_init(void) · line 923
Quoted 8 lines
arch/tile/kernel/pci_gx.c +2
-0@@ -916,6 +916,8 @@ int __init pcibios_init(void)/* Configure the max_payload_size values for this domain. */ fixup_read_and_payload_sizes (controller); +pci_bus_add_devices (root_bus); +/* Alloc a PIO region for PCI memory access for each RC port. */ ret =gxio_trio_alloc_pio_regions (trio_context,1 ,0 ,0 );if (ret <0 ) {
I don't know what all the magic gxio_trio_alloc and init stuff after this is, but it looks to me like the pci_bus_add_devices(root_bus) should be done *after* all of it.
arch/x86/pci/common.c void pcibios_scan_root(int busnum) · line 494
Quoted 9 lines
arch/x86/pci/common.c +1
-0@@ -491,6 +491,7 @@ void pcibios_scan_root(int busnum)pci_free_resource_list (&resources);kfree (sd); } +pci_bus_add_devices (bus);
This one is tricky. I don't think your patch makes it any worse than it is today, but it doesn't fix the problem. We need to either fix it or call it out in the changelog.
pci_subsys_init # subsys_initcall (level 4)
pci_legacy_init
pcibios_scan_root
pci_scan_root_bus
pci_bus_add_devices
pcibios_assign_resources # fs_initcall (level 5)
Quoted 8 lines
arch/x86/pci/common.c +0
-0}void __init pcibios_set_cache_line_size (void )arch/xtensa/kernel/pci.c +0
-0
arch/xtensa/kernel/pci.c static int __init pcibios_init(void) · line 191
Quoted 7 lines
arch/xtensa/kernel/pci.c +2
-0@@ -185,6 +185,8 @@ static int __init pcibios_init(void)pci_controller_apertures (pci_ctrl, &resources); bus =pci_scan_root_bus (NULL , pci_ctrl->first_busno, pci_ctrl->ops, pci_ctrl, &resources); +if (bus) +pci_bus_add_devices (bus); pci_ctrl->bus = bus; pci_ctrl->last_busno = bus->busn_res.end;
Oops, we just dereferenced a potentially NULL pointer here (of course, this could happen even before your patch).
I don't understand the platform_pcibios_fixup() that follows. I can't find a definition of that, but it sounds like something that maybe should happen before pci_bus_add_devices().
Quoted 20 lines
arch/xtensa/kernel/pci.c +0
-0if (next_busno <= pci_ctrl->last_busno)drivers/pci/probe.c +0
-1@@ -2087,7 +2087,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,if (!found)pci_bus_update_busn_res_end (b, max); -pci_bus_add_devices (b);return b; }EXPORT_SYMBOL (pci_scan_root_bus);Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 02/30] PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
Quoted 69 lines · Bjorn Helgaas
Quoted 56 lines · Yijing Wang
Just like
pci_scan_bus(), we also should rip outpci_bus_add_devices()frompci_scan_root_bus(). Lots platforms first callpci_scan_root_bus(), but after that, they callpci_bus_size_bridges()andpci_bus_assign_resources(). Placepci_bus_add_devices()inpci_scan_root_bus()hurts PCI scan logic. For armhw_pci->scan()functions which callpci_scan_root_bus(), it's no need to change anything, becausepci_bus_add_devices()will be called later inpci_common_init_dev().Signed-off-by Yijing Wang <[email protected]>CC Richard Henderson <[email protected]>CC Ivan Kokshaysky <[email protected]>CC Matt Turner <[email protected]>CC David Howells <[email protected]>CC Tony Luck <[email protected]>CC Michal Simek <[email protected]>CC Ralf Baechle <[email protected]>CC Koichi Yasutake <[email protected]>CC Sebastian Ott <[email protected]>CC "David S. Miller" <[email protected]>CC Chris Metcalf <[email protected]>CC Chris Zankel <[email protected]>CC Max Filippov <[email protected]>CC Thomas Gleixner <[email protected]>--- arch/alpha/kernel/pci.c | 2 ++ arch/frv/mb93090-mb00/pci-vdk.c | 6 ++++-- arch/ia64/sn/kernel/io_init.c | 1 + arch/microblaze/pci/pci-common.c | 1 + arch/mips/pci/pci.c | 1 + arch/mn10300/unit-asb2305/pci.c | 5 ++++- arch/s390/pci/pci.c | 2 +- arch/sh/drivers/pci/pci.c | 1 + arch/sparc/kernel/leon_pci.c | 1 + arch/tile/kernel/pci.c | 2 ++ arch/tile/kernel/pci_gx.c | 2 ++ arch/x86/pci/common.c | 1 + arch/xtensa/kernel/pci.c | 2 ++ drivers/pci/probe.c | 1 - 14 files changed, 23 insertions(+), 5 deletions(-)arch/alpha/kernel/pci.c +0
-0arch/alpha/kernel/pci.c common_init_pci(void) · line 345
Quoted 8 lines
arch/alpha/kernel/pci.c +2
-0@@ -338,6 +338,8 @@ common_init_pci(void) bus =pci_scan_root_bus (NULL , next_busno, alpha_mv.pci_ops, hose, &resources); +if (bus) +pci_bus_add_devices (bus); hose->bus = bus; hose->need_domain_info = need_domain_info; next_busno = bus->busn_res.end +1 ;This doesn't look right. The code above is inside a loop, and just after the loop we have:
Quoted 5 lines
pci_assign_unassigned_resources(); pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);I think the
pci_bus_add_devices()needs to go inside another loop after the assign andfixup_irqscode.
What about introduce a new function to add all pci bus here like:
pci_bus_add_devices_all()
{
struct pci_bus *root_bus;
list_for_each_entry(root_bus, &pci_root_buses, node)
pci_bus_add_devices(root_bus);
}pci_assign_unassigned_resources(); pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq); pci_bus_add_devices_all();
Quoted 9 lines
You didn't fix arm, but I think it has the same problem:
pci_common_init_dev
pcibios_init_hw
pci_scan_root_bus
pci_fixup_irqs
pci_bus_size_bridges
pci_bus_assign_resources
void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
{
struct pci_sys_data *sys;
LIST_HEAD(head);
pci_add_flags(PCI_REASSIGN_ALL_RSRC);
if (hw->preinit)
hw->preinit();
pcibios_init_hw(parent, hw, &head); --------> scan root bus
if (hw->postinit)
hw->postinit();
pci_fixup_irqs(pcibios_swizzle, pcibios_map_irq);
list_for_each_entry(sys, &head, node) {
struct pci_bus *bus = sys->bus;
if (!pci_has_flag(PCI_PROBE_ONLY)) {
/*
* Size the bridge windows.
*/
pci_bus_size_bridges(bus);
/*
* Assign resources.
*/
pci_bus_assign_resources(bus);
}
/*
* Tell drivers about devices found.
*/
pci_bus_add_devices(bus); ------>try to attach driver
}pci_bus_add_devices() is already in loops, so what problem here do you mean ?
Quoted 17 lines
Quoted 5 lines
arch/frv/mb93090-mb00/pci-vdk.c +0
-0arch/frv/mb93090-mb00/pci-vdk.c int __init pcibios_init(void) · line 393
Quoted 9 lines
arch/frv/mb93090-mb00/pci-vdk.c +3
-2-pci_scan_root_bus (NULL ,0 , pci_root_ops,NULL , &resources); + bus =pci_scan_root_bus (NULL ,0 , pci_root_ops,NULL , &resources);pcibios_irq_init ();pcibios_fixup_irqs ();pcibios_resource_survey (); - +if (bus) +pci_bus_add_devices (bus);It's one more line of code, but personally I would write:
Quoted 6 lines
if (!bus)
return 0;
pci_bus_add_devices(bus);
return 0;OK, will update it.
Quoted 14 lines
arch/ia64/sn/kernel/io_init.c sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus) · line 273
Quoted 10 lines
arch/frv/mb93090-mb00/pci-vdk.c +0
-0return 0 ; }arch/ia64/sn/kernel/io_init.c +0
-0@@ -272,6 +272,7 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)kfree (res);kfree (controller);This needs a "return;" right here. Otherwise we'll call
pci_bus_add_devices(NULL)below.
Sorry for my mistake, will correct it.
Quoted 18 lines
Quoted 10 lines
arch/ia64/sn/kernel/io_init.c +1
-0} +pci_bus_add_devices (bus); }/* arch/microblaze/pci/pci-common.c +0
-0arch/microblaze/pci/pci-common.c static void pcibios_scan_phb(struct pci_controller *hose) · line 1366
Quoted 5 lines
arch/microblaze/pci/pci-common.c +1
-0@@ -1362,6 +1362,7 @@ static void pcibios_scan_phb(struct pci_controller *hose) hose->bus = bus; hose->last_busno = bus->busn_res.end; +pci_bus_add_devices (bus); }I think this is still wrong:
Quoted 5 lines
pcibios_init
pcibios_scan_phb
pci_scan_root_bus
pci_bus_add_devices
pcibios_resource_survey<-- oops
We could also call pci_bus_add_devices_all() like above here ?
Quoted 16 lines
arch/mips/pci/pci.c static void pcibios_scanbus(struct pci_controller *hose) · line 118
Quoted 12 lines
arch/microblaze/pci/pci-common.c +0
-0static int __init pcibios_init (void )arch/mips/pci/pci.c +1
-0@@ -114,6 +114,7 @@ static void pcibios_scanbus(struct pci_controller *hose)pci_bus_size_bridges (bus);pci_bus_assign_resources (bus); } +pci_bus_add_devices (bus); }I would add a new patch at the end of your series to cosmetically restructure this as:
Quoted 7 lines
if (!bus)
return;
next_busno = bus->busn_res.end + 1;
...
pci_bus_add_devices(bus);That's good.
Quoted 21 lines
Quoted 21 lines
arch/mips/pci/pci.c +0
-0}arch/mn10300/unit-asb2305/pci.c +2
-1@@ -340,6 +340,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)*/ static int __init pcibios_init (void ) { +struct pci_bus *bus;resource_size_t io_offset, mem_offset;LIST_HEAD (resources);@@ -371,11 +372,13 @@ static int __init pcibios_init(void)pci_add_resource_offset (&resources, &pci_ioport_resource, io_offset);pci_add_resource_offset (&resources, &pci_iomem_resource, mem_offset); -pci_scan_root_bus (NULL ,0 , &pci_direct_ampci,NULL , &resources); + bus =pci_scan_root_bus (NULL ,0 , &pci_direct_ampci,NULL , &resources);
Quoted 10 lines
arch/mn10300/unit-asb2305/pci.c static int __init pcibios_init(void) · line 381
Quoted 5 lines
arch/mn10300/unit-asb2305/pci.c +2
-0pcibios_irq_init ();pcibios_fixup_irqs ();pcibios_resource_survey (); +if (bus) +pci_bus_add_devices (bus);if (!bus) return 0; pci_bus_add_devices(bus);
OK
Quoted 18 lines
Quoted 8 lines
arch/mn10300/unit-asb2305/pci.c +0
-0return 0 ; }arch/s390/pci/pci.c +0
-0arch/s390/pci/pci.c static int zpci_scan_bus(struct zpci_dev *zdev) · line 780
Quoted 6 lines
arch/s390/pci/pci.c +1
-1@@ -776,7 +776,7 @@ static int zpci_scan_bus(struct zpci_dev *zdev)zpci_cleanup_bus_resources (zdev);return -EIO ; } - +pci_bus_add_devices (zdev->bus); zdev->bus->max_bus_speed = zdev->max_bus_speed;We should set
zdev->bus->max_bus_speedbefore callingpci_bus_add_devices(). Some drivers look atmax_bus_speed.
OK, will adjust the order.
Quoted 17 lines
Quoted 7 lines
arch/s390/pci/pci.c +0
-0return 0 ; }arch/sh/drivers/pci/pci.c +0
-0arch/sh/drivers/pci/pci.c static void pcibios_scanbus(struct pci_channel *hose) · line 75
Quoted 7 lines
arch/sh/drivers/pci/pci.c +1
-0@@ -69,6 +69,7 @@ static void pcibios_scanbus(struct pci_channel *hose)pci_bus_size_bridges (bus);pci_bus_assign_resources (bus); +pci_bus_add_devices (bus); }else {pci_free_resource_list (&resources); }Cosmetic restructure (new patch at end of series):
Quoted 8 lines
if (!bus) {
pci_free_resource_list(&resources);
return;
}
next_busno = bus->busn_res.end + 1;
...
pci_bus_add_devices(bus);OK.
Quoted 37 lines
arch/sparc/kernel/leon_pci.c void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) · line 46
Quoted 13 lines
arch/sparc/kernel/leon_pci.c +1
-0@@ -40,6 +40,7 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)/* Assign devices with resources */ pci_assign_unassigned_resources (); +pci_bus_add_devices (root_bus); }else {pci_free_resource_list (&resources); }Restructure this with the same pattern (in a new patch).
Quoted 21 lines
arch/tile/kernel/pci.c +2
-0@@ -339,6 +339,8 @@ int __init pcibios_init(void)struct pci_bus *next_bus;struct pci_dev *dev; +pci_bus_add_devices (root_bus); +list_for_each_entry (dev, &root_bus->devices, bus_list) {/* * Find the PCI host controller, ie. the 1st arch/tile/kernel/pci_gx.c +0
-0@@ -916,6 +916,8 @@ int __init pcibios_init(void)/* Configure the max_payload_size values for this domain. */ fixup_read_and_payload_sizes (controller);
Quoted 9 lines
arch/tile/kernel/pci_gx.c int __init pcibios_init(void) · line 923
Quoted 5 lines
arch/tile/kernel/pci_gx.c +2
-0+pci_bus_add_devices (root_bus); +/* Alloc a PIO region for PCI memory access for each RC port. */ ret =gxio_trio_alloc_pio_regions (trio_context,1 ,0 ,0 );if (ret <0 ) {I don't know what all the magic
gxio_trio_allocand init stuff after this is, but it looks to me like thepci_bus_add_devices(root_bus)should be done *after* all of it.
I don't know much too, but I agree it, I would poke arch tile guys.
Quoted 15 lines
arch/x86/pci/common.c void pcibios_scan_root(int busnum) · line 494
Quoted 10 lines
arch/x86/pci/common.c +1
-0@@ -491,6 +491,7 @@ void pcibios_scan_root(int busnum)pci_free_resource_list (&resources);kfree (sd); } +pci_bus_add_devices (bus);This one is tricky. I don't think your patch makes it any worse than it is today, but it doesn't fix the problem. We need to either fix it or call it out in the changelog.
Quoted 8 lines
pci_subsys_init#subsys_initcall(level 4)
pci_legacy_init
pcibios_scan_root
pci_scan_root_bus
pci_bus_add_devices
pcibios_assign_resources#fs_initcall(level 5)
I would like to keep it here, and we know that in this routine, it is always in system boot up context. Which do you prefer ?
Quoted 19 lines
Quoted 8 lines
arch/x86/pci/common.c +0
-0}void __init pcibios_set_cache_line_size (void )arch/xtensa/kernel/pci.c +0
-0arch/xtensa/kernel/pci.c static int __init pcibios_init(void) · line 191
Quoted 7 lines
arch/xtensa/kernel/pci.c +2
-0@@ -185,6 +185,8 @@ static int __init pcibios_init(void)pci_controller_apertures (pci_ctrl, &resources); bus =pci_scan_root_bus (NULL , pci_ctrl->first_busno, pci_ctrl->ops, pci_ctrl, &resources); +if (bus) +pci_bus_add_devices (bus); pci_ctrl->bus = bus; pci_ctrl->last_busno = bus->busn_res.end;Oops, we just dereferenced a potentially NULL pointer here (of course, this could happen even before your patch).
Quoted 3 lines
I don't understand the
platform_pcibios_fixup()that follows. I can't find a definition of that, but it sounds like something that maybe should happen beforepci_bus_add_devices().
I Will move the pci_bus_add_devices() after the platform_pcibios_fixup(), because now only driver attachment in it, I think delay it is safe.
Thanks!
Yijing.
Quoted 24 lines
Quoted 21 lines
arch/xtensa/kernel/pci.c +0
-0if (next_busno <= pci_ctrl->last_busno)drivers/pci/probe.c +0
-1@@ -2087,7 +2087,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,if (!found)pci_bus_update_busn_res_end (b, max); -pci_bus_add_devices (b);return b; }EXPORT_SYMBOL (pci_scan_root_bus);Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html.
Signature · 2 lines
Thanks! Yijing
Re: [PATCH v4 02/30] PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
In reply to Bjorn HelgaasQuoted 69 lines · Bjorn Helgaas
Quoted 56 lines · Yijing Wang
Just like
pci_scan_bus(), we also should rip outpci_bus_add_devices()frompci_scan_root_bus(). Lots platforms first callpci_scan_root_bus(), but after that, they callpci_bus_size_bridges()andpci_bus_assign_resources(). Placepci_bus_add_devices()inpci_scan_root_bus()hurts PCI scan logic. For armhw_pci->scan()functions which callpci_scan_root_bus(), it's no need to change anything, becausepci_bus_add_devices()will be called later inpci_common_init_dev().Signed-off-by Yijing Wang <[email protected]>CC Richard Henderson <[email protected]>CC Ivan Kokshaysky <[email protected]>CC Matt Turner <[email protected]>CC David Howells <[email protected]>CC Tony Luck <[email protected]>CC Michal Simek <[email protected]>CC Ralf Baechle <[email protected]>CC Koichi Yasutake <[email protected]>CC Sebastian Ott <[email protected]>CC "David S. Miller" <[email protected]>CC Chris Metcalf <[email protected]>CC Chris Zankel <[email protected]>CC Max Filippov <[email protected]>CC Thomas Gleixner <[email protected]>--- arch/alpha/kernel/pci.c | 2 ++ arch/frv/mb93090-mb00/pci-vdk.c | 6 ++++-- arch/ia64/sn/kernel/io_init.c | 1 + arch/microblaze/pci/pci-common.c | 1 + arch/mips/pci/pci.c | 1 + arch/mn10300/unit-asb2305/pci.c | 5 ++++- arch/s390/pci/pci.c | 2 +- arch/sh/drivers/pci/pci.c | 1 + arch/sparc/kernel/leon_pci.c | 1 + arch/tile/kernel/pci.c | 2 ++ arch/tile/kernel/pci_gx.c | 2 ++ arch/x86/pci/common.c | 1 + arch/xtensa/kernel/pci.c | 2 ++ drivers/pci/probe.c | 1 - 14 files changed, 23 insertions(+), 5 deletions(-)arch/alpha/kernel/pci.c +0
-0arch/alpha/kernel/pci.c common_init_pci(void) · line 345
Quoted 8 lines
arch/alpha/kernel/pci.c +2
-0@@ -338,6 +338,8 @@ common_init_pci(void) bus =pci_scan_root_bus (NULL , next_busno, alpha_mv.pci_ops, hose, &resources); +if (bus) +pci_bus_add_devices (bus); hose->bus = bus; hose->need_domain_info = need_domain_info; next_busno = bus->busn_res.end +1 ;This doesn't look right. The code above is inside a loop, and just after the loop we have:
Quoted 5 lines
pci_assign_unassigned_resources(); pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);I think the
pci_bus_add_devices()needs to go inside another loop after the assign andfixup_irqscode.
What about introduce a new function to add all pci bus here like:
pci_bus_add_devices_all()
{
struct pci_bus *root_bus;
list_for_each_entry(root_bus, &pci_root_buses, node)
pci_bus_add_devices(root_bus);
}pci_assign_unassigned_resources(); pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq); pci_bus_add_devices_all();
Quoted 9 lines
You didn't fix arm, but I think it has the same problem:
pci_common_init_dev
pcibios_init_hw
pci_scan_root_bus
pci_fixup_irqs
pci_bus_size_bridges
pci_bus_assign_resources
void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
{
struct pci_sys_data *sys;
LIST_HEAD(head);
pci_add_flags(PCI_REASSIGN_ALL_RSRC);
if (hw->preinit)
hw->preinit();
pcibios_init_hw(parent, hw, &head); --------> scan root bus
if (hw->postinit)
hw->postinit();
pci_fixup_irqs(pcibios_swizzle, pcibios_map_irq);
list_for_each_entry(sys, &head, node) {
struct pci_bus *bus = sys->bus;
if (!pci_has_flag(PCI_PROBE_ONLY)) {
/*
* Size the bridge windows.
*/
pci_bus_size_bridges(bus);
/*
* Assign resources.
*/
pci_bus_assign_resources(bus);
}
/*
* Tell drivers about devices found.
*/
pci_bus_add_devices(bus); ------>try to attach driver
}pci_bus_add_devices() is already in loops, so what problem here do you mean ?
Quoted 17 lines
Quoted 5 lines
arch/frv/mb93090-mb00/pci-vdk.c +0
-0arch/frv/mb93090-mb00/pci-vdk.c int __init pcibios_init(void) · line 393
Quoted 9 lines
arch/frv/mb93090-mb00/pci-vdk.c +3
-2-pci_scan_root_bus (NULL ,0 , pci_root_ops,NULL , &resources); + bus =pci_scan_root_bus (NULL ,0 , pci_root_ops,NULL , &resources);pcibios_irq_init ();pcibios_fixup_irqs ();pcibios_resource_survey (); - +if (bus) +pci_bus_add_devices (bus);It's one more line of code, but personally I would write:
Quoted 6 lines
if (!bus)
return 0;
pci_bus_add_devices(bus);
return 0;OK, will update it.
Quoted 14 lines
arch/ia64/sn/kernel/io_init.c sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus) · line 273
Quoted 10 lines
arch/frv/mb93090-mb00/pci-vdk.c +0
-0return 0 ; }arch/ia64/sn/kernel/io_init.c +0
-0@@ -272,6 +272,7 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)kfree (res);kfree (controller);This needs a "return;" right here. Otherwise we'll call
pci_bus_add_devices(NULL)below.
Sorry for my mistake, will correct it.
Quoted 18 lines
Quoted 10 lines
arch/ia64/sn/kernel/io_init.c +1
-0} +pci_bus_add_devices (bus); }/* arch/microblaze/pci/pci-common.c +0
-0arch/microblaze/pci/pci-common.c static void pcibios_scan_phb(struct pci_controller *hose) · line 1366
Quoted 5 lines
arch/microblaze/pci/pci-common.c +1
-0@@ -1362,6 +1362,7 @@ static void pcibios_scan_phb(struct pci_controller *hose) hose->bus = bus; hose->last_busno = bus->busn_res.end; +pci_bus_add_devices (bus); }I think this is still wrong:
Quoted 5 lines
pcibios_init
pcibios_scan_phb
pci_scan_root_bus
pci_bus_add_devices
pcibios_resource_survey<-- oops
We could also call pci_bus_add_devices_all() like above here ?
Quoted 16 lines
arch/mips/pci/pci.c static void pcibios_scanbus(struct pci_controller *hose) · line 118
Quoted 12 lines
arch/microblaze/pci/pci-common.c +0
-0static int __init pcibios_init (void )arch/mips/pci/pci.c +1
-0@@ -114,6 +114,7 @@ static void pcibios_scanbus(struct pci_controller *hose)pci_bus_size_bridges (bus);pci_bus_assign_resources (bus); } +pci_bus_add_devices (bus); }I would add a new patch at the end of your series to cosmetically restructure this as:
Quoted 7 lines
if (!bus)
return;
next_busno = bus->busn_res.end + 1;
...
pci_bus_add_devices(bus);That's good.
Quoted 21 lines
Quoted 21 lines
arch/mips/pci/pci.c +0
-0}arch/mn10300/unit-asb2305/pci.c +2
-1@@ -340,6 +340,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)*/ static int __init pcibios_init (void ) { +struct pci_bus *bus;resource_size_t io_offset, mem_offset;LIST_HEAD (resources);@@ -371,11 +372,13 @@ static int __init pcibios_init(void)pci_add_resource_offset (&resources, &pci_ioport_resource, io_offset);pci_add_resource_offset (&resources, &pci_iomem_resource, mem_offset); -pci_scan_root_bus (NULL ,0 , &pci_direct_ampci,NULL , &resources); + bus =pci_scan_root_bus (NULL ,0 , &pci_direct_ampci,NULL , &resources);
Quoted 10 lines
arch/mn10300/unit-asb2305/pci.c static int __init pcibios_init(void) · line 381
Quoted 5 lines
arch/mn10300/unit-asb2305/pci.c +2
-0pcibios_irq_init ();pcibios_fixup_irqs ();pcibios_resource_survey (); +if (bus) +pci_bus_add_devices (bus);if (!bus) return 0; pci_bus_add_devices(bus);
OK
Quoted 18 lines
Quoted 8 lines
arch/mn10300/unit-asb2305/pci.c +0
-0return 0 ; }arch/s390/pci/pci.c +0
-0arch/s390/pci/pci.c static int zpci_scan_bus(struct zpci_dev *zdev) · line 780
Quoted 6 lines
arch/s390/pci/pci.c +1
-1@@ -776,7 +776,7 @@ static int zpci_scan_bus(struct zpci_dev *zdev)zpci_cleanup_bus_resources (zdev);return -EIO ; } - +pci_bus_add_devices (zdev->bus); zdev->bus->max_bus_speed = zdev->max_bus_speed;We should set
zdev->bus->max_bus_speedbefore callingpci_bus_add_devices(). Some drivers look atmax_bus_speed.
OK, will adjust the order.
Quoted 17 lines
Quoted 7 lines
arch/s390/pci/pci.c +0
-0return 0 ; }arch/sh/drivers/pci/pci.c +0
-0arch/sh/drivers/pci/pci.c static void pcibios_scanbus(struct pci_channel *hose) · line 75
Quoted 7 lines
arch/sh/drivers/pci/pci.c +1
-0@@ -69,6 +69,7 @@ static void pcibios_scanbus(struct pci_channel *hose)pci_bus_size_bridges (bus);pci_bus_assign_resources (bus); +pci_bus_add_devices (bus); }else {pci_free_resource_list (&resources); }Cosmetic restructure (new patch at end of series):
Quoted 8 lines
if (!bus) {
pci_free_resource_list(&resources);
return;
}
next_busno = bus->busn_res.end + 1;
...
pci_bus_add_devices(bus);OK.
Quoted 37 lines
arch/sparc/kernel/leon_pci.c void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) · line 46
Quoted 13 lines
arch/sparc/kernel/leon_pci.c +1
-0@@ -40,6 +40,7 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)/* Assign devices with resources */ pci_assign_unassigned_resources (); +pci_bus_add_devices (root_bus); }else {pci_free_resource_list (&resources); }Restructure this with the same pattern (in a new patch).
Quoted 21 lines
arch/tile/kernel/pci.c +2
-0@@ -339,6 +339,8 @@ int __init pcibios_init(void)struct pci_bus *next_bus;struct pci_dev *dev; +pci_bus_add_devices (root_bus); +list_for_each_entry (dev, &root_bus->devices, bus_list) {/* * Find the PCI host controller, ie. the 1st arch/tile/kernel/pci_gx.c +0
-0@@ -916,6 +916,8 @@ int __init pcibios_init(void)/* Configure the max_payload_size values for this domain. */ fixup_read_and_payload_sizes (controller);
Quoted 9 lines
arch/tile/kernel/pci_gx.c int __init pcibios_init(void) · line 923
Quoted 5 lines
arch/tile/kernel/pci_gx.c +2
-0+pci_bus_add_devices (root_bus); +/* Alloc a PIO region for PCI memory access for each RC port. */ ret =gxio_trio_alloc_pio_regions (trio_context,1 ,0 ,0 );if (ret <0 ) {I don't know what all the magic
gxio_trio_allocand init stuff after this is, but it looks to me like thepci_bus_add_devices(root_bus)should be done *after* all of it.
I don't know much too, but I agree it, I would poke arch tile guys.
Quoted 15 lines
arch/x86/pci/common.c void pcibios_scan_root(int busnum) · line 494
Quoted 10 lines
arch/x86/pci/common.c +1
-0@@ -491,6 +491,7 @@ void pcibios_scan_root(int busnum)pci_free_resource_list (&resources);kfree (sd); } +pci_bus_add_devices (bus);This one is tricky. I don't think your patch makes it any worse than it is today, but it doesn't fix the problem. We need to either fix it or call it out in the changelog.
Quoted 8 lines
pci_subsys_init#subsys_initcall(level 4)
pci_legacy_init
pcibios_scan_root
pci_scan_root_bus
pci_bus_add_devices
pcibios_assign_resources#fs_initcall(level 5)
I would like to keep it here, and we know that in this routine, it is always in system boot up context. Which do you prefer ?
Quoted 19 lines
Quoted 8 lines
arch/x86/pci/common.c +0
-0}void __init pcibios_set_cache_line_size (void )arch/xtensa/kernel/pci.c +0
-0arch/xtensa/kernel/pci.c static int __init pcibios_init(void) · line 191
Quoted 7 lines
arch/xtensa/kernel/pci.c +2
-0@@ -185,6 +185,8 @@ static int __init pcibios_init(void)pci_controller_apertures (pci_ctrl, &resources); bus =pci_scan_root_bus (NULL , pci_ctrl->first_busno, pci_ctrl->ops, pci_ctrl, &resources); +if (bus) +pci_bus_add_devices (bus); pci_ctrl->bus = bus; pci_ctrl->last_busno = bus->busn_res.end;Oops, we just dereferenced a potentially NULL pointer here (of course, this could happen even before your patch).
Quoted 3 lines
I don't understand the
platform_pcibios_fixup()that follows. I can't find a definition of that, but it sounds like something that maybe should happen beforepci_bus_add_devices().
I Will move the pci_bus_add_devices() after the platform_pcibios_fixup(), because now only driver attachment in it, I think delay it is safe.
Thanks!
Yijing.
Quoted 24 lines
Quoted 21 lines
arch/xtensa/kernel/pci.c +0
-0if (next_busno <= pci_ctrl->last_busno)drivers/pci/probe.c +0
-1@@ -2087,7 +2087,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,if (!found)pci_bus_update_busn_res_end (b, max); -pci_bus_add_devices (b);return b; }EXPORT_SYMBOL (pci_scan_root_bus);Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html.
Signature · 2 lines
Thanks! Yijing
Bjorn Helgaas
maintainerRe: [PATCH v4 02/30] PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
In reply to Yijing WangQuoted 56 lines · Yijing Wang
Just like
pci_scan_bus(), we also should rip outpci_bus_add_devices()frompci_scan_root_bus(). Lots platforms first callpci_scan_root_bus(), but after that, they callpci_bus_size_bridges()andpci_bus_assign_resources(). Placepci_bus_add_devices()inpci_scan_root_bus()hurts PCI scan logic. For armhw_pci->scan()functions which callpci_scan_root_bus(), it's no need to change anything, becausepci_bus_add_devices()will be called later inpci_common_init_dev().Signed-off-by Yijing Wang <[email protected]>CC Richard Henderson <[email protected]>CC Ivan Kokshaysky <[email protected]>CC Matt Turner <[email protected]>CC David Howells <[email protected]>CC Tony Luck <[email protected]>CC Michal Simek <[email protected]>CC Ralf Baechle <[email protected]>CC Koichi Yasutake <[email protected]>CC Sebastian Ott <[email protected]>CC "David S. Miller" <[email protected]>CC Chris Metcalf <[email protected]>CC Chris Zankel <[email protected]>CC Max Filippov <[email protected]>CC Thomas Gleixner <[email protected]>--- arch/alpha/kernel/pci.c | 2 ++ arch/frv/mb93090-mb00/pci-vdk.c | 6 ++++-- arch/ia64/sn/kernel/io_init.c | 1 + arch/microblaze/pci/pci-common.c | 1 + arch/mips/pci/pci.c | 1 + arch/mn10300/unit-asb2305/pci.c | 5 ++++- arch/s390/pci/pci.c | 2 +- arch/sh/drivers/pci/pci.c | 1 + arch/sparc/kernel/leon_pci.c | 1 + arch/tile/kernel/pci.c | 2 ++ arch/tile/kernel/pci_gx.c | 2 ++ arch/x86/pci/common.c | 1 + arch/xtensa/kernel/pci.c | 2 ++ drivers/pci/probe.c | 1 - 14 files changed, 23 insertions(+), 5 deletions(-)arch/alpha/kernel/pci.c +0
-0
arch/alpha/kernel/pci.c common_init_pci(void) · line 345
Quoted 8 lines
arch/alpha/kernel/pci.c +2
-0@@ -338,6 +338,8 @@ common_init_pci(void) bus =pci_scan_root_bus (NULL , next_busno, alpha_mv.pci_ops, hose, &resources); +if (bus) +pci_bus_add_devices (bus); hose->bus = bus; hose->need_domain_info = need_domain_info; next_busno = bus->busn_res.end +1 ;
This doesn't look right. The code above is inside a loop, and just after the loop we have:
pci_assign_unassigned_resources();
pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq);I think the pci_bus_add_devices() needs to go inside another loop after the assign and fixup_irqs code.
You didn't fix arm, but I think it has the same problem:
pci_common_init_dev
pcibios_init_hw
pci_scan_root_bus
pci_fixup_irqs
pci_bus_size_bridges
pci_bus_assign_resources
Quoted 15 lines
arch/frv/mb93090-mb00/pci-vdk.c +1
-0@@ -316,6 +316,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)int __init pcibios_init (void ) { +struct pci_bus *bus;struct pci_ops *dir =NULL ;LIST_HEAD (resources);@@ -383,12 +384,13 @@ int __init pcibios_init(void)printk ("PCI: Probing PCI hardware\n" );pci_add_resource (&resources, &pci_ioport_resource);
arch/frv/mb93090-mb00/pci-vdk.c int __init pcibios_init(void) · line 393
Quoted 10 lines
arch/frv/mb93090-mb00/pci-vdk.c +3
-2pci_add_resource (&resources, &pci_iomem_resource); -pci_scan_root_bus (NULL ,0 , pci_root_ops,NULL , &resources); + bus =pci_scan_root_bus (NULL ,0 , pci_root_ops,NULL , &resources);pcibios_irq_init ();pcibios_fixup_irqs ();pcibios_resource_survey (); - +if (bus) +pci_bus_add_devices (bus);
It's one more line of code, but personally I would write:
if (!bus)
return 0;
pci_bus_add_devices(bus);
return 0;arch/ia64/sn/kernel/io_init.c sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus) · line 273
Quoted 10 lines
arch/frv/mb93090-mb00/pci-vdk.c +0
-0return 0 ; }arch/ia64/sn/kernel/io_init.c +0
-0@@ -272,6 +272,7 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)kfree (res);kfree (controller);
This needs a "return;" right here. Otherwise we'll call pci_bus_add_devices(NULL) below.
Quoted 10 lines
arch/ia64/sn/kernel/io_init.c +1
-0} +pci_bus_add_devices (bus); }/* arch/microblaze/pci/pci-common.c +0
-0
arch/microblaze/pci/pci-common.c static void pcibios_scan_phb(struct pci_controller *hose) · line 1366
Quoted 5 lines
arch/microblaze/pci/pci-common.c +1
-0@@ -1362,6 +1362,7 @@ static void pcibios_scan_phb(struct pci_controller *hose) hose->bus = bus; hose->last_busno = bus->busn_res.end; +pci_bus_add_devices (bus); }
I think this is still wrong:
pcibios_init
pcibios_scan_phb
pci_scan_root_bus
pci_bus_add_devices
pcibios_resource_survey <-- oops
arch/mips/pci/pci.c static void pcibios_scanbus(struct pci_controller *hose) · line 118
Quoted 12 lines
arch/microblaze/pci/pci-common.c +0
-0static int __init pcibios_init (void )arch/mips/pci/pci.c +1
-0@@ -114,6 +114,7 @@ static void pcibios_scanbus(struct pci_controller *hose)pci_bus_size_bridges (bus);pci_bus_assign_resources (bus); } +pci_bus_add_devices (bus); }
I would add a new patch at the end of your series to cosmetically restructure this as:
if (!bus)
return;
next_busno = bus->busn_res.end + 1;
...
pci_bus_add_devices(bus);Quoted 16 lines
arch/mips/pci/pci.c +0
-0}arch/mn10300/unit-asb2305/pci.c +1
-0@@ -340,6 +340,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)*/ static int __init pcibios_init (void ) { +struct pci_bus *bus;resource_size_t io_offset, mem_offset;LIST_HEAD (resources);@@ -371,11 +372,13 @@ static int __init pcibios_init(void)
arch/mn10300/unit-asb2305/pci.c static int __init pcibios_init(void) · line 381
Quoted 10 lines
arch/mn10300/unit-asb2305/pci.c +3
-1pci_add_resource_offset (&resources, &pci_ioport_resource, io_offset);pci_add_resource_offset (&resources, &pci_iomem_resource, mem_offset); -pci_scan_root_bus (NULL ,0 , &pci_direct_ampci,NULL , &resources); + bus =pci_scan_root_bus (NULL ,0 , &pci_direct_ampci,NULL , &resources);pcibios_irq_init ();pcibios_fixup_irqs ();pcibios_resource_survey (); +if (bus) +pci_bus_add_devices (bus);
if (!bus)
return 0;
pci_bus_add_devices(bus);Quoted 8 lines
arch/mn10300/unit-asb2305/pci.c +0
-0return 0 ; }arch/s390/pci/pci.c +0
-0
arch/s390/pci/pci.c static int zpci_scan_bus(struct zpci_dev *zdev) · line 780
Quoted 6 lines
arch/s390/pci/pci.c +1
-1@@ -776,7 +776,7 @@ static int zpci_scan_bus(struct zpci_dev *zdev)zpci_cleanup_bus_resources (zdev);return -EIO ; } - +pci_bus_add_devices (zdev->bus); zdev->bus->max_bus_speed = zdev->max_bus_speed;
We should set zdev->bus->max_bus_speed before calling pci_bus_add_devices(). Some drivers look at max_bus_speed.
Quoted 7 lines
arch/s390/pci/pci.c +0
-0return 0 ; }arch/sh/drivers/pci/pci.c +0
-0
arch/sh/drivers/pci/pci.c static void pcibios_scanbus(struct pci_channel *hose) · line 75
Quoted 7 lines
arch/sh/drivers/pci/pci.c +1
-0@@ -69,6 +69,7 @@ static void pcibios_scanbus(struct pci_channel *hose)pci_bus_size_bridges (bus);pci_bus_assign_resources (bus); +pci_bus_add_devices (bus); }else {pci_free_resource_list (&resources); }
Cosmetic restructure (new patch at end of series):
if (!bus) {
pci_free_resource_list(&resources);
return;
}
next_busno = bus->busn_res.end + 1;
...
pci_bus_add_devices(bus);arch/sparc/kernel/leon_pci.c void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) · line 46
Quoted 12 lines
arch/sparc/kernel/leon_pci.c +1
-0@@ -40,6 +40,7 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)/* Assign devices with resources */ pci_assign_unassigned_resources (); +pci_bus_add_devices (root_bus); }else {pci_free_resource_list (&resources); }
Restructure this with the same pattern (in a new patch).
Quoted 18 lines
arch/tile/kernel/pci.c +2
-0@@ -339,6 +339,8 @@ int __init pcibios_init(void)struct pci_bus *next_bus;struct pci_dev *dev; +pci_bus_add_devices (root_bus); +list_for_each_entry (dev, &root_bus->devices, bus_list) {/* * Find the PCI host controller, ie. the 1st arch/tile/kernel/pci_gx.c +0
-0
arch/tile/kernel/pci_gx.c int __init pcibios_init(void) · line 923
Quoted 8 lines
arch/tile/kernel/pci_gx.c +2
-0@@ -916,6 +916,8 @@ int __init pcibios_init(void)/* Configure the max_payload_size values for this domain. */ fixup_read_and_payload_sizes (controller); +pci_bus_add_devices (root_bus); +/* Alloc a PIO region for PCI memory access for each RC port. */ ret =gxio_trio_alloc_pio_regions (trio_context,1 ,0 ,0 );if (ret <0 ) {
I don't know what all the magic gxio_trio_alloc and init stuff after this is, but it looks to me like the pci_bus_add_devices(root_bus) should be done *after* all of it.
arch/x86/pci/common.c void pcibios_scan_root(int busnum) · line 494
Quoted 9 lines
arch/x86/pci/common.c +1
-0@@ -491,6 +491,7 @@ void pcibios_scan_root(int busnum)pci_free_resource_list (&resources);kfree (sd); } +pci_bus_add_devices (bus);
This one is tricky. I don't think your patch makes it any worse than it is today, but it doesn't fix the problem. We need to either fix it or call it out in the changelog.
pci_subsys_init # subsys_initcall (level 4)
pci_legacy_init
pcibios_scan_root
pci_scan_root_bus
pci_bus_add_devices
pcibios_assign_resources # fs_initcall (level 5)
Quoted 8 lines
arch/x86/pci/common.c +0
-0}void __init pcibios_set_cache_line_size (void )arch/xtensa/kernel/pci.c +0
-0
arch/xtensa/kernel/pci.c static int __init pcibios_init(void) · line 191
Quoted 7 lines
arch/xtensa/kernel/pci.c +2
-0@@ -185,6 +185,8 @@ static int __init pcibios_init(void)pci_controller_apertures (pci_ctrl, &resources); bus =pci_scan_root_bus (NULL , pci_ctrl->first_busno, pci_ctrl->ops, pci_ctrl, &resources); +if (bus) +pci_bus_add_devices (bus); pci_ctrl->bus = bus; pci_ctrl->last_busno = bus->busn_res.end;
Oops, we just dereferenced a potentially NULL pointer here (of course, this could happen even before your patch).
I don't understand the platform_pcibios_fixup() that follows. I can't find a definition of that, but it sounds like something that maybe should happen before pci_bus_add_devices().
Quoted 20 lines
arch/xtensa/kernel/pci.c +0
-0if (next_busno <= pci_ctrl->last_busno)drivers/pci/probe.c +0
-1@@ -2087,7 +2087,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,if (!found)pci_bus_update_busn_res_end (b, max); -pci_bus_add_devices (b);return b; }EXPORT_SYMBOL (pci_scan_root_bus);Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 2/30 PCI: Rip out pci_bus_add_devices() from pci_scan_root_bus()
In reply to Yijing WangJust like pci_scan_bus(), we also should rip out pci_bus_add_devices() from pci_scan_root_bus(). Lots platforms first call pci_scan_root_bus(), but after that, they call pci_bus_size_bridges() and pci_bus_assign_resources(). Place pci_bus_add_devices() in pci_scan_root_bus() hurts PCI scan logic. For arm hw_pci->scan() functions which call pci_scan_root_bus(), it's no need to change anything, because pci_bus_add_devices() will be called later in pci_common_init_dev().
--- arch/alpha/kernel/pci.c | 2 ++ arch/frv/mb93090-mb00/pci-vdk.c | 6 ++++-- arch/ia64/sn/kernel/io_init.c | 1 + arch/microblaze/pci/pci-common.c | 1 + arch/mips/pci/pci.c | 1 + arch/mn10300/unit-asb2305/pci.c | 5 ++++- arch/s390/pci/pci.c | 2 +- arch/sh/drivers/pci/pci.c | 1 + arch/sparc/kernel/leon_pci.c | 1 + arch/tile/kernel/pci.c | 2 ++ arch/tile/kernel/pci_gx.c | 2 ++ arch/x86/pci/common.c | 1 + arch/xtensa/kernel/pci.c | 2 ++ drivers/pci/probe.c | 1 - 14 files changed, 23 insertions(+), 5 deletions(-)
arch/alpha/kernel/pci.c +2 -0
@@ -338,6 +338,8 @@ common_init_pci(void) bus =pci_scan_root_bus (NULL , next_busno, alpha_mv.pci_ops, hose, &resources); +if (bus) +pci_bus_add_devices (bus); hose->bus = bus; hose->need_domain_info = need_domain_info; next_busno = bus->busn_res.end +1 ;
arch/frv/mb93090-mb00/pci-vdk.c +4 -2
@@ -316,6 +316,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)int __init pcibios_init (void ) { +struct pci_bus *bus;struct pci_ops *dir =NULL ;LIST_HEAD (resources);
@@ -383,12 +384,13 @@ int __init pcibios_init(void)printk ("PCI: Probing PCI hardware\n" );pci_add_resource (&resources, &pci_ioport_resource);pci_add_resource (&resources, &pci_iomem_resource); -pci_scan_root_bus (NULL ,0 , pci_root_ops,NULL , &resources); + bus =pci_scan_root_bus (NULL ,0 , pci_root_ops,NULL , &resources);pcibios_irq_init ();pcibios_fixup_irqs ();pcibios_resource_survey (); - +if (bus) +pci_bus_add_devices (bus);return 0 ; }
arch/ia64/sn/kernel/io_init.c +1 -0
@@ -272,6 +272,7 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)kfree (res);kfree (controller); } +pci_bus_add_devices (bus); }/*
arch/microblaze/pci/pci-common.c +1 -0
@@ -1362,6 +1362,7 @@ static void pcibios_scan_phb(struct pci_controller *hose) hose->bus = bus; hose->last_busno = bus->busn_res.end; +pci_bus_add_devices (bus); }static int __init pcibios_init (void )
arch/mips/pci/pci.c +1 -0
@@ -114,6 +114,7 @@ static void pcibios_scanbus(struct pci_controller *hose)pci_bus_size_bridges (bus);pci_bus_assign_resources (bus); } +pci_bus_add_devices (bus); } }
arch/mn10300/unit-asb2305/pci.c +4 -1
@@ -340,6 +340,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)*/ static int __init pcibios_init (void ) { +struct pci_bus *bus;resource_size_t io_offset, mem_offset;LIST_HEAD (resources);
@@ -371,11 +372,13 @@ static int __init pcibios_init(void)pci_add_resource_offset (&resources, &pci_ioport_resource, io_offset);pci_add_resource_offset (&resources, &pci_iomem_resource, mem_offset); -pci_scan_root_bus (NULL ,0 , &pci_direct_ampci,NULL , &resources); + bus =pci_scan_root_bus (NULL ,0 , &pci_direct_ampci,NULL , &resources);pcibios_irq_init ();pcibios_fixup_irqs ();pcibios_resource_survey (); +if (bus) +pci_bus_add_devices (bus);return 0 ; }
arch/s390/pci/pci.c +1 -1
@@ -776,7 +776,7 @@ static int zpci_scan_bus(struct zpci_dev *zdev)zpci_cleanup_bus_resources (zdev);return -EIO ; } - +pci_bus_add_devices (zdev->bus); zdev->bus->max_bus_speed = zdev->max_bus_speed;return 0 ; }
arch/sh/drivers/pci/pci.c +1 -0
@@ -69,6 +69,7 @@ static void pcibios_scanbus(struct pci_channel *hose)pci_bus_size_bridges (bus);pci_bus_assign_resources (bus); +pci_bus_add_devices (bus); }else {pci_free_resource_list (&resources); }
arch/sparc/kernel/leon_pci.c +1 -0
@@ -40,6 +40,7 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)/* Assign devices with resources */ pci_assign_unassigned_resources (); +pci_bus_add_devices (root_bus); }else {pci_free_resource_list (&resources); }
arch/tile/kernel/pci.c +2 -0
@@ -339,6 +339,8 @@ int __init pcibios_init(void)struct pci_bus *next_bus;struct pci_dev *dev; +pci_bus_add_devices (root_bus); +list_for_each_entry (dev, &root_bus->devices, bus_list) {/* * Find the PCI host controller, ie. the 1st
arch/tile/kernel/pci_gx.c +2 -0
@@ -916,6 +916,8 @@ int __init pcibios_init(void)/* Configure the max_payload_size values for this domain. */ fixup_read_and_payload_sizes (controller); +pci_bus_add_devices (root_bus); +/* Alloc a PIO region for PCI memory access for each RC port. */ ret =gxio_trio_alloc_pio_regions (trio_context,1 ,0 ,0 );if (ret <0 ) {
arch/x86/pci/common.c +1 -0
@@ -491,6 +491,7 @@ void pcibios_scan_root(int busnum)pci_free_resource_list (&resources);kfree (sd); } +pci_bus_add_devices (bus); }void __init pcibios_set_cache_line_size (void )
arch/xtensa/kernel/pci.c +2 -0
@@ -185,6 +185,8 @@ static int __init pcibios_init(void)pci_controller_apertures (pci_ctrl, &resources); bus =pci_scan_root_bus (NULL , pci_ctrl->first_busno, pci_ctrl->ops, pci_ctrl, &resources); +if (bus) +pci_bus_add_devices (bus); pci_ctrl->bus = bus; pci_ctrl->last_busno = bus->busn_res.end;if (next_busno <= pci_ctrl->last_busno)
drivers/pci/probe.c +0 -1
@@ -2087,7 +2087,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,if (!found)pci_bus_update_busn_res_end (b, max); -pci_bus_add_devices (b);return b; }EXPORT_SYMBOL (pci_scan_root_bus);
Signature · 1 line
1.7.1
PATCH v4 3/30 xen/PCI: Don't use deprecated function pci_scan_bus_parented()
In reply to Yijing WangFrom: Arnd Bergmann <[email protected]>
Use pci_scan_root_bus() instead of deprecated function pci_scan_bus_parented().
--- drivers/pci/xen-pcifront.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
drivers/pci/xen-pcifront.c +7 -3
@@ -446,6 +446,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev, unsigned int domain, unsigned int bus) {struct pci_bus *b; +LIST_HEAD (resources);struct pcifront_sd *sd =NULL ;struct pci_bus_entry *bus_entry =NULL ;int err =0 ;
@@ -470,17 +471,20 @@ static int pcifront_scan_root(struct pcifront_device *pdev, err = -ENOMEM ; goto err_out; } +pci_add_resource (&resources, &ioport_resource); +pci_add_resource (&resources, &iomem_resource);pcifront_init_sd (sd, domain, bus, pdev);pci_lock_rescan_remove (); - b =pci_scan_bus_parented (&pdev->xdev->dev, bus, - &pcifront_bus_ops, sd); + b =pci_scan_root_bus (&pdev->xdev->dev, bus, + &pcifront_bus_ops, sd, &resources);if (!b) {dev_err (&pdev->xdev->dev,"Error creating PCI Frontend Bus!\n" ); err = -ENOMEM ;pci_unlock_rescan_remove (); +pci_free_resource_list (&resources); goto err_out; }
@@ -488,7 +492,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,list_add (&bus_entry->list, &pdev->root_buses); -/* pci_scan_bus_parented skips devices which do not have a have +/* pci_scan_root_bus skips devices which do not have a have * devfn==0. The pcifront_scan_bus enumerates all devfn. */ err =pcifront_scan_bus (pdev, domain, bus, b);
Signature · 1 line
1.7.1
Bjorn Helgaas
maintainerRe: [PATCH v4 03/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
Quoted 26 lines · Yijing Wang
From: Arnd Bergmann <[email protected]>
Use
pci_scan_root_bus()instead of deprecated functionpci_scan_bus_parented().Signed-off-by Arnd Bergmann <[email protected]>Signed-off-by Yijing Wang <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>--- drivers/pci/xen-pcifront.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)drivers/pci/xen-pcifront.c +1
-0@@ -446,6 +446,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev, unsigned int domain, unsigned int bus) {struct pci_bus *b; +LIST_HEAD (resources);struct pcifront_sd *sd =NULL ;struct pci_bus_entry *bus_entry =NULL ;int err =0 ;
drivers/pci/xen-pcifront.c static int pcifront_scan_root(struct pcifront_device *pdev, · line 475
Quoted 5 lines
drivers/pci/xen-pcifront.c +2
-0@@ -470,17 +471,20 @@ static int pcifront_scan_root(struct pcifront_device *pdev, err = -ENOMEM ; goto err_out; } +pci_add_resource (&resources, &ioport_resource); +pci_add_resource (&resources, &iomem_resource);
This doesn't add &busn_resource like pci_scan_bus_parented() does. That might be OK, but I think we'll now emit "No busn resource found for root bus, will use [bus %02x-ff]" when we didn't before. I don't know how xen-pcifront works; it would be nice if it could supply the correct bus resource (and ioport and iomem).
Quoted 18 lines
drivers/pci/xen-pcifront.c +3
-2pcifront_init_sd (sd, domain, bus, pdev);pci_lock_rescan_remove (); - b =pci_scan_bus_parented (&pdev->xdev->dev, bus, - &pcifront_bus_ops, sd); + b =pci_scan_root_bus (&pdev->xdev->dev, bus, + &pcifront_bus_ops, sd, &resources);if (!b) {dev_err (&pdev->xdev->dev,"Error creating PCI Frontend Bus!\n" ); err = -ENOMEM ;pci_unlock_rescan_remove (); +pci_free_resource_list (&resources); goto err_out; }
drivers/pci/xen-pcifront.c static int pcifront_scan_root(struct pcifront_device *pdev, · line 495
Quoted 5 lines
drivers/pci/xen-pcifront.c +1
-1@@ -488,7 +492,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,list_add (&bus_entry->list, &pdev->root_buses); -/* pci_scan_bus_parented skips devices which do not have a have +/* pci_scan_root_bus skips devices which do not have a have
Please fix the comment typo at the same time ("have a have").
Quoted 6 lines
drivers/pci/xen-pcifront.c +0
-0* devfn==0. The pcifront_scan_bus enumerates all devfn. */ err =pcifront_scan_bus (pdev, domain, bus, b);Signature · 1 line
1.7.1
Re: [PATCH v4 03/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
Quoted 14 lines
Quoted 14 lines
drivers/pci/xen-pcifront.c +1
-0@@ -446,6 +446,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev, unsigned int domain, unsigned int bus) {struct pci_bus *b; +LIST_HEAD (resources);struct pcifront_sd *sd =NULL ;struct pci_bus_entry *bus_entry =NULL ;int err =0 ;@@ -470,17 +471,20 @@ static int pcifront_scan_root(struct pcifront_device *pdev, err = -ENOMEM ; goto err_out; }
Quoted 8 lines
drivers/pci/xen-pcifront.c static int pcifront_scan_root(struct pcifront_device *pdev, · line 475
Quoted 2 lines
drivers/pci/xen-pcifront.c +2
-0+pci_add_resource (&resources, &ioport_resource); +pci_add_resource (&resources, &iomem_resource);This doesn't add
&busn_resourcelikepci_scan_bus_parented()does. That might be OK, but I think we'll now emit "No busn resource found for root bus, will use [bus %02x-ff]" when we didn't before. I don't know how xen-pcifront works; it would be nice if it could supply the correct bus resource (and ioport and iomem).
Because the pci_scan_bus_parented() add the default busn_resource for it, I would add the default busn_resource in pcifront_scan_root() too to fix the "No busn resource found ..." debug info.
Quoted 18 lines
Quoted 18 lines
drivers/pci/xen-pcifront.c +3
-2pcifront_init_sd (sd, domain, bus, pdev);pci_lock_rescan_remove (); - b =pci_scan_bus_parented (&pdev->xdev->dev, bus, - &pcifront_bus_ops, sd); + b =pci_scan_root_bus (&pdev->xdev->dev, bus, + &pcifront_bus_ops, sd, &resources);if (!b) {dev_err (&pdev->xdev->dev,"Error creating PCI Frontend Bus!\n" ); err = -ENOMEM ;pci_unlock_rescan_remove (); +pci_free_resource_list (&resources); goto err_out; }
Quoted 8 lines
drivers/pci/xen-pcifront.c static int pcifront_scan_root(struct pcifront_device *pdev, · line 495
Quoted 6 lines
drivers/pci/xen-pcifront.c +1
-1@@ -488,7 +492,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,list_add (&bus_entry->list, &pdev->root_buses); -/* pci_scan_bus_parented skips devices which do not have a have +/* pci_scan_root_bus skips devices which do not have a have Please fix the comment typo at the same time ("have a have").
Ok.
Quoted 10 lines
Quoted 7 lines
drivers/pci/xen-pcifront.c +0
-0* devfn==0. The pcifront_scan_bus enumerates all devfn. */ err =pcifront_scan_bus (pdev, domain, bus, b);Signature · 1 line
1.7.1.
Signature · 2 lines
Thanks! Yijing
Re: [PATCH v4 03/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
In reply to Bjorn HelgaasQuoted 14 lines
Quoted 14 lines
drivers/pci/xen-pcifront.c +1
-0@@ -446,6 +446,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev, unsigned int domain, unsigned int bus) {struct pci_bus *b; +LIST_HEAD (resources);struct pcifront_sd *sd =NULL ;struct pci_bus_entry *bus_entry =NULL ;int err =0 ;@@ -470,17 +471,20 @@ static int pcifront_scan_root(struct pcifront_device *pdev, err = -ENOMEM ; goto err_out; }
Quoted 8 lines
drivers/pci/xen-pcifront.c static int pcifront_scan_root(struct pcifront_device *pdev, · line 475
Quoted 2 lines
drivers/pci/xen-pcifront.c +2
-0+pci_add_resource (&resources, &ioport_resource); +pci_add_resource (&resources, &iomem_resource);This doesn't add
&busn_resourcelikepci_scan_bus_parented()does. That might be OK, but I think we'll now emit "No busn resource found for root bus, will use [bus %02x-ff]" when we didn't before. I don't know how xen-pcifront works; it would be nice if it could supply the correct bus resource (and ioport and iomem).
Because the pci_scan_bus_parented() add the default busn_resource for it, I would add the default busn_resource in pcifront_scan_root() too to fix the "No busn resource found ..." debug info.
Quoted 18 lines
Quoted 18 lines
drivers/pci/xen-pcifront.c +3
-2pcifront_init_sd (sd, domain, bus, pdev);pci_lock_rescan_remove (); - b =pci_scan_bus_parented (&pdev->xdev->dev, bus, - &pcifront_bus_ops, sd); + b =pci_scan_root_bus (&pdev->xdev->dev, bus, + &pcifront_bus_ops, sd, &resources);if (!b) {dev_err (&pdev->xdev->dev,"Error creating PCI Frontend Bus!\n" ); err = -ENOMEM ;pci_unlock_rescan_remove (); +pci_free_resource_list (&resources); goto err_out; }
Quoted 8 lines
drivers/pci/xen-pcifront.c static int pcifront_scan_root(struct pcifront_device *pdev, · line 495
Quoted 6 lines
drivers/pci/xen-pcifront.c +1
-1@@ -488,7 +492,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,list_add (&bus_entry->list, &pdev->root_buses); -/* pci_scan_bus_parented skips devices which do not have a have +/* pci_scan_root_bus skips devices which do not have a have Please fix the comment typo at the same time ("have a have").
Ok.
Quoted 10 lines
Quoted 7 lines
drivers/pci/xen-pcifront.c +0
-0* devfn==0. The pcifront_scan_bus enumerates all devfn. */ err =pcifront_scan_bus (pdev, domain, bus, b);Signature · 1 line
1.7.1.
Signature · 2 lines
Thanks! Yijing
Re: [PATCH v4 03/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
In reply to Bjorn HelgaasQuoted 14 lines
Quoted 14 lines
drivers/pci/xen-pcifront.c +1
-0@@ -446,6 +446,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev, unsigned int domain, unsigned int bus) {struct pci_bus *b; +LIST_HEAD (resources);struct pcifront_sd *sd =NULL ;struct pci_bus_entry *bus_entry =NULL ;int err =0 ;@@ -470,17 +471,20 @@ static int pcifront_scan_root(struct pcifront_device *pdev, err = -ENOMEM ; goto err_out; }
Quoted 8 lines
drivers/pci/xen-pcifront.c static int pcifront_scan_root(struct pcifront_device *pdev, · line 475
Quoted 2 lines
drivers/pci/xen-pcifront.c +2
-0+pci_add_resource (&resources, &ioport_resource); +pci_add_resource (&resources, &iomem_resource);This doesn't add
&busn_resourcelikepci_scan_bus_parented()does. That might be OK, but I think we'll now emit "No busn resource found for root bus, will use [bus %02x-ff]" when we didn't before. I don't know how xen-pcifront works; it would be nice if it could supply the correct bus resource (and ioport and iomem).
Because the pci_scan_bus_parented() add the default busn_resource for it, I would add the default busn_resource in pcifront_scan_root() too to fix the "No busn resource found ..." debug info.
Quoted 18 lines
Quoted 18 lines
drivers/pci/xen-pcifront.c +3
-2pcifront_init_sd (sd, domain, bus, pdev);pci_lock_rescan_remove (); - b =pci_scan_bus_parented (&pdev->xdev->dev, bus, - &pcifront_bus_ops, sd); + b =pci_scan_root_bus (&pdev->xdev->dev, bus, + &pcifront_bus_ops, sd, &resources);if (!b) {dev_err (&pdev->xdev->dev,"Error creating PCI Frontend Bus!\n" ); err = -ENOMEM ;pci_unlock_rescan_remove (); +pci_free_resource_list (&resources); goto err_out; }
Quoted 8 lines
drivers/pci/xen-pcifront.c static int pcifront_scan_root(struct pcifront_device *pdev, · line 495
Quoted 6 lines
drivers/pci/xen-pcifront.c +1
-1@@ -488,7 +492,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,list_add (&bus_entry->list, &pdev->root_buses); -/* pci_scan_bus_parented skips devices which do not have a have +/* pci_scan_root_bus skips devices which do not have a have Please fix the comment typo at the same time ("have a have").
Ok.
Quoted 10 lines
Quoted 7 lines
drivers/pci/xen-pcifront.c +0
-0* devfn==0. The pcifront_scan_bus enumerates all devfn. */ err =pcifront_scan_bus (pdev, domain, bus, b);Signature · 1 line
1.7.1.
Signature · 2 lines
Thanks! Yijing
Bjorn Helgaas
maintainerRe: [PATCH v4 03/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
In reply to Yijing WangQuoted 26 lines · Yijing Wang
From: Arnd Bergmann <[email protected]>
Use
pci_scan_root_bus()instead of deprecated functionpci_scan_bus_parented().Signed-off-by Arnd Bergmann <[email protected]>Signed-off-by Yijing Wang <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>--- drivers/pci/xen-pcifront.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)drivers/pci/xen-pcifront.c +1
-0@@ -446,6 +446,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev, unsigned int domain, unsigned int bus) {struct pci_bus *b; +LIST_HEAD (resources);struct pcifront_sd *sd =NULL ;struct pci_bus_entry *bus_entry =NULL ;int err =0 ;
drivers/pci/xen-pcifront.c static int pcifront_scan_root(struct pcifront_device *pdev, · line 475
Quoted 5 lines
drivers/pci/xen-pcifront.c +2
-0@@ -470,17 +471,20 @@ static int pcifront_scan_root(struct pcifront_device *pdev, err = -ENOMEM ; goto err_out; } +pci_add_resource (&resources, &ioport_resource); +pci_add_resource (&resources, &iomem_resource);
This doesn't add &busn_resource like pci_scan_bus_parented() does. That might be OK, but I think we'll now emit "No busn resource found for root bus, will use [bus %02x-ff]" when we didn't before. I don't know how xen-pcifront works; it would be nice if it could supply the correct bus resource (and ioport and iomem).
Quoted 18 lines
drivers/pci/xen-pcifront.c +3
-2pcifront_init_sd (sd, domain, bus, pdev);pci_lock_rescan_remove (); - b =pci_scan_bus_parented (&pdev->xdev->dev, bus, - &pcifront_bus_ops, sd); + b =pci_scan_root_bus (&pdev->xdev->dev, bus, + &pcifront_bus_ops, sd, &resources);if (!b) {dev_err (&pdev->xdev->dev,"Error creating PCI Frontend Bus!\n" ); err = -ENOMEM ;pci_unlock_rescan_remove (); +pci_free_resource_list (&resources); goto err_out; }
drivers/pci/xen-pcifront.c static int pcifront_scan_root(struct pcifront_device *pdev, · line 495
Quoted 5 lines
drivers/pci/xen-pcifront.c +1
-1@@ -488,7 +492,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,list_add (&bus_entry->list, &pdev->root_buses); -/* pci_scan_bus_parented skips devices which do not have a have +/* pci_scan_root_bus skips devices which do not have a have
Please fix the comment typo at the same time ("have a have").
Quoted 6 lines
drivers/pci/xen-pcifront.c +0
-0* devfn==0. The pcifront_scan_bus enumerates all devfn. */ err =pcifront_scan_bus (pdev, domain, bus, b);Signature · 1 line
1.7.1
Bjorn Helgaas
maintainerRe: [PATCH v4 03/30] xen/PCI: Don't use deprecated function pci_scan_bus_parented()
In reply to Yijing WangQuoted 26 lines · Yijing Wang
From: Arnd Bergmann <[email protected]>
Use
pci_scan_root_bus()instead of deprecated functionpci_scan_bus_parented().Signed-off-by Arnd Bergmann <[email protected]>Signed-off-by Yijing Wang <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>--- drivers/pci/xen-pcifront.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)drivers/pci/xen-pcifront.c +1
-0@@ -446,6 +446,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev, unsigned int domain, unsigned int bus) {struct pci_bus *b; +LIST_HEAD (resources);struct pcifront_sd *sd =NULL ;struct pci_bus_entry *bus_entry =NULL ;int err =0 ;
drivers/pci/xen-pcifront.c static int pcifront_scan_root(struct pcifront_device *pdev, · line 475
Quoted 5 lines
drivers/pci/xen-pcifront.c +2
-0@@ -470,17 +471,20 @@ static int pcifront_scan_root(struct pcifront_device *pdev, err = -ENOMEM ; goto err_out; } +pci_add_resource (&resources, &ioport_resource); +pci_add_resource (&resources, &iomem_resource);
This doesn't add &busn_resource like pci_scan_bus_parented() does. That might be OK, but I think we'll now emit "No busn resource found for root bus, will use [bus %02x-ff]" when we didn't before. I don't know how xen-pcifront works; it would be nice if it could supply the correct bus resource (and ioport and iomem).
Quoted 18 lines
drivers/pci/xen-pcifront.c +3
-2pcifront_init_sd (sd, domain, bus, pdev);pci_lock_rescan_remove (); - b =pci_scan_bus_parented (&pdev->xdev->dev, bus, - &pcifront_bus_ops, sd); + b =pci_scan_root_bus (&pdev->xdev->dev, bus, + &pcifront_bus_ops, sd, &resources);if (!b) {dev_err (&pdev->xdev->dev,"Error creating PCI Frontend Bus!\n" ); err = -ENOMEM ;pci_unlock_rescan_remove (); +pci_free_resource_list (&resources); goto err_out; }
drivers/pci/xen-pcifront.c static int pcifront_scan_root(struct pcifront_device *pdev, · line 495
Quoted 5 lines
drivers/pci/xen-pcifront.c +1
-1@@ -488,7 +492,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,list_add (&bus_entry->list, &pdev->root_buses); -/* pci_scan_bus_parented skips devices which do not have a have +/* pci_scan_root_bus skips devices which do not have a have
Please fix the comment typo at the same time ("have a have").
Quoted 6 lines
drivers/pci/xen-pcifront.c +0
-0* devfn==0. The pcifront_scan_bus enumerates all devfn. */ err =pcifront_scan_bus (pdev, domain, bus, b);Signature · 1 line
1.7.1
PATCH v4 3/30 xen/PCI: Don't use deprecated function pci_scan_bus_parented()
In reply to Yijing WangFrom: Arnd Bergmann <[email protected]>
Use pci_scan_root_bus() instead of deprecated function pci_scan_bus_parented().
--- drivers/pci/xen-pcifront.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
drivers/pci/xen-pcifront.c +7 -3
@@ -446,6 +446,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev, unsigned int domain, unsigned int bus) {struct pci_bus *b; +LIST_HEAD (resources);struct pcifront_sd *sd =NULL ;struct pci_bus_entry *bus_entry =NULL ;int err =0 ;
@@ -470,17 +471,20 @@ static int pcifront_scan_root(struct pcifront_device *pdev, err = -ENOMEM ; goto err_out; } +pci_add_resource (&resources, &ioport_resource); +pci_add_resource (&resources, &iomem_resource);pcifront_init_sd (sd, domain, bus, pdev);pci_lock_rescan_remove (); - b =pci_scan_bus_parented (&pdev->xdev->dev, bus, - &pcifront_bus_ops, sd); + b =pci_scan_root_bus (&pdev->xdev->dev, bus, + &pcifront_bus_ops, sd, &resources);if (!b) {dev_err (&pdev->xdev->dev,"Error creating PCI Frontend Bus!\n" ); err = -ENOMEM ;pci_unlock_rescan_remove (); +pci_free_resource_list (&resources); goto err_out; }
@@ -488,7 +492,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,list_add (&bus_entry->list, &pdev->root_buses); -/* pci_scan_bus_parented skips devices which do not have a have +/* pci_scan_root_bus skips devices which do not have a have * devfn==0. The pcifront_scan_bus enumerates all devfn. */ err =pcifront_scan_bus (pdev, domain, bus, b);
Signature · 1 line
1.7.1
PATCH v4 4/30 PCI: Remove deprecated pci_scan_bus_parented()
In reply to Yijing WangNo one uses pci_scan_bus_parented() any more,
remove it.
--- drivers/pci/probe.c | 19 ------------------- include/linux/pci.h | 2 -- 2 files changed, 0 insertions(+), 21 deletions(-)
drivers/pci/probe.c +0 -19
@@ -2091,25 +2091,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, }EXPORT_SYMBOL (pci_scan_root_bus); -/* Deprecated; use pci_scan_root_bus() instead */ -struct pci_bus *pci_scan_bus_parented (struct device *parent, -int bus,struct pci_ops *ops,void *sysdata) -{ -LIST_HEAD (resources); -struct pci_bus *b; - -pci_add_resource (&resources, &ioport_resource); -pci_add_resource (&resources, &iomem_resource); -pci_add_resource (&resources, &busn_resource); - b =pci_create_root_bus (parent, bus, ops, sysdata, &resources); -if (b) -pci_scan_child_bus (b); -else -pci_free_resource_list (&resources); -return b; -} -EXPORT_SYMBOL (pci_scan_bus_parented); -struct pci_bus *pci_scan_bus (int bus,struct pci_ops *ops,void *sysdata) {
include/linux/pci.h +0 -2
@@ -769,8 +769,6 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,void pcibios_scan_specific_bus (int busn);struct pci_bus *pci_find_bus (int domain,int busnr);void pci_bus_add_devices (const struct pci_bus *bus); -struct pci_bus *pci_scan_bus_parented (struct device *parent,int bus, -struct pci_ops *ops,void *sysdata);struct pci_bus *pci_scan_bus (int bus,struct pci_ops *ops,void *sysdata); struct pci_bus *pci_create_root_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata,
Signature · 1 line
1.7.1
PATCH v4 4/30 PCI: Remove deprecated pci_scan_bus_parented()
In reply to Yijing WangNo one uses pci_scan_bus_parented() any more,
remove it.
--- drivers/pci/probe.c | 19 ------------------- include/linux/pci.h | 2 -- 2 files changed, 0 insertions(+), 21 deletions(-)
drivers/pci/probe.c +0 -19
@@ -2091,25 +2091,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, }EXPORT_SYMBOL (pci_scan_root_bus); -/* Deprecated; use pci_scan_root_bus() instead */ -struct pci_bus *pci_scan_bus_parented (struct device *parent, -int bus,struct pci_ops *ops,void *sysdata) -{ -LIST_HEAD (resources); -struct pci_bus *b; - -pci_add_resource (&resources, &ioport_resource); -pci_add_resource (&resources, &iomem_resource); -pci_add_resource (&resources, &busn_resource); - b =pci_create_root_bus (parent, bus, ops, sysdata, &resources); -if (b) -pci_scan_child_bus (b); -else -pci_free_resource_list (&resources); -return b; -} -EXPORT_SYMBOL (pci_scan_bus_parented); -struct pci_bus *pci_scan_bus (int bus,struct pci_ops *ops,void *sysdata) {
include/linux/pci.h +0 -2
@@ -769,8 +769,6 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,void pcibios_scan_specific_bus (int busn);struct pci_bus *pci_find_bus (int domain,int busnr);void pci_bus_add_devices (const struct pci_bus *bus); -struct pci_bus *pci_scan_bus_parented (struct device *parent,int bus, -struct pci_ops *ops,void *sysdata);struct pci_bus *pci_scan_bus (int bus,struct pci_ops *ops,void *sysdata); struct pci_bus *pci_create_root_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata,
Signature · 1 line
1.7.1
PATCH v4 5/30 PCI: Rename pci_scan_bus() to pci_scan_bus_legacy()
In reply to Yijing WangPci_scan_bus() is called by legacy pci host drivers, the legacy host drivers mean they use NULL as parent device, use all IO/MEM as default resources. Rename pci_scan_bus() to pci_scan_bus_legacy() for better readability.
--- arch/alpha/kernel/sys_nautilus.c | 2 +- arch/m68k/coldfire/pci.c | 2 +- arch/sparc/kernel/pcic.c | 2 +- arch/unicore32/kernel/pci.c | 2 +- drivers/pci/hotplug/ibmphp_core.c | 2 +- drivers/pci/probe.c | 4 ++-- include/linux/pci.h | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-)
arch/alpha/kernel/sys_nautilus.c +1 -1
@@ -206,7 +206,7 @@ nautilus_init_pci(void)unsigned long memtop = max_low_pfn <<PAGE_SHIFT ;/* Scan our single hose. */ - bus =pci_scan_bus (0 , alpha_mv.pci_ops, hose); + bus =pci_scan_bus_legacy (0 , alpha_mv.pci_ops, hose); hose->bus = bus;pcibios_claim_one_bus (bus);
arch/m68k/coldfire/pci.c +1 -1
@@ -312,7 +312,7 @@ static int __init mcf_pci_init(void)set_current_state (TASK_UNINTERRUPTIBLE );schedule_timeout (msecs_to_jiffies (200 )); - rootbus =pci_scan_bus (0 , &mcf_pci_ops,NULL ); + rootbus =pci_scan_bus_legacy (0 , &mcf_pci_ops,NULL ); rootbus->resource[0 ] = &mcf_pci_io; rootbus->resource[1 ] = &mcf_pci_mem;
arch/sparc/kernel/pcic.c +1 -1
@@ -390,7 +390,7 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic) {struct linux_pbm_info *pbm = &pcic->pbm; - pbm->pci_bus =pci_scan_bus (pbm->pci_first_busno, &pcic_ops, pbm); + pbm->pci_bus =pci_scan_bus_legacy (pbm->pci_first_busno, &pcic_ops, pbm);if (pbm->pci_bus)pci_bus_add_devices (pbm->pci_bus);#if 0 /* deadwood transplanted from sparc64 */
arch/unicore32/kernel/pci.c +1 -1
@@ -258,7 +258,7 @@ static int __init pci_common_init(void)pci_puv3_preinit (); - puv3_bus =pci_scan_bus (0 , &pci_puv3_ops,NULL ); + puv3_bus =pci_scan_bus_legacy (0 , &pci_puv3_ops,NULL );if (!puv3_bus)panic ("PCI: unable to scan bus!" );
drivers/pci/hotplug/ibmphp_core.c +1 -1
@@ -765,7 +765,7 @@ static u8 bus_structure_fixup(u8 busno) (l != 0x0000) && (l != 0xffff)) {debug ("%s - Inside bus_structure_fixup()\n" , __func__); - b =pci_scan_bus (busno, ibmphp_pci_bus->ops,NULL ); + b =pci_scan_bus_legacy (busno, ibmphp_pci_bus->ops,NULL );if (b)pci_bus_add_devices (b);break ;
drivers/pci/probe.c +2 -2
@@ -2091,7 +2091,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, }EXPORT_SYMBOL (pci_scan_root_bus); -struct pci_bus *pci_scan_bus (int bus,struct pci_ops *ops, +struct pci_bus *pci_scan_bus_legacy (int bus,struct pci_ops *ops,void *sysdata) {LIST_HEAD (resources);
@@ -2108,7 +2108,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, }return b; } -EXPORT_SYMBOL (pci_scan_bus); +EXPORT_SYMBOL (pci_scan_bus_legacy);/** * pci_rescan_bus_bridge_resize - scan a PCI bus for devices.
include/linux/pci.h +1 -1
@@ -769,7 +769,7 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,void pcibios_scan_specific_bus (int busn);struct pci_bus *pci_find_bus (int domain,int busnr);void pci_bus_add_devices (const struct pci_bus *bus); -struct pci_bus *pci_scan_bus (int bus,struct pci_ops *ops,void *sysdata); +struct pci_bus *pci_scan_bus_legacy (int bus,struct pci_ops *ops,void *sysdata);struct pci_bus *pci_create_root_bus (struct device *parent,int bus,struct pci_ops *ops,void *sysdata,struct list_head *resources);
Signature · 1 line
1.7.1
Bjorn Helgaas
maintainerRe: [PATCH v4 05/30] PCI: Rename pci_scan_bus() to pci_scan_bus_legacy()
Quoted 5 lines · Yijing Wang
Pci_scan_bus()is called by legacy pci host drivers, the legacy host drivers mean they use NULL as parent device, use all IO/MEM as default resources. Renamepci_scan_bus()topci_scan_bus_legacy()for better readability.
We should mention that this changes an exported symbol, because that's potentially an issue for distros.
I'm not saying we can't change it, but I don't want to do it unless there's real benefit. I'm not convinced of the benefit yet, but maybe I will be by the end of the series.
Quoted 114 lines
Signed-off-by Yijing Wang <[email protected]>--- arch/alpha/kernel/sys_nautilus.c | 2 +- arch/m68k/coldfire/pci.c | 2 +- arch/sparc/kernel/pcic.c | 2 +- arch/unicore32/kernel/pci.c | 2 +- drivers/pci/hotplug/ibmphp_core.c | 2 +- drivers/pci/probe.c | 4 ++-- include/linux/pci.h | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-)arch/alpha/kernel/sys_nautilus.c +1
-1@@ -206,7 +206,7 @@ nautilus_init_pci(void)unsigned long memtop = max_low_pfn <<PAGE_SHIFT ;/* Scan our single hose. */ - bus =pci_scan_bus (0 , alpha_mv.pci_ops, hose); + bus =pci_scan_bus_legacy (0 , alpha_mv.pci_ops, hose); hose->bus = bus;pcibios_claim_one_bus (bus);arch/m68k/coldfire/pci.c +1
-1@@ -312,7 +312,7 @@ static int __init mcf_pci_init(void)set_current_state (TASK_UNINTERRUPTIBLE );schedule_timeout (msecs_to_jiffies (200 )); - rootbus =pci_scan_bus (0 , &mcf_pci_ops,NULL ); + rootbus =pci_scan_bus_legacy (0 , &mcf_pci_ops,NULL ); rootbus->resource[0 ] = &mcf_pci_io; rootbus->resource[1 ] = &mcf_pci_mem;arch/sparc/kernel/pcic.c +1
-1@@ -390,7 +390,7 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic) {struct linux_pbm_info *pbm = &pcic->pbm; - pbm->pci_bus =pci_scan_bus (pbm->pci_first_busno, &pcic_ops, pbm); + pbm->pci_bus =pci_scan_bus_legacy (pbm->pci_first_busno, &pcic_ops, pbm);if (pbm->pci_bus)pci_bus_add_devices (pbm->pci_bus);#if 0 /* deadwood transplanted from sparc64 */ arch/unicore32/kernel/pci.c +1
-1@@ -258,7 +258,7 @@ static int __init pci_common_init(void)pci_puv3_preinit (); - puv3_bus =pci_scan_bus (0 , &pci_puv3_ops,NULL ); + puv3_bus =pci_scan_bus_legacy (0 , &pci_puv3_ops,NULL );if (!puv3_bus)panic ("PCI: unable to scan bus!" );drivers/pci/hotplug/ibmphp_core.c +1
-1@@ -765,7 +765,7 @@ static u8 bus_structure_fixup(u8 busno) (l != 0x0000) && (l != 0xffff)) {debug ("%s - Inside bus_structure_fixup()\n" , __func__); - b =pci_scan_bus (busno, ibmphp_pci_bus->ops,NULL ); + b =pci_scan_bus_legacy (busno, ibmphp_pci_bus->ops,NULL );if (b)pci_bus_add_devices (b);break ;drivers/pci/probe.c +2
-2@@ -2091,7 +2091,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, }EXPORT_SYMBOL (pci_scan_root_bus); -struct pci_bus *pci_scan_bus (int bus,struct pci_ops *ops, +struct pci_bus *pci_scan_bus_legacy (int bus,struct pci_ops *ops,void *sysdata) {LIST_HEAD (resources);@@ -2108,7 +2108,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, }return b; } -EXPORT_SYMBOL (pci_scan_bus); +EXPORT_SYMBOL (pci_scan_bus_legacy);/** * pci_rescan_bus_bridge_resize - scan a PCI bus for devices. include/linux/pci.h +1
-1@@ -769,7 +769,7 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,void pcibios_scan_specific_bus (int busn);struct pci_bus *pci_find_bus (int domain,int busnr);void pci_bus_add_devices (const struct pci_bus *bus); -struct pci_bus *pci_scan_bus (int bus,struct pci_ops *ops,void *sysdata); +struct pci_bus *pci_scan_bus_legacy (int bus,struct pci_ops *ops,void *sysdata);struct pci_bus *pci_create_root_bus (struct device *parent,int bus,struct pci_ops *ops,void *sysdata,struct list_head *resources);Signature · 1 line
1.7.1
Re: [PATCH v4 05/30] PCI: Rename pci_scan_bus() to pci_scan_bus_legacy()
Quoted 7 lines · Bjorn Helgaas
Quoted 5 lines · Yijing Wang
Pci_scan_bus()is called by legacy pci host drivers, the legacy host drivers mean they use NULL as parent device, use all IO/MEM as default resources. Renamepci_scan_bus()topci_scan_bus_legacy()for better readability.
Quoted 7 lines
We should mention that this changes an exported symbol, because that's potentially an issue for distros.
I'm not saying we can't change it, but I don't want to do it unless there's real benefit. I'm not convinced of the benefit yet, but maybe I will be by the end of the series.
Ok, I would move this one out of this series temporarily.
Quoted 117 lines
Quoted 114 lines
Signed-off-by Yijing Wang <[email protected]>--- arch/alpha/kernel/sys_nautilus.c | 2 +- arch/m68k/coldfire/pci.c | 2 +- arch/sparc/kernel/pcic.c | 2 +- arch/unicore32/kernel/pci.c | 2 +- drivers/pci/hotplug/ibmphp_core.c | 2 +- drivers/pci/probe.c | 4 ++-- include/linux/pci.h | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-)arch/alpha/kernel/sys_nautilus.c +1
-1@@ -206,7 +206,7 @@ nautilus_init_pci(void)unsigned long memtop = max_low_pfn <<PAGE_SHIFT ;/* Scan our single hose. */ - bus =pci_scan_bus (0 , alpha_mv.pci_ops, hose); + bus =pci_scan_bus_legacy (0 , alpha_mv.pci_ops, hose); hose->bus = bus;pcibios_claim_one_bus (bus);arch/m68k/coldfire/pci.c +1
-1@@ -312,7 +312,7 @@ static int __init mcf_pci_init(void)set_current_state (TASK_UNINTERRUPTIBLE );schedule_timeout (msecs_to_jiffies (200 )); - rootbus =pci_scan_bus (0 , &mcf_pci_ops,NULL ); + rootbus =pci_scan_bus_legacy (0 , &mcf_pci_ops,NULL ); rootbus->resource[0 ] = &mcf_pci_io; rootbus->resource[1 ] = &mcf_pci_mem;arch/sparc/kernel/pcic.c +1
-1@@ -390,7 +390,7 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic) {struct linux_pbm_info *pbm = &pcic->pbm; - pbm->pci_bus =pci_scan_bus (pbm->pci_first_busno, &pcic_ops, pbm); + pbm->pci_bus =pci_scan_bus_legacy (pbm->pci_first_busno, &pcic_ops, pbm);if (pbm->pci_bus)pci_bus_add_devices (pbm->pci_bus);#if 0 /* deadwood transplanted from sparc64 */ arch/unicore32/kernel/pci.c +1
-1@@ -258,7 +258,7 @@ static int __init pci_common_init(void)pci_puv3_preinit (); - puv3_bus =pci_scan_bus (0 , &pci_puv3_ops,NULL ); + puv3_bus =pci_scan_bus_legacy (0 , &pci_puv3_ops,NULL );if (!puv3_bus)panic ("PCI: unable to scan bus!" );drivers/pci/hotplug/ibmphp_core.c +1
-1@@ -765,7 +765,7 @@ static u8 bus_structure_fixup(u8 busno) (l != 0x0000) && (l != 0xffff)) {debug ("%s - Inside bus_structure_fixup()\n" , __func__); - b =pci_scan_bus (busno, ibmphp_pci_bus->ops,NULL ); + b =pci_scan_bus_legacy (busno, ibmphp_pci_bus->ops,NULL );if (b)pci_bus_add_devices (b);break ;drivers/pci/probe.c +2
-2@@ -2091,7 +2091,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, }EXPORT_SYMBOL (pci_scan_root_bus); -struct pci_bus *pci_scan_bus (int bus,struct pci_ops *ops, +struct pci_bus *pci_scan_bus_legacy (int bus,struct pci_ops *ops,void *sysdata) {LIST_HEAD (resources);@@ -2108,7 +2108,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, }return b; } -EXPORT_SYMBOL (pci_scan_bus); +EXPORT_SYMBOL (pci_scan_bus_legacy);/** * pci_rescan_bus_bridge_resize - scan a PCI bus for devices. include/linux/pci.h +1
-1@@ -769,7 +769,7 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,void pcibios_scan_specific_bus (int busn);struct pci_bus *pci_find_bus (int domain,int busnr);void pci_bus_add_devices (const struct pci_bus *bus); -struct pci_bus *pci_scan_bus (int bus,struct pci_ops *ops,void *sysdata); +struct pci_bus *pci_scan_bus_legacy (int bus,struct pci_ops *ops,void *sysdata);struct pci_bus *pci_create_root_bus (struct device *parent,int bus,struct pci_ops *ops,void *sysdata,struct list_head *resources);Signature · 1 line
1.7.1.
Signature · 2 lines
Thanks! Yijing
Bjorn Helgaas
maintainerRe: [PATCH v4 05/30] PCI: Rename pci_scan_bus() to pci_scan_bus_legacy()
In reply to Yijing WangQuoted 5 lines · Yijing Wang
Pci_scan_bus()is called by legacy pci host drivers, the legacy host drivers mean they use NULL as parent device, use all IO/MEM as default resources. Renamepci_scan_bus()topci_scan_bus_legacy()for better readability.
We should mention that this changes an exported symbol, because that's potentially an issue for distros.
I'm not saying we can't change it, but I don't want to do it unless there's real benefit. I'm not convinced of the benefit yet, but maybe I will be by the end of the series.
Quoted 114 lines
Signed-off-by Yijing Wang <[email protected]>--- arch/alpha/kernel/sys_nautilus.c | 2 +- arch/m68k/coldfire/pci.c | 2 +- arch/sparc/kernel/pcic.c | 2 +- arch/unicore32/kernel/pci.c | 2 +- drivers/pci/hotplug/ibmphp_core.c | 2 +- drivers/pci/probe.c | 4 ++-- include/linux/pci.h | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-)arch/alpha/kernel/sys_nautilus.c +1
-1@@ -206,7 +206,7 @@ nautilus_init_pci(void)unsigned long memtop = max_low_pfn <<PAGE_SHIFT ;/* Scan our single hose. */ - bus =pci_scan_bus (0 , alpha_mv.pci_ops, hose); + bus =pci_scan_bus_legacy (0 , alpha_mv.pci_ops, hose); hose->bus = bus;pcibios_claim_one_bus (bus);arch/m68k/coldfire/pci.c +1
-1@@ -312,7 +312,7 @@ static int __init mcf_pci_init(void)set_current_state (TASK_UNINTERRUPTIBLE );schedule_timeout (msecs_to_jiffies (200 )); - rootbus =pci_scan_bus (0 , &mcf_pci_ops,NULL ); + rootbus =pci_scan_bus_legacy (0 , &mcf_pci_ops,NULL ); rootbus->resource[0 ] = &mcf_pci_io; rootbus->resource[1 ] = &mcf_pci_mem;arch/sparc/kernel/pcic.c +1
-1@@ -390,7 +390,7 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic) {struct linux_pbm_info *pbm = &pcic->pbm; - pbm->pci_bus =pci_scan_bus (pbm->pci_first_busno, &pcic_ops, pbm); + pbm->pci_bus =pci_scan_bus_legacy (pbm->pci_first_busno, &pcic_ops, pbm);if (pbm->pci_bus)pci_bus_add_devices (pbm->pci_bus);#if 0 /* deadwood transplanted from sparc64 */ arch/unicore32/kernel/pci.c +1
-1@@ -258,7 +258,7 @@ static int __init pci_common_init(void)pci_puv3_preinit (); - puv3_bus =pci_scan_bus (0 , &pci_puv3_ops,NULL ); + puv3_bus =pci_scan_bus_legacy (0 , &pci_puv3_ops,NULL );if (!puv3_bus)panic ("PCI: unable to scan bus!" );drivers/pci/hotplug/ibmphp_core.c +1
-1@@ -765,7 +765,7 @@ static u8 bus_structure_fixup(u8 busno) (l != 0x0000) && (l != 0xffff)) {debug ("%s - Inside bus_structure_fixup()\n" , __func__); - b =pci_scan_bus (busno, ibmphp_pci_bus->ops,NULL ); + b =pci_scan_bus_legacy (busno, ibmphp_pci_bus->ops,NULL );if (b)pci_bus_add_devices (b);break ;drivers/pci/probe.c +2
-2@@ -2091,7 +2091,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, }EXPORT_SYMBOL (pci_scan_root_bus); -struct pci_bus *pci_scan_bus (int bus,struct pci_ops *ops, +struct pci_bus *pci_scan_bus_legacy (int bus,struct pci_ops *ops,void *sysdata) {LIST_HEAD (resources);@@ -2108,7 +2108,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, }return b; } -EXPORT_SYMBOL (pci_scan_bus); +EXPORT_SYMBOL (pci_scan_bus_legacy);/** * pci_rescan_bus_bridge_resize - scan a PCI bus for devices. include/linux/pci.h +1
-1@@ -769,7 +769,7 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,void pcibios_scan_specific_bus (int busn);struct pci_bus *pci_find_bus (int domain,int busnr);void pci_bus_add_devices (const struct pci_bus *bus); -struct pci_bus *pci_scan_bus (int bus,struct pci_ops *ops,void *sysdata); +struct pci_bus *pci_scan_bus_legacy (int bus,struct pci_ops *ops,void *sysdata);struct pci_bus *pci_create_root_bus (struct device *parent,int bus,struct pci_ops *ops,void *sysdata,struct list_head *resources);Signature · 1 line
1.7.1
PATCH v4 5/30 PCI: Rename pci_scan_bus() to pci_scan_bus_legacy()
In reply to Yijing WangPci_scan_bus() is called by legacy pci host drivers, the legacy host drivers mean they use NULL as parent device, use all IO/MEM as default resources. Rename pci_scan_bus() to pci_scan_bus_legacy() for better readability.
--- arch/alpha/kernel/sys_nautilus.c | 2 +- arch/m68k/coldfire/pci.c | 2 +- arch/sparc/kernel/pcic.c | 2 +- arch/unicore32/kernel/pci.c | 2 +- drivers/pci/hotplug/ibmphp_core.c | 2 +- drivers/pci/probe.c | 4 ++-- include/linux/pci.h | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-)
arch/alpha/kernel/sys_nautilus.c +1 -1
@@ -206,7 +206,7 @@ nautilus_init_pci(void)unsigned long memtop = max_low_pfn <<PAGE_SHIFT ;/* Scan our single hose. */ - bus =pci_scan_bus (0 , alpha_mv.pci_ops, hose); + bus =pci_scan_bus_legacy (0 , alpha_mv.pci_ops, hose); hose->bus = bus;pcibios_claim_one_bus (bus);
arch/m68k/coldfire/pci.c +1 -1
@@ -312,7 +312,7 @@ static int __init mcf_pci_init(void)set_current_state (TASK_UNINTERRUPTIBLE );schedule_timeout (msecs_to_jiffies (200 )); - rootbus =pci_scan_bus (0 , &mcf_pci_ops,NULL ); + rootbus =pci_scan_bus_legacy (0 , &mcf_pci_ops,NULL ); rootbus->resource[0 ] = &mcf_pci_io; rootbus->resource[1 ] = &mcf_pci_mem;
arch/sparc/kernel/pcic.c +1 -1
@@ -390,7 +390,7 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic) {struct linux_pbm_info *pbm = &pcic->pbm; - pbm->pci_bus =pci_scan_bus (pbm->pci_first_busno, &pcic_ops, pbm); + pbm->pci_bus =pci_scan_bus_legacy (pbm->pci_first_busno, &pcic_ops, pbm);if (pbm->pci_bus)pci_bus_add_devices (pbm->pci_bus);#if 0 /* deadwood transplanted from sparc64 */
arch/unicore32/kernel/pci.c +1 -1
@@ -258,7 +258,7 @@ static int __init pci_common_init(void)pci_puv3_preinit (); - puv3_bus =pci_scan_bus (0 , &pci_puv3_ops,NULL ); + puv3_bus =pci_scan_bus_legacy (0 , &pci_puv3_ops,NULL );if (!puv3_bus)panic ("PCI: unable to scan bus!" );
drivers/pci/hotplug/ibmphp_core.c +1 -1
@@ -765,7 +765,7 @@ static u8 bus_structure_fixup(u8 busno) (l != 0x0000) && (l != 0xffff)) {debug ("%s - Inside bus_structure_fixup()\n" , __func__); - b =pci_scan_bus (busno, ibmphp_pci_bus->ops,NULL ); + b =pci_scan_bus_legacy (busno, ibmphp_pci_bus->ops,NULL );if (b)pci_bus_add_devices (b);break ;
drivers/pci/probe.c +2 -2
@@ -2091,7 +2091,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, }EXPORT_SYMBOL (pci_scan_root_bus); -struct pci_bus *pci_scan_bus (int bus,struct pci_ops *ops, +struct pci_bus *pci_scan_bus_legacy (int bus,struct pci_ops *ops,void *sysdata) {LIST_HEAD (resources);
@@ -2108,7 +2108,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, }return b; } -EXPORT_SYMBOL (pci_scan_bus); +EXPORT_SYMBOL (pci_scan_bus_legacy);/** * pci_rescan_bus_bridge_resize - scan a PCI bus for devices.
include/linux/pci.h +1 -1
@@ -769,7 +769,7 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,void pcibios_scan_specific_bus (int busn);struct pci_bus *pci_find_bus (int domain,int busnr);void pci_bus_add_devices (const struct pci_bus *bus); -struct pci_bus *pci_scan_bus (int bus,struct pci_ops *ops,void *sysdata); +struct pci_bus *pci_scan_bus_legacy (int bus,struct pci_ops *ops,void *sysdata);struct pci_bus *pci_create_root_bus (struct device *parent,int bus,struct pci_ops *ops,void *sysdata,struct list_head *resources);
Signature · 1 line
1.7.1
PATCH v4 6/30 PCI: Combine PCI domain and bus number in u32 arg
In reply to Yijing WangCurrently, we use int type for bus number in pci_create_root_bus(), pci_scan_root_bus() and pci_scan_bus_legacy. Because PCI bus number always <= 255, so we could change the bus number argument type to u32, and combine PCI domain and bus number in one. Also add a domain member in pci_host_bridge to save domain number. Finally, we could eliminate lots of the platform specific pci_domain_nr() in the last of the series.
--- drivers/pci/probe.c | 16 +++++++++------- include/linux/pci.h | 7 ++++--- include/uapi/linux/pci.h | 3 +++ 3 files changed, 16 insertions(+), 10 deletions(-)
drivers/pci/probe.c +9 -7
@@ -1889,7 +1889,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus) { } -struct pci_bus *pci_create_root_bus (struct device *parent,int bus, +struct pci_bus *pci_create_root_bus (struct device *parent,u32 db,struct pci_ops *ops,void *sysdata,struct list_head *resources) {int error;
@@ -1900,6 +1900,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,resource_size_t offset;char bus_addr[64 ];char *fmt; +u8 bus =PCI_BUSNUM (db); b =pci_alloc_bus (NULL );if (!b)
@@ -1920,6 +1921,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,if (!bridge) goto err_out; + bridge->domain =PCI_DOMAIN (db); bridge->dev.parent = parent; bridge->dev.release = pci_release_host_bridge_dev;dev_set_name (&bridge->dev,"pci%04x:%02x" ,pci_domain_nr (b), bus);
@@ -2057,7 +2059,7 @@ void pci_bus_release_busn_res(struct pci_bus *b) res, ret ? "can not be" : "is"); } -struct pci_bus *pci_scan_root_bus (struct device *parent,int bus, +struct pci_bus *pci_scan_root_bus (struct device *parent,u32 db,struct pci_ops *ops,void *sysdata,struct list_head *resources) {struct resource_entry *window;
@@ -2071,15 +2073,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,break ; } - b =pci_create_root_bus (parent, bus, ops, sysdata, resources); + b =pci_create_root_bus (parent, db, ops, sysdata, resources);if (!b)return NULL ;if (!found) {dev_info (&b->dev,"No busn resource found for root bus, will use [bus %02x-ff]\n" , - bus); -pci_bus_insert_busn_res (b, bus,255 ); +PCI_BUSNUM (db)); +pci_bus_insert_busn_res (b,PCI_BUSNUM (db),255 ); } max =pci_scan_child_bus (b);
@@ -2091,7 +2093,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, }EXPORT_SYMBOL (pci_scan_root_bus); -struct pci_bus *pci_scan_bus_legacy (int bus,struct pci_ops *ops, +struct pci_bus *pci_scan_bus_legacy (u32 db,struct pci_ops *ops,void *sysdata) {LIST_HEAD (resources);
@@ -2100,7 +2102,7 @@ struct pci_bus *pci_scan_bus_legacy(int bus, struct pci_ops *ops,pci_add_resource (&resources, &ioport_resource);pci_add_resource (&resources, &iomem_resource);pci_add_resource (&resources, &busn_resource); - b =pci_create_root_bus (NULL , bus, ops, sysdata, &resources); + b =pci_create_root_bus (NULL , db, ops, sysdata, &resources);if (b) {pci_scan_child_bus (b); }else {
include/linux/pci.h +4 -3
@@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev) }struct pci_host_bridge { +u16 domain;struct device dev;struct pci_bus *bus;/* root bus */ struct list_head windows;/* resource_entry */
@@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,void pcibios_scan_specific_bus (int busn);struct pci_bus *pci_find_bus (int domain,int busnr);void pci_bus_add_devices (const struct pci_bus *bus); -struct pci_bus *pci_scan_bus_legacy (int bus,struct pci_ops *ops,void *sysdata); -struct pci_bus *pci_create_root_bus (struct device *parent,int bus, +struct pci_bus *pci_scan_bus_legacy (u32 dombus,struct pci_ops *ops,void *sysdata); +struct pci_bus *pci_create_root_bus (struct device *parent,u32 dombus,struct pci_ops *ops,void *sysdata,struct list_head *resources);int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int busmax);int pci_bus_update_busn_res_end (struct pci_bus *b,int busmax);void pci_bus_release_busn_res (struct pci_bus *b); -struct pci_bus *pci_scan_root_bus (struct device *parent,int bus, +struct pci_bus *pci_scan_root_bus (struct device *parent,u32 dombus,struct pci_ops *ops,void *sysdata,struct list_head *resources); struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
include/uapi/linux/pci.h +3 -0
@@ -30,6 +30,9 @@#define PCI_DEVFN (slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))#define PCI_SLOT (devfn) (((devfn) >> 3) & 0x1f)#define PCI_FUNC (devfn) ((devfn) & 0x07) +#define PCI_DOMAIN (db) ((db) >> 16) +#define PCI_BUSNUM (db) ((db) & 0xffff) +#define PCI_DOMBUS (domain, bus) (((domain) << 16) | (bus))/* Ioctls for /proc/bus/pci/X/Y nodes. */ #define PCIIOC_BASE ('P' << 24 | 'C' << 16 | 'I' << 8)
Signature · 1 line
1.7.1
PATCH v4 6/30 PCI: Combine PCI domain and bus number in u32 arg
In reply to Yijing WangCurrently, we use int type for bus number in pci_create_root_bus(), pci_scan_root_bus() and pci_scan_bus_legacy. Because PCI bus number always <= 255, so we could change the bus number argument type to u32, and combine PCI domain and bus number in one. Also add a domain member in pci_host_bridge to save domain number. Finally, we could eliminate lots of the platform specific pci_domain_nr() in the last of the series.
--- drivers/pci/probe.c | 16 +++++++++------- include/linux/pci.h | 7 ++++--- include/uapi/linux/pci.h | 3 +++ 3 files changed, 16 insertions(+), 10 deletions(-)
drivers/pci/probe.c +9 -7
@@ -1889,7 +1889,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus) { } -struct pci_bus *pci_create_root_bus (struct device *parent,int bus, +struct pci_bus *pci_create_root_bus (struct device *parent,u32 db,struct pci_ops *ops,void *sysdata,struct list_head *resources) {int error;
@@ -1900,6 +1900,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,resource_size_t offset;char bus_addr[64 ];char *fmt; +u8 bus =PCI_BUSNUM (db); b =pci_alloc_bus (NULL );if (!b)
@@ -1920,6 +1921,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,if (!bridge) goto err_out; + bridge->domain =PCI_DOMAIN (db); bridge->dev.parent = parent; bridge->dev.release = pci_release_host_bridge_dev;dev_set_name (&bridge->dev,"pci%04x:%02x" ,pci_domain_nr (b), bus);
@@ -2057,7 +2059,7 @@ void pci_bus_release_busn_res(struct pci_bus *b) res, ret ? "can not be" : "is"); } -struct pci_bus *pci_scan_root_bus (struct device *parent,int bus, +struct pci_bus *pci_scan_root_bus (struct device *parent,u32 db,struct pci_ops *ops,void *sysdata,struct list_head *resources) {struct resource_entry *window;
@@ -2071,15 +2073,15 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus,break ; } - b =pci_create_root_bus (parent, bus, ops, sysdata, resources); + b =pci_create_root_bus (parent, db, ops, sysdata, resources);if (!b)return NULL ;if (!found) {dev_info (&b->dev,"No busn resource found for root bus, will use [bus %02x-ff]\n" , - bus); -pci_bus_insert_busn_res (b, bus,255 ); +PCI_BUSNUM (db)); +pci_bus_insert_busn_res (b,PCI_BUSNUM (db),255 ); } max =pci_scan_child_bus (b);
@@ -2091,7 +2093,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, }EXPORT_SYMBOL (pci_scan_root_bus); -struct pci_bus *pci_scan_bus_legacy (int bus,struct pci_ops *ops, +struct pci_bus *pci_scan_bus_legacy (u32 db,struct pci_ops *ops,void *sysdata) {LIST_HEAD (resources);
@@ -2100,7 +2102,7 @@ struct pci_bus *pci_scan_bus_legacy(int bus, struct pci_ops *ops,pci_add_resource (&resources, &ioport_resource);pci_add_resource (&resources, &iomem_resource);pci_add_resource (&resources, &busn_resource); - b =pci_create_root_bus (NULL , bus, ops, sysdata, &resources); + b =pci_create_root_bus (NULL , db, ops, sysdata, &resources);if (b) {pci_scan_child_bus (b); }else {
include/linux/pci.h +4 -3
@@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev) }struct pci_host_bridge { +u16 domain;struct device dev;struct pci_bus *bus;/* root bus */ struct list_head windows;/* resource_entry */
@@ -769,14 +770,14 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,void pcibios_scan_specific_bus (int busn);struct pci_bus *pci_find_bus (int domain,int busnr);void pci_bus_add_devices (const struct pci_bus *bus); -struct pci_bus *pci_scan_bus_legacy (int bus,struct pci_ops *ops,void *sysdata); -struct pci_bus *pci_create_root_bus (struct device *parent,int bus, +struct pci_bus *pci_scan_bus_legacy (u32 dombus,struct pci_ops *ops,void *sysdata); +struct pci_bus *pci_create_root_bus (struct device *parent,u32 dombus,struct pci_ops *ops,void *sysdata,struct list_head *resources);int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int busmax);int pci_bus_update_busn_res_end (struct pci_bus *b,int busmax);void pci_bus_release_busn_res (struct pci_bus *b); -struct pci_bus *pci_scan_root_bus (struct device *parent,int bus, +struct pci_bus *pci_scan_root_bus (struct device *parent,u32 dombus,struct pci_ops *ops,void *sysdata,struct list_head *resources); struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
include/uapi/linux/pci.h +3 -0
@@ -30,6 +30,9 @@#define PCI_DEVFN (slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))#define PCI_SLOT (devfn) (((devfn) >> 3) & 0x1f)#define PCI_FUNC (devfn) ((devfn) & 0x07) +#define PCI_DOMAIN (db) ((db) >> 16) +#define PCI_BUSNUM (db) ((db) & 0xffff) +#define PCI_DOMBUS (domain, bus) (((domain) << 16) | (bus))/* Ioctls for /proc/bus/pci/X/Y nodes. */ #define PCIIOC_BASE ('P' << 24 | 'C' << 16 | 'I' << 8)
Signature · 1 line
1.7.1
PATCH v4 7/30 PCI: Pass PCI domain number combined with root bus number
In reply to Yijing WangNow we could pass PCI domain combined with bus number in u32 argu. Because in arm/arm64, PCI domain number is assigned by pci_bus_assign_domain_nr(). So we leave pci_scan_root_bus() and pci_create_root_bus() in arm/arm64 unchanged. A new function pci_host_assign_domain_nr() will be introduced for arm/arm64 to assign domain number in later patch.
--- arch/alpha/kernel/pci.c | 5 +++-- arch/alpha/kernel/sys_nautilus.c | 3 ++- arch/ia64/pci/pci.c | 4 ++-- arch/ia64/sn/kernel/io_init.c | 5 +++-- arch/microblaze/pci/pci-common.c | 5 +++-- arch/mips/pci/pci.c | 4 ++-- arch/powerpc/kernel/pci-common.c | 5 +++-- arch/s390/pci/pci.c | 5 +++-- arch/sh/drivers/pci/pci.c | 5 +++-- arch/sparc/kernel/pci.c | 5 +++-- arch/tile/kernel/pci.c | 4 ++-- arch/tile/kernel/pci_gx.c | 5 +++-- arch/x86/pci/acpi.c | 6 +++--- arch/x86/pci/common.c | 3 ++- drivers/pci/xen-pcifront.c | 5 +++-- 15 files changed, 40 insertions(+), 29 deletions(-)
arch/alpha/kernel/pci.c +3 -2
@@ -336,8 +336,9 @@ common_init_pci(void)pci_add_resource_offset (&resources, hose->mem_space, hose->mem_space->start); - bus =pci_scan_root_bus (NULL , next_busno, alpha_mv.pci_ops, - hose, &resources); + bus =pci_scan_root_bus (NULL , +PCI_DOMBUS (hose->index, next_busno), alpha_mv.pci_ops, + hose, &resources);if (bus)pci_bus_add_devices (bus); hose->bus = bus;
arch/alpha/kernel/sys_nautilus.c +2 -1
@@ -206,7 +206,8 @@ nautilus_init_pci(void)unsigned long memtop = max_low_pfn <<PAGE_SHIFT ;/* Scan our single hose. */ - bus =pci_scan_bus_legacy (0 , alpha_mv.pci_ops, hose); + bus =pci_scan_bus_legacy (PCI_DOMBUS (hose->index,0 ), + alpha_mv.pci_ops, hose); hose->bus = bus;pcibios_claim_one_bus (bus);
arch/ia64/pci/pci.c +2 -2
@@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)* should handle the case here, but it appears that IA64 hasn't * such quirk. So we just ignore the case now. */ - pbus =pci_create_root_bus (NULL , bus, &pci_root_ops, controller, - &info->resources); + pbus =pci_create_root_bus (NULL ,PCI_DOMBUS (domain, bus), + &pci_root_ops, controller, &info->resources);if (!pbus) {pci_free_resource_list (&info->resources);__release_pci_root_info (info);
arch/ia64/sn/kernel/io_init.c +3 -2
@@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)pci_add_resource_offset (&resources, &res[1 ], prom_bussoft_ptr->bs_legacy_mem); - bus =pci_scan_root_bus (NULL , busnum, &pci_root_ops, controller, - &resources); + bus =pci_scan_root_bus (NULL , +PCI_DOMBUS (controller->segment, busnum), + &pci_root_ops, controller, &resources);if (bus ==NULL ) {kfree (res);kfree (controller);
arch/microblaze/pci/pci-common.c +3 -2
@@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)pcibios_setup_phb_resources (hose, &resources); - bus =pci_scan_root_bus (hose->parent, hose->first_busno, - hose->ops, hose, &resources); + bus =pci_scan_root_bus (hose->parent, +PCI_DOMBUS (hose->global_number, hose->first_busno), + hose->ops, hose, &resources);if (bus ==NULL ) {pr_err ("Failed to create bus for PCI domain %04x\n" , hose->global_number);
arch/mips/pci/pci.c +2 -2
@@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)pci_add_resource_offset (&resources, hose->mem_resource, hose->mem_offset);pci_add_resource_offset (&resources, hose->io_resource, hose->io_offset); - bus =pci_scan_root_bus (NULL , next_busno, hose->pci_ops, hose, - &resources); + bus =pci_scan_root_bus (NULL ,PCI_DOMBUS (hose->index, next_busno), + hose->pci_ops, hose, &resources);if (!bus)pci_free_resource_list (&resources);
arch/powerpc/kernel/pci-common.c +3 -2
@@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)pci_add_resource (&resources, &hose->busn);/* Create an empty bus for the toplevel */ - bus =pci_create_root_bus (hose->parent, hose->first_busno, - hose->ops, hose, &resources); + bus =pci_create_root_bus (hose->parent, +PCI_DOMBUS (hose->global_number, hose->first_busno), + hose->ops, hose, &resources);if (bus ==NULL ) {pr_err ("Failed to create bus for PCI domain %04x\n" , hose->global_number);
arch/s390/pci/pci.c +3 -2
@@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)if (ret)return ret; - zdev->bus =pci_scan_root_bus (NULL ,ZPCI_BUS_NR , &pci_root_ops, - zdev, &resources); + zdev->bus =pci_scan_root_bus (NULL , +PCI_DOMBUS (zdev->domain,ZPCI_BUS_NR ), &pci_root_ops, + zdev, &resources);if (!zdev->bus) {zpci_cleanup_bus_resources (zdev);return -EIO ;
arch/sh/drivers/pci/pci.c +3 -2
@@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)pci_add_resource_offset (&resources, res, offset); } - bus =pci_scan_root_bus (NULL , next_busno, hose->pci_ops, hose, - &resources); + bus =pci_scan_root_bus (NULL , +PCI_DOMBUS (hose->index, next_busno), + hose->pci_ops, hose, &resources); hose->bus = bus; need_domain_info = need_domain_info || hose->index;
arch/sparc/kernel/pci.c +3 -2
@@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, pbm->busn.end = pbm->pci_last_busno; pbm->busn.flags =IORESOURCE_BUS ;pci_add_resource (&resources, &pbm->busn); - bus =pci_create_root_bus (parent, pbm->pci_first_busno, pbm->pci_ops, - pbm, &resources); + bus =pci_create_root_bus (parent, +PCI_DOMBUS (pbm->index, pbm->pci_first_busno), + pbm->pci_ops, pbm, &resources);if (!bus) {printk (KERN_ERR "Failed to create bus for %s\n" , node->full_name);
arch/tile/kernel/pci.c +2 -2
@@ -306,8 +306,8 @@ int __init pcibios_init(void)pci_add_resource (&resources, &ioport_resource);pci_add_resource (&resources, &iomem_resource); - bus =pci_scan_root_bus (NULL ,0 , controller->ops, - controller, &resources); + bus =pci_scan_root_bus (NULL ,PCI_DOMBUS (controller->index,0 ), + controller->ops, controller, &resources); controller->root_bus = bus; controller->last_busno = bus->busn_res.end; }
arch/tile/kernel/pci_gx.c +3 -2
@@ -881,8 +881,9 @@ int __init pcibios_init(void) controller->mem_offset);pci_add_resource (&resources, &controller->io_space); controller->first_busno = next_busno; - bus =pci_scan_root_bus (NULL , next_busno, controller->ops, - controller, &resources); + bus =pci_scan_root_bus (NULL , +PCI_DOMBUS (controller->index, next_busno), + controller->ops, controller, &resources); controller->root_bus = bus; next_busno = bus->busn_res.end +1 ; }
arch/x86/pci/acpi.c +3 -3
@@ -424,9 +424,9 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) }if (!setup_mcfg_map (info, domain, (u8 )root->secondary.start, - (u8 )root->secondary.end, root->mcfg_addr)) - bus =pci_create_root_bus (NULL , busnum, &pci_root_ops, - sd, &resources); + (u8 )root->secondary.end, root->mcfg_addr)) + bus =pci_create_root_bus (NULL ,PCI_DOMBUS (domain, busnum), + &pci_root_ops, sd, &resources);if (bus) {pci_scan_child_bus (bus);
arch/x86/pci/common.c +2 -1
@@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum) sd->node =x86_pci_root_bus_node (busnum);x86_pci_root_bus_resources (busnum, &resources);printk (KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n" , busnum); - bus =pci_scan_root_bus (NULL , busnum, &pci_root_ops, sd, &resources); + bus =pci_scan_root_bus (NULL ,PCI_DOMBUS (0 , busnum), + &pci_root_ops, sd, &resources);if (!bus) {pci_free_resource_list (&resources);kfree (sd);
drivers/pci/xen-pcifront.c +3 -2
@@ -477,8 +477,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,pci_lock_rescan_remove (); - b =pci_scan_root_bus (&pdev->xdev->dev, bus, - &pcifront_bus_ops, sd, &resources); + b =pci_scan_root_bus (&pdev->xdev->dev, +PCI_DOMBUS (sd->domain, bus), + &pcifront_bus_ops, sd, &resources);if (!b) {dev_err (&pdev->xdev->dev,"Error creating PCI Frontend Bus!\n" );
Signature · 1 line
1.7.1
PATCH v4 7/30 PCI: Pass PCI domain number combined with root bus number
In reply to Yijing WangNow we could pass PCI domain combined with bus number in u32 argu. Because in arm/arm64, PCI domain number is assigned by pci_bus_assign_domain_nr(). So we leave pci_scan_root_bus() and pci_create_root_bus() in arm/arm64 unchanged. A new function pci_host_assign_domain_nr() will be introduced for arm/arm64 to assign domain number in later patch.
--- arch/alpha/kernel/pci.c | 5 +++-- arch/alpha/kernel/sys_nautilus.c | 3 ++- arch/ia64/pci/pci.c | 4 ++-- arch/ia64/sn/kernel/io_init.c | 5 +++-- arch/microblaze/pci/pci-common.c | 5 +++-- arch/mips/pci/pci.c | 4 ++-- arch/powerpc/kernel/pci-common.c | 5 +++-- arch/s390/pci/pci.c | 5 +++-- arch/sh/drivers/pci/pci.c | 5 +++-- arch/sparc/kernel/pci.c | 5 +++-- arch/tile/kernel/pci.c | 4 ++-- arch/tile/kernel/pci_gx.c | 5 +++-- arch/x86/pci/acpi.c | 6 +++--- arch/x86/pci/common.c | 3 ++- drivers/pci/xen-pcifront.c | 5 +++-- 15 files changed, 40 insertions(+), 29 deletions(-)
arch/alpha/kernel/pci.c +3 -2
@@ -336,8 +336,9 @@ common_init_pci(void)pci_add_resource_offset (&resources, hose->mem_space, hose->mem_space->start); - bus =pci_scan_root_bus (NULL , next_busno, alpha_mv.pci_ops, - hose, &resources); + bus =pci_scan_root_bus (NULL , +PCI_DOMBUS (hose->index, next_busno), alpha_mv.pci_ops, + hose, &resources);if (bus)pci_bus_add_devices (bus); hose->bus = bus;
arch/alpha/kernel/sys_nautilus.c +2 -1
@@ -206,7 +206,8 @@ nautilus_init_pci(void)unsigned long memtop = max_low_pfn <<PAGE_SHIFT ;/* Scan our single hose. */ - bus =pci_scan_bus_legacy (0 , alpha_mv.pci_ops, hose); + bus =pci_scan_bus_legacy (PCI_DOMBUS (hose->index,0 ), + alpha_mv.pci_ops, hose); hose->bus = bus;pcibios_claim_one_bus (bus);
arch/ia64/pci/pci.c +2 -2
@@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)* should handle the case here, but it appears that IA64 hasn't * such quirk. So we just ignore the case now. */ - pbus =pci_create_root_bus (NULL , bus, &pci_root_ops, controller, - &info->resources); + pbus =pci_create_root_bus (NULL ,PCI_DOMBUS (domain, bus), + &pci_root_ops, controller, &info->resources);if (!pbus) {pci_free_resource_list (&info->resources);__release_pci_root_info (info);
arch/ia64/sn/kernel/io_init.c +3 -2
@@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)pci_add_resource_offset (&resources, &res[1 ], prom_bussoft_ptr->bs_legacy_mem); - bus =pci_scan_root_bus (NULL , busnum, &pci_root_ops, controller, - &resources); + bus =pci_scan_root_bus (NULL , +PCI_DOMBUS (controller->segment, busnum), + &pci_root_ops, controller, &resources);if (bus ==NULL ) {kfree (res);kfree (controller);
arch/microblaze/pci/pci-common.c +3 -2
@@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)pcibios_setup_phb_resources (hose, &resources); - bus =pci_scan_root_bus (hose->parent, hose->first_busno, - hose->ops, hose, &resources); + bus =pci_scan_root_bus (hose->parent, +PCI_DOMBUS (hose->global_number, hose->first_busno), + hose->ops, hose, &resources);if (bus ==NULL ) {pr_err ("Failed to create bus for PCI domain %04x\n" , hose->global_number);
arch/mips/pci/pci.c +2 -2
@@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)pci_add_resource_offset (&resources, hose->mem_resource, hose->mem_offset);pci_add_resource_offset (&resources, hose->io_resource, hose->io_offset); - bus =pci_scan_root_bus (NULL , next_busno, hose->pci_ops, hose, - &resources); + bus =pci_scan_root_bus (NULL ,PCI_DOMBUS (hose->index, next_busno), + hose->pci_ops, hose, &resources);if (!bus)pci_free_resource_list (&resources);
arch/powerpc/kernel/pci-common.c +3 -2
@@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)pci_add_resource (&resources, &hose->busn);/* Create an empty bus for the toplevel */ - bus =pci_create_root_bus (hose->parent, hose->first_busno, - hose->ops, hose, &resources); + bus =pci_create_root_bus (hose->parent, +PCI_DOMBUS (hose->global_number, hose->first_busno), + hose->ops, hose, &resources);if (bus ==NULL ) {pr_err ("Failed to create bus for PCI domain %04x\n" , hose->global_number);
arch/s390/pci/pci.c +3 -2
@@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)if (ret)return ret; - zdev->bus =pci_scan_root_bus (NULL ,ZPCI_BUS_NR , &pci_root_ops, - zdev, &resources); + zdev->bus =pci_scan_root_bus (NULL , +PCI_DOMBUS (zdev->domain,ZPCI_BUS_NR ), &pci_root_ops, + zdev, &resources);if (!zdev->bus) {zpci_cleanup_bus_resources (zdev);return -EIO ;
arch/sh/drivers/pci/pci.c +3 -2
@@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)pci_add_resource_offset (&resources, res, offset); } - bus =pci_scan_root_bus (NULL , next_busno, hose->pci_ops, hose, - &resources); + bus =pci_scan_root_bus (NULL , +PCI_DOMBUS (hose->index, next_busno), + hose->pci_ops, hose, &resources); hose->bus = bus; need_domain_info = need_domain_info || hose->index;
arch/sparc/kernel/pci.c +3 -2
@@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, pbm->busn.end = pbm->pci_last_busno; pbm->busn.flags =IORESOURCE_BUS ;pci_add_resource (&resources, &pbm->busn); - bus =pci_create_root_bus (parent, pbm->pci_first_busno, pbm->pci_ops, - pbm, &resources); + bus =pci_create_root_bus (parent, +PCI_DOMBUS (pbm->index, pbm->pci_first_busno), + pbm->pci_ops, pbm, &resources);if (!bus) {printk (KERN_ERR "Failed to create bus for %s\n" , node->full_name);
arch/tile/kernel/pci.c +2 -2
@@ -306,8 +306,8 @@ int __init pcibios_init(void)pci_add_resource (&resources, &ioport_resource);pci_add_resource (&resources, &iomem_resource); - bus =pci_scan_root_bus (NULL ,0 , controller->ops, - controller, &resources); + bus =pci_scan_root_bus (NULL ,PCI_DOMBUS (controller->index,0 ), + controller->ops, controller, &resources); controller->root_bus = bus; controller->last_busno = bus->busn_res.end; }
arch/tile/kernel/pci_gx.c +3 -2
@@ -881,8 +881,9 @@ int __init pcibios_init(void) controller->mem_offset);pci_add_resource (&resources, &controller->io_space); controller->first_busno = next_busno; - bus =pci_scan_root_bus (NULL , next_busno, controller->ops, - controller, &resources); + bus =pci_scan_root_bus (NULL , +PCI_DOMBUS (controller->index, next_busno), + controller->ops, controller, &resources); controller->root_bus = bus; next_busno = bus->busn_res.end +1 ; }
arch/x86/pci/acpi.c +3 -3
@@ -424,9 +424,9 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) }if (!setup_mcfg_map (info, domain, (u8 )root->secondary.start, - (u8 )root->secondary.end, root->mcfg_addr)) - bus =pci_create_root_bus (NULL , busnum, &pci_root_ops, - sd, &resources); + (u8 )root->secondary.end, root->mcfg_addr)) + bus =pci_create_root_bus (NULL ,PCI_DOMBUS (domain, busnum), + &pci_root_ops, sd, &resources);if (bus) {pci_scan_child_bus (bus);
arch/x86/pci/common.c +2 -1
@@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum) sd->node =x86_pci_root_bus_node (busnum);x86_pci_root_bus_resources (busnum, &resources);printk (KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n" , busnum); - bus =pci_scan_root_bus (NULL , busnum, &pci_root_ops, sd, &resources); + bus =pci_scan_root_bus (NULL ,PCI_DOMBUS (0 , busnum), + &pci_root_ops, sd, &resources);if (!bus) {pci_free_resource_list (&resources);kfree (sd);
drivers/pci/xen-pcifront.c +3 -2
@@ -477,8 +477,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,pci_lock_rescan_remove (); - b =pci_scan_root_bus (&pdev->xdev->dev, bus, - &pcifront_bus_ops, sd, &resources); + b =pci_scan_root_bus (&pdev->xdev->dev, +PCI_DOMBUS (sd->domain, bus), + &pcifront_bus_ops, sd, &resources);if (!b) {dev_err (&pdev->xdev->dev,"Error creating PCI Frontend Bus!\n" );
Signature · 1 line
1.7.1
PATCH v4 7/30 PCI: Pass PCI domain number combined with root bus number
In reply to Yijing WangNow we could pass PCI domain combined with bus number in u32 argu. Because in arm/arm64, PCI domain number is assigned by pci_bus_assign_domain_nr(). So we leave pci_scan_root_bus() and pci_create_root_bus() in arm/arm64 unchanged. A new function pci_host_assign_domain_nr() will be introduced for arm/arm64 to assign domain number in later patch.
--- arch/alpha/kernel/pci.c | 5 +++-- arch/alpha/kernel/sys_nautilus.c | 3 ++- arch/ia64/pci/pci.c | 4 ++-- arch/ia64/sn/kernel/io_init.c | 5 +++-- arch/microblaze/pci/pci-common.c | 5 +++-- arch/mips/pci/pci.c | 4 ++-- arch/powerpc/kernel/pci-common.c | 5 +++-- arch/s390/pci/pci.c | 5 +++-- arch/sh/drivers/pci/pci.c | 5 +++-- arch/sparc/kernel/pci.c | 5 +++-- arch/tile/kernel/pci.c | 4 ++-- arch/tile/kernel/pci_gx.c | 5 +++-- arch/x86/pci/acpi.c | 6 +++--- arch/x86/pci/common.c | 3 ++- drivers/pci/xen-pcifront.c | 5 +++-- 15 files changed, 40 insertions(+), 29 deletions(-)
arch/alpha/kernel/pci.c +3 -2
@@ -336,8 +336,9 @@ common_init_pci(void)pci_add_resource_offset (&resources, hose->mem_space, hose->mem_space->start); - bus =pci_scan_root_bus (NULL , next_busno, alpha_mv.pci_ops, - hose, &resources); + bus =pci_scan_root_bus (NULL , +PCI_DOMBUS (hose->index, next_busno), alpha_mv.pci_ops, + hose, &resources);if (bus)pci_bus_add_devices (bus); hose->bus = bus;
arch/alpha/kernel/sys_nautilus.c +2 -1
@@ -206,7 +206,8 @@ nautilus_init_pci(void)unsigned long memtop = max_low_pfn <<PAGE_SHIFT ;/* Scan our single hose. */ - bus =pci_scan_bus_legacy (0 , alpha_mv.pci_ops, hose); + bus =pci_scan_bus_legacy (PCI_DOMBUS (hose->index,0 ), + alpha_mv.pci_ops, hose); hose->bus = bus;pcibios_claim_one_bus (bus);
arch/ia64/pci/pci.c +2 -2
@@ -465,8 +465,8 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)* should handle the case here, but it appears that IA64 hasn't * such quirk. So we just ignore the case now. */ - pbus =pci_create_root_bus (NULL , bus, &pci_root_ops, controller, - &info->resources); + pbus =pci_create_root_bus (NULL ,PCI_DOMBUS (domain, bus), + &pci_root_ops, controller, &info->resources);if (!pbus) {pci_free_resource_list (&info->resources);__release_pci_root_info (info);
arch/ia64/sn/kernel/io_init.c +3 -2
@@ -266,8 +266,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)pci_add_resource_offset (&resources, &res[1 ], prom_bussoft_ptr->bs_legacy_mem); - bus =pci_scan_root_bus (NULL , busnum, &pci_root_ops, controller, - &resources); + bus =pci_scan_root_bus (NULL , +PCI_DOMBUS (controller->segment, busnum), + &pci_root_ops, controller, &resources);if (bus ==NULL ) {kfree (res);kfree (controller);
arch/microblaze/pci/pci-common.c +3 -2
@@ -1350,8 +1350,9 @@ static void pcibios_scan_phb(struct pci_controller *hose)pcibios_setup_phb_resources (hose, &resources); - bus =pci_scan_root_bus (hose->parent, hose->first_busno, - hose->ops, hose, &resources); + bus =pci_scan_root_bus (hose->parent, +PCI_DOMBUS (hose->global_number, hose->first_busno), + hose->ops, hose, &resources);if (bus ==NULL ) {pr_err ("Failed to create bus for PCI domain %04x\n" , hose->global_number);
arch/mips/pci/pci.c +2 -2
@@ -92,8 +92,8 @@ static void pcibios_scanbus(struct pci_controller *hose)pci_add_resource_offset (&resources, hose->mem_resource, hose->mem_offset);pci_add_resource_offset (&resources, hose->io_resource, hose->io_offset); - bus =pci_scan_root_bus (NULL , next_busno, hose->pci_ops, hose, - &resources); + bus =pci_scan_root_bus (NULL ,PCI_DOMBUS (hose->index, next_busno), + hose->pci_ops, hose, &resources);if (!bus)pci_free_resource_list (&resources);
arch/powerpc/kernel/pci-common.c +3 -2
@@ -1612,8 +1612,9 @@ void pcibios_scan_phb(struct pci_controller *hose)pci_add_resource (&resources, &hose->busn);/* Create an empty bus for the toplevel */ - bus =pci_create_root_bus (hose->parent, hose->first_busno, - hose->ops, hose, &resources); + bus =pci_create_root_bus (hose->parent, +PCI_DOMBUS (hose->global_number, hose->first_busno), + hose->ops, hose, &resources);if (bus ==NULL ) {pr_err ("Failed to create bus for PCI domain %04x\n" , hose->global_number);
arch/s390/pci/pci.c +3 -2
@@ -770,8 +770,9 @@ static int zpci_scan_bus(struct zpci_dev *zdev)if (ret)return ret; - zdev->bus =pci_scan_root_bus (NULL ,ZPCI_BUS_NR , &pci_root_ops, - zdev, &resources); + zdev->bus =pci_scan_root_bus (NULL , +PCI_DOMBUS (zdev->domain,ZPCI_BUS_NR ), &pci_root_ops, + zdev, &resources);if (!zdev->bus) {zpci_cleanup_bus_resources (zdev);return -EIO ;
arch/sh/drivers/pci/pci.c +3 -2
@@ -52,8 +52,9 @@ static void pcibios_scanbus(struct pci_channel *hose)pci_add_resource_offset (&resources, res, offset); } - bus =pci_scan_root_bus (NULL , next_busno, hose->pci_ops, hose, - &resources); + bus =pci_scan_root_bus (NULL , +PCI_DOMBUS (hose->index, next_busno), + hose->pci_ops, hose, &resources); hose->bus = bus; need_domain_info = need_domain_info || hose->index;
arch/sparc/kernel/pci.c +3 -2
@@ -667,8 +667,9 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, pbm->busn.end = pbm->pci_last_busno; pbm->busn.flags =IORESOURCE_BUS ;pci_add_resource (&resources, &pbm->busn); - bus =pci_create_root_bus (parent, pbm->pci_first_busno, pbm->pci_ops, - pbm, &resources); + bus =pci_create_root_bus (parent, +PCI_DOMBUS (pbm->index, pbm->pci_first_busno), + pbm->pci_ops, pbm, &resources);if (!bus) {printk (KERN_ERR "Failed to create bus for %s\n" , node->full_name);
arch/tile/kernel/pci.c +2 -2
@@ -306,8 +306,8 @@ int __init pcibios_init(void)pci_add_resource (&resources, &ioport_resource);pci_add_resource (&resources, &iomem_resource); - bus =pci_scan_root_bus (NULL ,0 , controller->ops, - controller, &resources); + bus =pci_scan_root_bus (NULL ,PCI_DOMBUS (controller->index,0 ), + controller->ops, controller, &resources); controller->root_bus = bus; controller->last_busno = bus->busn_res.end; }
arch/tile/kernel/pci_gx.c +3 -2
@@ -881,8 +881,9 @@ int __init pcibios_init(void) controller->mem_offset);pci_add_resource (&resources, &controller->io_space); controller->first_busno = next_busno; - bus =pci_scan_root_bus (NULL , next_busno, controller->ops, - controller, &resources); + bus =pci_scan_root_bus (NULL , +PCI_DOMBUS (controller->index, next_busno), + controller->ops, controller, &resources); controller->root_bus = bus; next_busno = bus->busn_res.end +1 ; }
arch/x86/pci/acpi.c +3 -3
@@ -424,9 +424,9 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) }if (!setup_mcfg_map (info, domain, (u8 )root->secondary.start, - (u8 )root->secondary.end, root->mcfg_addr)) - bus =pci_create_root_bus (NULL , busnum, &pci_root_ops, - sd, &resources); + (u8 )root->secondary.end, root->mcfg_addr)) + bus =pci_create_root_bus (NULL ,PCI_DOMBUS (domain, busnum), + &pci_root_ops, sd, &resources);if (bus) {pci_scan_child_bus (bus);
arch/x86/pci/common.c +2 -1
@@ -486,7 +486,8 @@ void pcibios_scan_root(int busnum) sd->node =x86_pci_root_bus_node (busnum);x86_pci_root_bus_resources (busnum, &resources);printk (KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n" , busnum); - bus =pci_scan_root_bus (NULL , busnum, &pci_root_ops, sd, &resources); + bus =pci_scan_root_bus (NULL ,PCI_DOMBUS (0 , busnum), + &pci_root_ops, sd, &resources);if (!bus) {pci_free_resource_list (&resources);kfree (sd);
drivers/pci/xen-pcifront.c +3 -2
@@ -477,8 +477,9 @@ static int pcifront_scan_root(struct pcifront_device *pdev,pci_lock_rescan_remove (); - b =pci_scan_root_bus (&pdev->xdev->dev, bus, - &pcifront_bus_ops, sd, &resources); + b =pci_scan_root_bus (&pdev->xdev->dev, +PCI_DOMBUS (sd->domain, bus), + &pcifront_bus_ops, sd, &resources);if (!b) {dev_err (&pdev->xdev->dev,"Error creating PCI Frontend Bus!\n" );
Signature · 1 line
1.7.1
PATCH v4 8/30 PCI: Introduce pci_host_assign_domain_nr() to assign domain
In reply to Yijing WangIntroduce pci_host_assign_domain_nr() to assign domain number for pci_host_bridge. Later we will remove pci_bus_assign_domain_nr().
--- drivers/pci/pci.c | 14 +++++++++++--- include/linux/pci.h | 4 ++++ 2 files changed, 15 insertions(+), 3 deletions(-)
drivers/pci/pci.c +11 -3
@@ -4501,10 +4501,10 @@ int pci_get_new_domain_nr(void) }#ifdef CONFIG_PCI_DOMAINS_GENERIC -void pci_bus_assign_domain_nr (struct pci_bus *bus,struct device *parent) +static int pci_assign_domain_nr (struct device *dev) {static int use_dt_domains =-1 ; -int domain =of_get_pci_domain_nr (parent->of_node); +int domain =of_get_pci_domain_nr (dev->of_node);/* * Check DT domain and use_dt_domains values.
@@ -4542,8 +4542,16 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent) parent->of_node->full_name); domain =-1 ; } +} - bus->domain_nr = domain; +void pci_host_assign_domain_nr (struct pci_host_bridge *host) +{ + host->domain =pci_assign_domain_nr (host->dev.parent); +} + +void pci_bus_assign_domain_nr (struct pci_bus *bus,struct device *parent) +{ + bus->domain_nr =pci_assign_domain_nr (parent); }#endif #endif
include/linux/pci.h +4 -0
@@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus) return bus->domain_nr; }void pci_bus_assign_domain_nr (struct pci_bus *bus,struct device *parent); +void pci_host_assign_domain_nr (struct pci_host_bridge *host);#else static inline void pci_bus_assign_domain_nr (struct pci_bus *bus,struct device *parent) { } +static inline void pci_host_assign_domain_nr (struct pci_host_bridge *host) +{ +}#endif /* some architectures require additional setup to direct VGA traffic */
Signature · 1 line
1.7.1
PATCH v4 8/30 PCI: Introduce pci_host_assign_domain_nr() to assign domain
In reply to Yijing WangIntroduce pci_host_assign_domain_nr() to assign domain number for pci_host_bridge. Later we will remove pci_bus_assign_domain_nr().
--- drivers/pci/pci.c | 14 +++++++++++--- include/linux/pci.h | 4 ++++ 2 files changed, 15 insertions(+), 3 deletions(-)
drivers/pci/pci.c +11 -3
@@ -4501,10 +4501,10 @@ int pci_get_new_domain_nr(void) }#ifdef CONFIG_PCI_DOMAINS_GENERIC -void pci_bus_assign_domain_nr (struct pci_bus *bus,struct device *parent) +static int pci_assign_domain_nr (struct device *dev) {static int use_dt_domains =-1 ; -int domain =of_get_pci_domain_nr (parent->of_node); +int domain =of_get_pci_domain_nr (dev->of_node);/* * Check DT domain and use_dt_domains values.
@@ -4542,8 +4542,16 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent) parent->of_node->full_name); domain =-1 ; } +} - bus->domain_nr = domain; +void pci_host_assign_domain_nr (struct pci_host_bridge *host) +{ + host->domain =pci_assign_domain_nr (host->dev.parent); +} + +void pci_bus_assign_domain_nr (struct pci_bus *bus,struct device *parent) +{ + bus->domain_nr =pci_assign_domain_nr (parent); }#endif #endif
include/linux/pci.h +4 -0
@@ -1327,11 +1327,15 @@ static inline int pci_domain_nr(struct pci_bus *bus) return bus->domain_nr; }void pci_bus_assign_domain_nr (struct pci_bus *bus,struct device *parent); +void pci_host_assign_domain_nr (struct pci_host_bridge *host);#else static inline void pci_bus_assign_domain_nr (struct pci_bus *bus,struct device *parent) { } +static inline void pci_host_assign_domain_nr (struct pci_host_bridge *host) +{ +}#endif /* some architectures require additional setup to direct VGA traffic */
Signature · 1 line
1.7.1
PATCH v4 9/30 PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
In reply to Yijing WangThis patch separate pci_host_bridge creation out of pci_create_root_bus(), and try to make a generic pci_host_bridge, then we could place generic PCI infos like domain number in it. Also Ripping out pci_host_bridge creation from pci_create_root_bus() make code more better readability. Further more, we could use the generic pci_host_bridge to hold host bridge specific operations like pcibios_root_bridge_prepare(). The changes are transparent to platform host bridge drivers.
--- drivers/pci/host-bridge.c | 56 ++++++++++++++++++++++ drivers/pci/probe.c | 114 ++++++++++++++++++++------------------------- include/linux/pci.h | 5 ++- 3 files changed, 110 insertions(+), 65 deletions(-)
drivers/pci/host-bridge.c +56 -0
@@ -8,6 +8,62 @@#include "pci.h" +static void pci_release_host_bridge_dev (struct device *dev) +{ +struct pci_host_bridge *bridge =to_pci_host_bridge (dev); + +if (bridge->release_fn) + bridge->release_fn (bridge); + +pci_free_resource_list (&bridge->windows); +kfree (bridge); +} + +struct pci_host_bridge *pci_create_host_bridge ( +struct device *parent,u32 db,struct list_head *resources) +{ +int error; +int bus =PCI_BUSNUM (db); +int domain =PCI_DOMAIN (db); +struct pci_host_bridge *host; +struct resource_entry *window, *n; + + host =kzalloc (sizeof (*host),GFP_KERNEL ); +if (!host) +return NULL ; + + host->busnum = bus; + host->domain = domain; +/* If support CONFIG_PCI_DOMAINS_GENERIC, use +* pci_host_assign_domain_nr() to assign domain +* number instead PCI_DOMAIN(db). +*/ +pci_host_assign_domain_nr (host); + + host->dev.parent = parent; +INIT_LIST_HEAD (&host->windows); + host->dev.release = pci_release_host_bridge_dev; +dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, + host->busnum); + + error =device_register (&host->dev); +if (error) { +put_device (&host->dev); +return NULL ; + } + +resource_list_for_each_entry_safe (window, n, resources) +list_move_tail (&window->node, &host->windows); + +return host; +} +EXPORT_SYMBOL (pci_create_host_bridge); + +void pci_free_host_bridge (struct pci_host_bridge *host) +{ +device_unregister (&host->dev); +} +static struct pci_bus *find_pci_root_bus (struct pci_bus *bus) {while (bus->parent)
drivers/pci/probe.c +50 -64
206 lines not on this page · raw message
include/linux/pci.h +4 -1
@@ -402,6 +402,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)struct pci_host_bridge {u16 domain; +u16 busnum;struct device dev;struct pci_bus *bus;/* root bus */ struct list_head windows;/* resource_entry */
@@ -415,7 +416,8 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge, void *release_data);int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge); - +struct pci_host_bridge *pci_create_host_bridge ( +struct device *parent,u32 dombus,struct list_head *resources);/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for
@@ -774,6 +776,7 @@ struct pci_bus *pci_scan_bus_legacy(u32 dombus, struct pci_ops *ops, void *sysdastruct pci_bus *pci_create_root_bus (struct device *parent,u32 dombus,struct pci_ops *ops,void *sysdata,struct list_head *resources); +void pci_free_host_bridge (struct pci_host_bridge *host);int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int busmax);int pci_bus_update_busn_res_end (struct pci_bus *b,int busmax);void pci_bus_release_busn_res (struct pci_bus *b);
Signature · 1 line
1.7.1
Bjorn Helgaas
maintainerRe: [PATCH v4 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
Quoted 66 lines · Yijing Wang
This patch separate
pci_host_bridgecreation out ofpci_create_root_bus(), and try to make a genericpci_host_bridge, then we could place generic PCI infos like domain number in it. Also Ripping outpci_host_bridgecreation frompci_create_root_bus()make code more better readability. Further more, we could use the genericpci_host_bridgeto hold host bridge specific operations likepcibios_root_bridge_prepare(). The changes are transparent to platform host bridge drivers.Signed-off-by Yijing Wang <[email protected]>--- drivers/pci/host-bridge.c | 56 ++++++++++++++++++++++ drivers/pci/probe.c | 114 ++++++++++++++++++++------------------------- include/linux/pci.h | 5 ++- 3 files changed, 110 insertions(+), 65 deletions(-)drivers/pci/host-bridge.c +40
-0@@ -8,6 +8,62 @@#include "pci.h" +static void pci_release_host_bridge_dev (struct device *dev) +{ +struct pci_host_bridge *bridge =to_pci_host_bridge (dev); + +if (bridge->release_fn) + bridge->release_fn (bridge); + +pci_free_resource_list (&bridge->windows); +kfree (bridge); +} + +struct pci_host_bridge *pci_create_host_bridge ( +struct device *parent,u32 db,struct list_head *resources) +{ +int error; +int bus =PCI_BUSNUM (db); +int domain =PCI_DOMAIN (db); +struct pci_host_bridge *host; +struct resource_entry *window, *n; + + host =kzalloc (sizeof (*host),GFP_KERNEL ); +if (!host) +return NULL ; + + host->busnum = bus; + host->domain = domain; +/* If support CONFIG_PCI_DOMAINS_GENERIC, use +* pci_host_assign_domain_nr() to assign domain +* number instead PCI_DOMAIN(db). +*/ +pci_host_assign_domain_nr (host); + + host->dev.parent = parent; +INIT_LIST_HEAD (&host->windows); + host->dev.release = pci_release_host_bridge_dev; +dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, + host->busnum); + + error =device_register (&host->dev); +if (error) {
drivers/pci/host-bridge.c line 60
Quoted 10 lines
drivers/pci/host-bridge.c +10
-0+put_device (&host->dev); +return NULL ; + } + +resource_list_for_each_entry_safe (window, n, resources) +list_move_tail (&window->node, &host->windows); + +return host; +} +EXPORT_SYMBOL (pci_create_host_bridge);
Why does this need to be exported? I don't want code outside drivers/pci using something like this.
Quoted 23 lines
drivers/pci/host-bridge.c +5
-0+void pci_free_host_bridge (struct pci_host_bridge *host) +{ +device_unregister (&host->dev); +} +static struct pci_bus *find_pci_root_bus (struct pci_bus *bus) {while (bus->parent)include/linux/pci.h +1
-0@@ -402,6 +402,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)struct pci_host_bridge {u16 domain; +u16 busnum;struct device dev;struct pci_bus *bus;/* root bus */ struct list_head windows;/* resource_entry */
include/linux/pci.h void pci_set_host_bridge_release(struct pci_host_bridge *bridge, · line 420
Quoted 6 lines
include/linux/pci.h +2
-1@@ -415,7 +416,8 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge, void *release_data);int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge); - +struct pci_host_bridge *pci_create_host_bridge ( +struct device *parent,u32 dombus,struct list_head *resources);
Can these function declarations go in drivers/pci/pci.h instead? I'd rather not expose them to the rest of the kernel unless we have to.
Quoted 14 lines
include/linux/pci.h +1
-0/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for @@ -774,6 +776,7 @@ struct pci_bus *pci_scan_bus_legacy(u32 dombus, struct pci_ops *ops, void *sysdastruct pci_bus *pci_create_root_bus (struct device *parent,u32 dombus,struct pci_ops *ops,void *sysdata,struct list_head *resources); +void pci_free_host_bridge (struct pci_host_bridge *host);int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int busmax);int pci_bus_update_busn_res_end (struct pci_bus *b,int busmax);void pci_bus_release_busn_res (struct pci_bus *b);Signature · 1 line
1.7.1
Re: [PATCH v4 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
Quoted 10 lines
drivers/pci/host-bridge.c line 60
Quoted 7 lines
drivers/pci/host-bridge.c +7
-0+ +resource_list_for_each_entry_safe (window, n, resources) +list_move_tail (&window->node, &host->windows); + +return host; +} +EXPORT_SYMBOL (pci_create_host_bridge);Why does this need to be exported? I don't want code outside
drivers/pciusing something like this.
OK, I will unexport it, if some drivers really want to export it, we could do it when needed.
Quoted 11 lines
Quoted 11 lines
include/linux/pci.h +2
-0+void pci_free_host_bridge (struct pci_host_bridge *host) struct pci_host_bridge {u16 domain; +u16 busnum;struct device dev;struct pci_bus *bus;/* root bus */ struct list_head windows;/* resource_entry */ @@ -415,7 +416,8 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge, void *release_data);
Quoted 7 lines
include/linux/pci.h void pci_set_host_bridge_release(struct pci_host_bridge *bridge, · line 420
Quoted 4 lines
include/linux/pci.h +2
-1int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge); - +struct pci_host_bridge *pci_create_host_bridge ( +struct device *parent,u32 dombus,struct list_head *resources);Can these function declarations go in
drivers/pci/pci.hinstead? I'd rather not expose them to the rest of the kernel unless we have to.
I would move it in drivers/pci/pci.h, thanks.
Quoted 18 lines
Quoted 15 lines
include/linux/pci.h +1
-0/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for @@ -774,6 +776,7 @@ struct pci_bus *pci_scan_bus_legacy(u32 dombus, struct pci_ops *ops, void *sysdastruct pci_bus *pci_create_root_bus (struct device *parent,u32 dombus,struct pci_ops *ops,void *sysdata,struct list_head *resources); +void pci_free_host_bridge (struct pci_host_bridge *host);int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int busmax);int pci_bus_update_busn_res_end (struct pci_bus *b,int busmax);void pci_bus_release_busn_res (struct pci_bus *b);Signature · 1 line
1.7.1.
Signature · 2 lines
Thanks! Yijing
Re: [PATCH v4 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
In reply to Bjorn HelgaasQuoted 10 lines
drivers/pci/host-bridge.c line 60
Quoted 7 lines
drivers/pci/host-bridge.c +7
-0+ +resource_list_for_each_entry_safe (window, n, resources) +list_move_tail (&window->node, &host->windows); + +return host; +} +EXPORT_SYMBOL (pci_create_host_bridge);Why does this need to be exported? I don't want code outside
drivers/pciusing something like this.
OK, I will unexport it, if some drivers really want to export it, we could do it when needed.
Quoted 11 lines
Quoted 11 lines
include/linux/pci.h +2
-0+void pci_free_host_bridge (struct pci_host_bridge *host) struct pci_host_bridge {u16 domain; +u16 busnum;struct device dev;struct pci_bus *bus;/* root bus */ struct list_head windows;/* resource_entry */ @@ -415,7 +416,8 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge, void *release_data);
Quoted 7 lines
include/linux/pci.h void pci_set_host_bridge_release(struct pci_host_bridge *bridge, · line 420
Quoted 4 lines
include/linux/pci.h +2
-1int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge); - +struct pci_host_bridge *pci_create_host_bridge ( +struct device *parent,u32 dombus,struct list_head *resources);Can these function declarations go in
drivers/pci/pci.hinstead? I'd rather not expose them to the rest of the kernel unless we have to.
I would move it in drivers/pci/pci.h, thanks.
Quoted 18 lines
Quoted 15 lines
include/linux/pci.h +1
-0/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for @@ -774,6 +776,7 @@ struct pci_bus *pci_scan_bus_legacy(u32 dombus, struct pci_ops *ops, void *sysdastruct pci_bus *pci_create_root_bus (struct device *parent,u32 dombus,struct pci_ops *ops,void *sysdata,struct list_head *resources); +void pci_free_host_bridge (struct pci_host_bridge *host);int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int busmax);int pci_bus_update_busn_res_end (struct pci_bus *b,int busmax);void pci_bus_release_busn_res (struct pci_bus *b);Signature · 1 line
1.7.1.
Signature · 2 lines
Thanks! Yijing
Bjorn Helgaas
maintainerRe: [PATCH v4 09/30] PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
In reply to Yijing WangQuoted 66 lines · Yijing Wang
This patch separate
pci_host_bridgecreation out ofpci_create_root_bus(), and try to make a genericpci_host_bridge, then we could place generic PCI infos like domain number in it. Also Ripping outpci_host_bridgecreation frompci_create_root_bus()make code more better readability. Further more, we could use the genericpci_host_bridgeto hold host bridge specific operations likepcibios_root_bridge_prepare(). The changes are transparent to platform host bridge drivers.Signed-off-by Yijing Wang <[email protected]>--- drivers/pci/host-bridge.c | 56 ++++++++++++++++++++++ drivers/pci/probe.c | 114 ++++++++++++++++++++------------------------- include/linux/pci.h | 5 ++- 3 files changed, 110 insertions(+), 65 deletions(-)drivers/pci/host-bridge.c +40
-0@@ -8,6 +8,62 @@#include "pci.h" +static void pci_release_host_bridge_dev (struct device *dev) +{ +struct pci_host_bridge *bridge =to_pci_host_bridge (dev); + +if (bridge->release_fn) + bridge->release_fn (bridge); + +pci_free_resource_list (&bridge->windows); +kfree (bridge); +} + +struct pci_host_bridge *pci_create_host_bridge ( +struct device *parent,u32 db,struct list_head *resources) +{ +int error; +int bus =PCI_BUSNUM (db); +int domain =PCI_DOMAIN (db); +struct pci_host_bridge *host; +struct resource_entry *window, *n; + + host =kzalloc (sizeof (*host),GFP_KERNEL ); +if (!host) +return NULL ; + + host->busnum = bus; + host->domain = domain; +/* If support CONFIG_PCI_DOMAINS_GENERIC, use +* pci_host_assign_domain_nr() to assign domain +* number instead PCI_DOMAIN(db). +*/ +pci_host_assign_domain_nr (host); + + host->dev.parent = parent; +INIT_LIST_HEAD (&host->windows); + host->dev.release = pci_release_host_bridge_dev; +dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, + host->busnum); + + error =device_register (&host->dev); +if (error) {
drivers/pci/host-bridge.c line 60
Quoted 10 lines
drivers/pci/host-bridge.c +10
-0+put_device (&host->dev); +return NULL ; + } + +resource_list_for_each_entry_safe (window, n, resources) +list_move_tail (&window->node, &host->windows); + +return host; +} +EXPORT_SYMBOL (pci_create_host_bridge);
Why does this need to be exported? I don't want code outside drivers/pci using something like this.
Quoted 23 lines
drivers/pci/host-bridge.c +5
-0+void pci_free_host_bridge (struct pci_host_bridge *host) +{ +device_unregister (&host->dev); +} +static struct pci_bus *find_pci_root_bus (struct pci_bus *bus) {while (bus->parent)include/linux/pci.h +1
-0@@ -402,6 +402,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)struct pci_host_bridge {u16 domain; +u16 busnum;struct device dev;struct pci_bus *bus;/* root bus */ struct list_head windows;/* resource_entry */
include/linux/pci.h void pci_set_host_bridge_release(struct pci_host_bridge *bridge, · line 420
Quoted 6 lines
include/linux/pci.h +2
-1@@ -415,7 +416,8 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge, void *release_data);int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge); - +struct pci_host_bridge *pci_create_host_bridge ( +struct device *parent,u32 dombus,struct list_head *resources);
Can these function declarations go in drivers/pci/pci.h instead? I'd rather not expose them to the rest of the kernel unless we have to.
Quoted 14 lines
include/linux/pci.h +1
-0/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for @@ -774,6 +776,7 @@ struct pci_bus *pci_scan_bus_legacy(u32 dombus, struct pci_ops *ops, void *sysdastruct pci_bus *pci_create_root_bus (struct device *parent,u32 dombus,struct pci_ops *ops,void *sysdata,struct list_head *resources); +void pci_free_host_bridge (struct pci_host_bridge *host);int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int busmax);int pci_bus_update_busn_res_end (struct pci_bus *b,int busmax);void pci_bus_release_busn_res (struct pci_bus *b);Signature · 1 line
1.7.1
PATCH v4 9/30 PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
In reply to Yijing WangThis patch separate pci_host_bridge creation out of pci_create_root_bus(), and try to make a generic pci_host_bridge, then we could place generic PCI infos like domain number in it. Also Ripping out pci_host_bridge creation from pci_create_root_bus() make code more better readability. Further more, we could use the generic pci_host_bridge to hold host bridge specific operations like pcibios_root_bridge_prepare(). The changes are transparent to platform host bridge drivers.
--- drivers/pci/host-bridge.c | 56 ++++++++++++++++++++++ drivers/pci/probe.c | 114 ++++++++++++++++++++------------------------- include/linux/pci.h | 5 ++- 3 files changed, 110 insertions(+), 65 deletions(-)
drivers/pci/host-bridge.c +56 -0
@@ -8,6 +8,62 @@#include "pci.h" +static void pci_release_host_bridge_dev (struct device *dev) +{ +struct pci_host_bridge *bridge =to_pci_host_bridge (dev); + +if (bridge->release_fn) + bridge->release_fn (bridge); + +pci_free_resource_list (&bridge->windows); +kfree (bridge); +} + +struct pci_host_bridge *pci_create_host_bridge ( +struct device *parent,u32 db,struct list_head *resources) +{ +int error; +int bus =PCI_BUSNUM (db); +int domain =PCI_DOMAIN (db); +struct pci_host_bridge *host; +struct resource_entry *window, *n; + + host =kzalloc (sizeof (*host),GFP_KERNEL ); +if (!host) +return NULL ; + + host->busnum = bus; + host->domain = domain; +/* If support CONFIG_PCI_DOMAINS_GENERIC, use +* pci_host_assign_domain_nr() to assign domain +* number instead PCI_DOMAIN(db). +*/ +pci_host_assign_domain_nr (host); + + host->dev.parent = parent; +INIT_LIST_HEAD (&host->windows); + host->dev.release = pci_release_host_bridge_dev; +dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, + host->busnum); + + error =device_register (&host->dev); +if (error) { +put_device (&host->dev); +return NULL ; + } + +resource_list_for_each_entry_safe (window, n, resources) +list_move_tail (&window->node, &host->windows); + +return host; +} +EXPORT_SYMBOL (pci_create_host_bridge); + +void pci_free_host_bridge (struct pci_host_bridge *host) +{ +device_unregister (&host->dev); +} +static struct pci_bus *find_pci_root_bus (struct pci_bus *bus) {while (bus->parent)
drivers/pci/probe.c +50 -64
206 lines not on this page · raw message
include/linux/pci.h +4 -1
@@ -402,6 +402,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)struct pci_host_bridge {u16 domain; +u16 busnum;struct device dev;struct pci_bus *bus;/* root bus */ struct list_head windows;/* resource_entry */
@@ -415,7 +416,8 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge, void *release_data);int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge); - +struct pci_host_bridge *pci_create_host_bridge ( +struct device *parent,u32 dombus,struct list_head *resources);/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for
@@ -774,6 +776,7 @@ struct pci_bus *pci_scan_bus_legacy(u32 dombus, struct pci_ops *ops, void *sysdastruct pci_bus *pci_create_root_bus (struct device *parent,u32 dombus,struct pci_ops *ops,void *sysdata,struct list_head *resources); +void pci_free_host_bridge (struct pci_host_bridge *host);int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int busmax);int pci_bus_update_busn_res_end (struct pci_bus *b,int busmax);void pci_bus_release_busn_res (struct pci_bus *b);
Signature · 1 line
1.7.1
PATCH v4 10/30 PCI: Introduce pci_host_bridge_list to manage host bridges
In reply to Yijing WangIntroduce pci_host_bridge_list to manage pci host bridges in system, so we could detect whether the host in domain:bus is alreay registered. Then we could remove bus alreay exist test in __pci_create_root_bus().
--- drivers/pci/host-bridge.c | 24 +++++++++++++++++++++++- drivers/pci/probe.c | 8 +------- include/linux/pci.h | 1 + 3 files changed, 25 insertions(+), 8 deletions(-)
drivers/pci/host-bridge.c +23 -1
@@ -8,6 +8,9 @@#include "pci.h" +static LIST_HEAD (pci_host_bridge_list); +static DEFINE_MUTEX (phb_mutex); +static void pci_release_host_bridge_dev (struct device *dev) {struct pci_host_bridge *bridge =to_pci_host_bridge (dev);
@@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(int error;int bus =PCI_BUSNUM (db);int domain =PCI_DOMAIN (db); -struct pci_host_bridge *host; +struct pci_host_bridge *host, *temp;struct resource_entry *window, *n; host =kzalloc (sizeof (*host),GFP_KERNEL );
@@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(*/ pci_host_assign_domain_nr (host); +mutex_lock (&phb_mutex); +list_for_each_entry (temp, &pci_host_bridge_list, list) +if (temp->domain == host->domain + && temp->busnum == host->busnum) { +dev_dbg (&host->dev,"pci host bridge pci%04x:%02x exist\n" , + host->domain, host->busnum); +mutex_unlock (&phb_mutex); +kfree (host); +return NULL ; + } +mutex_unlock (&phb_mutex); + host->dev.parent = parent;INIT_LIST_HEAD (&host->windows); host->dev.release = pci_release_host_bridge_dev;
@@ -55,12 +70,19 @@ struct pci_host_bridge *pci_create_host_bridge(resource_list_for_each_entry_safe (window, n, resources)list_move_tail (&window->node, &host->windows); +mutex_lock (&phb_mutex); +list_add_tail (&host->list, &pci_host_bridge_list); +mutex_unlock (&phb_mutex);return host; }EXPORT_SYMBOL (pci_create_host_bridge);void pci_free_host_bridge (struct pci_host_bridge *host) { +mutex_lock (&phb_mutex); +list_del (&host->list); +mutex_unlock (&phb_mutex); +device_unregister (&host->dev); }
drivers/pci/probe.c +1 -7
@@ -1869,7 +1869,7 @@ static struct pci_bus *__pci_create_root_bus( void *sysdata) {int error; -struct pci_bus *b, *b2; +struct pci_bus *b;struct resource_entry *window;struct device *parent;struct resource *res;
@@ -1886,12 +1886,6 @@ static struct pci_bus *__pci_create_root_bus( b->ops = ops; b->number = b->busn_res.start = bridge->busnum;pci_bus_assign_domain_nr (b, parent); - b2 =pci_find_bus (pci_domain_nr (b), b->number); -if (b2) { -/* If we already got to this bus through a different bridge, ignore it */ -dev_dbg (&b2->dev,"bus already known\n" ); - goto err_out; - } bridge->bus = b; b->bridge =get_device (&bridge->dev);
include/linux/pci.h +1 -0
@@ -406,6 +406,7 @@ struct pci_host_bridge {struct device dev;struct pci_bus *bus;/* root bus */ struct list_head windows;/* resource_entry */ +struct list_head list;void (*release_fn)(struct pci_host_bridge *);void *release_data; };
Signature · 1 line
1.7.1
PATCH v4 10/30 PCI: Introduce pci_host_bridge_list to manage host bridges
In reply to Yijing WangIntroduce pci_host_bridge_list to manage pci host bridges in system, so we could detect whether the host in domain:bus is alreay registered. Then we could remove bus alreay exist test in __pci_create_root_bus().
--- drivers/pci/host-bridge.c | 24 +++++++++++++++++++++++- drivers/pci/probe.c | 8 +------- include/linux/pci.h | 1 + 3 files changed, 25 insertions(+), 8 deletions(-)
drivers/pci/host-bridge.c +23 -1
@@ -8,6 +8,9 @@#include "pci.h" +static LIST_HEAD (pci_host_bridge_list); +static DEFINE_MUTEX (phb_mutex); +static void pci_release_host_bridge_dev (struct device *dev) {struct pci_host_bridge *bridge =to_pci_host_bridge (dev);
@@ -25,7 +28,7 @@ struct pci_host_bridge *pci_create_host_bridge(int error;int bus =PCI_BUSNUM (db);int domain =PCI_DOMAIN (db); -struct pci_host_bridge *host; +struct pci_host_bridge *host, *temp;struct resource_entry *window, *n; host =kzalloc (sizeof (*host),GFP_KERNEL );
@@ -40,6 +43,18 @@ struct pci_host_bridge *pci_create_host_bridge(*/ pci_host_assign_domain_nr (host); +mutex_lock (&phb_mutex); +list_for_each_entry (temp, &pci_host_bridge_list, list) +if (temp->domain == host->domain + && temp->busnum == host->busnum) { +dev_dbg (&host->dev,"pci host bridge pci%04x:%02x exist\n" , + host->domain, host->busnum); +mutex_unlock (&phb_mutex); +kfree (host); +return NULL ; + } +mutex_unlock (&phb_mutex); + host->dev.parent = parent;INIT_LIST_HEAD (&host->windows); host->dev.release = pci_release_host_bridge_dev;
@@ -55,12 +70,19 @@ struct pci_host_bridge *pci_create_host_bridge(resource_list_for_each_entry_safe (window, n, resources)list_move_tail (&window->node, &host->windows); +mutex_lock (&phb_mutex); +list_add_tail (&host->list, &pci_host_bridge_list); +mutex_unlock (&phb_mutex);return host; }EXPORT_SYMBOL (pci_create_host_bridge);void pci_free_host_bridge (struct pci_host_bridge *host) { +mutex_lock (&phb_mutex); +list_del (&host->list); +mutex_unlock (&phb_mutex); +device_unregister (&host->dev); }
drivers/pci/probe.c +1 -7
@@ -1869,7 +1869,7 @@ static struct pci_bus *__pci_create_root_bus( void *sysdata) {int error; -struct pci_bus *b, *b2; +struct pci_bus *b;struct resource_entry *window;struct device *parent;struct resource *res;
@@ -1886,12 +1886,6 @@ static struct pci_bus *__pci_create_root_bus( b->ops = ops; b->number = b->busn_res.start = bridge->busnum;pci_bus_assign_domain_nr (b, parent); - b2 =pci_find_bus (pci_domain_nr (b), b->number); -if (b2) { -/* If we already got to this bus through a different bridge, ignore it */ -dev_dbg (&b2->dev,"bus already known\n" ); - goto err_out; - } bridge->bus = b; b->bridge =get_device (&bridge->dev);
include/linux/pci.h +1 -0
@@ -406,6 +406,7 @@ struct pci_host_bridge {struct device dev;struct pci_bus *bus;/* root bus */ struct list_head windows;/* resource_entry */ +struct list_head list;void (*release_fn)(struct pci_host_bridge *);void *release_data; };
Signature · 1 line
1.7.1
PATCH v4 11/30 PCI: Save sysdata in pci_host_bridge drvdata
In reply to Yijing WangSave platform specific sysdata in pci_host_bridge
drvdata, host bridge specific operation need to
access it before the pci bus creation.
--- drivers/pci/host-bridge.c | 4 +++- drivers/pci/probe.c | 18 ++++++++---------- include/linux/pci.h | 3 ++- 3 files changed, 13 insertions(+), 12 deletions(-)
drivers/pci/host-bridge.c +3 -1
@@ -23,7 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev) }struct pci_host_bridge *pci_create_host_bridge ( -struct device *parent,u32 db,struct list_head *resources) +struct device *parent,u32 db, +struct list_head *resources,void *sysdata) {int error;int bus =PCI_BUSNUM (db);
@@ -58,6 +59,7 @@ struct pci_host_bridge *pci_create_host_bridge( host->dev.parent = parent;INIT_LIST_HEAD (&host->windows); host->dev.release = pci_release_host_bridge_dev; +dev_set_drvdata (&host->dev, sysdata);dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, host->busnum);
drivers/pci/probe.c +8 -10
@@ -1865,8 +1865,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus) }static struct pci_bus *__pci_create_root_bus ( -struct pci_host_bridge *bridge,struct pci_ops *ops, -void *sysdata) +struct pci_host_bridge *bridge,struct pci_ops *ops) {int error;struct pci_bus *b;
@@ -1882,7 +1881,7 @@ static struct pci_bus *__pci_create_root_bus(if (!b)return NULL ; - b->sysdata = sysdata; + b->sysdata =dev_get_drvdata (&bridge->dev); b->ops = ops; b->number = b->busn_res.start = bridge->busnum;pci_bus_assign_domain_nr (b, parent);
@@ -1954,11 +1953,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db, {struct pci_host_bridge *host; - host =pci_create_host_bridge (parent, db, resources); + host =pci_create_host_bridge (parent, db, resources, sysdata);if (!host)return NULL ; -return __pci_create_root_bus (host, ops, sysdata); +return __pci_create_root_bus (host, ops); }int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int bus_max)
@@ -2025,8 +2024,7 @@ void pci_bus_release_busn_res(struct pci_bus *b) }static struct pci_bus *__pci_scan_root_bus ( -struct pci_host_bridge *host,struct pci_ops *ops, -void *sysdata) +struct pci_host_bridge *host,struct pci_ops *ops) {struct resource_entry *window;bool found = false;
@@ -2039,7 +2037,7 @@ static struct pci_bus *__pci_scan_root_bus(break ; } - b =__pci_create_root_bus (host, ops, sysdata); + b =__pci_create_root_bus (host, ops);if (!b) {pci_free_host_bridge (host);return NULL ;
@@ -2065,11 +2063,11 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db, {struct pci_host_bridge *host; - host =pci_create_host_bridge (parent, db, resources); + host =pci_create_host_bridge (parent, db, resources, sysdata);if (!host)return NULL ; -return __pci_scan_root_bus (host, ops, sysdata); +return __pci_scan_root_bus (host, ops); }EXPORT_SYMBOL (pci_scan_root_bus);
include/linux/pci.h +2 -1
@@ -418,7 +418,8 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge);struct pci_host_bridge *pci_create_host_bridge ( -struct device *parent,u32 dombus,struct list_head *resources); +struct device *parent,u32 dombus, +struct list_head *resources,void *sysdata);/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for
Signature · 1 line
1.7.1
PATCH v4 11/30 PCI: Save sysdata in pci_host_bridge drvdata
In reply to Yijing WangSave platform specific sysdata in pci_host_bridge
drvdata, host bridge specific operation need to
access it before the pci bus creation.
--- drivers/pci/host-bridge.c | 4 +++- drivers/pci/probe.c | 18 ++++++++---------- include/linux/pci.h | 3 ++- 3 files changed, 13 insertions(+), 12 deletions(-)
drivers/pci/host-bridge.c +3 -1
@@ -23,7 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev) }struct pci_host_bridge *pci_create_host_bridge ( -struct device *parent,u32 db,struct list_head *resources) +struct device *parent,u32 db, +struct list_head *resources,void *sysdata) {int error;int bus =PCI_BUSNUM (db);
@@ -58,6 +59,7 @@ struct pci_host_bridge *pci_create_host_bridge( host->dev.parent = parent;INIT_LIST_HEAD (&host->windows); host->dev.release = pci_release_host_bridge_dev; +dev_set_drvdata (&host->dev, sysdata);dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, host->busnum);
drivers/pci/probe.c +8 -10
@@ -1865,8 +1865,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus) }static struct pci_bus *__pci_create_root_bus ( -struct pci_host_bridge *bridge,struct pci_ops *ops, -void *sysdata) +struct pci_host_bridge *bridge,struct pci_ops *ops) {int error;struct pci_bus *b;
@@ -1882,7 +1881,7 @@ static struct pci_bus *__pci_create_root_bus(if (!b)return NULL ; - b->sysdata = sysdata; + b->sysdata =dev_get_drvdata (&bridge->dev); b->ops = ops; b->number = b->busn_res.start = bridge->busnum;pci_bus_assign_domain_nr (b, parent);
@@ -1954,11 +1953,11 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db, {struct pci_host_bridge *host; - host =pci_create_host_bridge (parent, db, resources); + host =pci_create_host_bridge (parent, db, resources, sysdata);if (!host)return NULL ; -return __pci_create_root_bus (host, ops, sysdata); +return __pci_create_root_bus (host, ops); }int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int bus_max)
@@ -2025,8 +2024,7 @@ void pci_bus_release_busn_res(struct pci_bus *b) }static struct pci_bus *__pci_scan_root_bus ( -struct pci_host_bridge *host,struct pci_ops *ops, -void *sysdata) +struct pci_host_bridge *host,struct pci_ops *ops) {struct resource_entry *window;bool found = false;
@@ -2039,7 +2037,7 @@ static struct pci_bus *__pci_scan_root_bus(break ; } - b =__pci_create_root_bus (host, ops, sysdata); + b =__pci_create_root_bus (host, ops);if (!b) {pci_free_host_bridge (host);return NULL ;
@@ -2065,11 +2063,11 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db, {struct pci_host_bridge *host; - host =pci_create_host_bridge (parent, db, resources); + host =pci_create_host_bridge (parent, db, resources, sysdata);if (!host)return NULL ; -return __pci_scan_root_bus (host, ops, sysdata); +return __pci_scan_root_bus (host, ops); }EXPORT_SYMBOL (pci_scan_root_bus);
include/linux/pci.h +2 -1
@@ -418,7 +418,8 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge);struct pci_host_bridge *pci_create_host_bridge ( -struct device *parent,u32 dombus,struct list_head *resources); +struct device *parent,u32 dombus, +struct list_head *resources,void *sysdata);/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for
Signature · 1 line
1.7.1
PATCH v4 12/30 PCI: Introduce pci_host_bridge_ops to support host specific operations
In reply to Yijing WangNow we have weak functions like pcibios_root_bridge_prepare() to setup pci host bridge, We could introduce pci_host_bridge_ops which contain host bridge specific ops to setup pci_host_bridge. Then host bridge driver could add pci_host_bridge_ops hooks intead of weak function to setup pci_host_bridge.
This patch add following pci_host_bridge_ops hooks:
pci_host_bridge_ops {
/* set root bus speed, some platform need this like powerpc */
void (*phb_set_root_bus_speed)(struct pci_host_bridge *host);
/* setup pci_host_bridge before pci_host_bridge be added to driver core */
int (*phb_prepare)(struct pci_host_bridge *host);
/* platform specific of scan hook to scan pci device */
void (*phb_of_scan_bus)(struct pci_host_bridge *);
}We could easily extend it to support different host bridge specific operations.
--- drivers/pci/host-bridge.c | 12 ++++++++++-- drivers/pci/probe.c | 17 +++++++++++------ include/linux/pci.h | 12 ++++++++++-- 3 files changed, 31 insertions(+), 10 deletions(-)
drivers/pci/host-bridge.c +10 -2
@@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev) }struct pci_host_bridge *pci_create_host_bridge ( -struct device *parent,u32 db, -struct list_head *resources,void *sysdata) +struct device *parent,u32 db,struct list_head *resources, +void *sysdata,struct pci_host_bridge_ops *ops) {int error;int bus =PCI_BUSNUM (db);
@@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge( }mutex_unlock (&phb_mutex); + host->ops = ops; host->dev.parent = parent;INIT_LIST_HEAD (&host->windows); host->dev.release = pci_release_host_bridge_dev;
@@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge(dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, host->busnum); +if (host->ops && host->ops->phb_prepare) { + error = host->ops->phb_prepare (host); +if (error) { +kfree (host); +return NULL ; + } + } error =device_register (&host->dev);if (error) {put_device (&host->dev);
drivers/pci/probe.c +11 -6
@@ -1888,6 +1888,8 @@ static struct pci_bus *__pci_create_root_bus( bridge->bus = b; b->bridge =get_device (&bridge->dev); +if (bridge->ops && bridge->ops->phb_set_root_bus_speed) + bridge->ops->phb_set_root_bus_speed (bridge); error =pcibios_root_bridge_prepare (bridge);if (error) goto err_out;
@@ -1953,7 +1955,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db, {struct pci_host_bridge *host; - host =pci_create_host_bridge (parent, db, resources, sysdata); + host =pci_create_host_bridge (parent, db, resources, sysdata,NULL );if (!host)return NULL ;
@@ -2050,10 +2052,13 @@ static struct pci_bus *__pci_scan_root_bus(pci_bus_insert_busn_res (b, b->number,255 ); } - max =pci_scan_child_bus (b); - -if (!found) -pci_bus_update_busn_res_end (b, max); +if (host->ops && host->ops->phb_of_scan_bus) { + host->ops->phb_of_scan_bus (host); + }else { + max =pci_scan_child_bus (b); +if (!found) +pci_bus_update_busn_res_end (b, max); + }return b; }
@@ -2063,7 +2068,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db, {struct pci_host_bridge *host; - host =pci_create_host_bridge (parent, db, resources, sysdata); + host =pci_create_host_bridge (parent, db, resources, sysdata,NULL );if (!host)return NULL ;
include/linux/pci.h +10 -2
@@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)return (pdev->error_state != pci_channel_io_normal); } +struct pci_host_bridge ; +struct pci_host_bridge_ops { +void (*phb_set_root_bus_speed)(struct pci_host_bridge *host); +int (*phb_prepare)(struct pci_host_bridge *host); +void (*phb_of_scan_bus)(struct pci_host_bridge *); +}; +struct pci_host_bridge {u16 domain;u16 busnum;
@@ -407,6 +414,7 @@ struct pci_host_bridge {struct pci_bus *bus;/* root bus */ struct list_head windows;/* resource_entry */ struct list_head list; +struct pci_host_bridge_ops *ops;void (*release_fn)(struct pci_host_bridge *);void *release_data; };
@@ -418,8 +426,8 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge);struct pci_host_bridge *pci_create_host_bridge ( -struct device *parent,u32 dombus, -struct list_head *resources,void *sysdata); +struct device *parent,u32 dombus,struct list_head *resources, +void *sysdata,struct pci_host_bridge_ops *ops);/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for
Signature · 1 line
1.7.1
Bjorn Helgaas
maintainerRe: [PATCH v4 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
Quoted 49 lines · Yijing Wang
Now we have weak functions like
pcibios_root_bridge_prepare()to setup pci host bridge, We could introducepci_host_bridge_opswhich contain host bridge specific ops to setuppci_host_bridge. Then host bridge driver could addpci_host_bridge_opshooks intead of weak function to setuppci_host_bridge.
This patch add followingpci_host_bridge_opshooks:pci_host_bridge_ops { /* set root bus speed, some platform need this like powerpc */ void (*phb_set_root_bus_speed)(struct pci_host_bridge *host); /* setup pci_host_bridge before pci_host_bridge be added to driver core */ int (*phb_prepare)(struct pci_host_bridge *host); /* platform specific of scan hook to scan pci device */ void (*phb_of_scan_bus)(struct pci_host_bridge *); }We could easily extend it to support different host bridge specific operations.
Signed-off-by Yijing Wang <[email protected]>--- drivers/pci/host-bridge.c | 12 ++++++++++-- drivers/pci/probe.c | 17 +++++++++++------ include/linux/pci.h | 12 ++++++++++-- 3 files changed, 31 insertions(+), 10 deletions(-)drivers/pci/host-bridge.c +3
-2@@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev) }struct pci_host_bridge *pci_create_host_bridge ( -struct device *parent,u32 db, -struct list_head *resources,void *sysdata) +struct device *parent,u32 db,struct list_head *resources, +void *sysdata,struct pci_host_bridge_ops *ops) {int error;int bus =PCI_BUSNUM (db);@@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge( }mutex_unlock (&phb_mutex); + host->ops = ops; host->dev.parent = parent;INIT_LIST_HEAD (&host->windows); host->dev.release = pci_release_host_bridge_dev;
drivers/pci/host-bridge.c struct pci_host_bridge *pci_create_host_bridge( · line 69
Quoted 6 lines
drivers/pci/host-bridge.c +3
-0@@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge(dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, host->busnum); +if (host->ops && host->ops->phb_prepare) { + error = host->ops->phb_prepare (host); +if (error) {
Whitespace error.
include/linux/pci.h static inline int pci_channel_offline(struct pci_dev *pdev) · line 407
Quoted 11 lines
include/linux/pci.h +5
-0@@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)return (pdev->error_state != pci_channel_io_normal); } +struct pci_host_bridge ; +struct pci_host_bridge_ops { +void (*phb_set_root_bus_speed)(struct pci_host_bridge *host); +int (*phb_prepare)(struct pci_host_bridge *host); +void (*phb_of_scan_bus)(struct pci_host_bridge *);
These function pointers don't need a "phb_" prefix.
Re: [PATCH v4 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
Quoted 5 lines
drivers/pci/host-bridge.c struct pci_host_bridge *pci_create_host_bridge( · line 69
Quoted 3 lines
drivers/pci/host-bridge.c +3
-0+if (host->ops && host->ops->phb_prepare) { + error = host->ops->phb_prepare (host); +if (error) {Whitespace error.
Will fix.
Quoted 7 lines
Quoted 7 lines
include/linux/pci.h +0
-0@@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)return (pdev->error_state != pci_channel_io_normal); }
Quoted 7 lines
include/linux/pci.h static inline int pci_channel_offline(struct pci_dev *pdev) · line 407
Quoted 5 lines
include/linux/pci.h +5
-0+struct pci_host_bridge ; +struct pci_host_bridge_ops { +void (*phb_set_root_bus_speed)(struct pci_host_bridge *host); +int (*phb_prepare)(struct pci_host_bridge *host); +void (*phb_of_scan_bus)(struct pci_host_bridge *);These function pointers don't need a "
phb_" prefix.
Will update them.
Quoted 3 lines
.
Signature · 2 lines
Thanks! Yijing
Re: [PATCH v4 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
In reply to Bjorn HelgaasQuoted 5 lines
drivers/pci/host-bridge.c struct pci_host_bridge *pci_create_host_bridge( · line 69
Quoted 3 lines
drivers/pci/host-bridge.c +3
-0+if (host->ops && host->ops->phb_prepare) { + error = host->ops->phb_prepare (host); +if (error) {Whitespace error.
Will fix.
Quoted 7 lines
Quoted 7 lines
include/linux/pci.h +0
-0@@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)return (pdev->error_state != pci_channel_io_normal); }
Quoted 7 lines
include/linux/pci.h static inline int pci_channel_offline(struct pci_dev *pdev) · line 407
Quoted 5 lines
include/linux/pci.h +5
-0+struct pci_host_bridge ; +struct pci_host_bridge_ops { +void (*phb_set_root_bus_speed)(struct pci_host_bridge *host); +int (*phb_prepare)(struct pci_host_bridge *host); +void (*phb_of_scan_bus)(struct pci_host_bridge *);These function pointers don't need a "
phb_" prefix.
Will update them.
Quoted 3 lines
.
Signature · 2 lines
Thanks! Yijing
Bjorn Helgaas
maintainerRe: [PATCH v4 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
In reply to Yijing WangQuoted 49 lines · Yijing Wang
Now we have weak functions like
pcibios_root_bridge_prepare()to setup pci host bridge, We could introducepci_host_bridge_opswhich contain host bridge specific ops to setuppci_host_bridge. Then host bridge driver could addpci_host_bridge_opshooks intead of weak function to setuppci_host_bridge.
This patch add followingpci_host_bridge_opshooks:pci_host_bridge_ops { /* set root bus speed, some platform need this like powerpc */ void (*phb_set_root_bus_speed)(struct pci_host_bridge *host); /* setup pci_host_bridge before pci_host_bridge be added to driver core */ int (*phb_prepare)(struct pci_host_bridge *host); /* platform specific of scan hook to scan pci device */ void (*phb_of_scan_bus)(struct pci_host_bridge *); }We could easily extend it to support different host bridge specific operations.
Signed-off-by Yijing Wang <[email protected]>--- drivers/pci/host-bridge.c | 12 ++++++++++-- drivers/pci/probe.c | 17 +++++++++++------ include/linux/pci.h | 12 ++++++++++-- 3 files changed, 31 insertions(+), 10 deletions(-)drivers/pci/host-bridge.c +3
-2@@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev) }struct pci_host_bridge *pci_create_host_bridge ( -struct device *parent,u32 db, -struct list_head *resources,void *sysdata) +struct device *parent,u32 db,struct list_head *resources, +void *sysdata,struct pci_host_bridge_ops *ops) {int error;int bus =PCI_BUSNUM (db);@@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge( }mutex_unlock (&phb_mutex); + host->ops = ops; host->dev.parent = parent;INIT_LIST_HEAD (&host->windows); host->dev.release = pci_release_host_bridge_dev;
drivers/pci/host-bridge.c struct pci_host_bridge *pci_create_host_bridge( · line 69
Quoted 6 lines
drivers/pci/host-bridge.c +3
-0@@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge(dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, host->busnum); +if (host->ops && host->ops->phb_prepare) { + error = host->ops->phb_prepare (host); +if (error) {
Whitespace error.
include/linux/pci.h static inline int pci_channel_offline(struct pci_dev *pdev) · line 407
Quoted 11 lines
include/linux/pci.h +5
-0@@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)return (pdev->error_state != pci_channel_io_normal); } +struct pci_host_bridge ; +struct pci_host_bridge_ops { +void (*phb_set_root_bus_speed)(struct pci_host_bridge *host); +int (*phb_prepare)(struct pci_host_bridge *host); +void (*phb_of_scan_bus)(struct pci_host_bridge *);
These function pointers don't need a "phb_" prefix.
Bjorn Helgaas
maintainerRe: [PATCH v4 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
In reply to Yijing WangQuoted 22 lines · Yijing Wang
Now we have weak functions like
pcibios_root_bridge_prepare()to setup pci host bridge, We could introducepci_host_bridge_opswhich contain host bridge specific ops to setuppci_host_bridge. Then host bridge driver could addpci_host_bridge_opshooks intead of weak function to setuppci_host_bridge.
This patch add followingpci_host_bridge_opshooks:pci_host_bridge_ops { /* set root bus speed, some platform need this like powerpc */ void (*phb_set_root_bus_speed)(struct pci_host_bridge *host); /* setup pci_host_bridge before pci_host_bridge be added to driver core */ int (*phb_prepare)(struct pci_host_bridge *host); /* platform specific of scan hook to scan pci device */ void (*phb_of_scan_bus)(struct pci_host_bridge *); }We could easily extend it to support different host bridge specific operations.
Signed-off-by Yijing Wang <[email protected]>...
drivers/pci/probe.c static struct pci_bus *__pci_scan_root_bus( · line 2056
Quoted 9 lines
drivers/pci/probe.c +2
-4@@ -2050,10 +2052,13 @@ static struct pci_bus *__pci_scan_root_bus(pci_bus_insert_busn_res (b, b->number,255 ); } - max =pci_scan_child_bus (b); - -if (!found) -pci_bus_update_busn_res_end (b, max); +if (host->ops && host->ops->phb_of_scan_bus) { + host->ops->phb_of_scan_bus (host);
The important thing here is not the use of OF (Open Firmware/Device Tree), is it? Why would we want "_of_" in the function name? I assume the intent is that this host bridge op performs the same function as pci_scan_child_bus(), so I think the op should be called "scan_bus".
Quoted 8 lines
drivers/pci/probe.c +5
-0+ }else { + max =pci_scan_child_bus (b); +if (!found) +pci_bus_update_busn_res_end (b, max); + }return b; }
Re: [PATCH v4 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
Quoted 26 lines · Bjorn Helgaas
Quoted 25 lines · Yijing Wang
Now we have weak functions like
pcibios_root_bridge_prepare()to setup pci host bridge, We could introducepci_host_bridge_opswhich contain host bridge specific ops to setuppci_host_bridge. Then host bridge driver could addpci_host_bridge_opshooks intead of weak function to setuppci_host_bridge.
This patch add followingpci_host_bridge_opshooks:pci_host_bridge_ops { /* set root bus speed, some platform need this like powerpc */ void (*phb_set_root_bus_speed)(struct pci_host_bridge *host); /* setup pci_host_bridge before pci_host_bridge be added to driver core */ int (*phb_prepare)(struct pci_host_bridge *host); /* platform specific of scan hook to scan pci device */ void (*phb_of_scan_bus)(struct pci_host_bridge *); }We could easily extend it to support different host bridge specific operations.
Signed-off-by Yijing Wang <[email protected]>...
drivers/pci/probe.c +0
-0@@ -2050,10 +2052,13 @@ static struct pci_bus *__pci_scan_root_bus(pci_bus_insert_busn_res (b, b->number,255 ); }
Quoted 11 lines
drivers/pci/probe.c static struct pci_bus *__pci_scan_root_bus( · line 2056
Quoted 6 lines
drivers/pci/probe.c +2
-4- max =pci_scan_child_bus (b); - -if (!found) -pci_bus_update_busn_res_end (b, max); +if (host->ops && host->ops->phb_of_scan_bus) { + host->ops->phb_of_scan_bus (host);The important thing here is not the use of OF (Open Firmware/Device Tree), is it? Why would we want "_of_" in the function name? I assume the intent is that this host bridge op performs the same function as
pci_scan_child_bus(), so I think the op should be called "scan_bus".
Yes, because now only OF code need the private scan_child_bus, so I named it phb_of_scan_bus(). I agree that rename it to scan_bus.
Quoted 12 lines
drivers/pci/probe.c static struct pci_bus *__pci_scan_root_bus( · line 2064
Quoted 9 lines
drivers/pci/probe.c +5
-0+ }else { + max =pci_scan_child_bus (b); +if (!found) +pci_bus_update_busn_res_end (b, max); + }return b; }.
Signature · 2 lines
Thanks! Yijing
Re: [PATCH v4 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
In reply to Bjorn HelgaasQuoted 26 lines · Bjorn Helgaas
Quoted 25 lines · Yijing Wang
Now we have weak functions like
pcibios_root_bridge_prepare()to setup pci host bridge, We could introducepci_host_bridge_opswhich contain host bridge specific ops to setuppci_host_bridge. Then host bridge driver could addpci_host_bridge_opshooks intead of weak function to setuppci_host_bridge.
This patch add followingpci_host_bridge_opshooks:pci_host_bridge_ops { /* set root bus speed, some platform need this like powerpc */ void (*phb_set_root_bus_speed)(struct pci_host_bridge *host); /* setup pci_host_bridge before pci_host_bridge be added to driver core */ int (*phb_prepare)(struct pci_host_bridge *host); /* platform specific of scan hook to scan pci device */ void (*phb_of_scan_bus)(struct pci_host_bridge *); }We could easily extend it to support different host bridge specific operations.
Signed-off-by Yijing Wang <[email protected]>...
drivers/pci/probe.c +0
-0@@ -2050,10 +2052,13 @@ static struct pci_bus *__pci_scan_root_bus(pci_bus_insert_busn_res (b, b->number,255 ); }
Quoted 11 lines
drivers/pci/probe.c static struct pci_bus *__pci_scan_root_bus( · line 2056
Quoted 6 lines
drivers/pci/probe.c +2
-4- max =pci_scan_child_bus (b); - -if (!found) -pci_bus_update_busn_res_end (b, max); +if (host->ops && host->ops->phb_of_scan_bus) { + host->ops->phb_of_scan_bus (host);The important thing here is not the use of OF (Open Firmware/Device Tree), is it? Why would we want "_of_" in the function name? I assume the intent is that this host bridge op performs the same function as
pci_scan_child_bus(), so I think the op should be called "scan_bus".
Yes, because now only OF code need the private scan_child_bus, so I named it phb_of_scan_bus(). I agree that rename it to scan_bus.
Quoted 12 lines
drivers/pci/probe.c static struct pci_bus *__pci_scan_root_bus( · line 2064
Quoted 9 lines
drivers/pci/probe.c +5
-0+ }else { + max =pci_scan_child_bus (b); +if (!found) +pci_bus_update_busn_res_end (b, max); + }return b; }.
Signature · 2 lines
Thanks! Yijing
Bjorn Helgaas
maintainerRe: [PATCH v4 12/30] PCI: Introduce pci_host_bridge_ops to support host specific operations
In reply to Yijing WangQuoted 22 lines · Yijing Wang
Now we have weak functions like
pcibios_root_bridge_prepare()to setup pci host bridge, We could introducepci_host_bridge_opswhich contain host bridge specific ops to setuppci_host_bridge. Then host bridge driver could addpci_host_bridge_opshooks intead of weak function to setuppci_host_bridge.
This patch add followingpci_host_bridge_opshooks:pci_host_bridge_ops { /* set root bus speed, some platform need this like powerpc */ void (*phb_set_root_bus_speed)(struct pci_host_bridge *host); /* setup pci_host_bridge before pci_host_bridge be added to driver core */ int (*phb_prepare)(struct pci_host_bridge *host); /* platform specific of scan hook to scan pci device */ void (*phb_of_scan_bus)(struct pci_host_bridge *); }We could easily extend it to support different host bridge specific operations.
Signed-off-by Yijing Wang <[email protected]>...
drivers/pci/probe.c static struct pci_bus *__pci_scan_root_bus( · line 2056
Quoted 9 lines
drivers/pci/probe.c +2
-4@@ -2050,10 +2052,13 @@ static struct pci_bus *__pci_scan_root_bus(pci_bus_insert_busn_res (b, b->number,255 ); } - max =pci_scan_child_bus (b); - -if (!found) -pci_bus_update_busn_res_end (b, max); +if (host->ops && host->ops->phb_of_scan_bus) { + host->ops->phb_of_scan_bus (host);
The important thing here is not the use of OF (Open Firmware/Device Tree), is it? Why would we want "_of_" in the function name? I assume the intent is that this host bridge op performs the same function as pci_scan_child_bus(), so I think the op should be called "scan_bus".
Quoted 8 lines
drivers/pci/probe.c +5
-0+ }else { + max =pci_scan_child_bus (b); +if (!found) +pci_bus_update_busn_res_end (b, max); + }return b; }
PATCH v4 12/30 PCI: Introduce pci_host_bridge_ops to support host specific operations
In reply to Yijing WangNow we have weak functions like pcibios_root_bridge_prepare() to setup pci host bridge, We could introduce pci_host_bridge_ops which contain host bridge specific ops to setup pci_host_bridge. Then host bridge driver could add pci_host_bridge_ops hooks intead of weak function to setup pci_host_bridge.
This patch add following pci_host_bridge_ops hooks:
pci_host_bridge_ops {
/* set root bus speed, some platform need this like powerpc */
void (*phb_set_root_bus_speed)(struct pci_host_bridge *host);
/* setup pci_host_bridge before pci_host_bridge be added to driver core */
int (*phb_prepare)(struct pci_host_bridge *host);
/* platform specific of scan hook to scan pci device */
void (*phb_of_scan_bus)(struct pci_host_bridge *);
}We could easily extend it to support different host bridge specific operations.
--- drivers/pci/host-bridge.c | 12 ++++++++++-- drivers/pci/probe.c | 17 +++++++++++------ include/linux/pci.h | 12 ++++++++++-- 3 files changed, 31 insertions(+), 10 deletions(-)
drivers/pci/host-bridge.c +10 -2
@@ -23,8 +23,8 @@ static void pci_release_host_bridge_dev(struct device *dev) }struct pci_host_bridge *pci_create_host_bridge ( -struct device *parent,u32 db, -struct list_head *resources,void *sysdata) +struct device *parent,u32 db,struct list_head *resources, +void *sysdata,struct pci_host_bridge_ops *ops) {int error;int bus =PCI_BUSNUM (db);
@@ -56,6 +56,7 @@ struct pci_host_bridge *pci_create_host_bridge( }mutex_unlock (&phb_mutex); + host->ops = ops; host->dev.parent = parent;INIT_LIST_HEAD (&host->windows); host->dev.release = pci_release_host_bridge_dev;
@@ -63,6 +64,13 @@ struct pci_host_bridge *pci_create_host_bridge(dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, host->busnum); +if (host->ops && host->ops->phb_prepare) { + error = host->ops->phb_prepare (host); +if (error) { +kfree (host); +return NULL ; + } + } error =device_register (&host->dev);if (error) {put_device (&host->dev);
drivers/pci/probe.c +11 -6
@@ -1888,6 +1888,8 @@ static struct pci_bus *__pci_create_root_bus( bridge->bus = b; b->bridge =get_device (&bridge->dev); +if (bridge->ops && bridge->ops->phb_set_root_bus_speed) + bridge->ops->phb_set_root_bus_speed (bridge); error =pcibios_root_bridge_prepare (bridge);if (error) goto err_out;
@@ -1953,7 +1955,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, u32 db, {struct pci_host_bridge *host; - host =pci_create_host_bridge (parent, db, resources, sysdata); + host =pci_create_host_bridge (parent, db, resources, sysdata,NULL );if (!host)return NULL ;
@@ -2050,10 +2052,13 @@ static struct pci_bus *__pci_scan_root_bus(pci_bus_insert_busn_res (b, b->number,255 ); } - max =pci_scan_child_bus (b); - -if (!found) -pci_bus_update_busn_res_end (b, max); +if (host->ops && host->ops->phb_of_scan_bus) { + host->ops->phb_of_scan_bus (host); + }else { + max =pci_scan_child_bus (b); +if (!found) +pci_bus_update_busn_res_end (b, max); + }return b; }
@@ -2063,7 +2068,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, u32 db, {struct pci_host_bridge *host; - host =pci_create_host_bridge (parent, db, resources, sysdata); + host =pci_create_host_bridge (parent, db, resources, sysdata,NULL );if (!host)return NULL ;
include/linux/pci.h +10 -2
@@ -400,6 +400,13 @@ static inline int pci_channel_offline(struct pci_dev *pdev)return (pdev->error_state != pci_channel_io_normal); } +struct pci_host_bridge ; +struct pci_host_bridge_ops { +void (*phb_set_root_bus_speed)(struct pci_host_bridge *host); +int (*phb_prepare)(struct pci_host_bridge *host); +void (*phb_of_scan_bus)(struct pci_host_bridge *); +}; +struct pci_host_bridge {u16 domain;u16 busnum;
@@ -407,6 +414,7 @@ struct pci_host_bridge {struct pci_bus *bus;/* root bus */ struct list_head windows;/* resource_entry */ struct list_head list; +struct pci_host_bridge_ops *ops;void (*release_fn)(struct pci_host_bridge *);void *release_data; };
@@ -418,8 +426,8 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge);struct pci_host_bridge *pci_create_host_bridge ( -struct device *parent,u32 dombus, -struct list_head *resources,void *sysdata); +struct device *parent,u32 dombus,struct list_head *resources, +void *sysdata,struct pci_host_bridge_ops *ops);/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for
Signature · 1 line
1.7.1
PATCH v4 13/30 PCI: Introduce new scan function pci_scan_root_bridge()
In reply to Yijing WangIntroduce new scan function pci_scan_root_bridge() to support host bridge drivers that need to provide platform own pci_host_bridge_ops.
--- drivers/pci/probe.c | 21 +++++++++++++++++++++ include/linux/pci.h | 3 +++ 2 files changed, 24 insertions(+), 0 deletions(-)
drivers/pci/probe.c +21 -0
@@ -2063,6 +2063,27 @@ static struct pci_bus *__pci_scan_root_bus(return b; } +struct pci_host_bridge *pci_scan_root_bridge (struct device *parent, +u32 db,struct pci_ops *ops,void *sysdata, +struct list_head *resources,struct pci_host_bridge_ops *phb_ops) +{ +struct pci_host_bridge *host; +struct pci_bus *bus; + + host =pci_create_host_bridge (parent, db, resources, + sysdata, phb_ops); +if (!host) +return NULL ; + + bus =__pci_scan_root_bus (host, ops); +if (!bus) +pci_free_host_bridge (host); + +return host; +} +EXPORT_SYMBOL (pci_scan_root_bridge); + +struct pci_bus *pci_scan_root_bus (struct device *parent,u32 db,struct pci_ops *ops,void *sysdata,struct list_head *resources) {
include/linux/pci.h +3 -0
@@ -793,6 +793,9 @@ void pci_bus_release_busn_res(struct pci_bus *b);struct pci_bus *pci_scan_root_bus (struct device *parent,u32 dombus,struct pci_ops *ops,void *sysdata,struct list_head *resources); +struct pci_host_bridge *pci_scan_root_bridge (struct device *parent, +u32 dombus,struct pci_ops *ops,void *sysdata, +struct list_head *resources,struct pci_host_bridge_ops *phb_ops);struct pci_bus *pci_add_new_bus (struct pci_bus *parent,struct pci_dev *dev,int busnr);void pcie_update_link_speed (struct pci_bus *bus,u16 link_status);
Signature · 1 line
1.7.1
Bjorn Helgaas
maintainerRe: [PATCH v4 13/30] PCI: Introduce new scan function pci_scan_root_bridge()
Quoted 15 lines · Yijing Wang
Introduce new scan function
pci_scan_root_bridge()to support host bridge drivers that need to provide platform ownpci_host_bridge_ops.Signed-off-by Yijing Wang <[email protected]>--- drivers/pci/probe.c | 21 +++++++++++++++++++++ include/linux/pci.h | 3 +++ 2 files changed, 24 insertions(+), 0 deletions(-)drivers/pci/probe.c +0
-0
drivers/pci/probe.c static struct pci_bus *__pci_scan_root_bus( · line 2068
Quoted 6 lines
drivers/pci/probe.c +3
-0@@ -2063,6 +2063,27 @@ static struct pci_bus *__pci_scan_root_bus(return b; } +struct pci_host_bridge *pci_scan_root_bridge (struct device *parent, +u32 db,struct pci_ops *ops,void *sysdata, +struct list_head *resources,struct pci_host_bridge_ops *phb_ops)
I prefer "host bridge" over "root bridge" because that's the terminology used by the PCI specs.
Re: [PATCH v4 13/30] PCI: Introduce new scan function pci_scan_root_bridge()
Quoted 19 lines · Bjorn Helgaas
Quoted 18 lines · Yijing Wang
Introduce new scan function
pci_scan_root_bridge()to support host bridge drivers that need to provide platform ownpci_host_bridge_ops.Signed-off-by Yijing Wang <[email protected]>--- drivers/pci/probe.c | 21 +++++++++++++++++++++ include/linux/pci.h | 3 +++ 2 files changed, 24 insertions(+), 0 deletions(-)drivers/pci/probe.c +0
-0@@ -2063,6 +2063,27 @@ static struct pci_bus *__pci_scan_root_bus(return b; }
Quoted 6 lines
drivers/pci/probe.c static struct pci_bus *__pci_scan_root_bus( · line 2068
Quoted 3 lines
drivers/pci/probe.c +3
-0+struct pci_host_bridge *pci_scan_root_bridge (struct device *parent, +u32 db,struct pci_ops *ops,void *sysdata, +struct list_head *resources,struct pci_host_bridge_ops *phb_ops)I prefer "host bridge" over "root bridge" because that's the terminology used by the PCI specs.
OK, I will use "host bridge" instead of "root bridge".
Quoted 3 lines
.
Signature · 2 lines
Thanks! Yijing
Re: [PATCH v4 13/30] PCI: Introduce new scan function pci_scan_root_bridge()
In reply to Bjorn HelgaasQuoted 19 lines · Bjorn Helgaas
Quoted 18 lines · Yijing Wang
Introduce new scan function
pci_scan_root_bridge()to support host bridge drivers that need to provide platform ownpci_host_bridge_ops.Signed-off-by Yijing Wang <[email protected]>--- drivers/pci/probe.c | 21 +++++++++++++++++++++ include/linux/pci.h | 3 +++ 2 files changed, 24 insertions(+), 0 deletions(-)drivers/pci/probe.c +0
-0@@ -2063,6 +2063,27 @@ static struct pci_bus *__pci_scan_root_bus(return b; }
Quoted 6 lines
drivers/pci/probe.c static struct pci_bus *__pci_scan_root_bus( · line 2068
Quoted 3 lines
drivers/pci/probe.c +3
-0+struct pci_host_bridge *pci_scan_root_bridge (struct device *parent, +u32 db,struct pci_ops *ops,void *sysdata, +struct list_head *resources,struct pci_host_bridge_ops *phb_ops)I prefer "host bridge" over "root bridge" because that's the terminology used by the PCI specs.
OK, I will use "host bridge" instead of "root bridge".
Quoted 3 lines
.
Signature · 2 lines
Thanks! Yijing
Bjorn Helgaas
maintainerRe: [PATCH v4 13/30] PCI: Introduce new scan function pci_scan_root_bridge()
In reply to Yijing WangQuoted 15 lines · Yijing Wang
Introduce new scan function
pci_scan_root_bridge()to support host bridge drivers that need to provide platform ownpci_host_bridge_ops.Signed-off-by Yijing Wang <[email protected]>--- drivers/pci/probe.c | 21 +++++++++++++++++++++ include/linux/pci.h | 3 +++ 2 files changed, 24 insertions(+), 0 deletions(-)drivers/pci/probe.c +0
-0
drivers/pci/probe.c static struct pci_bus *__pci_scan_root_bus( · line 2068
Quoted 6 lines
drivers/pci/probe.c +3
-0@@ -2063,6 +2063,27 @@ static struct pci_bus *__pci_scan_root_bus(return b; } +struct pci_host_bridge *pci_scan_root_bridge (struct device *parent, +u32 db,struct pci_ops *ops,void *sysdata, +struct list_head *resources,struct pci_host_bridge_ops *phb_ops)
I prefer "host bridge" over "root bridge" because that's the terminology used by the PCI specs.
PATCH v4 13/30 PCI: Introduce new scan function pci_scan_root_bridge()
In reply to Yijing WangIntroduce new scan function pci_scan_root_bridge() to support host bridge drivers that need to provide platform own pci_host_bridge_ops.
--- drivers/pci/probe.c | 21 +++++++++++++++++++++ include/linux/pci.h | 3 +++ 2 files changed, 24 insertions(+), 0 deletions(-)
drivers/pci/probe.c +21 -0
@@ -2063,6 +2063,27 @@ static struct pci_bus *__pci_scan_root_bus(return b; } +struct pci_host_bridge *pci_scan_root_bridge (struct device *parent, +u32 db,struct pci_ops *ops,void *sysdata, +struct list_head *resources,struct pci_host_bridge_ops *phb_ops) +{ +struct pci_host_bridge *host; +struct pci_bus *bus; + + host =pci_create_host_bridge (parent, db, resources, + sysdata, phb_ops); +if (!host) +return NULL ; + + bus =__pci_scan_root_bus (host, ops); +if (!bus) +pci_free_host_bridge (host); + +return host; +} +EXPORT_SYMBOL (pci_scan_root_bridge); + +struct pci_bus *pci_scan_root_bus (struct device *parent,u32 db,struct pci_ops *ops,void *sysdata,struct list_head *resources) {
include/linux/pci.h +3 -0
@@ -793,6 +793,9 @@ void pci_bus_release_busn_res(struct pci_bus *b);struct pci_bus *pci_scan_root_bus (struct device *parent,u32 dombus,struct pci_ops *ops,void *sysdata,struct list_head *resources); +struct pci_host_bridge *pci_scan_root_bridge (struct device *parent, +u32 dombus,struct pci_ops *ops,void *sysdata, +struct list_head *resources,struct pci_host_bridge_ops *phb_ops);struct pci_bus *pci_add_new_bus (struct pci_bus *parent,struct pci_dev *dev,int busnr);void pcie_update_link_speed (struct pci_bus *bus,u16 link_status);
Signature · 1 line
1.7.1
PATCH v4 14/30 PCI/x86: Refine pci_acpi_scan_root() with generic pci_host_bridge
In reply to Yijing Wang--- arch/x86/pci/acpi.c | 36 ++++++++++++++++++++---------------- 1 files changed, 20 insertions(+), 16 deletions(-)
arch/x86/pci/acpi.c +20 -16
@@ -349,6 +349,18 @@ static void probe_pci_root_info(struct pci_root_info *info, entry->res->name = info->name; } +static int pci_host_bridge_prepare (struct pci_host_bridge *bridge) +{ +struct pci_sysdata *sd =dev_get_drvdata (&bridge->dev); + +ACPI_COMPANION_SET (&bridge->dev, sd->companion); +return 0 ; +} + +static struct pci_host_bridge_ops phb_ops = { + .phb_prepare = pci_host_bridge_prepare, +}; +struct pci_bus *pci_acpi_scan_root (struct acpi_pci_root *root) {struct acpi_device *device = root->device;
@@ -359,6 +371,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)LIST_HEAD (crs_res);LIST_HEAD (resources);struct pci_bus *bus; +struct pci_host_bridge *host =NULL ;struct pci_sysdata *sd;int node;
@@ -425,14 +438,13 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)if (!setup_mcfg_map (info, domain, (u8 )root->secondary.start, (u8 )root->secondary.end, root->mcfg_addr)) - bus =pci_create_root_bus (NULL ,PCI_DOMBUS (domain, busnum), - &pci_root_ops, sd, &resources); - -if (bus) { -pci_scan_child_bus (bus); -pci_set_host_bridge_release ( -to_pci_host_bridge (bus->bridge), - release_pci_root_info, info); + host =pci_scan_root_bridge (NULL ,PCI_DOMBUS (domain, busnum), + &pci_root_ops, sd, &resources, &phb_ops); + +if (host) { + bus = host->bus; +pci_set_host_bridge_release (host, release_pci_root_info, + info); }else {resource_list_free (&resources);teardown_mcfg_map (info);
@@ -455,14 +467,6 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)return bus; } -int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge) -{ -struct pci_sysdata *sd = bridge->bus->sysdata; - -ACPI_COMPANION_SET (&bridge->dev, sd->companion); -return 0 ; -} -int __init pci_acpi_init (void ) {struct pci_dev *dev =NULL ;
Signature · 1 line
1.7.1
PATCH v4 14/30 PCI/x86: Refine pci_acpi_scan_root() with generic pci_host_bridge
In reply to Yijing Wang--- arch/x86/pci/acpi.c | 36 ++++++++++++++++++++---------------- 1 files changed, 20 insertions(+), 16 deletions(-)
arch/x86/pci/acpi.c +20 -16
@@ -349,6 +349,18 @@ static void probe_pci_root_info(struct pci_root_info *info, entry->res->name = info->name; } +static int pci_host_bridge_prepare (struct pci_host_bridge *bridge) +{ +struct pci_sysdata *sd =dev_get_drvdata (&bridge->dev); + +ACPI_COMPANION_SET (&bridge->dev, sd->companion); +return 0 ; +} + +static struct pci_host_bridge_ops phb_ops = { + .phb_prepare = pci_host_bridge_prepare, +}; +struct pci_bus *pci_acpi_scan_root (struct acpi_pci_root *root) {struct acpi_device *device = root->device;
@@ -359,6 +371,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)LIST_HEAD (crs_res);LIST_HEAD (resources);struct pci_bus *bus; +struct pci_host_bridge *host =NULL ;struct pci_sysdata *sd;int node;
@@ -425,14 +438,13 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)if (!setup_mcfg_map (info, domain, (u8 )root->secondary.start, (u8 )root->secondary.end, root->mcfg_addr)) - bus =pci_create_root_bus (NULL ,PCI_DOMBUS (domain, busnum), - &pci_root_ops, sd, &resources); - -if (bus) { -pci_scan_child_bus (bus); -pci_set_host_bridge_release ( -to_pci_host_bridge (bus->bridge), - release_pci_root_info, info); + host =pci_scan_root_bridge (NULL ,PCI_DOMBUS (domain, busnum), + &pci_root_ops, sd, &resources, &phb_ops); + +if (host) { + bus = host->bus; +pci_set_host_bridge_release (host, release_pci_root_info, + info); }else {resource_list_free (&resources);teardown_mcfg_map (info);
@@ -455,14 +467,6 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)return bus; } -int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge) -{ -struct pci_sysdata *sd = bridge->bus->sysdata; - -ACPI_COMPANION_SET (&bridge->dev, sd->companion); -return 0 ; -} -int __init pci_acpi_init (void ) {struct pci_dev *dev =NULL ;
Signature · 1 line
1.7.1
PATCH v4 15/30 PCI/IA64: Refine pci_acpi_scan_root() with generic pci_host_bridge
In reply to Yijing WangFrom: Yijing Wang <[email protected]>
--- arch/ia64/pci/pci.c | 34 ++++++++++++++++++---------------- 1 files changed, 18 insertions(+), 16 deletions(-)
arch/ia64/pci/pci.c +18 -16
@@ -420,6 +420,18 @@ probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device,return 0 ; } +static int pci_host_bridge_prepare (struct pci_host_bridge *bridge) +{ +struct pci_controller *controller = bridge->bus->sysdata; + +ACPI_COMPANION_SET (&bridge->dev, controller->companion); +return 0 ; +} + +static struct pci_host_bridge_ops phb_ops = { + .phb_prepare = pci_host_bridge_prepare, +}; +struct pci_bus *pci_acpi_scan_root (struct acpi_pci_root *root) {struct acpi_device *device = root->device;
@@ -428,7 +440,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)struct pci_controller *controller;struct pci_root_info *info =NULL ;int busnum = root->secondary.start; -struct pci_bus *pbus; +struct pci_host_bridge *host;int ret; controller =alloc_pci_controller (domain);
@@ -465,26 +477,16 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)* should handle the case here, but it appears that IA64 hasn't * such quirk. So we just ignore the case now. */ - pbus =pci_create_root_bus (NULL ,PCI_DOMBUS (domain, bus), - &pci_root_ops, controller, &info->resources); -if (!pbus) { + host =pci_scan_root_bridge (NULL ,PCI_DOMBUS (domain, bus), + &pci_root_ops, controller, &info->resources, &phb_ops); +if (!host) {pci_free_resource_list (&info->resources);__release_pci_root_info (info);return NULL ; } -pci_set_host_bridge_release (to_pci_host_bridge (pbus->bridge), - release_pci_root_info, info); -pci_scan_child_bus (pbus); -return pbus; -} - -int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge) -{ -struct pci_controller *controller = bridge->bus->sysdata; - -ACPI_COMPANION_SET (&bridge->dev, controller->companion); -return 0 ; +pci_set_host_bridge_release (host, release_pci_root_info, info); +return host->bus; }void pcibios_fixup_device_resources (struct pci_dev *dev)
Signature · 1 line
1.7.1
PATCH v4 15/30 PCI/IA64: Refine pci_acpi_scan_root() with generic pci_host_bridge
In reply to Yijing WangFrom: Yijing Wang <[email protected]>
--- arch/ia64/pci/pci.c | 34 ++++++++++++++++++---------------- 1 files changed, 18 insertions(+), 16 deletions(-)
arch/ia64/pci/pci.c +18 -16
@@ -420,6 +420,18 @@ probe_pci_root_info(struct pci_root_info *info, struct acpi_device *device,return 0 ; } +static int pci_host_bridge_prepare (struct pci_host_bridge *bridge) +{ +struct pci_controller *controller = bridge->bus->sysdata; + +ACPI_COMPANION_SET (&bridge->dev, controller->companion); +return 0 ; +} + +static struct pci_host_bridge_ops phb_ops = { + .phb_prepare = pci_host_bridge_prepare, +}; +struct pci_bus *pci_acpi_scan_root (struct acpi_pci_root *root) {struct acpi_device *device = root->device;
@@ -428,7 +440,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)struct pci_controller *controller;struct pci_root_info *info =NULL ;int busnum = root->secondary.start; -struct pci_bus *pbus; +struct pci_host_bridge *host;int ret; controller =alloc_pci_controller (domain);
@@ -465,26 +477,16 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)* should handle the case here, but it appears that IA64 hasn't * such quirk. So we just ignore the case now. */ - pbus =pci_create_root_bus (NULL ,PCI_DOMBUS (domain, bus), - &pci_root_ops, controller, &info->resources); -if (!pbus) { + host =pci_scan_root_bridge (NULL ,PCI_DOMBUS (domain, bus), + &pci_root_ops, controller, &info->resources, &phb_ops); +if (!host) {pci_free_resource_list (&info->resources);__release_pci_root_info (info);return NULL ; } -pci_set_host_bridge_release (to_pci_host_bridge (pbus->bridge), - release_pci_root_info, info); -pci_scan_child_bus (pbus); -return pbus; -} - -int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge) -{ -struct pci_controller *controller = bridge->bus->sysdata; - -ACPI_COMPANION_SET (&bridge->dev, controller->companion); -return 0 ; +pci_set_host_bridge_release (host, release_pci_root_info, info); +return host->bus; }void pcibios_fixup_device_resources (struct pci_dev *dev)
Signature · 1 line
1.7.1
PATCH v4 16/30 PCI/IA64: Fix the build warning about pci_domain_nr()
In reply to Yijing WangShould pass pci_bus * instead of pci_dev * to pci_domain_nr().
--- arch/ia64/sn/kernel/io_acpi_init.c | 6 +++--- arch/ia64/sn/kernel/io_init.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/ia64/sn/kernel/io_acpi_init.c +3 -3
@@ -364,12 +364,12 @@ sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info, status =acpi_evaluate_integer (rootbus_handle,METHOD_NAME__SEG ,NULL , &segment);if (ACPI_SUCCESS (status)) { -if (segment !=pci_domain_nr (dev)) { +if (segment !=pci_domain_nr (dev->bus)) {acpi_get_name (rootbus_handle,ACPI_FULL_PATHNAME , &name_buffer);printk (KERN_ERR "%s: Segment number mismatch, 0x%llx vs 0x%x for: %s\n" , - __func__, segment,pci_domain_nr (dev), + __func__, segment,pci_domain_nr (dev->bus), (char *)name_buffer.pointer);kfree (name_buffer.pointer);return 1 ;
@@ -407,7 +407,7 @@ sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info,/* Build up the pcidev_info.pdi_slot_host_handle */ host_devfn =get_host_devfn (pcidev_match.handle, rootbus_handle); (*pcidev_info)->pdi_slot_host_handle = - ((unsigned long )pci_domain_nr (dev) <<40 ) | + ((unsigned long )pci_domain_nr (dev->bus) <<40 ) |/* bus == 0 */ host_devfn;return 0 ;
arch/ia64/sn/kernel/io_init.c +1 -1
@@ -164,7 +164,7 @@ sn_io_slot_fixup(struct pci_dev *dev)panic ("%s: Unable to alloc memory for sn_irq_info" , __func__);/* Call to retrieve pci device information needed by kernel. */ - status = sal_get_pcidev_info((u64) pci_domain_nr(dev), + status = sal_get_pcidev_info((u64) pci_domain_nr(dev->bus), (u64) dev->bus->number, dev->devfn, (u64) __pa(pcidev_info),
Signature · 1 line
1.7.1
Bjorn Helgaas
maintainerRe: [PATCH v4 16/30] PCI/IA64: Fix the build warning about pci_domain_nr()
Quoted 16 lines · Yijing Wang
Should pass
pci_bus* instead ofpci_dev* topci_domain_nr().Signed-off-by Yijing Wang <[email protected]>CC Tony Luck <[email protected]>CC Fenghua Yu <[email protected]>--- arch/ia64/sn/kernel/io_acpi_init.c | 6 +++--- arch/ia64/sn/kernel/io_init.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)arch/ia64/sn/kernel/io_acpi_init.c +0
-0
arch/ia64/sn/kernel/io_acpi_init.c sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info, · line 367
Quoted 5 lines
arch/ia64/sn/kernel/io_acpi_init.c +1
-1@@ -364,12 +364,12 @@ sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info, status =acpi_evaluate_integer (rootbus_handle,METHOD_NAME__SEG ,NULL , &segment);if (ACPI_SUCCESS (status)) { -if (segment !=pci_domain_nr (dev)) { +if (segment !=pci_domain_nr (dev->bus)) {
This is completely unrelated to the series, isn't it? It looks like this is a bug fix that should be handled separately and marked for stable.
Quoted 38 lines
arch/ia64/sn/kernel/io_acpi_init.c +2
-2acpi_get_name (rootbus_handle,ACPI_FULL_PATHNAME , &name_buffer);printk (KERN_ERR "%s: Segment number mismatch, 0x%llx vs 0x%x for: %s\n" , - __func__, segment,pci_domain_nr (dev), + __func__, segment,pci_domain_nr (dev->bus), (char *)name_buffer.pointer);kfree (name_buffer.pointer);return 1 ;@@ -407,7 +407,7 @@ sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info,/* Build up the pcidev_info.pdi_slot_host_handle */ host_devfn =get_host_devfn (pcidev_match.handle, rootbus_handle); (*pcidev_info)->pdi_slot_host_handle = - ((unsigned long )pci_domain_nr (dev) <<40 ) | + ((unsigned long )pci_domain_nr (dev->bus) <<40 ) |/* bus == 0 */ host_devfn;return 0 ;arch/ia64/sn/kernel/io_init.c +1
-1@@ -164,7 +164,7 @@ sn_io_slot_fixup(struct pci_dev *dev)panic ("%s: Unable to alloc memory for sn_irq_info" , __func__);/* Call to retrieve pci device information needed by kernel. */ - status = sal_get_pcidev_info((u64) pci_domain_nr(dev), + status = sal_get_pcidev_info((u64) pci_domain_nr(dev->bus), (u64) dev->bus->number, dev->devfn, (u64) __pa(pcidev_info),Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 16/30] PCI/IA64: Fix the build warning about pci_domain_nr()
Quoted 12 lines · Bjorn Helgaas
Quoted 11 lines · Yijing Wang
Should pass
pci_bus* instead ofpci_dev* topci_domain_nr().Signed-off-by Yijing Wang <[email protected]>CC Tony Luck <[email protected]>CC Fenghua Yu <[email protected]>--- arch/ia64/sn/kernel/io_acpi_init.c | 6 +++--- arch/ia64/sn/kernel/io_init.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
Quoted 13 lines
arch/ia64/sn/kernel/io_acpi_init.c sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info, · line 367
Quoted 10 lines
arch/ia64/sn/kernel/io_acpi_init.c +1
-1@@ -364,12 +364,12 @@ sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info, status =acpi_evaluate_integer (rootbus_handle,METHOD_NAME__SEG ,NULL , &segment);if (ACPI_SUCCESS (status)) { -if (segment !=pci_domain_nr (dev)) { +if (segment !=pci_domain_nr (dev->bus)) {This is completely unrelated to the series, isn't it? It looks like this is a bug fix that should be handled separately and marked for stable.
Yes, it's a separate patch, I would move it out of this series, and post it out separately.
Thanks!
Yijing.
Quoted 42 lines
Quoted 39 lines
arch/ia64/sn/kernel/io_acpi_init.c +2
-2acpi_get_name (rootbus_handle,ACPI_FULL_PATHNAME , &name_buffer);printk (KERN_ERR "%s: Segment number mismatch, 0x%llx vs 0x%x for: %s\n" , - __func__, segment,pci_domain_nr (dev), + __func__, segment,pci_domain_nr (dev->bus), (char *)name_buffer.pointer);kfree (name_buffer.pointer);return 1 ;@@ -407,7 +407,7 @@ sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info,/* Build up the pcidev_info.pdi_slot_host_handle */ host_devfn =get_host_devfn (pcidev_match.handle, rootbus_handle); (*pcidev_info)->pdi_slot_host_handle = - ((unsigned long )pci_domain_nr (dev) <<40 ) | + ((unsigned long )pci_domain_nr (dev->bus) <<40 ) |/* bus == 0 */ host_devfn;return 0 ;arch/ia64/sn/kernel/io_init.c +1
-1@@ -164,7 +164,7 @@ sn_io_slot_fixup(struct pci_dev *dev)panic ("%s: Unable to alloc memory for sn_irq_info" , __func__);/* Call to retrieve pci device information needed by kernel. */ - status = sal_get_pcidev_info((u64) pci_domain_nr(dev), + status = sal_get_pcidev_info((u64) pci_domain_nr(dev->bus), (u64) dev->bus->number, dev->devfn, (u64) __pa(pcidev_info),Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html.
Signature · 2 lines
Thanks! Yijing
Re: [PATCH v4 16/30] PCI/IA64: Fix the build warning about pci_domain_nr()
In reply to Bjorn HelgaasQuoted 12 lines · Bjorn Helgaas
Quoted 11 lines · Yijing Wang
Should pass
pci_bus* instead ofpci_dev* topci_domain_nr().Signed-off-by Yijing Wang <[email protected]>CC Tony Luck <[email protected]>CC Fenghua Yu <[email protected]>--- arch/ia64/sn/kernel/io_acpi_init.c | 6 +++--- arch/ia64/sn/kernel/io_init.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
Quoted 13 lines
arch/ia64/sn/kernel/io_acpi_init.c sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info, · line 367
Quoted 10 lines
arch/ia64/sn/kernel/io_acpi_init.c +1
-1@@ -364,12 +364,12 @@ sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info, status =acpi_evaluate_integer (rootbus_handle,METHOD_NAME__SEG ,NULL , &segment);if (ACPI_SUCCESS (status)) { -if (segment !=pci_domain_nr (dev)) { +if (segment !=pci_domain_nr (dev->bus)) {This is completely unrelated to the series, isn't it? It looks like this is a bug fix that should be handled separately and marked for stable.
Yes, it's a separate patch, I would move it out of this series, and post it out separately.
Thanks!
Yijing.
Quoted 42 lines
Quoted 39 lines
arch/ia64/sn/kernel/io_acpi_init.c +2
-2acpi_get_name (rootbus_handle,ACPI_FULL_PATHNAME , &name_buffer);printk (KERN_ERR "%s: Segment number mismatch, 0x%llx vs 0x%x for: %s\n" , - __func__, segment,pci_domain_nr (dev), + __func__, segment,pci_domain_nr (dev->bus), (char *)name_buffer.pointer);kfree (name_buffer.pointer);return 1 ;@@ -407,7 +407,7 @@ sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info,/* Build up the pcidev_info.pdi_slot_host_handle */ host_devfn =get_host_devfn (pcidev_match.handle, rootbus_handle); (*pcidev_info)->pdi_slot_host_handle = - ((unsigned long )pci_domain_nr (dev) <<40 ) | + ((unsigned long )pci_domain_nr (dev->bus) <<40 ) |/* bus == 0 */ host_devfn;return 0 ;arch/ia64/sn/kernel/io_init.c +1
-1@@ -164,7 +164,7 @@ sn_io_slot_fixup(struct pci_dev *dev)panic ("%s: Unable to alloc memory for sn_irq_info" , __func__);/* Call to retrieve pci device information needed by kernel. */ - status = sal_get_pcidev_info((u64) pci_domain_nr(dev), + status = sal_get_pcidev_info((u64) pci_domain_nr(dev->bus), (u64) dev->bus->number, dev->devfn, (u64) __pa(pcidev_info),Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html.
Signature · 2 lines
Thanks! Yijing
Bjorn Helgaas
maintainerRe: [PATCH v4 16/30] PCI/IA64: Fix the build warning about pci_domain_nr()
In reply to Yijing WangQuoted 16 lines · Yijing Wang
Should pass
pci_bus* instead ofpci_dev* topci_domain_nr().Signed-off-by Yijing Wang <[email protected]>CC Tony Luck <[email protected]>CC Fenghua Yu <[email protected]>--- arch/ia64/sn/kernel/io_acpi_init.c | 6 +++--- arch/ia64/sn/kernel/io_init.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)arch/ia64/sn/kernel/io_acpi_init.c +0
-0
arch/ia64/sn/kernel/io_acpi_init.c sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info, · line 367
Quoted 5 lines
arch/ia64/sn/kernel/io_acpi_init.c +1
-1@@ -364,12 +364,12 @@ sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info, status =acpi_evaluate_integer (rootbus_handle,METHOD_NAME__SEG ,NULL , &segment);if (ACPI_SUCCESS (status)) { -if (segment !=pci_domain_nr (dev)) { +if (segment !=pci_domain_nr (dev->bus)) {
This is completely unrelated to the series, isn't it? It looks like this is a bug fix that should be handled separately and marked for stable.
Quoted 38 lines
arch/ia64/sn/kernel/io_acpi_init.c +2
-2acpi_get_name (rootbus_handle,ACPI_FULL_PATHNAME , &name_buffer);printk (KERN_ERR "%s: Segment number mismatch, 0x%llx vs 0x%x for: %s\n" , - __func__, segment,pci_domain_nr (dev), + __func__, segment,pci_domain_nr (dev->bus), (char *)name_buffer.pointer);kfree (name_buffer.pointer);return 1 ;@@ -407,7 +407,7 @@ sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info,/* Build up the pcidev_info.pdi_slot_host_handle */ host_devfn =get_host_devfn (pcidev_match.handle, rootbus_handle); (*pcidev_info)->pdi_slot_host_handle = - ((unsigned long )pci_domain_nr (dev) <<40 ) | + ((unsigned long )pci_domain_nr (dev->bus) <<40 ) |/* bus == 0 */ host_devfn;return 0 ;arch/ia64/sn/kernel/io_init.c +1
-1@@ -164,7 +164,7 @@ sn_io_slot_fixup(struct pci_dev *dev)panic ("%s: Unable to alloc memory for sn_irq_info" , __func__);/* Call to retrieve pci device information needed by kernel. */ - status = sal_get_pcidev_info((u64) pci_domain_nr(dev), + status = sal_get_pcidev_info((u64) pci_domain_nr(dev->bus), (u64) dev->bus->number, dev->devfn, (u64) __pa(pcidev_info),Signature · 6 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v4 16/30 PCI/IA64: Fix the build warning about pci_domain_nr()
In reply to Yijing WangShould pass pci_bus * instead of pci_dev * to pci_domain_nr().
--- arch/ia64/sn/kernel/io_acpi_init.c | 6 +++--- arch/ia64/sn/kernel/io_init.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/ia64/sn/kernel/io_acpi_init.c +3 -3
@@ -364,12 +364,12 @@ sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info, status =acpi_evaluate_integer (rootbus_handle,METHOD_NAME__SEG ,NULL , &segment);if (ACPI_SUCCESS (status)) { -if (segment !=pci_domain_nr (dev)) { +if (segment !=pci_domain_nr (dev->bus)) {acpi_get_name (rootbus_handle,ACPI_FULL_PATHNAME , &name_buffer);printk (KERN_ERR "%s: Segment number mismatch, 0x%llx vs 0x%x for: %s\n" , - __func__, segment,pci_domain_nr (dev), + __func__, segment,pci_domain_nr (dev->bus), (char *)name_buffer.pointer);kfree (name_buffer.pointer);return 1 ;
@@ -407,7 +407,7 @@ sn_acpi_get_pcidev_info(struct pci_dev *dev, struct pcidev_info **pcidev_info,/* Build up the pcidev_info.pdi_slot_host_handle */ host_devfn =get_host_devfn (pcidev_match.handle, rootbus_handle); (*pcidev_info)->pdi_slot_host_handle = - ((unsigned long )pci_domain_nr (dev) <<40 ) | + ((unsigned long )pci_domain_nr (dev->bus) <<40 ) |/* bus == 0 */ host_devfn;return 0 ;
arch/ia64/sn/kernel/io_init.c +1 -1
@@ -164,7 +164,7 @@ sn_io_slot_fixup(struct pci_dev *dev)panic ("%s: Unable to alloc memory for sn_irq_info" , __func__);/* Call to retrieve pci device information needed by kernel. */ - status = sal_get_pcidev_info((u64) pci_domain_nr(dev), + status = sal_get_pcidev_info((u64) pci_domain_nr(dev->bus), (u64) dev->bus->number, dev->devfn, (u64) __pa(pcidev_info),
Signature · 1 line
1.7.1
PATCH v4 17/30 PCI/powerpc: Rename pcibios_root_bridge_prepare()
In reply to Yijing WangPcibios_root_bridge_prepare() in powerpc is used to set root bus speed. Rename it to pcibios_set_root_bus_speed() for better readability.
--- arch/powerpc/include/asm/machdep.h | 2 +- arch/powerpc/kernel/pci-common.c | 6 +++--- arch/powerpc/platforms/pseries/pci.c | 2 +- arch/powerpc/platforms/pseries/pseries.h | 2 +- arch/powerpc/platforms/pseries/setup.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/machdep.h +1 -1
@@ -129,7 +129,7 @@ struct machdep_calls {void (*pcibios_fixup)(void );int (*pci_probe_mode)(struct pci_bus *);void (*pci_irq_fixup)(struct pci_dev *dev); -int (*pcibios_root_bridge_prepare)(struct pci_host_bridge +int (*pcibios_set_root_bus_speed)(struct pci_host_bridge *bridge);/* To setup PHBs when using automatic OF platform driver for PCI */
arch/powerpc/kernel/pci-common.c +3 -3
@@ -769,9 +769,9 @@ int pci_proc_domain(struct pci_bus *bus)int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge) { -if (ppc_md.pcibios_root_bridge_prepare) -return ppc_md.pcibios_root_bridge_prepare (bridge); - +if (ppc_md.pcibios_set_root_bus_speed) +return ppc_md.pcibios_set_root_bus_speed (bridge); +return 0 ; }
arch/powerpc/platforms/pseries/pci.c +1 -1
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_WINBOND ,PCI_DEVICE_ID_WINBOND_82C105 , fixup_winbond_82c105); -int pseries_root_bridge_prepare (struct pci_host_bridge *bridge) +int pseries_set_root_bus_speed (struct pci_host_bridge *bridge) {struct device_node *dn, *pdn;struct pci_bus *bus;
arch/powerpc/platforms/pseries/pseries.h +1 -1
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);/* PCI root bridge prepare function override for pseries */ struct pci_host_bridge ; -int pseries_root_bridge_prepare (struct pci_host_bridge *bridge); +int pseries_set_root_bus_speed (struct pci_host_bridge *bridge);unsigned long pseries_memory_block_size (void );
arch/powerpc/platforms/pseries/setup.c +1 -1
@@ -496,7 +496,7 @@ static void __init pSeries_setup_arch(void) ppc_md.enable_pmcs = power4_enable_pmcs; } - ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare; + ppc_md.pcibios_set_root_bus_speed = pseries_set_root_bus_speed;if (firmware_has_feature (FW_FEATURE_SET_MODE )) {long rc;
Signature · 6 lines
1.7.1 _______________________________________________ Linuxppc-dev mailing list [email protected] https://lists.ozlabs.org/listinfo/linuxppc-dev
PATCH v4 17/30 PCI/powerpc: Rename pcibios_root_bridge_prepare()
In reply to Yijing WangPcibios_root_bridge_prepare() in powerpc is used to set root bus speed. Rename it to pcibios_set_root_bus_speed() for better readability.
--- arch/powerpc/include/asm/machdep.h | 2 +- arch/powerpc/kernel/pci-common.c | 6 +++--- arch/powerpc/platforms/pseries/pci.c | 2 +- arch/powerpc/platforms/pseries/pseries.h | 2 +- arch/powerpc/platforms/pseries/setup.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
arch/powerpc/include/asm/machdep.h +1 -1
@@ -129,7 +129,7 @@ struct machdep_calls {void (*pcibios_fixup)(void );int (*pci_probe_mode)(struct pci_bus *);void (*pci_irq_fixup)(struct pci_dev *dev); -int (*pcibios_root_bridge_prepare)(struct pci_host_bridge +int (*pcibios_set_root_bus_speed)(struct pci_host_bridge *bridge);/* To setup PHBs when using automatic OF platform driver for PCI */
arch/powerpc/kernel/pci-common.c +3 -3
@@ -769,9 +769,9 @@ int pci_proc_domain(struct pci_bus *bus)int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge) { -if (ppc_md.pcibios_root_bridge_prepare) -return ppc_md.pcibios_root_bridge_prepare (bridge); - +if (ppc_md.pcibios_set_root_bus_speed) +return ppc_md.pcibios_set_root_bus_speed (bridge); +return 0 ; }
arch/powerpc/platforms/pseries/pci.c +1 -1
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_WINBOND ,PCI_DEVICE_ID_WINBOND_82C105 , fixup_winbond_82c105); -int pseries_root_bridge_prepare (struct pci_host_bridge *bridge) +int pseries_set_root_bus_speed (struct pci_host_bridge *bridge) {struct device_node *dn, *pdn;struct pci_bus *bus;
arch/powerpc/platforms/pseries/pseries.h +1 -1
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);/* PCI root bridge prepare function override for pseries */ struct pci_host_bridge ; -int pseries_root_bridge_prepare (struct pci_host_bridge *bridge); +int pseries_set_root_bus_speed (struct pci_host_bridge *bridge);unsigned long pseries_memory_block_size (void );
arch/powerpc/platforms/pseries/setup.c +1 -1
@@ -496,7 +496,7 @@ static void __init pSeries_setup_arch(void) ppc_md.enable_pmcs = power4_enable_pmcs; } - ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare; + ppc_md.pcibios_set_root_bus_speed = pseries_set_root_bus_speed;if (firmware_has_feature (FW_FEATURE_SET_MODE )) {long rc;
Signature · 1 line
1.7.1
PATCH v4 18/30 PCI/powerpc: Use pci_scan_root_bridge() for simplicity
In reply to Yijing WangNow we could use pci_scan_root_bridge() to scan pci buses, provide powerpc specific pci_host_bridge_ops.
--- arch/powerpc/include/asm/machdep.h | 2 +- arch/powerpc/kernel/pci-common.c | 63 +++++++++++++++++------------- arch/powerpc/platforms/pseries/pci.c | 8 ++-- arch/powerpc/platforms/pseries/pseries.h | 2 +- 4 files changed, 42 insertions(+), 33 deletions(-)
arch/powerpc/include/asm/machdep.h +1 -1
@@ -129,7 +129,7 @@ struct machdep_calls {void (*pcibios_fixup)(void );int (*pci_probe_mode)(struct pci_bus *);void (*pci_irq_fixup)(struct pci_dev *dev); -int (*pcibios_set_root_bus_speed)(struct pci_host_bridge +void (*pcibios_set_root_bus_speed)(struct pci_host_bridge *bridge);/* To setup PHBs when using automatic OF platform driver for PCI */
arch/powerpc/kernel/pci-common.c +36 -27
104 lines not on this page · raw message
arch/powerpc/platforms/pseries/pci.c +4 -4
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_WINBOND ,PCI_DEVICE_ID_WINBOND_82C105 , fixup_winbond_82c105); -int pseries_set_root_bus_speed (struct pci_host_bridge *bridge) +void pseries_set_root_bus_speed (struct pci_host_bridge *bridge) {struct device_node *dn, *pdn;struct pci_bus *bus;
@@ -121,7 +121,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge) dn =pcibios_get_phb_of_node (bus);if (!dn) -return 0 ; +return ;for (pdn = dn; pdn !=NULL ; pdn =of_get_next_parent (pdn)) { rc = of_property_read_u32_array(pdn,
@@ -135,7 +135,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)if (rc) {pr_debug ("no ibm,pcie-link-speed-stats property\n" ); -return 0 ; +return ; }switch (pcie_link_speed_stats[0 ]) {
@@ -168,5 +168,5 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)break ; } -return 0 ; +return ; }
arch/powerpc/platforms/pseries/pseries.h +1 -1
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);/* PCI root bridge prepare function override for pseries */ struct pci_host_bridge ; -int pseries_set_root_bus_speed (struct pci_host_bridge *bridge); +void pseries_set_root_bus_speed (struct pci_host_bridge *bridge);unsigned long pseries_memory_block_size (void );
Signature · 1 line
1.7.1
PATCH v4 18/30 PCI/powerpc: Use pci_scan_root_bridge() for simplicity
In reply to Yijing WangNow we could use pci_scan_root_bridge() to scan pci buses, provide powerpc specific pci_host_bridge_ops.
--- arch/powerpc/include/asm/machdep.h | 2 +- arch/powerpc/kernel/pci-common.c | 63 +++++++++++++++++------------- arch/powerpc/platforms/pseries/pci.c | 8 ++-- arch/powerpc/platforms/pseries/pseries.h | 2 +- 4 files changed, 42 insertions(+), 33 deletions(-)
arch/powerpc/include/asm/machdep.h +1 -1
@@ -129,7 +129,7 @@ struct machdep_calls {void (*pcibios_fixup)(void );int (*pci_probe_mode)(struct pci_bus *);void (*pci_irq_fixup)(struct pci_dev *dev); -int (*pcibios_set_root_bus_speed)(struct pci_host_bridge +void (*pcibios_set_root_bus_speed)(struct pci_host_bridge *bridge);/* To setup PHBs when using automatic OF platform driver for PCI */
arch/powerpc/kernel/pci-common.c +36 -27
104 lines not on this page · raw message
arch/powerpc/platforms/pseries/pci.c +4 -4
@@ -110,7 +110,7 @@ static void fixup_winbond_82c105(struct pci_dev* dev)DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_WINBOND ,PCI_DEVICE_ID_WINBOND_82C105 , fixup_winbond_82c105); -int pseries_set_root_bus_speed (struct pci_host_bridge *bridge) +void pseries_set_root_bus_speed (struct pci_host_bridge *bridge) {struct device_node *dn, *pdn;struct pci_bus *bus;
@@ -121,7 +121,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge) dn =pcibios_get_phb_of_node (bus);if (!dn) -return 0 ; +return ;for (pdn = dn; pdn !=NULL ; pdn =of_get_next_parent (pdn)) { rc = of_property_read_u32_array(pdn,
@@ -135,7 +135,7 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)if (rc) {pr_debug ("no ibm,pcie-link-speed-stats property\n" ); -return 0 ; +return ; }switch (pcie_link_speed_stats[0 ]) {
@@ -168,5 +168,5 @@ int pseries_set_root_bus_speed(struct pci_host_bridge *bridge)break ; } -return 0 ; +return ; }
arch/powerpc/platforms/pseries/pseries.h +1 -1
@@ -63,7 +63,7 @@ extern int dlpar_detach_node(struct device_node *);/* PCI root bridge prepare function override for pseries */ struct pci_host_bridge ; -int pseries_set_root_bus_speed (struct pci_host_bridge *bridge); +void pseries_set_root_bus_speed (struct pci_host_bridge *bridge);unsigned long pseries_memory_block_size (void );
Signature · 1 line
1.7.1
PATCH v4 19/30 PCI: Remove weak pcibios_root_bridge_prepare()
In reply to Yijing WangNow no one use weak pcibios_root_bridge_prepare(), we could remove it.
--- drivers/pci/probe.c | 15 --------------- include/linux/pci.h | 2 -- 2 files changed, 0 insertions(+), 17 deletions(-)
drivers/pci/probe.c +0 -15
@@ -1844,18 +1844,6 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus) }EXPORT_SYMBOL_GPL (pci_scan_child_bus); -/** -* pcibios_root_bridge_prepare - Platform-specific host bridge setup. -* @bridge: Host bridge to set up. -* -* Default empty implementation. Replace with an architecture-specific setup -* routine, if necessary. -*/ -int __weak pcibios_root_bridge_prepare (struct pci_host_bridge *bridge) -{ -return 0 ; -} -void __weak pcibios_add_bus (struct pci_bus *bus) { }
@@ -1890,9 +1878,6 @@ static struct pci_bus *__pci_create_root_bus( b->bridge =get_device (&bridge->dev);if (bridge->ops && bridge->ops->phb_set_root_bus_speed) bridge->ops->phb_set_root_bus_speed (bridge); - error =pcibios_root_bridge_prepare (bridge); -if (error) - goto err_out;device_enable_async_suspend (b->bridge);pci_set_bus_of_node (b);
include/linux/pci.h +0 -2
@@ -423,8 +423,6 @@ struct pci_host_bridge {void pci_set_host_bridge_release (struct pci_host_bridge *bridge,void (*release_fn)(struct pci_host_bridge *),void *release_data); - -int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge);struct pci_host_bridge *pci_create_host_bridge (struct device *parent,u32 dombus,struct list_head *resources,void *sysdata,struct pci_host_bridge_ops *ops);
Signature · 1 line
1.7.1
PATCH v4 19/30 PCI: Remove weak pcibios_root_bridge_prepare()
In reply to Yijing WangNow no one use weak pcibios_root_bridge_prepare(), we could remove it.
--- drivers/pci/probe.c | 15 --------------- include/linux/pci.h | 2 -- 2 files changed, 0 insertions(+), 17 deletions(-)
drivers/pci/probe.c +0 -15
@@ -1844,18 +1844,6 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus) }EXPORT_SYMBOL_GPL (pci_scan_child_bus); -/** -* pcibios_root_bridge_prepare - Platform-specific host bridge setup. -* @bridge: Host bridge to set up. -* -* Default empty implementation. Replace with an architecture-specific setup -* routine, if necessary. -*/ -int __weak pcibios_root_bridge_prepare (struct pci_host_bridge *bridge) -{ -return 0 ; -} -void __weak pcibios_add_bus (struct pci_bus *bus) { }
@@ -1890,9 +1878,6 @@ static struct pci_bus *__pci_create_root_bus( b->bridge =get_device (&bridge->dev);if (bridge->ops && bridge->ops->phb_set_root_bus_speed) bridge->ops->phb_set_root_bus_speed (bridge); - error =pcibios_root_bridge_prepare (bridge); -if (error) - goto err_out;device_enable_async_suspend (b->bridge);pci_set_bus_of_node (b);
include/linux/pci.h +0 -2
@@ -423,8 +423,6 @@ struct pci_host_bridge {void pci_set_host_bridge_release (struct pci_host_bridge *bridge,void (*release_fn)(struct pci_host_bridge *),void *release_data); - -int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge);struct pci_host_bridge *pci_create_host_bridge (struct device *parent,u32 dombus,struct list_head *resources,void *sysdata,struct pci_host_bridge_ops *ops);
Signature · 1 line
1.7.1
PATCH v4 20/30 PCI/sparc: Use pci_scan_root_bridge() for simplicity
In reply to Yijing WangNow we could use pci_scan_root_bridge() to scan pci buses, provide sparc specific pci_host_bridge_ops.
--- arch/sparc/kernel/pci.c | 32 ++++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 10 deletions(-)
arch/sparc/kernel/pci.c +22 -10
@@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)pci_claim_bus_resources (child_bus); } +static void pci_host_bridge_of_scan_bus ( +struct pci_host_bridge *host) +{ +struct pci_pbm_info *pbm =dev_get_drvdata (&host->dev); +struct device_node *node = pbm->op->dev.of_node; + +pci_of_scan_bus (pbm, node, host->bus); +} + +static struct pci_host_bridge_ops phb_ops = { + .phb_of_scan_bus = pci_host_bridge_of_scan_bus, +}; +struct pci_bus *pci_scan_one_pbm (struct pci_pbm_info *pbm,struct device *parent) {LIST_HEAD (resources);struct device_node *node = pbm->op->dev.of_node; -struct pci_bus *bus; +struct pci_host_bridge *host;printk ("PCI: Scanning PBM %s\n" , node->full_name);
@@ -667,23 +680,22 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, pbm->busn.end = pbm->pci_last_busno; pbm->busn.flags =IORESOURCE_BUS ;pci_add_resource (&resources, &pbm->busn); - bus =pci_create_root_bus (parent, + host =pci_scan_root_bridge (parent,PCI_DOMBUS (pbm->index, pbm->pci_first_busno), - pbm->pci_ops, pbm, &resources); -if (!bus) { -printk (KERN_ERR "Failed to create bus for %s\n" , + pbm->pci_ops, pbm, &resources, &phb_ops); +if (!host) { +printk (KERN_ERR "Failed to create host bridge for %s\n" , node->full_name);pci_free_resource_list (&resources);return NULL ; } -pci_of_scan_bus (pbm, node, bus); -pci_bus_add_devices (bus); -pci_bus_register_of_sysfs (bus); +pci_bus_add_devices (host->bus); +pci_bus_register_of_sysfs (host->bus); -pci_claim_bus_resources (bus); +pci_claim_bus_resources (host->bus); -return bus; +return host->bus; }void pcibios_fixup_bus (struct pci_bus *pbus)
Signature · 1 line
1.7.1
Bjorn Helgaas
maintainerRe: [PATCH v4 20/30] PCI/sparc: Use pci_scan_root_bridge() for simplicity
Quoted 57 lines · Yijing Wang
Now we could use
pci_scan_root_bridge()to scan pci buses, provide sparc specificpci_host_bridge_ops.Signed-off-by Yijing Wang <[email protected]>CC "David S. Miller" <[email protected]>--- arch/sparc/kernel/pci.c | 32 ++++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 10 deletions(-)arch/sparc/kernel/pci.c +18
-5@@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)pci_claim_bus_resources (child_bus); } +static void pci_host_bridge_of_scan_bus ( +struct pci_host_bridge *host) +{ +struct pci_pbm_info *pbm =dev_get_drvdata (&host->dev); +struct device_node *node = pbm->op->dev.of_node; + +pci_of_scan_bus (pbm, node, host->bus); +} + +static struct pci_host_bridge_ops phb_ops = { + .phb_of_scan_bus = pci_host_bridge_of_scan_bus, +}; +struct pci_bus *pci_scan_one_pbm (struct pci_pbm_info *pbm,struct device *parent) {LIST_HEAD (resources);struct device_node *node = pbm->op->dev.of_node; -struct pci_bus *bus; +struct pci_host_bridge *host;printk ("PCI: Scanning PBM %s\n" , node->full_name);@@ -667,23 +680,22 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, pbm->busn.end = pbm->pci_last_busno; pbm->busn.flags =IORESOURCE_BUS ;pci_add_resource (&resources, &pbm->busn); - bus =pci_create_root_bus (parent, + host =pci_scan_root_bridge (parent,PCI_DOMBUS (pbm->index, pbm->pci_first_busno), - pbm->pci_ops, pbm, &resources); -if (!bus) { -printk (KERN_ERR "Failed to create bus for %s\n" , + pbm->pci_ops, pbm, &resources, &phb_ops); +if (!host) { +printk (KERN_ERR "Failed to create host bridge for %s\n" , node->full_name);pci_free_resource_list (&resources);return NULL ;
arch/sparc/kernel/pci.c struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, · line 696
Quoted 10 lines
arch/sparc/kernel/pci.c +3
-4} -pci_of_scan_bus (pbm, node, bus); -pci_bus_add_devices (bus); -pci_bus_register_of_sysfs (bus); +pci_bus_add_devices (host->bus); +pci_bus_register_of_sysfs (host->bus); -pci_claim_bus_resources (bus); +pci_claim_bus_resources (host->bus);
Isn't this a case where pci_claim_bus_resources() should be done before pci_bus_add_devices()? You didn't introduce this problem, but since you're fixing similar issues, seems like we should fix this one, too. In a patch of its own, of course.
Quoted 14 lines
arch/sparc/kernel/pci.c +1
-1-return bus; +return host->bus; }void pcibios_fixup_bus (struct pci_bus *pbus)Signature · 7 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v4 20/30] PCI/sparc: Use pci_scan_root_bridge() for simplicity
Quoted 6 lines
Quoted 6 lines
arch/sparc/kernel/pci.c +2
-3-pci_of_scan_bus (pbm, node, bus); -pci_bus_add_devices (bus); -pci_bus_register_of_sysfs (bus); +pci_bus_add_devices (host->bus); +pci_bus_register_of_sysfs (host->bus);
Quoted 7 lines
arch/sparc/kernel/pci.c struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, · line 696
Quoted 2 lines
arch/sparc/kernel/pci.c +1
-1-pci_claim_bus_resources (bus); +pci_claim_bus_resources (host->bus);Isn't this a case where
pci_claim_bus_resources()should be done beforepci_bus_add_devices()? You didn't introduce this problem, but since you're fixing similar issues, seems like we should fix this one, too. In a patch of its own, of course.
OK, will fix in a another patch.
Quoted 18 lines
Quoted 15 lines
arch/sparc/kernel/pci.c +1
-1-return bus; +return host->bus; }void pcibios_fixup_bus (struct pci_bus *pbus)Signature · 7 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/.
Signature · 2 lines
Thanks! Yijing
Bjorn Helgaas
maintainerRe: [PATCH v4 20/30] PCI/sparc: Use pci_scan_root_bridge() for simplicity
In reply to Yijing WangQuoted 57 lines · Yijing Wang
Now we could use
pci_scan_root_bridge()to scan pci buses, provide sparc specificpci_host_bridge_ops.Signed-off-by Yijing Wang <[email protected]>CC "David S. Miller" <[email protected]>--- arch/sparc/kernel/pci.c | 32 ++++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 10 deletions(-)arch/sparc/kernel/pci.c +18
-5@@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)pci_claim_bus_resources (child_bus); } +static void pci_host_bridge_of_scan_bus ( +struct pci_host_bridge *host) +{ +struct pci_pbm_info *pbm =dev_get_drvdata (&host->dev); +struct device_node *node = pbm->op->dev.of_node; + +pci_of_scan_bus (pbm, node, host->bus); +} + +static struct pci_host_bridge_ops phb_ops = { + .phb_of_scan_bus = pci_host_bridge_of_scan_bus, +}; +struct pci_bus *pci_scan_one_pbm (struct pci_pbm_info *pbm,struct device *parent) {LIST_HEAD (resources);struct device_node *node = pbm->op->dev.of_node; -struct pci_bus *bus; +struct pci_host_bridge *host;printk ("PCI: Scanning PBM %s\n" , node->full_name);@@ -667,23 +680,22 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, pbm->busn.end = pbm->pci_last_busno; pbm->busn.flags =IORESOURCE_BUS ;pci_add_resource (&resources, &pbm->busn); - bus =pci_create_root_bus (parent, + host =pci_scan_root_bridge (parent,PCI_DOMBUS (pbm->index, pbm->pci_first_busno), - pbm->pci_ops, pbm, &resources); -if (!bus) { -printk (KERN_ERR "Failed to create bus for %s\n" , + pbm->pci_ops, pbm, &resources, &phb_ops); +if (!host) { +printk (KERN_ERR "Failed to create host bridge for %s\n" , node->full_name);pci_free_resource_list (&resources);return NULL ;
arch/sparc/kernel/pci.c struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, · line 696
Quoted 10 lines
arch/sparc/kernel/pci.c +3
-4} -pci_of_scan_bus (pbm, node, bus); -pci_bus_add_devices (bus); -pci_bus_register_of_sysfs (bus); +pci_bus_add_devices (host->bus); +pci_bus_register_of_sysfs (host->bus); -pci_claim_bus_resources (bus); +pci_claim_bus_resources (host->bus);
Isn't this a case where pci_claim_bus_resources() should be done before pci_bus_add_devices()? You didn't introduce this problem, but since you're fixing similar issues, seems like we should fix this one, too. In a patch of its own, of course.
Quoted 14 lines
arch/sparc/kernel/pci.c +1
-1-return bus; +return host->bus; }void pcibios_fixup_bus (struct pci_bus *pbus)Signature · 7 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
PATCH v4 20/30 PCI/sparc: Use pci_scan_root_bridge() for simplicity
In reply to Yijing WangNow we could use pci_scan_root_bridge() to scan pci buses, provide sparc specific pci_host_bridge_ops.
--- arch/sparc/kernel/pci.c | 32 ++++++++++++++++++++++---------- 1 files changed, 22 insertions(+), 10 deletions(-)
arch/sparc/kernel/pci.c +22 -10
@@ -650,12 +650,25 @@ static void pci_claim_bus_resources(struct pci_bus *bus)pci_claim_bus_resources (child_bus); } +static void pci_host_bridge_of_scan_bus ( +struct pci_host_bridge *host) +{ +struct pci_pbm_info *pbm =dev_get_drvdata (&host->dev); +struct device_node *node = pbm->op->dev.of_node; + +pci_of_scan_bus (pbm, node, host->bus); +} + +static struct pci_host_bridge_ops phb_ops = { + .phb_of_scan_bus = pci_host_bridge_of_scan_bus, +}; +struct pci_bus *pci_scan_one_pbm (struct pci_pbm_info *pbm,struct device *parent) {LIST_HEAD (resources);struct device_node *node = pbm->op->dev.of_node; -struct pci_bus *bus; +struct pci_host_bridge *host;printk ("PCI: Scanning PBM %s\n" , node->full_name);
@@ -667,23 +680,22 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, pbm->busn.end = pbm->pci_last_busno; pbm->busn.flags =IORESOURCE_BUS ;pci_add_resource (&resources, &pbm->busn); - bus =pci_create_root_bus (parent, + host =pci_scan_root_bridge (parent,PCI_DOMBUS (pbm->index, pbm->pci_first_busno), - pbm->pci_ops, pbm, &resources); -if (!bus) { -printk (KERN_ERR "Failed to create bus for %s\n" , + pbm->pci_ops, pbm, &resources, &phb_ops); +if (!host) { +printk (KERN_ERR "Failed to create host bridge for %s\n" , node->full_name);pci_free_resource_list (&resources);return NULL ; } -pci_of_scan_bus (pbm, node, bus); -pci_bus_add_devices (bus); -pci_bus_register_of_sysfs (bus); +pci_bus_add_devices (host->bus); +pci_bus_register_of_sysfs (host->bus); -pci_claim_bus_resources (bus); +pci_claim_bus_resources (host->bus); -return bus; +return host->bus; }void pcibios_fixup_bus (struct pci_bus *pbus)
Signature · 1 line
1.7.1
PATCH v4 21/30 PCI: Introduce pci_bus_child_max_busnr()
In reply to Yijing WangSometimes, we need to know the highest reserved busnr for children bus. Because parent's bus->busn_res could have padding in it. This function return the max child busnr as pci_scan_child_bus().
--- drivers/pci/hotplug/acpiphp_glue.c | 29 +---------------------------- drivers/pci/pci.c | 25 ++++++++++++++++++++++++- include/linux/pci.h | 2 +- 3 files changed, 26 insertions(+), 30 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +1 -28
@@ -397,33 +397,6 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)acpi_unlock_hp_context (); } -/** -* acpiphp_max_busnr - return the highest reserved bus number under the given bus. -* @bus: bus to start search with -*/ -static unsigned char acpiphp_max_busnr (struct pci_bus *bus) -{ -struct pci_bus *tmp; -unsigned char max, n; - -/* -* pci_bus_max_busnr will return the highest -* reserved busnr for all these children. -* that is equivalent to the bus->subordinate -* value. We don't want to use the parent's -* bus->subordinate value because it could have -* padding in it. -*/ - max = bus->busn_res.start; - -list_for_each_entry (tmp, &bus->children, node) { - n =pci_bus_max_busnr (tmp); -if (n > max) - max = n; - } -return max; -} -static void acpiphp_set_acpi_region (struct acpiphp_slot *slot) {struct acpiphp_func *func;
@@ -489,7 +462,7 @@ static void enable_slot(struct acpiphp_slot *slot)LIST_HEAD (add_list);acpiphp_rescan_slot (slot); - max =acpiphp_max_busnr (bus); + max =pci_bus_child_max_busnr (bus);for (pass =0 ; pass <2 ; pass++) {list_for_each_entry (dev, &bus->devices, bus_list) {if (PCI_SLOT (dev->devfn) != slot->device)
drivers/pci/pci.c +24 -1
@@ -121,7 +121,30 @@ unsigned char pci_bus_max_busnr(struct pci_bus *bus) }return max; } -EXPORT_SYMBOL_GPL (pci_bus_max_busnr); + +unsigned char pci_bus_child_max_busnr (struct pci_bus *bus) +{ +struct pci_bus *tmp; +unsigned char max, n; + +/* +* pci_bus_max_busnr will return the highest +* reserved busnr for all these children. +* that is equivalent to the bus->subordinate +* value. We don't want to use the parent's +* bus->subordinate value because it could have +* padding in it. +*/ + max = bus->busn_res.start; + +list_for_each_entry (tmp, &bus->children, node) { + n =pci_bus_max_busnr (tmp); +if (n > max) + max = n; + } +return max; +} +EXPORT_SYMBOL_GPL (pci_bus_child_max_busnr);#ifdef CONFIG_HAS_IOMEM void __iomem *pci_ioremap_bar (struct pci_dev *pdev,int bar)
include/linux/pci.h +1 -1
@@ -1183,7 +1183,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,void pci_walk_bus (struct pci_bus *top,int (*cb)(struct pci_dev *,void *),void *userdata);int pci_cfg_space_size (struct pci_dev *dev); -unsigned char pci_bus_max_busnr (struct pci_bus *bus); +unsigned char pci_bus_child_max_busnr (struct pci_bus *bus);void pci_setup_bridge (struct pci_bus *bus);resource_size_t pcibios_window_alignment (struct pci_bus *bus,unsigned long type);
Signature · 1 line
1.7.1
PATCH v4 21/30 PCI: Introduce pci_bus_child_max_busnr()
In reply to Yijing WangSometimes, we need to know the highest reserved busnr for children bus. Because parent's bus->busn_res could have padding in it. This function return the max child busnr as pci_scan_child_bus().
--- drivers/pci/hotplug/acpiphp_glue.c | 29 +---------------------------- drivers/pci/pci.c | 25 ++++++++++++++++++++++++- include/linux/pci.h | 2 +- 3 files changed, 26 insertions(+), 30 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +1 -28
@@ -397,33 +397,6 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)acpi_unlock_hp_context (); } -/** -* acpiphp_max_busnr - return the highest reserved bus number under the given bus. -* @bus: bus to start search with -*/ -static unsigned char acpiphp_max_busnr (struct pci_bus *bus) -{ -struct pci_bus *tmp; -unsigned char max, n; - -/* -* pci_bus_max_busnr will return the highest -* reserved busnr for all these children. -* that is equivalent to the bus->subordinate -* value. We don't want to use the parent's -* bus->subordinate value because it could have -* padding in it. -*/ - max = bus->busn_res.start; - -list_for_each_entry (tmp, &bus->children, node) { - n =pci_bus_max_busnr (tmp); -if (n > max) - max = n; - } -return max; -} -static void acpiphp_set_acpi_region (struct acpiphp_slot *slot) {struct acpiphp_func *func;
@@ -489,7 +462,7 @@ static void enable_slot(struct acpiphp_slot *slot)LIST_HEAD (add_list);acpiphp_rescan_slot (slot); - max =acpiphp_max_busnr (bus); + max =pci_bus_child_max_busnr (bus);for (pass =0 ; pass <2 ; pass++) {list_for_each_entry (dev, &bus->devices, bus_list) {if (PCI_SLOT (dev->devfn) != slot->device)
drivers/pci/pci.c +24 -1
@@ -121,7 +121,30 @@ unsigned char pci_bus_max_busnr(struct pci_bus *bus) }return max; } -EXPORT_SYMBOL_GPL (pci_bus_max_busnr); + +unsigned char pci_bus_child_max_busnr (struct pci_bus *bus) +{ +struct pci_bus *tmp; +unsigned char max, n; + +/* +* pci_bus_max_busnr will return the highest +* reserved busnr for all these children. +* that is equivalent to the bus->subordinate +* value. We don't want to use the parent's +* bus->subordinate value because it could have +* padding in it. +*/ + max = bus->busn_res.start; + +list_for_each_entry (tmp, &bus->children, node) { + n =pci_bus_max_busnr (tmp); +if (n > max) + max = n; + } +return max; +} +EXPORT_SYMBOL_GPL (pci_bus_child_max_busnr);#ifdef CONFIG_HAS_IOMEM void __iomem *pci_ioremap_bar (struct pci_dev *pdev,int bar)
include/linux/pci.h +1 -1
@@ -1183,7 +1183,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,void pci_walk_bus (struct pci_bus *top,int (*cb)(struct pci_dev *,void *),void *userdata);int pci_cfg_space_size (struct pci_dev *dev); -unsigned char pci_bus_max_busnr (struct pci_bus *bus); +unsigned char pci_bus_child_max_busnr (struct pci_bus *bus);void pci_setup_bridge (struct pci_bus *bus);resource_size_t pcibios_window_alignment (struct pci_bus *bus,unsigned long type);
Signature · 1 line
1.7.1
PATCH v4 22/30 PCI/Parisc: Use pci_scan_root_bus() for simplicity
In reply to Yijing WangFrom: Yijing Wang <[email protected]>
Now pci_bus_add_devices() has been ripped out
from pci_scan_root_bus(), we could use pci_scan_root_bus() instead of pci_create_root_bus() + pci_scan_child_bus() for simplicity. We could also remove the pci bus resource(dino_current_bus,255) and pci_bus_update_busn_res_end(), because pci_scan_root_bus() would do the same thing.
--- drivers/parisc/dino.c | 11 ++--------- drivers/parisc/lba_pci.c | 7 ++----- 2 files changed, 4 insertions(+), 14 deletions(-)
drivers/parisc/dino.c +2 -9
@@ -977,15 +977,11 @@ static int __init dino_probe(struct parisc_device *dev)if (dino_dev->hba.gmmio_space.flags)pci_add_resource (&resources, &dino_dev->hba.gmmio_space); - dino_dev->hba.bus_num.start = dino_current_bus; - dino_dev->hba.bus_num.end =255 ; - dino_dev->hba.bus_num.flags =IORESOURCE_BUS ; -pci_add_resource (&resources, &dino_dev->hba.bus_num);/* ** It's not used to avoid chicken/egg problems ** with configuration accessor functions. */ - dino_dev->hba.hba_bus = bus =pci_create_root_bus (&dev->dev, + dino_dev->hba.hba_bus = bus =pci_scan_root_bus (&dev->dev, dino_current_bus, &dino_cfg_ops,NULL , &resources);if (!bus) { printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n",
@@ -996,13 +992,10 @@ static int __init dino_probe(struct parisc_device *dev)return 0 ; } - max =pci_scan_child_bus (bus); -pci_bus_update_busn_res_end (bus, max); -/* This code *depends* on scanning being single threaded * if it isn't, this global bus number count will fail */ - dino_current_bus = max +1 ; + dino_current_bus = bus->busn_res.end +1 ;pci_bus_assign_resources (bus);pci_bus_add_devices (bus);return 0 ;
drivers/parisc/lba_pci.c +2 -5
@@ -1422,7 +1422,6 @@ lba_driver_probe(struct parisc_device *dev)void *tmp_obj;char *version;void __iomem *addr =ioremap_nocache (dev->hpa.start,4096 ); -int max;/* Read HW Rev First */ func_class =READ_REG32 (addr +LBA_FCLASS );
@@ -1563,15 +1562,13 @@ lba_driver_probe(struct parisc_device *dev) dev->dev.platform_data = lba_dev; lba_bus = lba_dev->hba.hba_bus = -pci_create_root_bus (&dev->dev, lba_dev->hba.bus_num.start, +pci_scan_root_bus (&dev->dev, lba_dev->hba.bus_num.start, cfg_ops,NULL , &resources);if (!lba_bus) {pci_free_resource_list (&resources);return 0 ; } - max =pci_scan_child_bus (lba_bus); -/* This is in lieu of calling pci_assign_unassigned_resources() */ if (is_pdc_pat ()) {/* assign resources to un-initialized devices */
@@ -1599,7 +1596,7 @@ lba_driver_probe(struct parisc_device *dev) lba_dev->flags |=LBA_FLAG_SKIP_PROBE ; } - lba_next_bus = max +1 ; + lba_next_bus =pci_bus_child_max_busnr (lba_bus) +1 ;pci_bus_add_devices (lba_bus);/* Whew! Finally done! Tell services we got this one covered. */
Signature · 1 line
1.7.1
Bjorn Helgaas
maintainerRe: [PATCH v4 22/30] PCI/Parisc: Use pci_scan_root_bus() for simplicity
Quoted 1 line · Yijing Wang
From: Yijing Wang <[email protected]>
When you write subject lines, I think it's friendly to run "git log --oneline" on the file you're changing, and make yours match the previous ones.
$ git log --oneline drivers/parisc/dino.c 3f05536d226d PCI/Parisc: Use pci_scan_root_bus() for simplicity 3335f75a8877 parisc: dino: fix %d confusingly prefixed with 0x in format string 3fad9b8d597f drivers/parisc: Use printf extension %pR for struct resource 0fe763c570ad Drivers: misc: remove __dev* attributes. 0b79ca2a800d parisc/PCI: Use list_for_each_entry() for bus->devices traversal 30aa80da43a5 parisc/PCI: register busn_res for root buses ...
Yours doesn't match any of them, but "parisc/PCI" seems the best match.
Quoted 20 lines
Now
pci_bus_add_devices()has been ripped out
frompci_scan_root_bus(), we could usepci_scan_root_bus()instead ofpci_create_root_bus()+pci_scan_child_bus()for simplicity. We could also remove the pci busresource(dino_current_bus,255)andpci_bus_update_busn_res_end(), becausepci_scan_root_bus()would do the same thing.Signed-off-by Yijing Wang <[email protected]>CC "James E.J. Bottomley" <[email protected]>--- drivers/parisc/dino.c | 11 ++--------- drivers/parisc/lba_pci.c | 7 ++----- 2 files changed, 4 insertions(+), 14 deletions(-)drivers/parisc/dino.c +0
-0
drivers/parisc/dino.c static int __init dino_probe(struct parisc_device *dev) · line 983
Quoted 7 lines
drivers/parisc/dino.c +0
-4@@ -977,15 +977,11 @@ static int __init dino_probe(struct parisc_device *dev)if (dino_dev->hba.gmmio_space.flags)pci_add_resource (&resources, &dino_dev->hba.gmmio_space); - dino_dev->hba.bus_num.start = dino_current_bus; - dino_dev->hba.bus_num.end =255 ; - dino_dev->hba.bus_num.flags =IORESOURCE_BUS ; -pci_add_resource (&resources, &dino_dev->hba.bus_num);
I know pci_scan_root_bus() does default to bus 0-255, but I don't really like that behavior, and I think it's a bug for drivers like this to rely on that. The PCI core has no way to discover the actual bus number range, and the only reason it supplies a default is because it was inconvenient to change all the callers. The host bridge driver is the only code that has any chance of discovering and/or configuring the correct range.
So I think it's more correct to leave the existing code here, even though this code is is likely incorrect. At least then if we trip over an issue with the bus range being incorrect, it will be clear that the fix should be in dino.c rather than the PCI core.
Re: [PATCH v4 22/30] PCI/Parisc: Use pci_scan_root_bus() for simplicity
Quoted 16 lines · Bjorn Helgaas
Quoted 1 line · Yijing Wang
From: Yijing Wang <[email protected]>
When you write subject lines, I think it's friendly to run "git log --oneline" on the file you're changing, and make yours match the previous ones.
$ git log --oneline drivers/parisc/dino.c 3f05536d226d PCI/Parisc: Use pci_scan_root_bus() for simplicity 3335f75a8877 parisc: dino: fix %d confusingly prefixed with 0x in format string 3fad9b8d597f drivers/parisc: Use printf extension %pR for struct resource 0fe763c570ad Drivers: misc: remove __dev* attributes. 0b79ca2a800d parisc/PCI: Use list_for_each_entry() for bus->devices traversal 30aa80da43a5 parisc/PCI: register busn_res for root buses ...
Quoted 1 line
Yours doesn't match any of them, but "parisc/PCI" seems the best match.
OK, I will refresh the title, sorry.
Quoted 36 lines
Quoted 21 lines
Now
pci_bus_add_devices()has been ripped out
frompci_scan_root_bus(), we could usepci_scan_root_bus()instead ofpci_create_root_bus()+pci_scan_child_bus()for simplicity. We could also remove the pci busresource(dino_current_bus,255)andpci_bus_update_busn_res_end(), becausepci_scan_root_bus()would do the same thing.Signed-off-by Yijing Wang <[email protected]>CC "James E.J. Bottomley" <[email protected]>--- drivers/parisc/dino.c | 11 ++--------- drivers/parisc/lba_pci.c | 7 ++----- 2 files changed, 4 insertions(+), 14 deletions(-)drivers/parisc/dino.c +0
-0drivers/parisc/dino.c static int __init dino_probe(struct parisc_device *dev) · line 983
Quoted 7 lines
drivers/parisc/dino.c +0
-4@@ -977,15 +977,11 @@ static int __init dino_probe(struct parisc_device *dev)if (dino_dev->hba.gmmio_space.flags)pci_add_resource (&resources, &dino_dev->hba.gmmio_space); - dino_dev->hba.bus_num.start = dino_current_bus; - dino_dev->hba.bus_num.end =255 ; - dino_dev->hba.bus_num.flags =IORESOURCE_BUS ; -pci_add_resource (&resources, &dino_dev->hba.bus_num);I know
pci_scan_root_bus()does default to bus 0-255, but I don't really like that behavior, and I think it's a bug for drivers like this to rely on that. The PCI core has no way to discover the actual bus number range, and the only reason it supplies a default is because it was inconvenient to change all the callers. The host bridge driver is the only code that has any chance of discovering and/or configuring the correct range.
Quoted 4 lines
So I think it's more correct to leave the existing code here, even though this code is is likely incorrect. At least then if we trip over an issue with the bus range being incorrect, it will be clear that the fix should be in
dino.crather than the PCI core.
OK, I would keep this code here, thanks!
Quoted 3 lines
.
Signature · 2 lines
Thanks! Yijing
Re: [PATCH v4 22/30] PCI/Parisc: Use pci_scan_root_bus() for simplicity
In reply to Bjorn HelgaasQuoted 16 lines · Bjorn Helgaas
Quoted 1 line · Yijing Wang
From: Yijing Wang <[email protected]>
When you write subject lines, I think it's friendly to run "git log --oneline" on the file you're changing, and make yours match the previous ones.
$ git log --oneline drivers/parisc/dino.c 3f05536d226d PCI/Parisc: Use pci_scan_root_bus() for simplicity 3335f75a8877 parisc: dino: fix %d confusingly prefixed with 0x in format string 3fad9b8d597f drivers/parisc: Use printf extension %pR for struct resource 0fe763c570ad Drivers: misc: remove __dev* attributes. 0b79ca2a800d parisc/PCI: Use list_for_each_entry() for bus->devices traversal 30aa80da43a5 parisc/PCI: register busn_res for root buses ...
Quoted 1 line
Yours doesn't match any of them, but "parisc/PCI" seems the best match.
OK, I will refresh the title, sorry.
Quoted 36 lines
Quoted 21 lines
Now
pci_bus_add_devices()has been ripped out
frompci_scan_root_bus(), we could usepci_scan_root_bus()instead ofpci_create_root_bus()+pci_scan_child_bus()for simplicity. We could also remove the pci busresource(dino_current_bus,255)andpci_bus_update_busn_res_end(), becausepci_scan_root_bus()would do the same thing.Signed-off-by Yijing Wang <[email protected]>CC "James E.J. Bottomley" <[email protected]>--- drivers/parisc/dino.c | 11 ++--------- drivers/parisc/lba_pci.c | 7 ++----- 2 files changed, 4 insertions(+), 14 deletions(-)drivers/parisc/dino.c +0
-0drivers/parisc/dino.c static int __init dino_probe(struct parisc_device *dev) · line 983
Quoted 7 lines
drivers/parisc/dino.c +0
-4@@ -977,15 +977,11 @@ static int __init dino_probe(struct parisc_device *dev)if (dino_dev->hba.gmmio_space.flags)pci_add_resource (&resources, &dino_dev->hba.gmmio_space); - dino_dev->hba.bus_num.start = dino_current_bus; - dino_dev->hba.bus_num.end =255 ; - dino_dev->hba.bus_num.flags =IORESOURCE_BUS ; -pci_add_resource (&resources, &dino_dev->hba.bus_num);I know
pci_scan_root_bus()does default to bus 0-255, but I don't really like that behavior, and I think it's a bug for drivers like this to rely on that. The PCI core has no way to discover the actual bus number range, and the only reason it supplies a default is because it was inconvenient to change all the callers. The host bridge driver is the only code that has any chance of discovering and/or configuring the correct range.
Quoted 4 lines
So I think it's more correct to leave the existing code here, even though this code is is likely incorrect. At least then if we trip over an issue with the bus range being incorrect, it will be clear that the fix should be in
dino.crather than the PCI core.
OK, I would keep this code here, thanks!
Quoted 3 lines
.
Signature · 2 lines
Thanks! Yijing
Bjorn Helgaas
maintainerRe: [PATCH v4 22/30] PCI/Parisc: Use pci_scan_root_bus() for simplicity
In reply to Yijing WangQuoted 1 line · Yijing Wang
From: Yijing Wang <[email protected]>
When you write subject lines, I think it's friendly to run "git log --oneline" on the file you're changing, and make yours match the previous ones.
$ git log --oneline drivers/parisc/dino.c 3f05536d226d PCI/Parisc: Use pci_scan_root_bus() for simplicity 3335f75a8877 parisc: dino: fix %d confusingly prefixed with 0x in format string 3fad9b8d597f drivers/parisc: Use printf extension %pR for struct resource 0fe763c570ad Drivers: misc: remove __dev* attributes. 0b79ca2a800d parisc/PCI: Use list_for_each_entry() for bus->devices traversal 30aa80da43a5 parisc/PCI: register busn_res for root buses ...
Yours doesn't match any of them, but "parisc/PCI" seems the best match.
Quoted 20 lines
Now
pci_bus_add_devices()has been ripped out
frompci_scan_root_bus(), we could usepci_scan_root_bus()instead ofpci_create_root_bus()+pci_scan_child_bus()for simplicity. We could also remove the pci busresource(dino_current_bus,255)andpci_bus_update_busn_res_end(), becausepci_scan_root_bus()would do the same thing.Signed-off-by Yijing Wang <[email protected]>CC "James E.J. Bottomley" <[email protected]>--- drivers/parisc/dino.c | 11 ++--------- drivers/parisc/lba_pci.c | 7 ++----- 2 files changed, 4 insertions(+), 14 deletions(-)drivers/parisc/dino.c +0
-0
drivers/parisc/dino.c static int __init dino_probe(struct parisc_device *dev) · line 983
Quoted 7 lines
drivers/parisc/dino.c +0
-4@@ -977,15 +977,11 @@ static int __init dino_probe(struct parisc_device *dev)if (dino_dev->hba.gmmio_space.flags)pci_add_resource (&resources, &dino_dev->hba.gmmio_space); - dino_dev->hba.bus_num.start = dino_current_bus; - dino_dev->hba.bus_num.end =255 ; - dino_dev->hba.bus_num.flags =IORESOURCE_BUS ; -pci_add_resource (&resources, &dino_dev->hba.bus_num);
I know pci_scan_root_bus() does default to bus 0-255, but I don't really like that behavior, and I think it's a bug for drivers like this to rely on that. The PCI core has no way to discover the actual bus number range, and the only reason it supplies a default is because it was inconvenient to change all the callers. The host bridge driver is the only code that has any chance of discovering and/or configuring the correct range.
So I think it's more correct to leave the existing code here, even though this code is is likely incorrect. At least then if we trip over an issue with the bus range being incorrect, it will be clear that the fix should be in dino.c rather than the PCI core.
PATCH v4 22/30 PCI/Parisc: Use pci_scan_root_bus() for simplicity
In reply to Yijing WangFrom: Yijing Wang <[email protected]>
Now pci_bus_add_devices() has been ripped out
from pci_scan_root_bus(), we could use pci_scan_root_bus() instead of pci_create_root_bus() + pci_scan_child_bus() for simplicity. We could also remove the pci bus resource(dino_current_bus,255) and pci_bus_update_busn_res_end(), because pci_scan_root_bus() would do the same thing.
--- drivers/parisc/dino.c | 11 ++--------- drivers/parisc/lba_pci.c | 7 ++----- 2 files changed, 4 insertions(+), 14 deletions(-)
drivers/parisc/dino.c +2 -9
@@ -977,15 +977,11 @@ static int __init dino_probe(struct parisc_device *dev)if (dino_dev->hba.gmmio_space.flags)pci_add_resource (&resources, &dino_dev->hba.gmmio_space); - dino_dev->hba.bus_num.start = dino_current_bus; - dino_dev->hba.bus_num.end =255 ; - dino_dev->hba.bus_num.flags =IORESOURCE_BUS ; -pci_add_resource (&resources, &dino_dev->hba.bus_num);/* ** It's not used to avoid chicken/egg problems ** with configuration accessor functions. */ - dino_dev->hba.hba_bus = bus =pci_create_root_bus (&dev->dev, + dino_dev->hba.hba_bus = bus =pci_scan_root_bus (&dev->dev, dino_current_bus, &dino_cfg_ops,NULL , &resources);if (!bus) { printk(KERN_ERR "ERROR: failed to scan PCI bus on %s (duplicate bus number %d?)\n",
@@ -996,13 +992,10 @@ static int __init dino_probe(struct parisc_device *dev)return 0 ; } - max =pci_scan_child_bus (bus); -pci_bus_update_busn_res_end (bus, max); -/* This code *depends* on scanning being single threaded * if it isn't, this global bus number count will fail */ - dino_current_bus = max +1 ; + dino_current_bus = bus->busn_res.end +1 ;pci_bus_assign_resources (bus);pci_bus_add_devices (bus);return 0 ;
drivers/parisc/lba_pci.c +2 -5
@@ -1422,7 +1422,6 @@ lba_driver_probe(struct parisc_device *dev)void *tmp_obj;char *version;void __iomem *addr =ioremap_nocache (dev->hpa.start,4096 ); -int max;/* Read HW Rev First */ func_class =READ_REG32 (addr +LBA_FCLASS );
@@ -1563,15 +1562,13 @@ lba_driver_probe(struct parisc_device *dev) dev->dev.platform_data = lba_dev; lba_bus = lba_dev->hba.hba_bus = -pci_create_root_bus (&dev->dev, lba_dev->hba.bus_num.start, +pci_scan_root_bus (&dev->dev, lba_dev->hba.bus_num.start, cfg_ops,NULL , &resources);if (!lba_bus) {pci_free_resource_list (&resources);return 0 ; } - max =pci_scan_child_bus (lba_bus); -/* This is in lieu of calling pci_assign_unassigned_resources() */ if (is_pdc_pat ()) {/* assign resources to un-initialized devices */
@@ -1599,7 +1596,7 @@ lba_driver_probe(struct parisc_device *dev) lba_dev->flags |=LBA_FLAG_SKIP_PROBE ; } - lba_next_bus = max +1 ; + lba_next_bus =pci_bus_child_max_busnr (lba_bus) +1 ;pci_bus_add_devices (lba_bus);/* Whew! Finally done! Tell services we got this one covered. */
Signature · 1 line
1.7.1
PATCH v4 23/30 PCI/mvebu: Use pci_common_init_dev() to simplify code
In reply to Yijing WangMvebu_pcie_scan_bus() is not necessary, we could use pci_common_init_dev() instead of pci_common_init(), and pass the device pointer as the parent. Then pci_scan_root_bus() will be called to scan the pci busses.
--- drivers/pci/host/pci-mvebu.c | 18 +----------------- 1 files changed, 1 insertions(+), 17 deletions(-)
drivers/pci/host/pci-mvebu.c +1 -17
@@ -750,21 +750,6 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys)return 1 ; } -static struct pci_bus *mvebu_pcie_scan_bus (int nr,struct pci_sys_data *sys) -{ -struct mvebu_pcie *pcie =sys_to_pcie (sys); -struct pci_bus *bus; - - bus =pci_create_root_bus (&pcie->pdev->dev, sys->busnr, - &mvebu_pcie_ops, sys, &sys->resources); -if (!bus) -return NULL ; - -pci_scan_child_bus (bus); - -return bus; -} - static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev, const struct resource *res, resource_size_t start,
@@ -808,12 +793,11 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie) hw.nr_controllers =1 ; hw.private_data = (void **)&pcie; hw.setup = mvebu_pcie_setup; - hw.scan = mvebu_pcie_scan_bus; hw.map_irq = of_irq_parse_and_map_pci; hw.ops = &mvebu_pcie_ops; hw.align_resource = mvebu_pcie_align_resource; -pci_common_init (&hw); +pci_common_init_dev (&pcie->pdev->dev, &hw); }/*
Signature · 1 line
1.7.1
Bjorn Helgaas
maintainerRe: [PATCH v4 23/30] PCI/mvebu: Use pci_common_init_dev() to simplify code
Quoted 39 lines · Yijing Wang
Mvebu_pcie_scan_bus()is not necessary, we could usepci_common_init_dev()instead ofpci_common_init(), and pass the device pointer as the parent. Thenpci_scan_root_bus()will be called to scan the pci busses.Signed-off-by Yijing Wang <[email protected]>CC Thomas Petazzoni <[email protected]>CC Jason Cooper <[email protected]>--- drivers/pci/host/pci-mvebu.c | 18 +----------------- 1 files changed, 1 insertions(+), 17 deletions(-)drivers/pci/host/pci-mvebu.c +0
-15@@ -750,21 +750,6 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys)return 1 ; } -static struct pci_bus *mvebu_pcie_scan_bus (int nr,struct pci_sys_data *sys) -{ -struct mvebu_pcie *pcie =sys_to_pcie (sys); -struct pci_bus *bus; - - bus =pci_create_root_bus (&pcie->pdev->dev, sys->busnr, - &mvebu_pcie_ops, sys, &sys->resources); -if (!bus) -return NULL ; - -pci_scan_child_bus (bus); - -return bus; -} - static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev, const struct resource *res, resource_size_t start,
drivers/pci/host/pci-mvebu.c static void mvebu_pcie_enable(struct mvebu_pcie *pcie) · line 800
Quoted 10 lines
drivers/pci/host/pci-mvebu.c +1
-2@@ -808,12 +793,11 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie) hw.nr_controllers =1 ; hw.private_data = (void **)&pcie; hw.setup = mvebu_pcie_setup; - hw.scan = mvebu_pcie_scan_bus; hw.map_irq = of_irq_parse_and_map_pci; hw.ops = &mvebu_pcie_ops; hw.align_resource = mvebu_pcie_align_resource; -pci_common_init (&hw); +pci_common_init_dev (&pcie->pdev->dev, &hw);
I'm not necessarily opposed to this, but it seems unrelated to the rest of the series. And I think it changes the behavior slightly (now we call pci_common_init_dev() with &pcie->pdev->dev instead of NULL). So I'll wait for an ack from Thomas and/or Jason.
Quoted 11 lines
drivers/pci/host/pci-mvebu.c +0
-0}/* Signature · 7 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Bjorn Helgaas
maintainerRe: [PATCH v4 23/30] PCI/mvebu: Use pci_common_init_dev() to simplify code
In reply to Yijing WangQuoted 39 lines · Yijing Wang
Mvebu_pcie_scan_bus()is not necessary, we could usepci_common_init_dev()instead ofpci_common_init(), and pass the device pointer as the parent. Thenpci_scan_root_bus()will be called to scan the pci busses.Signed-off-by Yijing Wang <[email protected]>CC Thomas Petazzoni <[email protected]>CC Jason Cooper <[email protected]>--- drivers/pci/host/pci-mvebu.c | 18 +----------------- 1 files changed, 1 insertions(+), 17 deletions(-)drivers/pci/host/pci-mvebu.c +0
-15@@ -750,21 +750,6 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys)return 1 ; } -static struct pci_bus *mvebu_pcie_scan_bus (int nr,struct pci_sys_data *sys) -{ -struct mvebu_pcie *pcie =sys_to_pcie (sys); -struct pci_bus *bus; - - bus =pci_create_root_bus (&pcie->pdev->dev, sys->busnr, - &mvebu_pcie_ops, sys, &sys->resources); -if (!bus) -return NULL ; - -pci_scan_child_bus (bus); - -return bus; -} - static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev, const struct resource *res, resource_size_t start,
drivers/pci/host/pci-mvebu.c static void mvebu_pcie_enable(struct mvebu_pcie *pcie) · line 800
Quoted 10 lines
drivers/pci/host/pci-mvebu.c +1
-2@@ -808,12 +793,11 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie) hw.nr_controllers =1 ; hw.private_data = (void **)&pcie; hw.setup = mvebu_pcie_setup; - hw.scan = mvebu_pcie_scan_bus; hw.map_irq = of_irq_parse_and_map_pci; hw.ops = &mvebu_pcie_ops; hw.align_resource = mvebu_pcie_align_resource; -pci_common_init (&hw); +pci_common_init_dev (&pcie->pdev->dev, &hw);
I'm not necessarily opposed to this, but it seems unrelated to the rest of the series. And I think it changes the behavior slightly (now we call pci_common_init_dev() with &pcie->pdev->dev instead of NULL). So I'll wait for an ack from Thomas and/or Jason.
Quoted 11 lines
drivers/pci/host/pci-mvebu.c +0
-0}/* Signature · 7 lines
1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
PATCH v4 23/30 PCI/mvebu: Use pci_common_init_dev() to simplify code
In reply to Yijing WangMvebu_pcie_scan_bus() is not necessary, we could use pci_common_init_dev() instead of pci_common_init(), and pass the device pointer as the parent. Then pci_scan_root_bus() will be called to scan the pci busses.
--- drivers/pci/host/pci-mvebu.c | 18 +----------------- 1 files changed, 1 insertions(+), 17 deletions(-)
drivers/pci/host/pci-mvebu.c +1 -17
@@ -750,21 +750,6 @@ static int mvebu_pcie_setup(int nr, struct pci_sys_data *sys)return 1 ; } -static struct pci_bus *mvebu_pcie_scan_bus (int nr,struct pci_sys_data *sys) -{ -struct mvebu_pcie *pcie =sys_to_pcie (sys); -struct pci_bus *bus; - - bus =pci_create_root_bus (&pcie->pdev->dev, sys->busnr, - &mvebu_pcie_ops, sys, &sys->resources); -if (!bus) -return NULL ; - -pci_scan_child_bus (bus); - -return bus; -} - static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev, const struct resource *res, resource_size_t start,
@@ -808,12 +793,11 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie) hw.nr_controllers =1 ; hw.private_data = (void **)&pcie; hw.setup = mvebu_pcie_setup; - hw.scan = mvebu_pcie_scan_bus; hw.map_irq = of_irq_parse_and_map_pci; hw.ops = &mvebu_pcie_ops; hw.align_resource = mvebu_pcie_align_resource; -pci_common_init (&hw); +pci_common_init_dev (&pcie->pdev->dev, &hw); }/*
Signature · 1 line
1.7.1
PATCH v4 24/30 PCI/tegra: Remove redundant tegra_pcie_scan_bus()
In reply to Yijing WangNow pci_scan_root_bus() is almost simliar to pci_create_root_bus() + pci_scan_child_bus(). So we could use common pci_scan_root_bus() in pci_common_init_dev() to scan pci busses. tegra_pcie_scan_bus() is redundant, remove it.
--- drivers/pci/host/pci-tegra.c | 16 ---------------- 1 files changed, 0 insertions(+), 16 deletions(-)
drivers/pci/host/pci-tegra.c +0 -16
@@ -630,21 +630,6 @@ static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)return irq; } -static struct pci_bus *tegra_pcie_scan_bus (int nr,struct pci_sys_data *sys) -{ -struct tegra_pcie *pcie =sys_to_pcie (sys); -struct pci_bus *bus; - - bus =pci_create_root_bus (pcie->dev, sys->busnr, &tegra_pcie_ops, sys, - &sys->resources); -if (!bus) -return NULL ; - -pci_scan_child_bus (bus); - -return bus; -} -static irqreturn_t tegra_pcie_isr (int irq,void *arg) {const char *err_msg[] = {
@@ -1831,7 +1816,6 @@ static int tegra_pcie_enable(struct tegra_pcie *pcie) hw.private_data = (void **)&pcie; hw.setup = tegra_pcie_setup; hw.map_irq = tegra_pcie_map_irq; - hw.scan = tegra_pcie_scan_bus; hw.ops = &tegra_pcie_ops;pci_common_init_dev (pcie->dev, &hw);
Signature · 1 line
1.7.1
PATCH v4 24/30 PCI/tegra: Remove redundant tegra_pcie_scan_bus()
In reply to Yijing WangNow pci_scan_root_bus() is almost simliar to pci_create_root_bus() + pci_scan_child_bus(). So we could use common pci_scan_root_bus() in pci_common_init_dev() to scan pci busses. tegra_pcie_scan_bus() is redundant, remove it.
--- drivers/pci/host/pci-tegra.c | 16 ---------------- 1 files changed, 0 insertions(+), 16 deletions(-)
drivers/pci/host/pci-tegra.c +0 -16
@@ -630,21 +630,6 @@ static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)return irq; } -static struct pci_bus *tegra_pcie_scan_bus (int nr,struct pci_sys_data *sys) -{ -struct tegra_pcie *pcie =sys_to_pcie (sys); -struct pci_bus *bus; - - bus =pci_create_root_bus (pcie->dev, sys->busnr, &tegra_pcie_ops, sys, - &sys->resources); -if (!bus) -return NULL ; - -pci_scan_child_bus (bus); - -return bus; -} -static irqreturn_t tegra_pcie_isr (int irq,void *arg) {const char *err_msg[] = {
@@ -1831,7 +1816,6 @@ static int tegra_pcie_enable(struct tegra_pcie *pcie) hw.private_data = (void **)&pcie; hw.setup = tegra_pcie_setup; hw.map_irq = tegra_pcie_map_irq; - hw.scan = tegra_pcie_scan_bus; hw.ops = &tegra_pcie_ops;pci_common_init_dev (pcie->dev, &hw);
Signature · 1 line
1.7.1
PATCH v4 25/30 PCI/designware: Use pci_scan_root_bus() for simplicity
In reply to Yijing WangUse pci_scan_root_bus() instead of pci_create_root_bus() + pci_scan_child_bus() for simplicity.
--- drivers/pci/host/pcie-designware.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/pci/host/pcie-designware.c +1 -3
@@ -728,13 +728,11 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)struct pcie_port *pp =sys_to_pcie (sys); pp->root_bus_nr = sys->busnr; - bus =pci_create_root_bus (pp->dev, sys->busnr, + bus =pci_scan_root_bus (pp->dev, sys->busnr, &dw_pcie_ops, sys, &sys->resources);if (!bus)return NULL ; -pci_scan_child_bus (bus); -if (bus && pp->ops->scan_bus) pp->ops->scan_bus (pp);
Signature · 1 line
1.7.1
PATCH v4 26/30 PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
In reply to Yijing WangUse pci_scan_root_bus() instead of pci_create_root_bus() + pci_scan_child_bus() for simplicity.
--- drivers/pci/host/pci-xgene.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/pci/host/pci-xgene.c +1 -2
@@ -499,12 +499,11 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)if (ret)return ret; - bus =pci_create_root_bus (&pdev->dev,0 , + bus =pci_scan_root_bus (&pdev->dev,0 , &xgene_pcie_ops, port, &res);if (!bus)return -ENOMEM ; -pci_scan_child_bus (bus);pci_assign_unassigned_bus_resources (bus);pci_bus_add_devices (bus);
Signature · 1 line
1.7.1
PATCH v4 26/30 PCI/xgene: Use pci_scan_root_bus() instead of pci_create_root_bus()
In reply to Yijing WangUse pci_scan_root_bus() instead of pci_create_root_bus() + pci_scan_child_bus() for simplicity.
--- drivers/pci/host/pci-xgene.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/pci/host/pci-xgene.c +1 -2
@@ -499,12 +499,11 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)if (ret)return ret; - bus =pci_create_root_bus (&pdev->dev,0 , + bus =pci_scan_root_bus (&pdev->dev,0 , &xgene_pcie_ops, port, &res);if (!bus)return -ENOMEM ; -pci_scan_child_bus (bus);pci_assign_unassigned_bus_resources (bus);pci_bus_add_devices (bus);
Signature · 1 line
1.7.1
PATCH v4 27/30 PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
In reply to Yijing WangNow no one use pci_create_root_bus(), we could remove it and rename __pci_create_root_bus() to pci_create_root_bus().
--- drivers/pci/probe.c | 27 ++++++++------------------- include/linux/pci.h | 3 --- 2 files changed, 8 insertions(+), 22 deletions(-)
drivers/pci/probe.c +8 -19
@@ -1852,7 +1852,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus) { } -static struct pci_bus *__pci_create_root_bus ( +static struct pci_bus *pci_create_root_bus (struct pci_host_bridge *bridge,struct pci_ops *ops) {int error;
@@ -1935,18 +1935,6 @@ err_out:return NULL ; } -struct pci_bus *pci_create_root_bus (struct device *parent,u32 db, -struct pci_ops *ops,void *sysdata,struct list_head *resources) -{ -struct pci_host_bridge *host; - - host =pci_create_host_bridge (parent, db, resources, sysdata,NULL ); -if (!host) -return NULL ; - -return __pci_create_root_bus (host, ops); -} -int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int bus_max) {struct resource *res = &b->busn_res;
@@ -2024,7 +2012,7 @@ static struct pci_bus *__pci_scan_root_bus(break ; } - b =__pci_create_root_bus (host, ops); + b =pci_create_root_bus (host, ops);if (!b) {pci_free_host_bridge (host);return NULL ;
@@ -2086,18 +2074,19 @@ struct pci_bus *pci_scan_bus_legacy(u32 db, struct pci_ops *ops, void *sysdata) {LIST_HEAD (resources); -struct pci_bus *b; +struct pci_host_bridge *host;pci_add_resource (&resources, &ioport_resource);pci_add_resource (&resources, &iomem_resource);pci_add_resource (&resources, &busn_resource); - b =pci_create_root_bus (NULL , db, ops, sysdata, &resources); -if (b) { -pci_scan_child_bus (b); + host =pci_create_host_bridge (NULL , db, sysdata, &resources,NULL ); +if (host) { +__pci_scan_root_bus (host, ops); +return host->bus; }else {pci_free_resource_list (&resources); } -return b; +return NULL ; }EXPORT_SYMBOL (pci_scan_bus_legacy);
include/linux/pci.h +0 -3
@@ -781,9 +781,6 @@ void pcibios_scan_specific_bus(int busn);struct pci_bus *pci_find_bus (int domain,int busnr);void pci_bus_add_devices (const struct pci_bus *bus);struct pci_bus *pci_scan_bus_legacy (u32 dombus,struct pci_ops *ops,void *sysdata); -struct pci_bus *pci_create_root_bus (struct device *parent,u32 dombus, -struct pci_ops *ops,void *sysdata, -struct list_head *resources);void pci_free_host_bridge (struct pci_host_bridge *host);int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int busmax);int pci_bus_update_busn_res_end (struct pci_bus *b,int busmax);
Signature · 1 line
1.7.1
PATCH v4 27/30 PCI: Rename __pci_create_root_bus() to pci_create_root_bus()
In reply to Yijing WangNow no one use pci_create_root_bus(), we could remove it and rename __pci_create_root_bus() to pci_create_root_bus().
--- drivers/pci/probe.c | 27 ++++++++------------------- include/linux/pci.h | 3 --- 2 files changed, 8 insertions(+), 22 deletions(-)
drivers/pci/probe.c +8 -19
@@ -1852,7 +1852,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus) { } -static struct pci_bus *__pci_create_root_bus ( +static struct pci_bus *pci_create_root_bus (struct pci_host_bridge *bridge,struct pci_ops *ops) {int error;
@@ -1935,18 +1935,6 @@ err_out:return NULL ; } -struct pci_bus *pci_create_root_bus (struct device *parent,u32 db, -struct pci_ops *ops,void *sysdata,struct list_head *resources) -{ -struct pci_host_bridge *host; - - host =pci_create_host_bridge (parent, db, resources, sysdata,NULL ); -if (!host) -return NULL ; - -return __pci_create_root_bus (host, ops); -} -int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int bus_max) {struct resource *res = &b->busn_res;
@@ -2024,7 +2012,7 @@ static struct pci_bus *__pci_scan_root_bus(break ; } - b =__pci_create_root_bus (host, ops); + b =pci_create_root_bus (host, ops);if (!b) {pci_free_host_bridge (host);return NULL ;
@@ -2086,18 +2074,19 @@ struct pci_bus *pci_scan_bus_legacy(u32 db, struct pci_ops *ops, void *sysdata) {LIST_HEAD (resources); -struct pci_bus *b; +struct pci_host_bridge *host;pci_add_resource (&resources, &ioport_resource);pci_add_resource (&resources, &iomem_resource);pci_add_resource (&resources, &busn_resource); - b =pci_create_root_bus (NULL , db, ops, sysdata, &resources); -if (b) { -pci_scan_child_bus (b); + host =pci_create_host_bridge (NULL , db, sysdata, &resources,NULL ); +if (host) { +__pci_scan_root_bus (host, ops); +return host->bus; }else {pci_free_resource_list (&resources); } -return b; +return NULL ; }EXPORT_SYMBOL (pci_scan_bus_legacy);
include/linux/pci.h +0 -3
@@ -781,9 +781,6 @@ void pcibios_scan_specific_bus(int busn);struct pci_bus *pci_find_bus (int domain,int busnr);void pci_bus_add_devices (const struct pci_bus *bus);struct pci_bus *pci_scan_bus_legacy (u32 dombus,struct pci_ops *ops,void *sysdata); -struct pci_bus *pci_create_root_bus (struct device *parent,u32 dombus, -struct pci_ops *ops,void *sysdata, -struct list_head *resources);void pci_free_host_bridge (struct pci_host_bridge *host);int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int busmax);int pci_bus_update_busn_res_end (struct pci_bus *b,int busmax);
Signature · 1 line
1.7.1
PATCH v4 28/30 PCI: Export find_pci_host_bridge()
In reply to Yijing WangExport find_pci_host_bridge().
--- drivers/pci/host-bridge.c | 2 +- include/linux/pci.h | 1 + 2 files changed, 2 insertions(+), 1 deletions(-)
drivers/pci/host-bridge.c +1 -1
@@ -104,7 +104,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)return bus; } -static struct pci_host_bridge *find_pci_host_bridge (struct pci_bus *bus) +struct pci_host_bridge *find_pci_host_bridge (struct pci_bus *bus) {struct pci_bus *root_bus =find_pci_root_bus (bus);
include/linux/pci.h +1 -0
@@ -426,6 +426,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,struct pci_host_bridge *pci_create_host_bridge (struct device *parent,u32 dombus,struct list_head *resources,void *sysdata,struct pci_host_bridge_ops *ops); +struct pci_host_bridge *find_pci_host_bridge (struct pci_bus * bus);/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for
Signature · 1 line
1.7.1
Bjorn Helgaas
maintainerRe: [PATCH v4 28/30] PCI: Export find_pci_host_bridge()
Quoted 13 lines · Yijing Wang
Export
find_pci_host_bridge().Signed-off-by Yijing Wang <[email protected]>--- drivers/pci/host-bridge.c | 2 +- include/linux/pci.h | 1 + 2 files changed, 2 insertions(+), 1 deletions(-)drivers/pci/host-bridge.c +0
-0
drivers/pci/host-bridge.c static struct pci_bus *find_pci_root_bus(struct pci_bus *bus) · line 107
Quoted 5 lines
drivers/pci/host-bridge.c +1
-1@@ -104,7 +104,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)return bus; } -static struct pci_host_bridge *find_pci_host_bridge (struct pci_bus *bus) +struct pci_host_bridge *find_pci_host_bridge (struct pci_bus *bus)
Please name this "pci_find_host_bridge()" or similar so it looks like other PCI functions.
include/linux/pci.h void pci_set_host_bridge_release(struct pci_host_bridge *bridge, · line 429
Quoted 12 lines
drivers/pci/host-bridge.c +0
-0{struct pci_bus *root_bus =find_pci_root_bus (bus);include/linux/pci.h +1
-0@@ -426,6 +426,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,struct pci_host_bridge *pci_create_host_bridge (struct device *parent,u32 dombus,struct list_head *resources,void *sysdata,struct pci_host_bridge_ops *ops); +struct pci_host_bridge *find_pci_host_bridge (struct pci_bus * bus);
I'm not sure this needs to be in include/linux/pci.h. Wouldn't drivers/pci/pci.h be enough?
Quoted 6 lines
include/linux/pci.h +0
-0/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for Signature · 1 line
1.7.1
Re: [PATCH v4 28/30] PCI: Export find_pci_host_bridge()
Quoted 17 lines · Bjorn Helgaas
Quoted 16 lines · Yijing Wang
Export
find_pci_host_bridge().Signed-off-by Yijing Wang <[email protected]>--- drivers/pci/host-bridge.c | 2 +- include/linux/pci.h | 1 + 2 files changed, 2 insertions(+), 1 deletions(-)drivers/pci/host-bridge.c +0
-0@@ -104,7 +104,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)return bus; }
Quoted 5 lines
drivers/pci/host-bridge.c static struct pci_bus *find_pci_root_bus(struct pci_bus *bus) · line 107
Quoted 2 lines
drivers/pci/host-bridge.c +1
-1-static struct pci_host_bridge *find_pci_host_bridge (struct pci_bus *bus) +struct pci_host_bridge *find_pci_host_bridge (struct pci_bus *bus)Please name this "
pci_find_host_bridge()" or similar so it looks like other PCI functions.
OK, will rename it to "pci_find_host_bridge()" like others.
Quoted 4 lines
Quoted 4 lines
drivers/pci/host-bridge.c +0
-0{struct pci_bus *root_bus =find_pci_root_bus (bus);
Quoted 12 lines
include/linux/pci.h void pci_set_host_bridge_release(struct pci_host_bridge *bridge, · line 429
Quoted 9 lines
include/linux/pci.h +1
-0@@ -426,6 +426,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,struct pci_host_bridge *pci_create_host_bridge (struct device *parent,u32 dombus,struct list_head *resources,void *sysdata,struct pci_host_bridge_ops *ops); +struct pci_host_bridge *find_pci_host_bridge (struct pci_bus * bus);I'm not sure this needs to be in
include/linux/pci.h. Wouldn'tdrivers/pci/pci.hbe enough?
It's enough for this series, so I would move it to drivers/pci/pci.h, thanks!
Quoted 10 lines
Quoted 7 lines
include/linux/pci.h +0
-0/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for Signature · 1 line
1.7.1.
Signature · 2 lines
Thanks! Yijing
Re: [PATCH v4 28/30] PCI: Export find_pci_host_bridge()
In reply to Bjorn HelgaasQuoted 17 lines · Bjorn Helgaas
Quoted 16 lines · Yijing Wang
Export
find_pci_host_bridge().Signed-off-by Yijing Wang <[email protected]>--- drivers/pci/host-bridge.c | 2 +- include/linux/pci.h | 1 + 2 files changed, 2 insertions(+), 1 deletions(-)drivers/pci/host-bridge.c +0
-0@@ -104,7 +104,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)return bus; }
Quoted 5 lines
drivers/pci/host-bridge.c static struct pci_bus *find_pci_root_bus(struct pci_bus *bus) · line 107
Quoted 2 lines
drivers/pci/host-bridge.c +1
-1-static struct pci_host_bridge *find_pci_host_bridge (struct pci_bus *bus) +struct pci_host_bridge *find_pci_host_bridge (struct pci_bus *bus)Please name this "
pci_find_host_bridge()" or similar so it looks like other PCI functions.
OK, will rename it to "pci_find_host_bridge()" like others.
Quoted 4 lines
Quoted 4 lines
drivers/pci/host-bridge.c +0
-0{struct pci_bus *root_bus =find_pci_root_bus (bus);
Quoted 12 lines
include/linux/pci.h void pci_set_host_bridge_release(struct pci_host_bridge *bridge, · line 429
Quoted 9 lines
include/linux/pci.h +1
-0@@ -426,6 +426,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,struct pci_host_bridge *pci_create_host_bridge (struct device *parent,u32 dombus,struct list_head *resources,void *sysdata,struct pci_host_bridge_ops *ops); +struct pci_host_bridge *find_pci_host_bridge (struct pci_bus * bus);I'm not sure this needs to be in
include/linux/pci.h. Wouldn'tdrivers/pci/pci.hbe enough?
It's enough for this series, so I would move it to drivers/pci/pci.h, thanks!
Quoted 10 lines
Quoted 7 lines
include/linux/pci.h +0
-0/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for Signature · 1 line
1.7.1.
Signature · 2 lines
Thanks! Yijing
Bjorn Helgaas
maintainerRe: [PATCH v4 28/30] PCI: Export find_pci_host_bridge()
In reply to Yijing WangQuoted 13 lines · Yijing Wang
Export
find_pci_host_bridge().Signed-off-by Yijing Wang <[email protected]>--- drivers/pci/host-bridge.c | 2 +- include/linux/pci.h | 1 + 2 files changed, 2 insertions(+), 1 deletions(-)drivers/pci/host-bridge.c +0
-0
drivers/pci/host-bridge.c static struct pci_bus *find_pci_root_bus(struct pci_bus *bus) · line 107
Quoted 5 lines
drivers/pci/host-bridge.c +1
-1@@ -104,7 +104,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)return bus; } -static struct pci_host_bridge *find_pci_host_bridge (struct pci_bus *bus) +struct pci_host_bridge *find_pci_host_bridge (struct pci_bus *bus)
Please name this "pci_find_host_bridge()" or similar so it looks like other PCI functions.
include/linux/pci.h void pci_set_host_bridge_release(struct pci_host_bridge *bridge, · line 429
Quoted 12 lines
drivers/pci/host-bridge.c +0
-0{struct pci_bus *root_bus =find_pci_root_bus (bus);include/linux/pci.h +1
-0@@ -426,6 +426,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,struct pci_host_bridge *pci_create_host_bridge (struct device *parent,u32 dombus,struct list_head *resources,void *sysdata,struct pci_host_bridge_ops *ops); +struct pci_host_bridge *find_pci_host_bridge (struct pci_bus * bus);
I'm not sure this needs to be in include/linux/pci.h. Wouldn't drivers/pci/pci.h be enough?
Quoted 6 lines
include/linux/pci.h +0
-0/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for Signature · 1 line
1.7.1
PATCH v4 28/30 PCI: Export find_pci_host_bridge()
In reply to Yijing WangExport find_pci_host_bridge().
--- drivers/pci/host-bridge.c | 2 +- include/linux/pci.h | 1 + 2 files changed, 2 insertions(+), 1 deletions(-)
drivers/pci/host-bridge.c +1 -1
@@ -104,7 +104,7 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus)return bus; } -static struct pci_host_bridge *find_pci_host_bridge (struct pci_bus *bus) +struct pci_host_bridge *find_pci_host_bridge (struct pci_bus *bus) {struct pci_bus *root_bus =find_pci_root_bus (bus);
include/linux/pci.h +1 -0
@@ -426,6 +426,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,struct pci_host_bridge *pci_create_host_bridge (struct device *parent,u32 dombus,struct list_head *resources,void *sysdata,struct pci_host_bridge_ops *ops); +struct pci_host_bridge *find_pci_host_bridge (struct pci_bus * bus);/* * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond * to P2P or CardBus bridge windows) go in a table. Additional ones (for
Signature · 1 line
1.7.1
PATCH v4 29/30 PCI: Remove platform specific pci_domain_nr()
In reply to Yijing WangNow pci_host_bridge holds the domain number,
so we could eliminate all platform specificpci_domain_nr().
--- arch/alpha/include/asm/pci.h | 2 -- arch/ia64/include/asm/pci.h | 1 - arch/microblaze/pci/pci-common.c | 11 ----------- arch/mips/include/asm/pci.h | 2 -- arch/powerpc/kernel/pci-common.c | 11 ----------- arch/s390/pci/pci.c | 6 ------ arch/sh/include/asm/pci.h | 2 -- arch/sparc/kernel/pci.c | 17 ----------------- arch/tile/include/asm/pci.h | 2 -- arch/x86/include/asm/pci.h | 6 ------ drivers/pci/pci.c | 8 ++++++++ include/linux/pci.h | 7 ++----- 12 files changed, 10 insertions(+), 65 deletions(-)
arch/alpha/include/asm/pci.h +0 -2
@@ -95,8 +95,6 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)return channel ?15 :14 ; } -#define pci_domain_nr (bus) ((struct pci_controller *)(bus)->sysdata)->index -static inline int pci_proc_domain (struct pci_bus *bus) {struct pci_controller *hose = bus->sysdata;
arch/ia64/include/asm/pci.h +0 -1
@@ -99,7 +99,6 @@ struct pci_controller {#define PCI_CONTROLLER (busdev) ((struct pci_controller *) busdev->sysdata) -#define pci_domain_nr (busdev) (PCI_CONTROLLER(busdev)->segment)extern struct pci_ops pci_root_ops;
arch/microblaze/pci/pci-common.c +0 -11
@@ -123,17 +123,6 @@ unsigned long pci_address_to_pio(phys_addr_t address) }EXPORT_SYMBOL_GPL (pci_address_to_pio); -/* -* Return the domain number for this bus. -*/ -int pci_domain_nr (struct pci_bus *bus) -{ -struct pci_controller *hose =pci_bus_to_host (bus); - -return hose->global_number; -} -EXPORT_SYMBOL (pci_domain_nr); -/* This routine is meant to be used early during boot, when the * PCI bus numbers have not yet been assigned, and you need to * issue PCI config cycles to an OF device.
arch/mips/include/asm/pci.h +0 -2
@@ -122,8 +122,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,#endif #ifdef CONFIG_PCI_DOMAINS -#define pci_domain_nr (bus) ((struct pci_controller *)(bus)->sysdata)->index -static inline int pci_proc_domain (struct pci_bus *bus) {struct pci_controller *hose = bus->sysdata;
arch/powerpc/kernel/pci-common.c +0 -11
@@ -181,17 +181,6 @@ unsigned long pci_address_to_pio(phys_addr_t address) }EXPORT_SYMBOL_GPL (pci_address_to_pio); -/* -* Return the domain number for this bus. -*/ -int pci_domain_nr (struct pci_bus *bus) -{ -struct pci_controller *hose =pci_bus_to_host (bus); - -return hose->global_number; -} -EXPORT_SYMBOL (pci_domain_nr); -/* This routine is meant to be used early during boot, when the * PCI bus numbers have not yet been assigned, and you need to * issue PCI config cycles to an OF device.
arch/s390/pci/pci.c +0 -6
@@ -101,12 +101,6 @@ static struct zpci_dev *get_zdev_by_bus(struct pci_bus *bus)return (bus && bus->sysdata) ? (struct zpci_dev *) bus->sysdata :NULL ; } -int pci_domain_nr (struct pci_bus *bus) -{ -return ((struct zpci_dev *) bus->sysdata)->domain; -} -EXPORT_SYMBOL_GPL (pci_domain_nr); -int pci_proc_domain (struct pci_bus *bus) {return pci_domain_nr (bus);
arch/sh/include/asm/pci.h +0 -2
@@ -109,8 +109,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,/* Board-specific fixup routines. */ int pcibios_map_platform_irq (const struct pci_dev *dev,u8 slot,u8 pin); -#define pci_domain_nr (bus) ((struct pci_channel *)(bus)->sysdata)->index -static inline int pci_proc_domain (struct pci_bus *bus) {struct pci_channel *hose = bus->sysdata;
arch/sparc/kernel/pci.c +0 -17
@@ -903,23 +903,6 @@ int pcibus_to_node(struct pci_bus *pbus)EXPORT_SYMBOL (pcibus_to_node);#endif -/* Return the domain number for this pci bus */ - -int pci_domain_nr (struct pci_bus *pbus) -{ -struct pci_pbm_info *pbm = pbus->sysdata; -int ret; - -if (!pbm) { - ret = -ENXIO ; - }else { - ret = pbm->index; - } - -return ret; -} -EXPORT_SYMBOL (pci_domain_nr); -#ifdef CONFIG_PCI_MSI int arch_setup_msi_irq (struct pci_dev *pdev,struct msi_desc *desc) {
arch/tile/include/asm/pci.h +0 -2
@@ -199,8 +199,6 @@ int __init pcibios_init(void);void pcibios_fixup_bus (struct pci_bus *bus); -#define pci_domain_nr (bus) (((struct pci_controller *)(bus)->sysdata)->index) -/* * This decides whether to display the domain number in /proc. */
arch/x86/include/asm/pci.h +0 -6
@@ -29,12 +29,6 @@ extern int noioapicreroute; #ifdef CONFIG_PCI #ifdef CONFIG_PCI_DOMAINS -static inline int pci_domain_nr(struct pci_bus *bus) -{ - struct pci_sysdata *sd = bus->sysdata; - return sd->domain; -} - static inline int pci_proc_domain(struct pci_bus *bus) { return pci_domain_nr(bus);
drivers/pci/pci.c +8 -0
@@ -4523,6 +4523,14 @@ int pci_get_new_domain_nr(void)return atomic_inc_return (&__domain_nr); } +int pci_domain_nr (struct pci_bus *bus) +{ +struct pci_host_bridge *host =find_pci_host_bridge (bus); + +return host->domain; +} +EXPORT_SYMBOL (pci_domain_nr); +#ifdef CONFIG_PCI_DOMAINS_GENERIC static int pci_assign_domain_nr (struct device *dev) {
include/linux/pci.h +2 -5
@@ -1321,6 +1321,7 @@ void pci_cfg_access_unlock(struct pci_dev *dev);#ifdef CONFIG_PCI_DOMAINS extern int pci_domains_supported;int pci_get_new_domain_nr (void ); +int pci_domain_nr (struct pci_bus *bus);#else enum { pci_domains_supported =0 };static inline int pci_domain_nr (struct pci_bus *bus) {return 0 ; }
@@ -1334,15 +1335,11 @@ static inline int pci_get_new_domain_nr(void) { return -ENOSYS; }* domains then this implementation will be used */ #ifdef CONFIG_PCI_DOMAINS_GENERIC -static inline int pci_domain_nr (struct pci_bus *bus) -{ -return bus->domain_nr; -}void pci_bus_assign_domain_nr (struct pci_bus *bus,struct device *parent);void pci_host_assign_domain_nr (struct pci_host_bridge *host);#else static inline void pci_bus_assign_domain_nr (struct pci_bus *bus, -struct device *parent) +struct device *parent) { }static inline void pci_host_assign_domain_nr (struct pci_host_bridge *host)
Signature · 1 line
1.7.1
PATCH v4 30/30 PCI: Remove pci_bus_assign_domain_nr()
In reply to Yijing WangNow we save the domain number in pci_host_bridge,
we could remove pci_bus_assign_domain_nr() and
clean the domain member in pci_bus.
--- drivers/pci/pci.c | 5 ----- drivers/pci/probe.c | 12 ++++-------- include/linux/pci.h | 3 --- 3 files changed, 4 insertions(+), 16 deletions(-)
drivers/pci/pci.c +0 -5
@@ -4579,11 +4579,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host) { host->domain =pci_assign_domain_nr (host->dev.parent); } - -void pci_bus_assign_domain_nr (struct pci_bus *bus,struct device *parent) -{ - bus->domain_nr =pci_assign_domain_nr (parent); -}#endif #endif
drivers/pci/probe.c +4 -8
@@ -480,7 +480,7 @@ void pci_read_bridge_bases(struct pci_bus *child) } } -static struct pci_bus *pci_alloc_bus (struct pci_bus *parent) +static struct pci_bus *pci_alloc_bus (void ) {struct pci_bus *b;
@@ -495,10 +495,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)INIT_LIST_HEAD (&b->resources); b->max_bus_speed =PCI_SPEED_UNKNOWN ; b->cur_bus_speed =PCI_SPEED_UNKNOWN ; -#ifdef CONFIG_PCI_DOMAINS_GENERIC -if (parent) - b->domain_nr = parent->domain_nr; -#endif +return b; }
@@ -645,7 +642,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,/* * Allocate a new bus, and inherit stuff from the parent.. */ - child =pci_alloc_bus (parent); + child =pci_alloc_bus ();if (!child)return NULL ;
@@ -1865,14 +1862,13 @@ static struct pci_bus *pci_create_root_bus(char *fmt; parent = bridge->dev.parent; - b =pci_alloc_bus (NULL ); + b =pci_alloc_bus ();if (!b)return NULL ; b->sysdata =dev_get_drvdata (&bridge->dev); b->ops = ops; b->number = b->busn_res.start = bridge->busnum; -pci_bus_assign_domain_nr (b, parent); bridge->bus = b; b->bridge =get_device (&bridge->dev);
include/linux/pci.h +0 -3
@@ -470,9 +470,6 @@ struct pci_bus {unsigned char primary;/* number of primary bridge */ unsigned char max_bus_speed;/* enum pci_bus_speed */ unsigned char cur_bus_speed;/* enum pci_bus_speed */ -#ifdef CONFIG_PCI_DOMAINS_GENERIC -int domain_nr; -#endif char name[48 ];
Signature · 1 line
1.7.1
PATCH v4 30/30 PCI: Remove pci_bus_assign_domain_nr()
In reply to Yijing WangNow we save the domain number in pci_host_bridge,
we could remove pci_bus_assign_domain_nr() and
clean the domain member in pci_bus.
--- drivers/pci/pci.c | 5 ----- drivers/pci/probe.c | 12 ++++-------- include/linux/pci.h | 3 --- 3 files changed, 4 insertions(+), 16 deletions(-)
drivers/pci/pci.c +0 -5
@@ -4579,11 +4579,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host) { host->domain =pci_assign_domain_nr (host->dev.parent); } - -void pci_bus_assign_domain_nr (struct pci_bus *bus,struct device *parent) -{ - bus->domain_nr =pci_assign_domain_nr (parent); -}#endif #endif
drivers/pci/probe.c +4 -8
@@ -480,7 +480,7 @@ void pci_read_bridge_bases(struct pci_bus *child) } } -static struct pci_bus *pci_alloc_bus (struct pci_bus *parent) +static struct pci_bus *pci_alloc_bus (void ) {struct pci_bus *b;
@@ -495,10 +495,7 @@ static struct pci_bus *pci_alloc_bus(struct pci_bus *parent)INIT_LIST_HEAD (&b->resources); b->max_bus_speed =PCI_SPEED_UNKNOWN ; b->cur_bus_speed =PCI_SPEED_UNKNOWN ; -#ifdef CONFIG_PCI_DOMAINS_GENERIC -if (parent) - b->domain_nr = parent->domain_nr; -#endif +return b; }
@@ -645,7 +642,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,/* * Allocate a new bus, and inherit stuff from the parent.. */ - child =pci_alloc_bus (parent); + child =pci_alloc_bus ();if (!child)return NULL ;
@@ -1865,14 +1862,13 @@ static struct pci_bus *pci_create_root_bus(char *fmt; parent = bridge->dev.parent; - b =pci_alloc_bus (NULL ); + b =pci_alloc_bus ();if (!b)return NULL ; b->sysdata =dev_get_drvdata (&bridge->dev); b->ops = ops; b->number = b->busn_res.start = bridge->busnum; -pci_bus_assign_domain_nr (b, parent); bridge->bus = b; b->bridge =get_device (&bridge->dev);
include/linux/pci.h +0 -3
@@ -470,9 +470,6 @@ struct pci_bus {unsigned char primary;/* number of primary bridge */ unsigned char max_bus_speed;/* enum pci_bus_speed */ unsigned char cur_bus_speed;/* enum pci_bus_speed */ -#ifdef CONFIG_PCI_DOMAINS_GENERIC -int domain_nr; -#endif char name[48 ];
Signature · 1 line
1.7.1
Bjorn Helgaas
maintainerQuoted 2 lines · Yijing Wang
v3->v4:
Fix the rebase issue.
This did apply on v4.0-rc1, but with many whitespace complaints:
Importing patch "pci-pass-pci-domain-number" ... <stdin>:29: trailing whitespace.
bus = pci_scan_root_bus(NULL,
<stdin>:44: trailing whitespace.
bus = pci_scan_bus_legacy(PCI_DOMBUS(hose->index, 0),
<stdin>:59: trailing whitespace.
pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus),
<stdin>:74: trailing whitespace.
bus = pci_scan_root_bus(NULL,
<stdin>:75: trailing whitespace.
PCI_DOMBUS(controller->segment, busnum),
warning: squelched 15 whitespace errors
warning: 20 lines add whitespace errors.
done
Importing patch "pci-introduce" ... done
Importing patch "pci-separate-pci_host_bridge" ... <stdin>:50: trailing whitespace.
dev_set_name(&host->dev, "pci%04x:%02x", host->domain,
<stdin>:181: trailing whitespace.
dev_set_name(&b->dev, "%04x:%02x", bridge->domain, <stdin>:225: trailing whitespace.
warning: 3 lines add whitespace errors.
I'll fix them myself this time because I want to make progress on this and I need something to do on the plane tomorrow, but please try to fix them yourself in the future.
Bjorn
Quoted 24 lines · Bjorn Helgaas
Quoted 2 lines · Yijing Wang
v3->v4:
Fix the rebase issue.This did apply on v4.0-rc1, but with many whitespace complaints:
Importing patch "pci-pass-pci-domain-number" ... <stdin>:29: trailing whitespace.
bus = pci_scan_root_bus(NULL,
<stdin>:44: trailing whitespace.bus = pci_scan_bus_legacy(PCI_DOMBUS(hose->index, 0), <stdin>:59: trailing whitespace. pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus), <stdin>:74: trailing whitespace. bus = pci_scan_root_bus(NULL, <stdin>:75: trailing whitespace. PCI_DOMBUS(controller->segment, busnum), warning: squelched 15 whitespace errors warning: 20 lines add whitespace errors. done Importing patch "pci-introduce" ... done Importing patch "pci-separate-pci_host_bridge" ... <stdin>:50: trailing whitespace. dev_set_name(&host->dev, "pci%04x:%02x", host->domain, <stdin>:181: trailing whitespace. dev_set_name(&b->dev, "%04x:%02x", bridge->domain,
Quoted 8 lines
<stdin>:225: trailing whitespace.
warning: 3 lines add whitespace errors.
I'll fix them myself this time because I want to make progress on this and I need something to do on the plane tomorrow, but please try to fix them yourself in the future.
I will fix them in the local, thanks!
Quoted 4 lines
Bjorn
.
Signature · 2 lines
Thanks! Yijing
Quoted 24 lines · Bjorn Helgaas
Quoted 2 lines · Yijing Wang
v3->v4:
Fix the rebase issue.This did apply on v4.0-rc1, but with many whitespace complaints:
Importing patch "pci-pass-pci-domain-number" ... <stdin>:29: trailing whitespace.
bus = pci_scan_root_bus(NULL,
<stdin>:44: trailing whitespace.bus = pci_scan_bus_legacy(PCI_DOMBUS(hose->index, 0), <stdin>:59: trailing whitespace. pbus = pci_create_root_bus(NULL, PCI_DOMBUS(domain, bus), <stdin>:74: trailing whitespace. bus = pci_scan_root_bus(NULL, <stdin>:75: trailing whitespace. PCI_DOMBUS(controller->segment, busnum), warning: squelched 15 whitespace errors warning: 20 lines add whitespace errors. done Importing patch "pci-introduce" ... done Importing patch "pci-separate-pci_host_bridge" ... <stdin>:50: trailing whitespace. dev_set_name(&host->dev, "pci%04x:%02x", host->domain, <stdin>:181: trailing whitespace. dev_set_name(&b->dev, "%04x:%02x", bridge->domain,
Quoted 8 lines
<stdin>:225: trailing whitespace.
warning: 3 lines add whitespace errors.
I'll fix them myself this time because I want to make progress on this and I need something to do on the plane tomorrow, but please try to fix them yourself in the future.
I will fix them in the local, thanks!
Quoted 4 lines
Bjorn
.
Signature · 2 lines
Thanks! Yijing