Refine PCI scan interfaces and make generic pci host bridge
Subsystems (23)
v7 cover Refine PCI scan interfaces and make generic pci host bridge
v6->v7:
Drop previous patch which combined the domain and bus in one argument. Make the pci_host_bridge hold the default busn resource, so we could check whether new host busn resource is conflict with existing ones. Move pci_host_assign_domain_nr() to drivers/pci/host-bridge.c Other changes suggested by Bjorn and Suravee.v5->v6:
Fix cross building errors found by kbuild test.
Export busn_resource to Xen pcifront driver.v4->v5:
Fix some code style issues and rename some functions suggested by Bjorn. Fix some code flaw(Eg. call pci_bus_add_devices() before resources claim or lack the return checking).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/enumeration branch.
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()
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_host_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 (30):
PCI: Remove deprecated pci_scan_bus_parented()
PCI: Save domain in pci_host_bridge
PCI: Move pci_bus_assign_domain_nr() declaration into
drivers/pci/pci.h
PCI: Introduce pci_host_assign_domain_nr() to assign domain
PCI: Separate pci_host_bridge creation out of pci_create_root_bus()
PCI: Add default bus resource in pci_host_bridge
PCI: Update pci_host_bridge bus resource
PCI: Introduce pci_host_first_busnr() function
PCI: Introduce pci_host_bridge_list to manage host bridges
PCI: Save sysdata in pci_host_bridge drvdata powerpc/PCI: Rename pcibios_root_bridge_prepare() to
pcibios_set_root_bus_speed()
PCI: Move pcibios_root_bridge_prepare() to pci_create_host_bridge()
PCI: Introduce pci_host_bridge_ops to support host specific
operations
PCI: Introduce new scan function pci_scan_host_bridge()
PCI: Introduce pci_bus_child_max_busnr()
x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge ia64/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge powerpc/pci: Use pci_scan_host_bridge() for simplicity
PCI: Remove pcibios_root_bridge_prepare() and
pcibos_set_root_bus_speed()
sparc/PCI: Use pci_scan_host_bridge() for simplicity parisc/PCI: 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: rename to pci_find_host_bridge()
PCI: Remove platform specific pci_domain_nr()
PCI: Remove pci_bus_assign_domain_nr()
PCI: Clean up CONFIG_PCI_DOMAINS_GENERIC
arch/alpha/include/asm/pci.h | 2 - arch/alpha/kernel/pci.c | 4 +- arch/alpha/kernel/sys_nautilus.c | 2 +- arch/arm/Kconfig | 3 - arch/arm/kernel/bios32.c | 2 +- arch/arm/mach-dove/pcie.c | 2 +- arch/arm/mach-iop13xx/pci.c | 4 +- arch/arm/mach-mv78xx0/pcie.c | 2 +- arch/arm/mach-orion5x/pci.c | 4 +- arch/arm64/Kconfig | 3 - arch/ia64/include/asm/pci.h | 1 - arch/ia64/pci/pci.c | 34 +++--- arch/ia64/sn/kernel/io_init.c | 4 +- arch/m68k/coldfire/pci.c | 2 +- arch/microblaze/pci/pci-common.c | 15 +-- arch/mips/include/asm/pci.h | 2 - arch/mips/pci/pci.c | 4 +- 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/setup.c | 2 +- arch/s390/pci/pci.c | 10 +-- arch/sh/drivers/pci/pci.c | 4 +- arch/sh/include/asm/pci.h | 2 - arch/sparc/kernel/pci.c | 44 +++---- arch/sparc/kernel/pcic.c | 2 +- arch/tile/include/asm/pci.h | 2 - arch/tile/kernel/pci.c | 4 +- arch/tile/kernel/pci_gx.c | 4 +- arch/unicore32/kernel/pci.c | 2 +- arch/x86/include/asm/pci.h | 6 - arch/x86/pci/acpi.c | 37 +++--- arch/x86/pci/common.c | 2 +- arch/xtensa/kernel/pci.c | 2 +- drivers/parisc/dino.c | 6 +- drivers/parisc/lba_pci.c | 4 +- drivers/pci/host-bridge.c | 206 ++++++++++++++++++++++++++++++- drivers/pci/host/pci-mvebu.c | 18 +--- drivers/pci/host/pci-tegra.c | 16 --- drivers/pci/host/pci-versatile.c | 3 +- drivers/pci/host/pci-xgene.c | 3 +- drivers/pci/host/pcie-designware.c | 4 +- drivers/pci/host/pcie-xilinx.c | 2 +- drivers/pci/hotplug/acpiphp_glue.c | 29 +---- drivers/pci/hotplug/ibmphp_core.c | 2 +- drivers/pci/pci.c | 85 ++++--------- drivers/pci/pci.h | 15 +++ drivers/pci/probe.c | 212 +++++++++++++------------------- drivers/pci/xen-pcifront.c | 16 ++- include/linux/pci.h | 46 +++---- 50 files changed, 510 insertions(+), 457 deletions(-)
PATCH v7 1/31 xen/PCI: Don't use deprecated function pci_scan_bus_parented()
From: Arnd Bergmann <[email protected]>
Use pci_scan_root_bus() instead of deprecated function pci_scan_bus_parented().
--- drivers/pci/xen-pcifront.c | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)
drivers/pci/xen-pcifront.c +13 -3
@@ -446,9 +446,15 @@ 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 ; +static struct resource busn_res = { + .start =0 , + .end =255 , + .flags =IORESOURCE_BUS , + };#ifndef CONFIG_PCI_DOMAINS if (domain !=0 ) {
@@ -470,17 +476,21 @@ 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); +pci_add_resource (&resources, &busn_res);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 +498,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 * devfn==0. The pcifront_scan_bus enumerates all devfn. */ err =pcifront_scan_bus (pdev, domain, bus, b);
Signature · 1 line
1.7.1
PATCH v7 1/31 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 | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)
drivers/pci/xen-pcifront.c +13 -3
@@ -446,9 +446,15 @@ 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 ; +static struct resource busn_res = { + .start =0 , + .end =255 , + .flags =IORESOURCE_BUS , + };#ifndef CONFIG_PCI_DOMAINS if (domain !=0 ) {
@@ -470,17 +476,21 @@ 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); +pci_add_resource (&resources, &busn_res);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 +498,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 * devfn==0. The pcifront_scan_bus enumerates all devfn. */ err =pcifront_scan_bus (pdev, domain, bus, b);
Signature · 1 line
1.7.1
PATCH v7 1/31 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 | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)
drivers/pci/xen-pcifront.c +13 -3
@@ -446,9 +446,15 @@ 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 ; +static struct resource busn_res = { + .start =0 , + .end =255 , + .flags =IORESOURCE_BUS , + };#ifndef CONFIG_PCI_DOMAINS if (domain !=0 ) {
@@ -470,17 +476,21 @@ 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); +pci_add_resource (&resources, &busn_res);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 +498,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 * devfn==0. The pcifront_scan_bus enumerates all devfn. */ err =pcifront_scan_bus (pdev, domain, bus, b);
Signature · 1 line
1.7.1
PATCH v7 2/31 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 v7 2/31 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 v7 3/31 PCI: Save domain in pci_host_bridge
In reply to Yijing WangSave domain in pci_host_bridge, so we could get domain from pci_host_bridge, and at the end of series, we could clean up the arch specific pci_domain_nr(). For arm, we pass -1 as the domain number, we would update the domain number in core by pci_bus_assign_domain_nr().
--- arch/alpha/kernel/pci.c | 4 ++-- arch/alpha/kernel/sys_nautilus.c | 2 +- arch/arm/kernel/bios32.c | 2 +- arch/arm/mach-dove/pcie.c | 2 +- arch/arm/mach-iop13xx/pci.c | 4 ++-- arch/arm/mach-mv78xx0/pcie.c | 2 +- arch/arm/mach-orion5x/pci.c | 4 ++-- arch/ia64/pci/pci.c | 4 ++-- arch/ia64/sn/kernel/io_init.c | 4 ++-- arch/m68k/coldfire/pci.c | 2 +- arch/microblaze/pci/pci-common.c | 4 ++-- arch/mips/pci/pci.c | 4 ++-- arch/powerpc/kernel/pci-common.c | 4 ++-- arch/s390/pci/pci.c | 4 ++-- arch/sh/drivers/pci/pci.c | 4 ++-- arch/sparc/kernel/pci.c | 4 ++-- arch/sparc/kernel/pcic.c | 2 +- arch/tile/kernel/pci.c | 4 ++-- arch/tile/kernel/pci_gx.c | 4 ++-- arch/unicore32/kernel/pci.c | 2 +- arch/x86/pci/acpi.c | 4 ++-- arch/x86/pci/common.c | 2 +- arch/xtensa/kernel/pci.c | 2 +- drivers/parisc/dino.c | 2 +- drivers/parisc/lba_pci.c | 2 +- drivers/pci/host/pci-mvebu.c | 2 +- drivers/pci/host/pci-tegra.c | 4 ++-- drivers/pci/host/pci-versatile.c | 3 ++- drivers/pci/host/pci-xgene.c | 2 +- drivers/pci/host/pcie-designware.c | 2 +- drivers/pci/host/pcie-xilinx.c | 2 +- drivers/pci/hotplug/ibmphp_core.c | 2 +- drivers/pci/probe.c | 21 +++++++++++++-------- drivers/pci/xen-pcifront.c | 2 +- include/linux/pci.h | 8 +++++--- 35 files changed, 67 insertions(+), 59 deletions(-)
arch/alpha/kernel/pci.c +2 -2
@@ -336,8 +336,8 @@ 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 , hose->index, next_busno, + alpha_mv.pci_ops, hose, &resources);if (!bus)continue ; hose->bus = bus;
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 (hose->index,0 , alpha_mv.pci_ops, hose);if (!bus)return ;
arch/arm/kernel/bios32.c +1 -1
@@ -486,7 +486,7 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw,if (hw->scan) sys->bus = hw->scan (nr, sys);else - sys->bus =pci_scan_root_bus (parent, sys->busnr, + sys->bus =pci_scan_root_bus (parent,-1 , sys->busnr, hw->ops, sys, &sys->resources);if (!sys->bus)
arch/arm/mach-dove/pcie.c +1 -1
@@ -160,7 +160,7 @@ dove_pcie_scan_bus(int nr, struct pci_sys_data *sys)return NULL ; } -return pci_scan_root_bus (NULL , sys->busnr, &pcie_ops, sys, +return pci_scan_root_bus (NULL ,-1 , sys->busnr, &pcie_ops, sys, &sys->resources); }
arch/arm/mach-iop13xx/pci.c +2 -2
@@ -535,12 +535,12 @@ struct pci_bus *iop13xx_scan_bus(int nr, struct pci_sys_data *sys)while (time_before (jiffies, atux_trhfa_timeout))udelay (100 ); - bus = pci_bus_atux =pci_scan_root_bus (NULL , sys->busnr, + bus = pci_bus_atux =pci_scan_root_bus (NULL ,-1 , sys->busnr, &iop13xx_atux_ops, sys, &sys->resources);break ;case IOP13XX_INIT_ATU_ATUE : - bus = pci_bus_atue =pci_scan_root_bus (NULL , sys->busnr, + bus = pci_bus_atue =pci_scan_root_bus (NULL ,-1 , sys->busnr, &iop13xx_atue_ops, sys, &sys->resources);break ;
arch/arm/mach-mv78xx0/pcie.c +1 -1
@@ -202,7 +202,7 @@ mv78xx0_pcie_scan_bus(int nr, struct pci_sys_data *sys)return NULL ; } -return pci_scan_root_bus (NULL , sys->busnr, &pcie_ops, sys, +return pci_scan_root_bus (NULL ,-1 , sys->busnr, &pcie_ops, sys, &sys->resources); }
arch/arm/mach-orion5x/pci.c +2 -2
@@ -558,11 +558,11 @@ int __init orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys)struct pci_bus __init *orion5x_pci_sys_scan_bus (int nr,struct pci_sys_data *sys) {if (nr ==0 ) -return pci_scan_root_bus (NULL , sys->busnr, &pcie_ops, sys, +return pci_scan_root_bus (NULL ,-1 , sys->busnr, &pcie_ops, sys, &sys->resources);if (nr ==1 && !orion5x_pci_disabled) -return pci_scan_root_bus (NULL , sys->busnr, &pci_ops, sys, +return pci_scan_root_bus (NULL ,-1 , sys->busnr, &pci_ops, sys, &sys->resources);BUG ();
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 , 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 +2 -2
@@ -266,8 +266,8 @@ 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 , controller->segment, busnum, + &pci_root_ops, controller, &resources);if (bus ==NULL ) {kfree (res);kfree (controller);
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 (0 ,0 , &mcf_pci_ops,NULL );if (!rootbus)return -ENODEV ;
arch/microblaze/pci/pci-common.c +2 -2
@@ -1350,8 +1350,8 @@ 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, 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 , hose->index, next_busno, + hose->pci_ops, hose, &resources); hose->bus = bus; need_domain_info = need_domain_info || hose->index;
arch/powerpc/kernel/pci-common.c +2 -2
@@ -1612,8 +1612,8 @@ 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, 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 +2 -2
@@ -770,8 +770,8 @@ 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 , 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 +2 -2
@@ -52,8 +52,8 @@ 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 , 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 +2 -2
@@ -667,8 +667,8 @@ 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, 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/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 (0 , pbm->pci_first_busno, &pcic_ops, pbm);if (!pbm->pci_bus)return ;
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 , controller->index,0 , + controller->ops, controller, &resources); controller->root_bus = bus; controller->last_busno = bus->busn_res.end; }
arch/tile/kernel/pci_gx.c +2 -2
@@ -881,8 +881,8 @@ 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 , controller->index, next_busno, + controller->ops, controller, &resources); controller->root_bus = bus; next_busno = bus->busn_res.end +1 ; }
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 (0 ,0 , &pci_puv3_ops,NULL );if (!puv3_bus)panic ("PCI: unable to scan bus!" );
arch/x86/pci/acpi.c +2 -2
@@ -425,8 +425,8 @@ 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); + bus =pci_create_root_bus (NULL , domain, busnum, + &pci_root_ops, sd, &resources);if (bus) {pci_scan_child_bus (bus);
arch/x86/pci/common.c +1 -1
@@ -486,7 +486,7 @@ 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 ,0 , busnum, &pci_root_ops, sd, &resources);if (!bus) {pci_free_resource_list (&resources);kfree (sd);
arch/xtensa/kernel/pci.c +1 -1
@@ -183,7 +183,7 @@ static int __init pcibios_init(void) pci_ctrl->last_busno =0xff ;INIT_LIST_HEAD (&resources);pci_controller_apertures (pci_ctrl, &resources); - bus =pci_scan_root_bus (NULL , pci_ctrl->first_busno, + bus =pci_scan_root_bus (NULL ,0 , pci_ctrl->first_busno, pci_ctrl->ops, pci_ctrl, &resources);if (!bus)continue ;
drivers/parisc/dino.c +1 -1
@@ -986,7 +986,7 @@ static int __init dino_probe(struct parisc_device *dev)** with configuration accessor functions. */ dino_dev->hba.hba_bus = bus =pci_create_root_bus (&dev->dev, - dino_current_bus, &dino_cfg_ops,NULL , &resources); +0 , 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" ,dev_name (&dev->dev), dino_current_bus);
drivers/parisc/lba_pci.c +1 -1
@@ -1563,7 +1563,7 @@ 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_create_root_bus (&dev->dev,0 , lba_dev->hba.bus_num.start, cfg_ops,NULL , &resources);if (!lba_bus) {pci_free_resource_list (&resources);
drivers/pci/host/pci-mvebu.c +1 -1
@@ -755,7 +755,7 @@ 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, + bus =pci_create_root_bus (&pcie->pdev->dev,-1 , sys->busnr, &mvebu_pcie_ops, sys, &sys->resources);if (!bus)return NULL ;
drivers/pci/host/pci-tegra.c +2 -2
@@ -635,8 +635,8 @@ 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); + bus =pci_create_root_bus (pcie->dev,-1 , sys->busnr, &tegra_pcie_ops, + sys, &sys->resources);if (!bus)return NULL ;
drivers/pci/host/pci-versatile.c +2 -1
@@ -208,7 +208,8 @@ static int versatile_pci_probe(struct platform_device *pdev)pci_add_flags (PCI_ENABLE_PROC_DOMAINS );pci_add_flags (PCI_REASSIGN_ALL_BUS |PCI_REASSIGN_ALL_RSRC ); - bus =pci_scan_root_bus (&pdev->dev,0 , &pci_versatile_ops, &sys, &pci_res); + bus =pci_scan_root_bus (&pdev->dev,-1 ,0 , &pci_versatile_ops, + &sys, &pci_res);if (!bus)return -ENOMEM ;
drivers/pci/host/pci-xgene.c +1 -1
@@ -499,7 +499,7 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)if (ret)return ret; - bus =pci_create_root_bus (&pdev->dev,0 , + bus =pci_create_root_bus (&pdev->dev,-1 ,0 , &xgene_pcie_ops, port, &res);if (!bus)return -ENOMEM ;
drivers/pci/host/pcie-designware.c +1 -1
@@ -728,7 +728,7 @@ 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_create_root_bus (pp->dev,-1 , sys->busnr, &dw_pcie_ops, sys, &sys->resources);if (!bus)return NULL ;
drivers/pci/host/pcie-xilinx.c +1 -1
@@ -647,7 +647,7 @@ static struct pci_bus *xilinx_pcie_scan_bus(int nr, struct pci_sys_data *sys)struct pci_bus *bus; port->root_busno = sys->busnr; - bus =pci_scan_root_bus (port->dev, sys->busnr, &xilinx_pcie_ops, + bus =pci_scan_root_bus (port->dev,-1 , sys->busnr, &xilinx_pcie_ops, sys, &sys->resources);return 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 (0 , busno, ibmphp_pci_bus->ops,NULL );if (!b)continue ;
drivers/pci/probe.c +13 -8
@@ -1889,8 +1889,9 @@ void __weak pcibios_remove_bus(struct pci_bus *bus) { } -struct pci_bus *pci_create_root_bus (struct device *parent,int bus, -struct pci_ops *ops,void *sysdata,struct list_head *resources) +struct pci_bus *pci_create_root_bus (struct device *parent,int domain, +int bus,struct pci_ops *ops,void *sysdata, +struct list_head *resources) {int error;struct pci_host_bridge *bridge;
@@ -1920,6 +1921,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,if (!bridge) goto err_out; + bridge->domain = domain; 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,8 +2059,9 @@ 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_ops *ops,void *sysdata,struct list_head *resources) +struct pci_bus *pci_scan_root_bus (struct device *parent,int domain, +int bus,struct pci_ops *ops,void *sysdata, +struct list_head *resources) {struct resource_entry *window;bool found = false;
@@ -2071,7 +2074,8 @@ 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, domain, bus, ops, + sysdata, resources);if (!b)return NULL ;
@@ -2091,8 +2095,8 @@ 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, -void *sysdata) +struct pci_bus *pci_scan_bus (int domain,int bus, +struct pci_ops *ops,void *sysdata) {LIST_HEAD (resources);struct pci_bus *b;
@@ -2100,7 +2104,8 @@ struct pci_bus *pci_scan_bus(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 , domain, bus, ops, sysdata, + &resources);if (b) {pci_scan_child_bus (b); }else {
drivers/pci/xen-pcifront.c +1 -1
@@ -483,7 +483,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,pci_lock_rescan_remove (); - b =pci_scan_root_bus (&pdev->xdev->dev, bus, + b =pci_scan_root_bus (&pdev->xdev->dev, sd->domain, bus, &pcifront_bus_ops, sd, &resources);if (!b) { dev_err(&pdev->xdev->dev,
include/linux/pci.h +5 -3
@@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev) }struct pci_host_bridge { +int domain;struct device dev;struct pci_bus *bus;/* root bus */ struct list_head windows;/* resource_entry */
@@ -769,14 +770,15 @@ 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_create_root_bus (struct device *parent,int bus, +struct pci_bus *pci_scan_bus (int domain,int bus,struct pci_ops *ops, +void *sysdata); +struct pci_bus *pci_create_root_bus (struct device *parent,int domain,int bus,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,int domain,int bus,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,
Signature · 1 line
1.7.1
PATCH v7 3/31 PCI: Save domain in pci_host_bridge
In reply to Yijing WangSave domain in pci_host_bridge, so we could get domain from pci_host_bridge, and at the end of series, we could clean up the arch specific pci_domain_nr(). For arm, we pass -1 as the domain number, we would update the domain number in core by pci_bus_assign_domain_nr().
--- arch/alpha/kernel/pci.c | 4 ++-- arch/alpha/kernel/sys_nautilus.c | 2 +- arch/arm/kernel/bios32.c | 2 +- arch/arm/mach-dove/pcie.c | 2 +- arch/arm/mach-iop13xx/pci.c | 4 ++-- arch/arm/mach-mv78xx0/pcie.c | 2 +- arch/arm/mach-orion5x/pci.c | 4 ++-- arch/ia64/pci/pci.c | 4 ++-- arch/ia64/sn/kernel/io_init.c | 4 ++-- arch/m68k/coldfire/pci.c | 2 +- arch/microblaze/pci/pci-common.c | 4 ++-- arch/mips/pci/pci.c | 4 ++-- arch/powerpc/kernel/pci-common.c | 4 ++-- arch/s390/pci/pci.c | 4 ++-- arch/sh/drivers/pci/pci.c | 4 ++-- arch/sparc/kernel/pci.c | 4 ++-- arch/sparc/kernel/pcic.c | 2 +- arch/tile/kernel/pci.c | 4 ++-- arch/tile/kernel/pci_gx.c | 4 ++-- arch/unicore32/kernel/pci.c | 2 +- arch/x86/pci/acpi.c | 4 ++-- arch/x86/pci/common.c | 2 +- arch/xtensa/kernel/pci.c | 2 +- drivers/parisc/dino.c | 2 +- drivers/parisc/lba_pci.c | 2 +- drivers/pci/host/pci-mvebu.c | 2 +- drivers/pci/host/pci-tegra.c | 4 ++-- drivers/pci/host/pci-versatile.c | 3 ++- drivers/pci/host/pci-xgene.c | 2 +- drivers/pci/host/pcie-designware.c | 2 +- drivers/pci/host/pcie-xilinx.c | 2 +- drivers/pci/hotplug/ibmphp_core.c | 2 +- drivers/pci/probe.c | 21 +++++++++++++-------- drivers/pci/xen-pcifront.c | 2 +- include/linux/pci.h | 8 +++++--- 35 files changed, 67 insertions(+), 59 deletions(-)
arch/alpha/kernel/pci.c +2 -2
@@ -336,8 +336,8 @@ 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 , hose->index, next_busno, + alpha_mv.pci_ops, hose, &resources);if (!bus)continue ; hose->bus = bus;
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 (hose->index,0 , alpha_mv.pci_ops, hose);if (!bus)return ;
arch/arm/kernel/bios32.c +1 -1
@@ -486,7 +486,7 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw,if (hw->scan) sys->bus = hw->scan (nr, sys);else - sys->bus =pci_scan_root_bus (parent, sys->busnr, + sys->bus =pci_scan_root_bus (parent,-1 , sys->busnr, hw->ops, sys, &sys->resources);if (!sys->bus)
arch/arm/mach-dove/pcie.c +1 -1
@@ -160,7 +160,7 @@ dove_pcie_scan_bus(int nr, struct pci_sys_data *sys)return NULL ; } -return pci_scan_root_bus (NULL , sys->busnr, &pcie_ops, sys, +return pci_scan_root_bus (NULL ,-1 , sys->busnr, &pcie_ops, sys, &sys->resources); }
arch/arm/mach-iop13xx/pci.c +2 -2
@@ -535,12 +535,12 @@ struct pci_bus *iop13xx_scan_bus(int nr, struct pci_sys_data *sys)while (time_before (jiffies, atux_trhfa_timeout))udelay (100 ); - bus = pci_bus_atux =pci_scan_root_bus (NULL , sys->busnr, + bus = pci_bus_atux =pci_scan_root_bus (NULL ,-1 , sys->busnr, &iop13xx_atux_ops, sys, &sys->resources);break ;case IOP13XX_INIT_ATU_ATUE : - bus = pci_bus_atue =pci_scan_root_bus (NULL , sys->busnr, + bus = pci_bus_atue =pci_scan_root_bus (NULL ,-1 , sys->busnr, &iop13xx_atue_ops, sys, &sys->resources);break ;
arch/arm/mach-mv78xx0/pcie.c +1 -1
@@ -202,7 +202,7 @@ mv78xx0_pcie_scan_bus(int nr, struct pci_sys_data *sys)return NULL ; } -return pci_scan_root_bus (NULL , sys->busnr, &pcie_ops, sys, +return pci_scan_root_bus (NULL ,-1 , sys->busnr, &pcie_ops, sys, &sys->resources); }
arch/arm/mach-orion5x/pci.c +2 -2
@@ -558,11 +558,11 @@ int __init orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys)struct pci_bus __init *orion5x_pci_sys_scan_bus (int nr,struct pci_sys_data *sys) {if (nr ==0 ) -return pci_scan_root_bus (NULL , sys->busnr, &pcie_ops, sys, +return pci_scan_root_bus (NULL ,-1 , sys->busnr, &pcie_ops, sys, &sys->resources);if (nr ==1 && !orion5x_pci_disabled) -return pci_scan_root_bus (NULL , sys->busnr, &pci_ops, sys, +return pci_scan_root_bus (NULL ,-1 , sys->busnr, &pci_ops, sys, &sys->resources);BUG ();
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 , 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 +2 -2
@@ -266,8 +266,8 @@ 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 , controller->segment, busnum, + &pci_root_ops, controller, &resources);if (bus ==NULL ) {kfree (res);kfree (controller);
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 (0 ,0 , &mcf_pci_ops,NULL );if (!rootbus)return -ENODEV ;
arch/microblaze/pci/pci-common.c +2 -2
@@ -1350,8 +1350,8 @@ 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, 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 , hose->index, next_busno, + hose->pci_ops, hose, &resources); hose->bus = bus; need_domain_info = need_domain_info || hose->index;
arch/powerpc/kernel/pci-common.c +2 -2
@@ -1612,8 +1612,8 @@ 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, 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 +2 -2
@@ -770,8 +770,8 @@ 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 , 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 +2 -2
@@ -52,8 +52,8 @@ 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 , 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 +2 -2
@@ -667,8 +667,8 @@ 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, 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/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 (0 , pbm->pci_first_busno, &pcic_ops, pbm);if (!pbm->pci_bus)return ;
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 , controller->index,0 , + controller->ops, controller, &resources); controller->root_bus = bus; controller->last_busno = bus->busn_res.end; }
arch/tile/kernel/pci_gx.c +2 -2
@@ -881,8 +881,8 @@ 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 , controller->index, next_busno, + controller->ops, controller, &resources); controller->root_bus = bus; next_busno = bus->busn_res.end +1 ; }
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 (0 ,0 , &pci_puv3_ops,NULL );if (!puv3_bus)panic ("PCI: unable to scan bus!" );
arch/x86/pci/acpi.c +2 -2
@@ -425,8 +425,8 @@ 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); + bus =pci_create_root_bus (NULL , domain, busnum, + &pci_root_ops, sd, &resources);if (bus) {pci_scan_child_bus (bus);
arch/x86/pci/common.c +1 -1
@@ -486,7 +486,7 @@ 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 ,0 , busnum, &pci_root_ops, sd, &resources);if (!bus) {pci_free_resource_list (&resources);kfree (sd);
arch/xtensa/kernel/pci.c +1 -1
@@ -183,7 +183,7 @@ static int __init pcibios_init(void) pci_ctrl->last_busno =0xff ;INIT_LIST_HEAD (&resources);pci_controller_apertures (pci_ctrl, &resources); - bus =pci_scan_root_bus (NULL , pci_ctrl->first_busno, + bus =pci_scan_root_bus (NULL ,0 , pci_ctrl->first_busno, pci_ctrl->ops, pci_ctrl, &resources);if (!bus)continue ;
drivers/parisc/dino.c +1 -1
@@ -986,7 +986,7 @@ static int __init dino_probe(struct parisc_device *dev)** with configuration accessor functions. */ dino_dev->hba.hba_bus = bus =pci_create_root_bus (&dev->dev, - dino_current_bus, &dino_cfg_ops,NULL , &resources); +0 , 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" ,dev_name (&dev->dev), dino_current_bus);
drivers/parisc/lba_pci.c +1 -1
@@ -1563,7 +1563,7 @@ 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_create_root_bus (&dev->dev,0 , lba_dev->hba.bus_num.start, cfg_ops,NULL , &resources);if (!lba_bus) {pci_free_resource_list (&resources);
drivers/pci/host/pci-mvebu.c +1 -1
@@ -755,7 +755,7 @@ 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, + bus =pci_create_root_bus (&pcie->pdev->dev,-1 , sys->busnr, &mvebu_pcie_ops, sys, &sys->resources);if (!bus)return NULL ;
drivers/pci/host/pci-tegra.c +2 -2
@@ -635,8 +635,8 @@ 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); + bus =pci_create_root_bus (pcie->dev,-1 , sys->busnr, &tegra_pcie_ops, + sys, &sys->resources);if (!bus)return NULL ;
drivers/pci/host/pci-versatile.c +2 -1
@@ -208,7 +208,8 @@ static int versatile_pci_probe(struct platform_device *pdev)pci_add_flags (PCI_ENABLE_PROC_DOMAINS );pci_add_flags (PCI_REASSIGN_ALL_BUS |PCI_REASSIGN_ALL_RSRC ); - bus =pci_scan_root_bus (&pdev->dev,0 , &pci_versatile_ops, &sys, &pci_res); + bus =pci_scan_root_bus (&pdev->dev,-1 ,0 , &pci_versatile_ops, + &sys, &pci_res);if (!bus)return -ENOMEM ;
drivers/pci/host/pci-xgene.c +1 -1
@@ -499,7 +499,7 @@ static int xgene_pcie_probe_bridge(struct platform_device *pdev)if (ret)return ret; - bus =pci_create_root_bus (&pdev->dev,0 , + bus =pci_create_root_bus (&pdev->dev,-1 ,0 , &xgene_pcie_ops, port, &res);if (!bus)return -ENOMEM ;
drivers/pci/host/pcie-designware.c +1 -1
@@ -728,7 +728,7 @@ 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_create_root_bus (pp->dev,-1 , sys->busnr, &dw_pcie_ops, sys, &sys->resources);if (!bus)return NULL ;
drivers/pci/host/pcie-xilinx.c +1 -1
@@ -647,7 +647,7 @@ static struct pci_bus *xilinx_pcie_scan_bus(int nr, struct pci_sys_data *sys)struct pci_bus *bus; port->root_busno = sys->busnr; - bus =pci_scan_root_bus (port->dev, sys->busnr, &xilinx_pcie_ops, + bus =pci_scan_root_bus (port->dev,-1 , sys->busnr, &xilinx_pcie_ops, sys, &sys->resources);return 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 (0 , busno, ibmphp_pci_bus->ops,NULL );if (!b)continue ;
drivers/pci/probe.c +13 -8
@@ -1889,8 +1889,9 @@ void __weak pcibios_remove_bus(struct pci_bus *bus) { } -struct pci_bus *pci_create_root_bus (struct device *parent,int bus, -struct pci_ops *ops,void *sysdata,struct list_head *resources) +struct pci_bus *pci_create_root_bus (struct device *parent,int domain, +int bus,struct pci_ops *ops,void *sysdata, +struct list_head *resources) {int error;struct pci_host_bridge *bridge;
@@ -1920,6 +1921,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,if (!bridge) goto err_out; + bridge->domain = domain; 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,8 +2059,9 @@ 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_ops *ops,void *sysdata,struct list_head *resources) +struct pci_bus *pci_scan_root_bus (struct device *parent,int domain, +int bus,struct pci_ops *ops,void *sysdata, +struct list_head *resources) {struct resource_entry *window;bool found = false;
@@ -2071,7 +2074,8 @@ 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, domain, bus, ops, + sysdata, resources);if (!b)return NULL ;
@@ -2091,8 +2095,8 @@ 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, -void *sysdata) +struct pci_bus *pci_scan_bus (int domain,int bus, +struct pci_ops *ops,void *sysdata) {LIST_HEAD (resources);struct pci_bus *b;
@@ -2100,7 +2104,8 @@ struct pci_bus *pci_scan_bus(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 , domain, bus, ops, sysdata, + &resources);if (b) {pci_scan_child_bus (b); }else {
drivers/pci/xen-pcifront.c +1 -1
@@ -483,7 +483,7 @@ static int pcifront_scan_root(struct pcifront_device *pdev,pci_lock_rescan_remove (); - b =pci_scan_root_bus (&pdev->xdev->dev, bus, + b =pci_scan_root_bus (&pdev->xdev->dev, sd->domain, bus, &pcifront_bus_ops, sd, &resources);if (!b) { dev_err(&pdev->xdev->dev,
include/linux/pci.h +5 -3
@@ -401,6 +401,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev) }struct pci_host_bridge { +int domain;struct device dev;struct pci_bus *bus;/* root bus */ struct list_head windows;/* resource_entry */
@@ -769,14 +770,15 @@ 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_create_root_bus (struct device *parent,int bus, +struct pci_bus *pci_scan_bus (int domain,int bus,struct pci_ops *ops, +void *sysdata); +struct pci_bus *pci_create_root_bus (struct device *parent,int domain,int bus,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,int domain,int bus,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,
Signature · 1 line
1.7.1
PATCH v7 4/31 PCI: Move pci_bus_assign_domain_nr() declaration into drivers/pci/pci.h
In reply to Yijing Wangpci_bus_assign_domain_nr() is only called in probe.c, Move pci_bus_assign_domain_nr() declaration into drivers/pci/pci.h.
--- drivers/pci/pci.h | 9 +++++++++ include/linux/pci.h | 6 ------ 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/pci/pci.h +9 -0
@@ -321,4 +321,13 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe) }#endif +#ifdef CONFIG_PCI_DOMAINS_GENERIC +void pci_bus_assign_domain_nr (struct pci_bus *bus,struct device *parent); +#else +static inline void pci_bus_assign_domain_nr (struct pci_bus *bus, +struct device *parent) +{ +} +#endif +#endif /* DRIVERS_PCI_H */
include/linux/pci.h +0 -6
@@ -1327,12 +1327,6 @@ 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); -#else -static inline void pci_bus_assign_domain_nr (struct pci_bus *bus, -struct device *parent) -{ -}#endif /* some architectures require additional setup to direct VGA traffic */
Signature · 1 line
1.7.1
PATCH v7 4/31 PCI: Move pci_bus_assign_domain_nr() declaration into drivers/pci/pci.h
In reply to Yijing Wangpci_bus_assign_domain_nr() is only called in probe.c, Move pci_bus_assign_domain_nr() declaration into drivers/pci/pci.h.
--- drivers/pci/pci.h | 9 +++++++++ include/linux/pci.h | 6 ------ 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/pci/pci.h +9 -0
@@ -321,4 +321,13 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe) }#endif +#ifdef CONFIG_PCI_DOMAINS_GENERIC +void pci_bus_assign_domain_nr (struct pci_bus *bus,struct device *parent); +#else +static inline void pci_bus_assign_domain_nr (struct pci_bus *bus, +struct device *parent) +{ +} +#endif +#endif /* DRIVERS_PCI_H */
include/linux/pci.h +0 -6
@@ -1327,12 +1327,6 @@ 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); -#else -static inline void pci_bus_assign_domain_nr (struct pci_bus *bus, -struct device *parent) -{ -}#endif /* some architectures require additional setup to direct VGA traffic */
Signature · 1 line
1.7.1
PATCH v7 5/31 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. In the later patch, we would assign domain in pci_create_host_bridge, clean up the pci_bus_assign_domain_nr() and move this function into drivers/pci/host-bridge.c.
--- drivers/pci/pci.c | 21 ++++++++++++++++----- drivers/pci/pci.h | 4 ++++ 2 files changed, 20 insertions(+), 5 deletions(-)
drivers/pci/pci.c +16 -5
@@ -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.
@@ -4538,13 +4538,24 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent) use_dt_domains =0 ; domain =pci_get_new_domain_nr (); } else { -dev_err (parent,"Node %s has inconsistent \"linux,pci-domain\" property in DT\n" , - parent->of_node->full_name); +dev_err (dev,"Node %s has inconsistent \"linux,pci-domain\" property in DT\n" , + dev->of_node->full_name); domain =-1 ; } - bus->domain_nr = domain; +return domain; +} + +void pci_bus_assign_domain_nr (struct pci_bus *bus,struct device *parent) +{ + bus->domain_nr =pci_assign_domain_nr (parent); } + +void pci_host_assign_domain_nr (struct pci_host_bridge *host) +{ + host->domain =pci_assign_domain_nr (host->dev.parent); +} +#endif #endif
drivers/pci/pci.h +4 -0
@@ -323,11 +323,15 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)#ifdef CONFIG_PCI_DOMAINS_GENERIC 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 #endif /* DRIVERS_PCI_H */
Signature · 1 line
1.7.1
PATCH v7 5/31 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. In the later patch, we would assign domain in pci_create_host_bridge, clean up the pci_bus_assign_domain_nr() and move this function into drivers/pci/host-bridge.c.
--- drivers/pci/pci.c | 21 ++++++++++++++++----- drivers/pci/pci.h | 4 ++++ 2 files changed, 20 insertions(+), 5 deletions(-)
drivers/pci/pci.c +16 -5
@@ -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.
@@ -4538,13 +4538,24 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent) use_dt_domains =0 ; domain =pci_get_new_domain_nr (); } else { -dev_err (parent,"Node %s has inconsistent \"linux,pci-domain\" property in DT\n" , - parent->of_node->full_name); +dev_err (dev,"Node %s has inconsistent \"linux,pci-domain\" property in DT\n" , + dev->of_node->full_name); domain =-1 ; } - bus->domain_nr = domain; +return domain; +} + +void pci_bus_assign_domain_nr (struct pci_bus *bus,struct device *parent) +{ + bus->domain_nr =pci_assign_domain_nr (parent); } + +void pci_host_assign_domain_nr (struct pci_host_bridge *host) +{ + host->domain =pci_assign_domain_nr (host->dev.parent); +} +#endif #endif
drivers/pci/pci.h +4 -0
@@ -323,11 +323,15 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)#ifdef CONFIG_PCI_DOMAINS_GENERIC 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 #endif /* DRIVERS_PCI_H */
Signature · 1 line
1.7.1
PATCH v7 6/31 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 make it hold host bridge specific operations like pcibios_root_bridge_prepare(). The changes are transparent to platform host bridge drivers.
--- drivers/pci/host-bridge.c | 52 +++++++++++++++++++++ drivers/pci/pci.h | 3 + drivers/pci/probe.c | 113 +++++++++++++++++++++------------------------ 3 files changed, 108 insertions(+), 60 deletions(-)
drivers/pci/host-bridge.c +52 -0
@@ -8,6 +8,58 @@#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,int domain,int bus, +struct list_head *resources) +{ +int error; +struct pci_host_bridge *host; +struct resource_entry *window, *n; + + host =kzalloc (sizeof (*host),GFP_KERNEL ); +if (!host) +return NULL ; + + host->dev.parent = parent; +INIT_LIST_HEAD (&host->windows); +resource_list_for_each_entry_safe (window, n, resources) +list_move_tail (&window->node, &host->windows); +/* +* If support CONFIG_PCI_DOMAINS_GENERIC, use +* pci_host_assign_domain_nr() to update domain +* number. +*/ + host->domain = domain; +pci_host_assign_domain_nr (host); + host->dev.release = pci_release_host_bridge_dev; +dev_set_name (&host->dev,"pci%04x:%02x" , + host->domain, bus); + + error =device_register (&host->dev); +if (error) { +put_device (&host->dev); +return NULL ; + } + +return host; +} + +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/pci.h +3 -0
@@ -334,4 +334,7 @@ static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host) }#endif +struct pci_host_bridge *pci_create_host_bridge (struct device *parent, +int domain,int bus,struct list_head *resources); +void pci_free_host_bridge (struct pci_host_bridge *host);#endif /* DRIVERS_PCI_H */
drivers/pci/probe.c +53 -60
190 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v7 6/31 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 make it hold host bridge specific operations like pcibios_root_bridge_prepare(). The changes are transparent to platform host bridge drivers.
--- drivers/pci/host-bridge.c | 52 +++++++++++++++++++++ drivers/pci/pci.h | 3 + drivers/pci/probe.c | 113 +++++++++++++++++++++------------------------ 3 files changed, 108 insertions(+), 60 deletions(-)
drivers/pci/host-bridge.c +52 -0
@@ -8,6 +8,58 @@#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,int domain,int bus, +struct list_head *resources) +{ +int error; +struct pci_host_bridge *host; +struct resource_entry *window, *n; + + host =kzalloc (sizeof (*host),GFP_KERNEL ); +if (!host) +return NULL ; + + host->dev.parent = parent; +INIT_LIST_HEAD (&host->windows); +resource_list_for_each_entry_safe (window, n, resources) +list_move_tail (&window->node, &host->windows); +/* +* If support CONFIG_PCI_DOMAINS_GENERIC, use +* pci_host_assign_domain_nr() to update domain +* number. +*/ + host->domain = domain; +pci_host_assign_domain_nr (host); + host->dev.release = pci_release_host_bridge_dev; +dev_set_name (&host->dev,"pci%04x:%02x" , + host->domain, bus); + + error =device_register (&host->dev); +if (error) { +put_device (&host->dev); +return NULL ; + } + +return host; +} + +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/pci.h +3 -0
@@ -334,4 +334,7 @@ static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host) }#endif +struct pci_host_bridge *pci_create_host_bridge (struct device *parent, +int domain,int bus,struct list_head *resources); +void pci_free_host_bridge (struct pci_host_bridge *host);#endif /* DRIVERS_PCI_H */
drivers/pci/probe.c +53 -60
190 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v7 7/31 PCI: Add default bus resource in pci_host_bridge
In reply to Yijing WangIf there is no busn resource provided for pci_scan_root_bus(), we would insert a default bus resource (root_bus_number, 255) in root bus, and update the max bus number we found after pci_scan_child_bus(). We also need to hold the default bus resource in pci_host_bridge, then we could identify whether the new pci host bridge conflict with existing one.
--- drivers/pci/host-bridge.c | 20 ++++++++++++++++++++ drivers/pci/probe.c | 26 ++++++++++---------------- include/linux/pci.h | 2 ++ 3 files changed, 32 insertions(+), 16 deletions(-)
drivers/pci/host-bridge.c +20 -0
@@ -19,6 +19,25 @@ static void pci_release_host_bridge_dev(struct device *dev)kfree (bridge); } +static void pci_host_update_busn_res ( +struct pci_host_bridge *host,int bus, +struct list_head *resources) +{ +struct resource_entry *window; + +resource_list_for_each_entry (window, resources) +if (window->res->flags &IORESOURCE_BUS ) +return ; + +pr_info ( +"No busn resource found for pci%04x:%02x, will use [bus %02x-ff]\n" , + host->domain, bus, bus); + host->busn_res.flags =IORESOURCE_BUS ; + host->busn_res.start = bus; + host->busn_res.end =255 ; +pci_add_resource (resources, &host->busn_res); +} +struct pci_host_bridge *pci_create_host_bridge (struct device *parent,int domain,int bus,struct list_head *resources)
@@ -33,6 +52,7 @@ struct pci_host_bridge *pci_create_host_bridge( host->dev.parent = parent;INIT_LIST_HEAD (&host->windows); +pci_host_update_busn_res (host, bus, resources);resource_list_for_each_entry_safe (window, n, resources)list_move_tail (&window->node, &host->windows);/*
drivers/pci/probe.c +10 -16
@@ -2022,6 +2022,12 @@ int pci_bus_update_busn_res_end(struct pci_bus *b, int bus_max)return ret; } +static void pci_host_update_busn_res_end ( +struct pci_host_bridge *host,int max) +{ + host->busn_res.end = max; +} +void pci_bus_release_busn_res (struct pci_bus *b) {struct resource *res = &b->busn_res;
@@ -2040,32 +2046,20 @@ static struct pci_bus *__pci_scan_root_bus(int bus, struct pci_host_bridge *host, struct pci_ops *ops, void *sysdata) { - struct resource_entry *window; -bool found = false; struct pci_bus *b;int max; -resource_list_for_each_entry (window, &host->windows) -if (window->res->flags &IORESOURCE_BUS ) { - found = true; -break ; - } - b =__pci_create_root_bus (bus, host, ops, sysdata);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 ); - } - max =pci_scan_child_bus (b); -if (!found) +/* If default busn resource used, update the max bus number */ +if (host->busn_res.flags &IORESOURCE_BUS ) { +pci_host_update_busn_res_end (host, max);pci_bus_update_busn_res_end (b, max); + }return b; }
include/linux/pci.h +2 -0
@@ -404,6 +404,8 @@ struct pci_host_bridge {int domain;struct device dev;struct pci_bus *bus;/* root bus */ +/* we use default bus resource if no bus resource provided */ +struct resource busn_res;struct list_head windows;/* resource_entry */ void (*release_fn)(struct pci_host_bridge *);void *release_data;
Signature · 1 line
1.7.1
PATCH v7 7/31 PCI: Add default bus resource in pci_host_bridge
In reply to Yijing WangIf there is no busn resource provided for pci_scan_root_bus(), we would insert a default bus resource (root_bus_number, 255) in root bus, and update the max bus number we found after pci_scan_child_bus(). We also need to hold the default bus resource in pci_host_bridge, then we could identify whether the new pci host bridge conflict with existing one.
--- drivers/pci/host-bridge.c | 20 ++++++++++++++++++++ drivers/pci/probe.c | 26 ++++++++++---------------- include/linux/pci.h | 2 ++ 3 files changed, 32 insertions(+), 16 deletions(-)
drivers/pci/host-bridge.c +20 -0
@@ -19,6 +19,25 @@ static void pci_release_host_bridge_dev(struct device *dev)kfree (bridge); } +static void pci_host_update_busn_res ( +struct pci_host_bridge *host,int bus, +struct list_head *resources) +{ +struct resource_entry *window; + +resource_list_for_each_entry (window, resources) +if (window->res->flags &IORESOURCE_BUS ) +return ; + +pr_info ( +"No busn resource found for pci%04x:%02x, will use [bus %02x-ff]\n" , + host->domain, bus, bus); + host->busn_res.flags =IORESOURCE_BUS ; + host->busn_res.start = bus; + host->busn_res.end =255 ; +pci_add_resource (resources, &host->busn_res); +} +struct pci_host_bridge *pci_create_host_bridge (struct device *parent,int domain,int bus,struct list_head *resources)
@@ -33,6 +52,7 @@ struct pci_host_bridge *pci_create_host_bridge( host->dev.parent = parent;INIT_LIST_HEAD (&host->windows); +pci_host_update_busn_res (host, bus, resources);resource_list_for_each_entry_safe (window, n, resources)list_move_tail (&window->node, &host->windows);/*
drivers/pci/probe.c +10 -16
@@ -2022,6 +2022,12 @@ int pci_bus_update_busn_res_end(struct pci_bus *b, int bus_max)return ret; } +static void pci_host_update_busn_res_end ( +struct pci_host_bridge *host,int max) +{ + host->busn_res.end = max; +} +void pci_bus_release_busn_res (struct pci_bus *b) {struct resource *res = &b->busn_res;
@@ -2040,32 +2046,20 @@ static struct pci_bus *__pci_scan_root_bus(int bus, struct pci_host_bridge *host, struct pci_ops *ops, void *sysdata) { - struct resource_entry *window; -bool found = false; struct pci_bus *b;int max; -resource_list_for_each_entry (window, &host->windows) -if (window->res->flags &IORESOURCE_BUS ) { - found = true; -break ; - } - b =__pci_create_root_bus (bus, host, ops, sysdata);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 ); - } - max =pci_scan_child_bus (b); -if (!found) +/* If default busn resource used, update the max bus number */ +if (host->busn_res.flags &IORESOURCE_BUS ) { +pci_host_update_busn_res_end (host, max);pci_bus_update_busn_res_end (b, max); + }return b; }
include/linux/pci.h +2 -0
@@ -404,6 +404,8 @@ struct pci_host_bridge {int domain;struct device dev;struct pci_bus *bus;/* root bus */ +/* we use default bus resource if no bus resource provided */ +struct resource busn_res;struct list_head windows;/* resource_entry */ void (*release_fn)(struct pci_host_bridge *);void *release_data;
Signature · 1 line
1.7.1
PATCH v7 8/31 PCI: Update pci_host_bridge bus resource
In reply to Yijing WangFrom: Yijing Wang <[email protected]>
Sometimes, the bus resource start number is not equal to root bus number. For example, in pci_scan_bus(), we always add the default bus resource which start bus number is 0, but the root bus number callers given may != 0, so we need to update pci_host_bridge bus resource, because we would check whether host bridge bus resoruce is confict in later patch.
--- drivers/pci/host-bridge.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/pci/host-bridge.c +4 -1
@@ -26,8 +26,11 @@ static void pci_host_update_busn_res(struct resource_entry *window;resource_list_for_each_entry (window, resources) -if (window->res->flags &IORESOURCE_BUS ) +if (window->res->flags &IORESOURCE_BUS ) { +if (bus > window->res->start) + window->res->start = bus;return ; + } pr_info( "No busn resource found for pci%04x:%02x, will use [bus %02x-ff]\n",
Signature · 1 line
1.7.1
PATCH v7 8/31 PCI: Update pci_host_bridge bus resource
In reply to Yijing WangFrom: Yijing Wang <[email protected]>
Sometimes, the bus resource start number is not equal to root bus number. For example, in pci_scan_bus(), we always add the default bus resource which start bus number is 0, but the root bus number callers given may != 0, so we need to update pci_host_bridge bus resource, because we would check whether host bridge bus resoruce is confict in later patch.
--- drivers/pci/host-bridge.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/pci/host-bridge.c +4 -1
@@ -26,8 +26,11 @@ static void pci_host_update_busn_res(struct resource_entry *window;resource_list_for_each_entry (window, resources) -if (window->res->flags &IORESOURCE_BUS ) +if (window->res->flags &IORESOURCE_BUS ) { +if (bus > window->res->start) + window->res->start = bus;return ; + } pr_info( "No busn resource found for pci%04x:%02x, will use [bus %02x-ff]\n",
Signature · 1 line
1.7.1
PATCH v7 9/31 PCI: Introduce pci_host_first_busnr() function
In reply to Yijing WangUse it to get the first bus number of the bus
resource.
--- drivers/pci/pci.h | 11 +++++++++++ drivers/pci/probe.c | 19 ++++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-)
drivers/pci/pci.h +11 -0
@@ -337,4 +337,15 @@ static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)struct pci_host_bridge *pci_create_host_bridge (struct device *parent,int domain,int bus,struct list_head *resources);void pci_free_host_bridge (struct pci_host_bridge *host); + +static inline int pci_host_first_busnr (struct pci_host_bridge *host) +{ +struct resource_entry *window; + +resource_list_for_each_entry (window, &host->windows) +if (window->res->flags &IORESOURCE_BUS ) +return window->res->start; +return -1 ; +} +#endif /* DRIVERS_PCI_H */
drivers/pci/probe.c +10 -9
@@ -1864,7 +1864,7 @@ void __weak pcibios_remove_bus(struct pci_bus *bus) { } -static struct pci_bus *__pci_create_root_bus (int bus, +static struct pci_bus *__pci_create_root_bus (struct pci_host_bridge *bridge,struct pci_ops *ops,void *sysdata) {
@@ -1884,9 +1884,10 @@ static struct pci_bus *__pci_create_root_bus(int bus, b->sysdata = sysdata; b->ops = ops; - b->number = b->busn_res.start = bus; + b->number = b->busn_res.start = +pci_host_first_busnr (bridge);pci_bus_assign_domain_nr (b, parent); - b2 =pci_find_bus (pci_domain_nr (b), bus); + 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" );
@@ -1907,7 +1908,7 @@ static struct pci_bus *__pci_create_root_bus(int bus, b->dev.class = &pcibus_class; b->dev.parent = b->bridge; -dev_set_name (&b->dev,"%04x:%02x" , bridge->domain, bus); +dev_set_name (&b->dev,"%04x:%02x" , bridge->domain, b->number); error =device_register (&b->dev);if (error) goto put_dev;
@@ -1927,7 +1928,7 @@ static struct pci_bus *__pci_create_root_bus(int bus, res = window->res; offset = window->offset;if (res->flags &IORESOURCE_BUS ) -pci_bus_insert_busn_res (b, bus, res->end); +pci_bus_insert_busn_res (b, b->number, res->end);else pci_bus_add_resource (b, res,0 );if (offset) {
@@ -1966,7 +1967,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent,if (!host)return NULL ; - host->bus =__pci_create_root_bus (bus, host, ops, sysdata); + host->bus =__pci_create_root_bus (host, ops, sysdata);if (!host->bus)pci_free_host_bridge (host);
@@ -2042,14 +2043,14 @@ void pci_bus_release_busn_res(struct pci_bus *b) res, ret ? "can not be" : "is"); } -static struct pci_bus *__pci_scan_root_bus (int bus, +static struct pci_bus *__pci_scan_root_bus (struct pci_host_bridge *host,struct pci_ops *ops,void *sysdata) {struct pci_bus *b;int max; - b =__pci_create_root_bus (bus, host, ops, sysdata); + b =__pci_create_root_bus (host, ops, sysdata);if (!b)return NULL ;
@@ -2074,7 +2075,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int domain,if (!host)return NULL ; - host->bus =__pci_scan_root_bus (bus, host, ops, sysdata); + host->bus =__pci_scan_root_bus (host, ops, sysdata);if (!host->bus)pci_free_host_bridge (host);
Signature · 1 line
1.7.1
PATCH v7 10/31 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, this make us have the ability to check whether the new host would conflict with existing one. Then we could remove bus alreay exist check in __pci_create_root_bus().
--- drivers/pci/host-bridge.c | 41 ++++++++++++++++++++++++++++++++++++++++- drivers/pci/probe.c | 9 +-------- include/linux/pci.h | 1 + 3 files changed, 42 insertions(+), 9 deletions(-)
drivers/pci/host-bridge.c +40 -1
@@ -8,6 +8,9 @@#include "pci.h" +static LIST_HEAD (pci_host_bridge_list); +static DEFINE_MUTEX (pci_host_mutex); +static void pci_release_host_bridge_dev (struct device *dev) {struct pci_host_bridge *bridge =to_pci_host_bridge (dev);
@@ -41,12 +44,29 @@ static void pci_host_update_busn_res(pci_add_resource (resources, &host->busn_res); } +static bool pci_host_busn_res_overlap ( +struct pci_host_bridge *new,struct pci_host_bridge *old) +{ +struct resource_entry *entry; +struct resource *res1 =NULL , *res2 =NULL ; + +resource_list_for_each_entry (entry, &old->windows) +if (entry->res->flags &IORESOURCE_BUS ) + res1 = entry->res; + +resource_list_for_each_entry (entry, &new->windows) +if (entry->res->flags &IORESOURCE_BUS ) + res2 = entry->res; + +return resource_overlaps (res1, res2); +} +struct pci_host_bridge *pci_create_host_bridge (struct device *parent,int domain,int bus,struct list_head *resources) {int error; -struct pci_host_bridge *host; +struct pci_host_bridge *host, *tmp;struct resource_entry *window, *n; host =kzalloc (sizeof (*host),GFP_KERNEL );
@@ -65,6 +85,21 @@ struct pci_host_bridge *pci_create_host_bridge(*/ host->domain = domain;pci_host_assign_domain_nr (host); +mutex_lock (&pci_host_mutex); +list_for_each_entry (tmp, &pci_host_bridge_list, list) { +if (tmp->domain != host->domain + ||pci_host_busn_res_overlap (host, tmp)) { +pr_warn ("pci host bridge pci%04x:%02x exist\n" , + host->domain, bus); +mutex_unlock (&pci_host_mutex); +pci_free_resource_list (&host->windows); +kfree (host); +return NULL ; + } + } +list_add_tail (&host->list, &pci_host_bridge_list); +mutex_unlock (&pci_host_mutex); + host->dev.release = pci_release_host_bridge_dev;dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, bus);
@@ -80,6 +115,10 @@ struct pci_host_bridge *pci_create_host_bridge(void pci_free_host_bridge (struct pci_host_bridge *host) { +mutex_lock (&pci_host_mutex); +list_del (&host->list); +mutex_unlock (&pci_host_mutex); +device_unregister (&host->dev); }
drivers/pci/probe.c +1 -8
@@ -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;
@@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus( b->number = b->busn_res.start =pci_host_first_busnr (bridge);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);
@@ -1952,7 +1946,6 @@ static struct pci_bus *__pci_create_root_bus( put_dev:put_device (&bridge->dev); -err_out:kfree (b);return NULL ; }
include/linux/pci.h +1 -0
@@ -407,6 +407,7 @@ struct pci_host_bridge {/* we use default bus resource if no bus resource provided */ struct resource busn_res;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 v7 10/31 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, this make us have the ability to check whether the new host would conflict with existing one. Then we could remove bus alreay exist check in __pci_create_root_bus().
--- drivers/pci/host-bridge.c | 41 ++++++++++++++++++++++++++++++++++++++++- drivers/pci/probe.c | 9 +-------- include/linux/pci.h | 1 + 3 files changed, 42 insertions(+), 9 deletions(-)
drivers/pci/host-bridge.c +40 -1
@@ -8,6 +8,9 @@#include "pci.h" +static LIST_HEAD (pci_host_bridge_list); +static DEFINE_MUTEX (pci_host_mutex); +static void pci_release_host_bridge_dev (struct device *dev) {struct pci_host_bridge *bridge =to_pci_host_bridge (dev);
@@ -41,12 +44,29 @@ static void pci_host_update_busn_res(pci_add_resource (resources, &host->busn_res); } +static bool pci_host_busn_res_overlap ( +struct pci_host_bridge *new,struct pci_host_bridge *old) +{ +struct resource_entry *entry; +struct resource *res1 =NULL , *res2 =NULL ; + +resource_list_for_each_entry (entry, &old->windows) +if (entry->res->flags &IORESOURCE_BUS ) + res1 = entry->res; + +resource_list_for_each_entry (entry, &new->windows) +if (entry->res->flags &IORESOURCE_BUS ) + res2 = entry->res; + +return resource_overlaps (res1, res2); +} +struct pci_host_bridge *pci_create_host_bridge (struct device *parent,int domain,int bus,struct list_head *resources) {int error; -struct pci_host_bridge *host; +struct pci_host_bridge *host, *tmp;struct resource_entry *window, *n; host =kzalloc (sizeof (*host),GFP_KERNEL );
@@ -65,6 +85,21 @@ struct pci_host_bridge *pci_create_host_bridge(*/ host->domain = domain;pci_host_assign_domain_nr (host); +mutex_lock (&pci_host_mutex); +list_for_each_entry (tmp, &pci_host_bridge_list, list) { +if (tmp->domain != host->domain + ||pci_host_busn_res_overlap (host, tmp)) { +pr_warn ("pci host bridge pci%04x:%02x exist\n" , + host->domain, bus); +mutex_unlock (&pci_host_mutex); +pci_free_resource_list (&host->windows); +kfree (host); +return NULL ; + } + } +list_add_tail (&host->list, &pci_host_bridge_list); +mutex_unlock (&pci_host_mutex); + host->dev.release = pci_release_host_bridge_dev;dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, bus);
@@ -80,6 +115,10 @@ struct pci_host_bridge *pci_create_host_bridge(void pci_free_host_bridge (struct pci_host_bridge *host) { +mutex_lock (&pci_host_mutex); +list_del (&host->list); +mutex_unlock (&pci_host_mutex); +device_unregister (&host->dev); }
drivers/pci/probe.c +1 -8
@@ -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;
@@ -1887,12 +1887,6 @@ static struct pci_bus *__pci_create_root_bus( b->number = b->busn_res.start =pci_host_first_busnr (bridge);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);
@@ -1952,7 +1946,6 @@ static struct pci_bus *__pci_create_root_bus( put_dev:put_device (&bridge->dev); -err_out:kfree (b);return NULL ; }
include/linux/pci.h +1 -0
@@ -407,6 +407,7 @@ struct pci_host_bridge {/* we use default bus resource if no bus resource provided */ struct resource busn_res;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 v7 11/31 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 | 3 ++- drivers/pci/pci.h | 2 +- drivers/pci/probe.c | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-)
drivers/pci/host-bridge.c +2 -1
@@ -63,7 +63,7 @@ static bool pci_host_busn_res_overlap(struct pci_host_bridge *pci_create_host_bridge (struct device *parent,int domain,int bus, -struct list_head *resources) +void *sysdata,struct list_head *resources) {int error;struct pci_host_bridge *host, *tmp;
@@ -101,6 +101,7 @@ struct pci_host_bridge *pci_create_host_bridge(mutex_unlock (&pci_host_mutex); host->dev.release = pci_release_host_bridge_dev; +dev_set_drvdata (&host->dev, sysdata);dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, bus);
drivers/pci/pci.h +1 -1
@@ -335,7 +335,7 @@ static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)#endif struct pci_host_bridge *pci_create_host_bridge (struct device *parent, -int domain,int bus,struct list_head *resources); +int domain,int bus,void *sysdata,struct list_head *resources);void pci_free_host_bridge (struct pci_host_bridge *host);static inline int pci_host_first_busnr (struct pci_host_bridge *host)
drivers/pci/probe.c +10 -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 =pci_host_first_busnr (bridge);
@@ -1956,11 +1955,12 @@ struct pci_bus *pci_create_root_bus(struct device *parent, {struct pci_host_bridge *host; - host =pci_create_host_bridge (parent, domain, bus, resources); + host =pci_create_host_bridge (parent, domain, bus, + sysdata, resources);if (!host)return NULL ; - host->bus =__pci_create_root_bus (host, ops, sysdata); + host->bus =__pci_create_root_bus (host, ops);if (!host->bus)pci_free_host_bridge (host);
@@ -2037,13 +2037,12 @@ 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 pci_bus *b;int max; - b =__pci_create_root_bus (host, ops, sysdata); + b =__pci_create_root_bus (host, ops);if (!b)return NULL ;
@@ -2064,11 +2063,12 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int domain, {struct pci_host_bridge *host; - host =pci_create_host_bridge (parent, domain, bus, resources); + host =pci_create_host_bridge (parent, domain, bus, + sysdata, resources);if (!host)return NULL ; - host->bus =__pci_scan_root_bus (host, ops, sysdata); + host->bus =__pci_scan_root_bus (host, ops);if (!host->bus)pci_free_host_bridge (host);
Signature · 1 line
1.7.1
PATCH v7 11/31 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 | 3 ++- drivers/pci/pci.h | 2 +- drivers/pci/probe.c | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-)
drivers/pci/host-bridge.c +2 -1
@@ -63,7 +63,7 @@ static bool pci_host_busn_res_overlap(struct pci_host_bridge *pci_create_host_bridge (struct device *parent,int domain,int bus, -struct list_head *resources) +void *sysdata,struct list_head *resources) {int error;struct pci_host_bridge *host, *tmp;
@@ -101,6 +101,7 @@ struct pci_host_bridge *pci_create_host_bridge(mutex_unlock (&pci_host_mutex); host->dev.release = pci_release_host_bridge_dev; +dev_set_drvdata (&host->dev, sysdata);dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, bus);
drivers/pci/pci.h +1 -1
@@ -335,7 +335,7 @@ static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host)#endif struct pci_host_bridge *pci_create_host_bridge (struct device *parent, -int domain,int bus,struct list_head *resources); +int domain,int bus,void *sysdata,struct list_head *resources);void pci_free_host_bridge (struct pci_host_bridge *host);static inline int pci_host_first_busnr (struct pci_host_bridge *host)
drivers/pci/probe.c +10 -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 =pci_host_first_busnr (bridge);
@@ -1956,11 +1955,12 @@ struct pci_bus *pci_create_root_bus(struct device *parent, {struct pci_host_bridge *host; - host =pci_create_host_bridge (parent, domain, bus, resources); + host =pci_create_host_bridge (parent, domain, bus, + sysdata, resources);if (!host)return NULL ; - host->bus =__pci_create_root_bus (host, ops, sysdata); + host->bus =__pci_create_root_bus (host, ops);if (!host->bus)pci_free_host_bridge (host);
@@ -2037,13 +2037,12 @@ 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 pci_bus *b;int max; - b =__pci_create_root_bus (host, ops, sysdata); + b =__pci_create_root_bus (host, ops);if (!b)return NULL ;
@@ -2064,11 +2063,12 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int domain, {struct pci_host_bridge *host; - host =pci_create_host_bridge (parent, domain, bus, resources); + host =pci_create_host_bridge (parent, domain, bus, + sysdata, resources);if (!host)return NULL ; - host->bus =__pci_scan_root_bus (host, ops, sysdata); + host->bus =__pci_scan_root_bus (host, ops);if (!host->bus)pci_free_host_bridge (host);
Signature · 1 line
1.7.1
PATCH v7 12/31 powerpc/PCI: Rename pcibios_root_bridge_prepare() to pcibios_set_root_bus_speed()
In reply to Yijing Wangpcibios_root_bridge_prepare() in powerpc set root bus speed, it's not the preparation for pci host bridge. Rename it for better readability, and we could move pcibios_root_bridge_prepare() to pci_create_host_bridge(), in which root bus is not created. We will clean up these weak functions, and add pci_host_bridge_ops to do the same thing in later patch.
--- arch/powerpc/include/asm/machdep.h | 2 +- arch/powerpc/kernel/pci-common.c | 8 +++----- arch/powerpc/platforms/pseries/pci.c | 8 ++++---- arch/powerpc/platforms/pseries/setup.c | 2 +- drivers/pci/probe.c | 5 +++++ 5 files changed, 14 insertions(+), 11 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 +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 +3 -5
@@ -767,12 +767,10 @@ int pci_proc_domain(struct pci_bus *bus)return 1 ; } -int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge) +void pcibios_set_root_bus_speed (struct pci_host_bridge *bridge) { -if (ppc_md.pcibios_root_bridge_prepare) -return ppc_md.pcibios_root_bridge_prepare (bridge); - -return 0 ; +if (ppc_md.pcibios_set_root_bus_speed) +return ppc_md.pcibios_set_root_bus_speed (bridge); }/* This header fixup will do the resource fixup for all devices as they are
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_root_bridge_prepare (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_root_bridge_prepare(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_root_bridge_prepare(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_root_bridge_prepare(struct pci_host_bridge *bridge)break ; } -return 0 ; +return ; }
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;
drivers/pci/probe.c +5 -0
@@ -1856,6 +1856,10 @@ int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)return 0 ; } +void __weak pcibios_set_root_bus_speed (struct pci_host_bridge *bridge) +{ +} +void __weak pcibios_add_bus (struct pci_bus *bus) { }
@@ -1893,6 +1897,7 @@ static struct pci_bus *__pci_create_root_bus(if (error) goto put_dev; +pcibios_set_root_bus_speed (bridge);device_enable_async_suspend (b->bridge);pci_set_bus_of_node (b);
Signature · 1 line
1.7.1
PATCH v7 12/31 powerpc/PCI: Rename pcibios_root_bridge_prepare() to pcibios_set_root_bus_speed()
In reply to Yijing Wangpcibios_root_bridge_prepare() in powerpc set root bus speed, it's not the preparation for pci host bridge. Rename it for better readability, and we could move pcibios_root_bridge_prepare() to pci_create_host_bridge(), in which root bus is not created. We will clean up these weak functions, and add pci_host_bridge_ops to do the same thing in later patch.
--- arch/powerpc/include/asm/machdep.h | 2 +- arch/powerpc/kernel/pci-common.c | 8 +++----- arch/powerpc/platforms/pseries/pci.c | 8 ++++---- arch/powerpc/platforms/pseries/setup.c | 2 +- drivers/pci/probe.c | 5 +++++ 5 files changed, 14 insertions(+), 11 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 +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 +3 -5
@@ -767,12 +767,10 @@ int pci_proc_domain(struct pci_bus *bus)return 1 ; } -int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge) +void pcibios_set_root_bus_speed (struct pci_host_bridge *bridge) { -if (ppc_md.pcibios_root_bridge_prepare) -return ppc_md.pcibios_root_bridge_prepare (bridge); - -return 0 ; +if (ppc_md.pcibios_set_root_bus_speed) +return ppc_md.pcibios_set_root_bus_speed (bridge); }/* This header fixup will do the resource fixup for all devices as they are
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_root_bridge_prepare (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_root_bridge_prepare(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_root_bridge_prepare(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_root_bridge_prepare(struct pci_host_bridge *bridge)break ; } -return 0 ; +return ; }
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;
drivers/pci/probe.c +5 -0
@@ -1856,6 +1856,10 @@ int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)return 0 ; } +void __weak pcibios_set_root_bus_speed (struct pci_host_bridge *bridge) +{ +} +void __weak pcibios_add_bus (struct pci_bus *bus) { }
@@ -1893,6 +1897,7 @@ static struct pci_bus *__pci_create_root_bus(if (error) goto put_dev; +pcibios_set_root_bus_speed (bridge);device_enable_async_suspend (b->bridge);pci_set_bus_of_node (b);
Signature · 1 line
1.7.1
PATCH v7 13/31 PCI: Move pcibios_root_bridge_prepare() to pci_create_host_bridge()
In reply to Yijing WangMove pcibios_root_bridge_prepare() to pci_create_host_bridge().
--- drivers/pci/host-bridge.c | 16 +++++++++++++--- drivers/pci/probe.c | 3 --- 2 files changed, 13 insertions(+), 6 deletions(-)
drivers/pci/host-bridge.c +13 -3
@@ -92,9 +92,7 @@ struct pci_host_bridge *pci_create_host_bridge(pr_warn ("pci host bridge pci%04x:%02x exist\n" , host->domain, bus);mutex_unlock (&pci_host_mutex); -pci_free_resource_list (&host->windows); -kfree (host); -return NULL ; + goto free_res; } }list_add_tail (&host->list, &pci_host_bridge_list);
@@ -105,6 +103,10 @@ struct pci_host_bridge *pci_create_host_bridge(dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, bus); + error =pcibios_root_bridge_prepare (host); +if (error) + goto list_del; + error =device_register (&host->dev);if (error) {put_device (&host->dev);
@@ -112,6 +114,14 @@ struct pci_host_bridge *pci_create_host_bridge( }return host; +list_del: +mutex_lock (&pci_host_mutex); +list_del (&host->list); +mutex_unlock (&pci_host_mutex); +free_res: +pci_free_resource_list (&host->windows); +kfree (host); +return NULL ; }void pci_free_host_bridge (struct pci_host_bridge *host)
drivers/pci/probe.c +0 -3
@@ -1893,9 +1893,6 @@ static struct pci_bus *__pci_create_root_bus( bridge->bus = b; b->bridge =get_device (&bridge->dev); - error =pcibios_root_bridge_prepare (bridge); -if (error) - goto put_dev;pcibios_set_root_bus_speed (bridge);device_enable_async_suspend (b->bridge);
Signature · 1 line
1.7.1
PATCH v7 13/31 PCI: Move pcibios_root_bridge_prepare() to pci_create_host_bridge()
In reply to Yijing WangMove pcibios_root_bridge_prepare() to pci_create_host_bridge().
--- drivers/pci/host-bridge.c | 16 +++++++++++++--- drivers/pci/probe.c | 3 --- 2 files changed, 13 insertions(+), 6 deletions(-)
drivers/pci/host-bridge.c +13 -3
@@ -92,9 +92,7 @@ struct pci_host_bridge *pci_create_host_bridge(pr_warn ("pci host bridge pci%04x:%02x exist\n" , host->domain, bus);mutex_unlock (&pci_host_mutex); -pci_free_resource_list (&host->windows); -kfree (host); -return NULL ; + goto free_res; } }list_add_tail (&host->list, &pci_host_bridge_list);
@@ -105,6 +103,10 @@ struct pci_host_bridge *pci_create_host_bridge(dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, bus); + error =pcibios_root_bridge_prepare (host); +if (error) + goto list_del; + error =device_register (&host->dev);if (error) {put_device (&host->dev);
@@ -112,6 +114,14 @@ struct pci_host_bridge *pci_create_host_bridge( }return host; +list_del: +mutex_lock (&pci_host_mutex); +list_del (&host->list); +mutex_unlock (&pci_host_mutex); +free_res: +pci_free_resource_list (&host->windows); +kfree (host); +return NULL ; }void pci_free_host_bridge (struct pci_host_bridge *host)
drivers/pci/probe.c +0 -3
@@ -1893,9 +1893,6 @@ static struct pci_bus *__pci_create_root_bus( bridge->bus = b; b->bridge =get_device (&bridge->dev); - error =pcibios_root_bridge_prepare (bridge); -if (error) - goto put_dev;pcibios_set_root_bus_speed (bridge);device_enable_async_suspend (b->bridge);
Signature · 1 line
1.7.1
PATCH v7 14/31 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 {
struct pci_ops *ops;
/* set root bus speed, some platform need this like powerpc */
void (*set_root_bus_speed)(struct pci_host_bridge *host);
/* setup pci_host_bridge before pci_host_bridge be added to driver core */
int (*prepare)(struct pci_host_bridge *host);
/* platform specific of scan hook to scan pci device */
int (*scan_bus)(struct pci_host_bridge *);
}We could easily extend it to support different host bridge specific operations.
--- drivers/pci/host-bridge.c | 9 ++++++++- drivers/pci/pci.h | 5 +++-- drivers/pci/probe.c | 11 ++++++++--- include/linux/pci.h | 9 +++++++++ 4 files changed, 28 insertions(+), 6 deletions(-)
drivers/pci/host-bridge.c +8 -1
@@ -63,7 +63,8 @@ static bool pci_host_busn_res_overlap(struct pci_host_bridge *pci_create_host_bridge (struct device *parent,int domain,int bus, -void *sysdata,struct list_head *resources) +void *sysdata,struct list_head *resources, +struct pci_host_bridge_ops *ops) {int error;struct pci_host_bridge *host, *tmp;
@@ -98,10 +99,16 @@ struct pci_host_bridge *pci_create_host_bridge(list_add_tail (&host->list, &pci_host_bridge_list);mutex_unlock (&pci_host_mutex); + host->ops = ops; host->dev.release = pci_release_host_bridge_dev;dev_set_drvdata (&host->dev, sysdata);dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, bus); +if (host->ops && host->ops->prepare) { + error = host->ops->prepare (host); +if (error) + goto list_del; + } error =pcibios_root_bridge_prepare (host);if (error)
drivers/pci/pci.h +3 -2
@@ -334,8 +334,9 @@ static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host) }#endif -struct pci_host_bridge *pci_create_host_bridge (struct device *parent, -int domain,int bus,void *sysdata,struct list_head *resources); +struct pci_host_bridge *pci_create_host_bridge ( +struct device *parent,int domain,int bus,void *sysdata, +struct list_head *resources,struct pci_host_bridge_ops *ops);void pci_free_host_bridge (struct pci_host_bridge *host);static inline int pci_host_first_busnr (struct pci_host_bridge *host)
drivers/pci/probe.c +8 -3
@@ -1894,6 +1894,8 @@ static struct pci_bus *__pci_create_root_bus( bridge->bus = b; b->bridge =get_device (&bridge->dev); +if (bridge->ops && bridge->ops->set_root_bus_speed) + bridge->ops->set_root_bus_speed (bridge);pcibios_set_root_bus_speed (bridge);device_enable_async_suspend (b->bridge);pci_set_bus_of_node (b);
@@ -1958,7 +1960,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent,struct pci_host_bridge *host; host =pci_create_host_bridge (parent, domain, bus, - sysdata, resources); + sysdata, resources,NULL );if (!host)return NULL ;
@@ -2048,7 +2050,10 @@ static struct pci_bus *__pci_scan_root_bus(if (!b)return NULL ; - max =pci_scan_child_bus (b); +if (host->ops && host->ops->scan_bus) + max = host->ops->scan_bus (host); +else + max =pci_scan_child_bus (b);/* If default busn resource used, update the max bus number */ if (host->busn_res.flags &IORESOURCE_BUS ) {
@@ -2066,7 +2071,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int domain,struct pci_host_bridge *host; host =pci_create_host_bridge (parent, domain, bus, - sysdata, resources); + sysdata, resources,NULL );if (!host)return NULL ;
include/linux/pci.h +9 -0
@@ -400,6 +400,14 @@ 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 { +struct pci_ops *pci_ops; +int (*prepare)(struct pci_host_bridge *host); +void (*set_root_bus_speed)(struct pci_host_bridge *host); +int (*scan_bus)(struct pci_host_bridge *host); +}; +struct pci_host_bridge {int domain;struct device dev;
@@ -408,6 +416,7 @@ struct pci_host_bridge {struct resource busn_res;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; };
Signature · 1 line
1.7.1
PATCH v7 14/31 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 {
struct pci_ops *ops;
/* set root bus speed, some platform need this like powerpc */
void (*set_root_bus_speed)(struct pci_host_bridge *host);
/* setup pci_host_bridge before pci_host_bridge be added to driver core */
int (*prepare)(struct pci_host_bridge *host);
/* platform specific of scan hook to scan pci device */
int (*scan_bus)(struct pci_host_bridge *);
}We could easily extend it to support different host bridge specific operations.
--- drivers/pci/host-bridge.c | 9 ++++++++- drivers/pci/pci.h | 5 +++-- drivers/pci/probe.c | 11 ++++++++--- include/linux/pci.h | 9 +++++++++ 4 files changed, 28 insertions(+), 6 deletions(-)
drivers/pci/host-bridge.c +8 -1
@@ -63,7 +63,8 @@ static bool pci_host_busn_res_overlap(struct pci_host_bridge *pci_create_host_bridge (struct device *parent,int domain,int bus, -void *sysdata,struct list_head *resources) +void *sysdata,struct list_head *resources, +struct pci_host_bridge_ops *ops) {int error;struct pci_host_bridge *host, *tmp;
@@ -98,10 +99,16 @@ struct pci_host_bridge *pci_create_host_bridge(list_add_tail (&host->list, &pci_host_bridge_list);mutex_unlock (&pci_host_mutex); + host->ops = ops; host->dev.release = pci_release_host_bridge_dev;dev_set_drvdata (&host->dev, sysdata);dev_set_name (&host->dev,"pci%04x:%02x" , host->domain, bus); +if (host->ops && host->ops->prepare) { + error = host->ops->prepare (host); +if (error) + goto list_del; + } error =pcibios_root_bridge_prepare (host);if (error)
drivers/pci/pci.h +3 -2
@@ -334,8 +334,9 @@ static inline void pci_host_assign_domain_nr(struct pci_host_bridge *host) }#endif -struct pci_host_bridge *pci_create_host_bridge (struct device *parent, -int domain,int bus,void *sysdata,struct list_head *resources); +struct pci_host_bridge *pci_create_host_bridge ( +struct device *parent,int domain,int bus,void *sysdata, +struct list_head *resources,struct pci_host_bridge_ops *ops);void pci_free_host_bridge (struct pci_host_bridge *host);static inline int pci_host_first_busnr (struct pci_host_bridge *host)
drivers/pci/probe.c +8 -3
@@ -1894,6 +1894,8 @@ static struct pci_bus *__pci_create_root_bus( bridge->bus = b; b->bridge =get_device (&bridge->dev); +if (bridge->ops && bridge->ops->set_root_bus_speed) + bridge->ops->set_root_bus_speed (bridge);pcibios_set_root_bus_speed (bridge);device_enable_async_suspend (b->bridge);pci_set_bus_of_node (b);
@@ -1958,7 +1960,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent,struct pci_host_bridge *host; host =pci_create_host_bridge (parent, domain, bus, - sysdata, resources); + sysdata, resources,NULL );if (!host)return NULL ;
@@ -2048,7 +2050,10 @@ static struct pci_bus *__pci_scan_root_bus(if (!b)return NULL ; - max =pci_scan_child_bus (b); +if (host->ops && host->ops->scan_bus) + max = host->ops->scan_bus (host); +else + max =pci_scan_child_bus (b);/* If default busn resource used, update the max bus number */ if (host->busn_res.flags &IORESOURCE_BUS ) {
@@ -2066,7 +2071,7 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int domain,struct pci_host_bridge *host; host =pci_create_host_bridge (parent, domain, bus, - sysdata, resources); + sysdata, resources,NULL );if (!host)return NULL ;
include/linux/pci.h +9 -0
@@ -400,6 +400,14 @@ 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 { +struct pci_ops *pci_ops; +int (*prepare)(struct pci_host_bridge *host); +void (*set_root_bus_speed)(struct pci_host_bridge *host); +int (*scan_bus)(struct pci_host_bridge *host); +}; +struct pci_host_bridge {int domain;struct device dev;
@@ -408,6 +416,7 @@ struct pci_host_bridge {struct resource busn_res;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; };
Signature · 1 line
1.7.1
PATCH v7 15/31 PCI: Introduce new scan function pci_scan_host_bridge()
In reply to Yijing WangIntroduce new scan function pci_scan_host_bridge() to support host bridge drivers that need to provide platform own pci_host_bridge_ops.
--- drivers/pci/probe.c | 22 ++++++++++++++++++++++ include/linux/pci.h | 3 +++ 2 files changed, 25 insertions(+), 0 deletions(-)
drivers/pci/probe.c +22 -0
@@ -2064,6 +2064,28 @@ static struct pci_bus *__pci_scan_root_bus(return b; } +struct pci_host_bridge *pci_scan_host_bridge ( +struct device *parent,int domain,int bus, +void *sysdata,struct list_head *resources, +struct pci_host_bridge_ops *ops) +{ +struct pci_host_bridge *host; + + host =pci_create_host_bridge (parent, domain, bus, sysdata, + resources, ops); +if (!host) +return NULL ; + + host->bus =__pci_scan_root_bus (host, ops->pci_ops); +if (!host->bus) { +pci_free_host_bridge (host); +return NULL ; + } + +return host; +} +EXPORT_SYMBOL (pci_scan_host_bridge); +struct pci_bus *pci_scan_root_bus (struct device *parent,int domain,int bus,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,int domain,int bus,struct pci_ops *ops,void *sysdata,struct list_head *resources); +struct pci_host_bridge *pci_scan_host_bridge (struct device *parent,int domain, +int bus,void *sysdata,struct list_head *resources, +struct pci_host_bridge_ops *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 v7 15/31 PCI: Introduce new scan function pci_scan_host_bridge()
In reply to Yijing WangIntroduce new scan function pci_scan_host_bridge() to support host bridge drivers that need to provide platform own pci_host_bridge_ops.
--- drivers/pci/probe.c | 22 ++++++++++++++++++++++ include/linux/pci.h | 3 +++ 2 files changed, 25 insertions(+), 0 deletions(-)
drivers/pci/probe.c +22 -0
@@ -2064,6 +2064,28 @@ static struct pci_bus *__pci_scan_root_bus(return b; } +struct pci_host_bridge *pci_scan_host_bridge ( +struct device *parent,int domain,int bus, +void *sysdata,struct list_head *resources, +struct pci_host_bridge_ops *ops) +{ +struct pci_host_bridge *host; + + host =pci_create_host_bridge (parent, domain, bus, sysdata, + resources, ops); +if (!host) +return NULL ; + + host->bus =__pci_scan_root_bus (host, ops->pci_ops); +if (!host->bus) { +pci_free_host_bridge (host); +return NULL ; + } + +return host; +} +EXPORT_SYMBOL (pci_scan_host_bridge); +struct pci_bus *pci_scan_root_bus (struct device *parent,int domain,int bus,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,int domain,int bus,struct pci_ops *ops,void *sysdata,struct list_head *resources); +struct pci_host_bridge *pci_scan_host_bridge (struct device *parent,int domain, +int bus,void *sysdata,struct list_head *resources, +struct pci_host_bridge_ops *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 v7 16/31 PCI: Introduce pci_bus_child_max_busnr()
In reply to Yijing WangSometimes, we want to know the highest reserved busnr for children bus. Because parent's bus->busn_res may have padding in it. For example, some host drivers don't know the bus end, so they supply the bus resource (root_bus, 255), they want to update the max bus number after pci scan complete. But pci scan functions won't return the actual max bus number. So we could use pci_bus_child_max_busnr() to find that.
--- drivers/pci/hotplug/acpiphp_glue.c | 29 +---------------------------- drivers/pci/pci.c | 27 +++++++++++++++++++++++++-- include/linux/pci.h | 2 +- 3 files changed, 27 insertions(+), 31 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 +25 -2
@@ -108,7 +108,7 @@ static bool pcie_ari_disabled;* Given a PCI bus, returns the highest PCI bus number present in the set * including the given PCI bus and its list of child PCI buses. */ -unsigned char pci_bus_max_busnr (struct pci_bus *bus) +static unsigned char pci_bus_max_busnr (struct pci_bus *bus) {struct pci_bus *tmp;unsigned char max, n;
@@ -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
@@ -1185,7 +1185,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 v7 16/31 PCI: Introduce pci_bus_child_max_busnr()
In reply to Yijing WangSometimes, we want to know the highest reserved busnr for children bus. Because parent's bus->busn_res may have padding in it. For example, some host drivers don't know the bus end, so they supply the bus resource (root_bus, 255), they want to update the max bus number after pci scan complete. But pci scan functions won't return the actual max bus number. So we could use pci_bus_child_max_busnr() to find that.
--- drivers/pci/hotplug/acpiphp_glue.c | 29 +---------------------------- drivers/pci/pci.c | 27 +++++++++++++++++++++++++-- include/linux/pci.h | 2 +- 3 files changed, 27 insertions(+), 31 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 +25 -2
@@ -108,7 +108,7 @@ static bool pcie_ari_disabled;* Given a PCI bus, returns the highest PCI bus number present in the set * including the given PCI bus and its list of child PCI buses. */ -unsigned char pci_bus_max_busnr (struct pci_bus *bus) +static unsigned char pci_bus_max_busnr (struct pci_bus *bus) {struct pci_bus *tmp;unsigned char max, n;
@@ -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
@@ -1185,7 +1185,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 v7 17/31 x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
In reply to Yijing Wang--- arch/x86/pci/acpi.c | 37 +++++++++++++++++++++---------------- 1 files changed, 21 insertions(+), 16 deletions(-)
arch/x86/pci/acpi.c +21 -16
@@ -349,6 +349,19 @@ 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 pci_host_ops = { + .pci_ops = &pci_root_ops, + .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 +372,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 +439,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 , 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_host_bridge (NULL , domain, busnum, sd, + &resources, &pci_host_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 +468,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 v7 17/31 x86/PCI: Refine pci_acpi_scan_root() with generic pci_host_bridge
In reply to Yijing Wang--- arch/x86/pci/acpi.c | 37 +++++++++++++++++++++---------------- 1 files changed, 21 insertions(+), 16 deletions(-)
arch/x86/pci/acpi.c +21 -16
@@ -349,6 +349,19 @@ 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 pci_host_ops = { + .pci_ops = &pci_root_ops, + .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 +372,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 +439,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 , 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_host_bridge (NULL , domain, busnum, sd, + &resources, &pci_host_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 +468,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 v7 18/31 ia64/PCI: 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, 19 insertions(+), 15 deletions(-)
arch/ia64/pci/pci.c +19 -15
@@ -420,6 +420,19 @@ 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 pci_host_ops = { + .pci_ops = &pci_root_ops, + .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 +441,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 +478,17 @@ 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 , domain, bus, &pci_root_ops, - controller, &info->resources); -if (!pbus) { + host =pci_scan_host_bridge (NULL , domain, bus, controller, + &info->resources, &pci_host_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), +pci_set_host_bridge_release (host, 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 ; +return host->bus; }void pcibios_fixup_device_resources (struct pci_dev *dev)
Signature · 1 line
1.7.1
PATCH v7 19/31 powerpc/pci: Use pci_scan_host_bridge() for simplicity
In reply to Yijing WangNow we could use pci_scan_host_bridge() to scan pci buses, provide powerpc specific pci_host_bridge_ops.
--- arch/powerpc/kernel/pci-common.c | 60 +++++++++++++++++++++++-------------- 1 files changed, 37 insertions(+), 23 deletions(-)
arch/powerpc/kernel/pci-common.c +37 -23
@@ -773,6 +773,29 @@ void pcibios_set_root_bus_speed(struct pci_host_bridge *bridge)return ppc_md.pcibios_set_root_bus_speed (bridge); } +static int pci_host_scan_bus (struct pci_host_bridge *host) +{ +int mode =PCI_PROBE_NORMAL ; +struct pci_bus *bus = host->bus; +struct pci_controller *hose =dev_get_drvdata (&host->dev); + +/* Get probe mode and perform scan */ +if (hose->dn && ppc_md.pci_probe_mode) + mode = ppc_md.pci_probe_mode (bus); + +pr_debug (" probe mode: %d\n" , mode); +if (mode ==PCI_PROBE_DEVTREE ) +of_scan_bus (hose->dn, bus); + +if (mode ==PCI_PROBE_NORMAL ) { +pci_bus_update_busn_res_end (bus,255 ); + hose->last_busno =pci_scan_child_bus (bus); +pci_bus_update_busn_res_end (bus, hose->last_busno); + } + +return pci_bus_child_max_busnr (bus); +} +/* This header fixup will do the resource fixup for all devices as they are * probed, but not for bridge ranges */
@@ -1585,6 +1608,11 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)return of_node_get (hose->dn); } +static struct pci_host_bridge_ops pci_host_ops = { + .set_root_bus_speed = pcibios_set_root_bus_speed, + .scan_bus = pci_host_scan_bus, +}; +/** * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus * @hose: Pointer to the PCI host controller instance structure
@@ -1592,9 +1620,8 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)void pcibios_scan_phb (struct pci_controller *hose) {LIST_HEAD (resources); -struct pci_bus *bus; +struct pci_host_bridge *host;struct device_node *node = hose->dn; -int mode;pr_debug ("PCI: Scanning PHB %s\n" ,of_node_full_name (node));
@@ -1609,31 +1636,18 @@ void pcibios_scan_phb(struct pci_controller *hose) hose->busn.flags =IORESOURCE_BUS ;pci_add_resource (&resources, &hose->busn); + pci_host_ops.pci_ops = hose->ops;/* Create an empty bus for the toplevel */ - bus =pci_create_root_bus (hose->parent, 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); + host =pci_scan_host_bridge (hose->parent, hose->global_number, + hose->first_busno, hose, &resources, &pci_host_ops); +if (host ==NULL ) { +pr_err ("Failed to create host bridge for pci%04x:%02x\n" , + hose->global_number, hose->first_busno);pci_free_resource_list (&resources);return ; } hose->bus = bus; -/* Get probe mode and perform scan */ - mode =PCI_PROBE_NORMAL ; -if (node && ppc_md.pci_probe_mode) - mode = ppc_md.pci_probe_mode (bus); -pr_debug (" probe mode: %d\n" , mode); -if (mode ==PCI_PROBE_DEVTREE ) -of_scan_bus (node, bus); - -if (mode ==PCI_PROBE_NORMAL ) { -pci_bus_update_busn_res_end (bus,255 ); - hose->last_busno =pci_scan_child_bus (bus); -pci_bus_update_busn_res_end (bus, hose->last_busno); - } -/* Platform gets a chance to do some global fixups before * we proceed to resource allocation */
@@ -1641,9 +1655,9 @@ void pcibios_scan_phb(struct pci_controller *hose) ppc_md.pcibios_fixup_phb (hose);/* Configure PCI Express settings */ -if (bus && !pci_has_flag (PCI_PROBE_ONLY )) { +if (host->bus && !pci_has_flag (PCI_PROBE_ONLY )) {struct pci_bus *child; -list_for_each_entry (child, &bus->children, node) +list_for_each_entry (child, &host->bus->children, node)pcie_bus_configure_settings (child); } }
Signature · 6 lines
1.7.1 _______________________________________________ Linuxppc-dev mailing list [email protected] https://lists.ozlabs.org/listinfo/linuxppc-dev
PATCH v7 19/31 powerpc/pci: Use pci_scan_host_bridge() for simplicity
In reply to Yijing WangNow we could use pci_scan_host_bridge() to scan pci buses, provide powerpc specific pci_host_bridge_ops.
--- arch/powerpc/kernel/pci-common.c | 60 +++++++++++++++++++++++-------------- 1 files changed, 37 insertions(+), 23 deletions(-)
arch/powerpc/kernel/pci-common.c +37 -23
@@ -773,6 +773,29 @@ void pcibios_set_root_bus_speed(struct pci_host_bridge *bridge)return ppc_md.pcibios_set_root_bus_speed (bridge); } +static int pci_host_scan_bus (struct pci_host_bridge *host) +{ +int mode =PCI_PROBE_NORMAL ; +struct pci_bus *bus = host->bus; +struct pci_controller *hose =dev_get_drvdata (&host->dev); + +/* Get probe mode and perform scan */ +if (hose->dn && ppc_md.pci_probe_mode) + mode = ppc_md.pci_probe_mode (bus); + +pr_debug (" probe mode: %d\n" , mode); +if (mode ==PCI_PROBE_DEVTREE ) +of_scan_bus (hose->dn, bus); + +if (mode ==PCI_PROBE_NORMAL ) { +pci_bus_update_busn_res_end (bus,255 ); + hose->last_busno =pci_scan_child_bus (bus); +pci_bus_update_busn_res_end (bus, hose->last_busno); + } + +return pci_bus_child_max_busnr (bus); +} +/* This header fixup will do the resource fixup for all devices as they are * probed, but not for bridge ranges */
@@ -1585,6 +1608,11 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)return of_node_get (hose->dn); } +static struct pci_host_bridge_ops pci_host_ops = { + .set_root_bus_speed = pcibios_set_root_bus_speed, + .scan_bus = pci_host_scan_bus, +}; +/** * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus * @hose: Pointer to the PCI host controller instance structure
@@ -1592,9 +1620,8 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)void pcibios_scan_phb (struct pci_controller *hose) {LIST_HEAD (resources); -struct pci_bus *bus; +struct pci_host_bridge *host;struct device_node *node = hose->dn; -int mode;pr_debug ("PCI: Scanning PHB %s\n" ,of_node_full_name (node));
@@ -1609,31 +1636,18 @@ void pcibios_scan_phb(struct pci_controller *hose) hose->busn.flags =IORESOURCE_BUS ;pci_add_resource (&resources, &hose->busn); + pci_host_ops.pci_ops = hose->ops;/* Create an empty bus for the toplevel */ - bus =pci_create_root_bus (hose->parent, 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); + host =pci_scan_host_bridge (hose->parent, hose->global_number, + hose->first_busno, hose, &resources, &pci_host_ops); +if (host ==NULL ) { +pr_err ("Failed to create host bridge for pci%04x:%02x\n" , + hose->global_number, hose->first_busno);pci_free_resource_list (&resources);return ; } hose->bus = bus; -/* Get probe mode and perform scan */ - mode =PCI_PROBE_NORMAL ; -if (node && ppc_md.pci_probe_mode) - mode = ppc_md.pci_probe_mode (bus); -pr_debug (" probe mode: %d\n" , mode); -if (mode ==PCI_PROBE_DEVTREE ) -of_scan_bus (node, bus); - -if (mode ==PCI_PROBE_NORMAL ) { -pci_bus_update_busn_res_end (bus,255 ); - hose->last_busno =pci_scan_child_bus (bus); -pci_bus_update_busn_res_end (bus, hose->last_busno); - } -/* Platform gets a chance to do some global fixups before * we proceed to resource allocation */
@@ -1641,9 +1655,9 @@ void pcibios_scan_phb(struct pci_controller *hose) ppc_md.pcibios_fixup_phb (hose);/* Configure PCI Express settings */ -if (bus && !pci_has_flag (PCI_PROBE_ONLY )) { +if (host->bus && !pci_has_flag (PCI_PROBE_ONLY )) {struct pci_bus *child; -list_for_each_entry (child, &bus->children, node) +list_for_each_entry (child, &host->bus->children, node)pcie_bus_configure_settings (child); } }
Signature · 1 line
1.7.1
PATCH v7 20/31 PCI: Remove pcibios_root_bridge_prepare() and pcibos_set_root_bus_speed()
In reply to Yijing WangNow no one use weak pcibios_root_bridge_prepare() and pcibios_set_root_bus_speed, we could clean up them.
--- drivers/pci/host-bridge.c | 4 ---- drivers/pci/probe.c | 18 +----------------- include/linux/pci.h | 2 -- 3 files changed, 1 insertions(+), 23 deletions(-)
drivers/pci/host-bridge.c +0 -4
@@ -110,10 +110,6 @@ struct pci_host_bridge *pci_create_host_bridge( goto list_del; } - error =pcibios_root_bridge_prepare (host); -if (error) - goto list_del; - error =device_register (&host->dev);if (error) {put_device (&host->dev);
drivers/pci/probe.c +1 -17
@@ -1844,22 +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_set_root_bus_speed (struct pci_host_bridge *bridge) -{ -} -void __weak pcibios_add_bus (struct pci_bus *bus) { }
@@ -1896,7 +1880,7 @@ static struct pci_bus *__pci_create_root_bus(if (bridge->ops && bridge->ops->set_root_bus_speed) bridge->ops->set_root_bus_speed (bridge); -pcibios_set_root_bus_speed (bridge); +device_enable_async_suspend (b->bridge);pci_set_bus_of_node (b);
include/linux/pci.h +0 -2
@@ -426,8 +426,6 @@ 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); -/* * 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 v7 20/31 PCI: Remove pcibios_root_bridge_prepare() and pcibos_set_root_bus_speed()
In reply to Yijing WangNow no one use weak pcibios_root_bridge_prepare() and pcibios_set_root_bus_speed, we could clean up them.
--- drivers/pci/host-bridge.c | 4 ---- drivers/pci/probe.c | 18 +----------------- include/linux/pci.h | 2 -- 3 files changed, 1 insertions(+), 23 deletions(-)
drivers/pci/host-bridge.c +0 -4
@@ -110,10 +110,6 @@ struct pci_host_bridge *pci_create_host_bridge( goto list_del; } - error =pcibios_root_bridge_prepare (host); -if (error) - goto list_del; - error =device_register (&host->dev);if (error) {put_device (&host->dev);
drivers/pci/probe.c +1 -17
@@ -1844,22 +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_set_root_bus_speed (struct pci_host_bridge *bridge) -{ -} -void __weak pcibios_add_bus (struct pci_bus *bus) { }
@@ -1896,7 +1880,7 @@ static struct pci_bus *__pci_create_root_bus(if (bridge->ops && bridge->ops->set_root_bus_speed) bridge->ops->set_root_bus_speed (bridge); -pcibios_set_root_bus_speed (bridge); +device_enable_async_suspend (b->bridge);pci_set_bus_of_node (b);
include/linux/pci.h +0 -2
@@ -426,8 +426,6 @@ 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); -/* * 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 v7 21/31 sparc/PCI: Use pci_scan_host_bridge() for simplicity
In reply to Yijing WangNow we could use pci_scan_host_bridge() to scan pci buses, provide sparc specific pci_host_bridge_ops.
--- arch/sparc/kernel/pci.c | 27 +++++++++++++++++++++------ 1 files changed, 21 insertions(+), 6 deletions(-)
arch/sparc/kernel/pci.c +21 -6
@@ -650,6 +650,20 @@ static void pci_claim_bus_resources(struct pci_bus *bus)pci_claim_bus_resources (child_bus); } +static int 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); +return pci_bus_child_max_busnr (host->bus); +} + +static struct pci_host_bridge_ops pci_host_ops = { + .scan_bus = pci_host_of_scan_bus, +}; +struct pci_bus *pci_scan_one_pbm (struct pci_pbm_info *pbm,struct device *parent) {
@@ -667,16 +681,17 @@ 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->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); + pci_host_ops.pci_ops = pbm->pci_ops; + bus =pci_scan_host_bridge (parent, pbm->index, pbm->pci_first_busno, + pbm, &resources, &pci_host_ops); +if (!host) { +pr_err ("Failed to create host bridge pci%04x:%02x for %s\n" , + pbm->index, pbm->pci_first_busno, node->full_name);pci_free_resource_list (&resources);return NULL ; } -pci_of_scan_bus (pbm, node, bus); + bus = host->bus;pci_bus_register_of_sysfs (bus);pci_claim_bus_resources (bus);
Signature · 1 line
1.7.1
PATCH v7 21/31 sparc/PCI: Use pci_scan_host_bridge() for simplicity
In reply to Yijing WangNow we could use pci_scan_host_bridge() to scan pci buses, provide sparc specific pci_host_bridge_ops.
--- arch/sparc/kernel/pci.c | 27 +++++++++++++++++++++------ 1 files changed, 21 insertions(+), 6 deletions(-)
arch/sparc/kernel/pci.c +21 -6
@@ -650,6 +650,20 @@ static void pci_claim_bus_resources(struct pci_bus *bus)pci_claim_bus_resources (child_bus); } +static int 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); +return pci_bus_child_max_busnr (host->bus); +} + +static struct pci_host_bridge_ops pci_host_ops = { + .scan_bus = pci_host_of_scan_bus, +}; +struct pci_bus *pci_scan_one_pbm (struct pci_pbm_info *pbm,struct device *parent) {
@@ -667,16 +681,17 @@ 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->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); + pci_host_ops.pci_ops = pbm->pci_ops; + bus =pci_scan_host_bridge (parent, pbm->index, pbm->pci_first_busno, + pbm, &resources, &pci_host_ops); +if (!host) { +pr_err ("Failed to create host bridge pci%04x:%02x for %s\n" , + pbm->index, pbm->pci_first_busno, node->full_name);pci_free_resource_list (&resources);return NULL ; } -pci_of_scan_bus (pbm, node, bus); + bus = host->bus;pci_bus_register_of_sysfs (bus);pci_claim_bus_resources (bus);
Signature · 1 line
1.7.1
PATCH v7 22/31 parisc/PCI: 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.
--- drivers/parisc/dino.c | 4 ++-- drivers/parisc/lba_pci.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/parisc/dino.c +2 -2
@@ -985,7 +985,7 @@ static int __init dino_probe(struct parisc_device *dev)** 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,0 , 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,7 +996,7 @@ static int __init dino_probe(struct parisc_device *dev)return 0 ; } - max =pci_scan_child_bus (bus); + max =pci_bus_child_max_busnr (bus);pci_bus_update_busn_res_end (bus, max);/* This code *depends* on scanning being single threaded
drivers/parisc/lba_pci.c +2 -2
@@ -1563,14 +1563,14 @@ 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,0 , lba_dev->hba.bus_num.start, +pci_scan_root_bus (&dev->dev,0 , 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); + max =pci_bus_child_max_busnr (lba_bus);/* This is in lieu of calling pci_assign_unassigned_resources() */ if (is_pdc_pat ()) {
Signature · 1 line
1.7.1
PATCH v7 22/31 parisc/PCI: 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.
--- drivers/parisc/dino.c | 4 ++-- drivers/parisc/lba_pci.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/parisc/dino.c +2 -2
@@ -985,7 +985,7 @@ static int __init dino_probe(struct parisc_device *dev)** 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,0 , 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,7 +996,7 @@ static int __init dino_probe(struct parisc_device *dev)return 0 ; } - max =pci_scan_child_bus (bus); + max =pci_bus_child_max_busnr (bus);pci_bus_update_busn_res_end (bus, max);/* This code *depends* on scanning being single threaded
drivers/parisc/lba_pci.c +2 -2
@@ -1563,14 +1563,14 @@ 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,0 , lba_dev->hba.bus_num.start, +pci_scan_root_bus (&dev->dev,0 , 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); + max =pci_bus_child_max_busnr (lba_bus);/* This is in lieu of calling pci_assign_unassigned_resources() */ if (is_pdc_pat ()) {
Signature · 1 line
1.7.1
PATCH v7 23/31 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,-1 , 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 v7 23/31 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,-1 , 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 v7 24/31 PCI/tegra: Remove redundant tegra_pcie_scan_bus()
In reply to Yijing WangNow pci_scan_root_bus() is almost similar topci_create_root_bus() + pci_scan_child_bus().
So we could use common pci_scan_root_bus() inpci_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,-1 , 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 v7 24/31 PCI/tegra: Remove redundant tegra_pcie_scan_bus()
In reply to Yijing WangNow pci_scan_root_bus() is almost similar 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,-1 , 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 v7 25/31 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,-1 , sys->busnr, + bus =pci_scan_root_bus (pp->dev,-1 , 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 v7 25/31 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,-1 , sys->busnr, + bus =pci_scan_root_bus (pp->dev,-1 , 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 v7 26/31 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,-1 ,0 , + bus =pci_scan_root_bus (&pdev->dev,-1 ,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 v7 26/31 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,-1 ,0 , + bus =pci_scan_root_bus (&pdev->dev,-1 ,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 v7 27/31 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 | 35 +++++++++-------------------------- include/linux/pci.h | 3 --- 2 files changed, 9 insertions(+), 29 deletions(-)
drivers/pci/probe.c +9 -26
@@ -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;
@@ -1937,24 +1937,6 @@ put_dev:return NULL ; } -struct pci_bus *pci_create_root_bus (struct device *parent, -int domain,int bus,struct pci_ops *ops,void *sysdata, -struct list_head *resources) -{ -struct pci_host_bridge *host; - - host =pci_create_host_bridge (parent, domain, bus, - sysdata, resources,NULL ); -if (!host) -return NULL ; - - host->bus =__pci_create_root_bus (host, ops); -if (!host->bus) -pci_free_host_bridge (host); - -return host->bus; -} -int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int bus_max) {struct resource *res = &b->busn_res;
@@ -2030,7 +2012,7 @@ static struct pci_bus *__pci_scan_root_bus(struct pci_bus *b;int max; - b =__pci_create_root_bus (host, ops); + b =pci_create_root_bus (host, ops);if (!b)return NULL ;
@@ -2093,19 +2075,20 @@ struct pci_bus *pci_scan_bus(int domain, int bus, 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 , domain, bus, ops, sysdata, - &resources); -if (b) { -pci_scan_child_bus (b); + host =pci_create_host_bridge (NULL , domain, bus, 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);
include/linux/pci.h +0 -3
@@ -782,9 +782,6 @@ 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 domain,int bus,struct pci_ops *ops,void *sysdata); -struct pci_bus *pci_create_root_bus (struct device *parent,int domain,int bus, -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);
Signature · 1 line
1.7.1
PATCH v7 28/31 PCI: rename to pci_find_host_bridge()
In reply to Yijing Wang--- drivers/pci/host-bridge.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/pci/host-bridge.c +3 -3
@@ -144,7 +144,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 *pci_find_host_bridge (struct pci_bus *bus) {struct pci_bus *root_bus =find_pci_root_bus (bus);
@@ -162,7 +162,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,void pcibios_resource_to_bus (struct pci_bus *bus,struct pci_bus_region *region,struct resource *res) { -struct pci_host_bridge *bridge =find_pci_host_bridge (bus); +struct pci_host_bridge *bridge =pci_find_host_bridge (bus);struct resource_entry *window;resource_size_t offset =0 ;
@@ -187,7 +187,7 @@ static bool region_contains(struct pci_bus_region *region1,void pcibios_bus_to_resource (struct pci_bus *bus,struct resource *res,struct pci_bus_region *region) { -struct pci_host_bridge *bridge =find_pci_host_bridge (bus); +struct pci_host_bridge *bridge =pci_find_host_bridge (bus);struct resource_entry *window;resource_size_t offset =0 ;
Signature · 1 line
1.7.1
PATCH v7 28/31 PCI: rename to pci_find_host_bridge()
In reply to Yijing Wang--- drivers/pci/host-bridge.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/pci/host-bridge.c +3 -3
@@ -144,7 +144,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 *pci_find_host_bridge (struct pci_bus *bus) {struct pci_bus *root_bus =find_pci_root_bus (bus);
@@ -162,7 +162,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,void pcibios_resource_to_bus (struct pci_bus *bus,struct pci_bus_region *region,struct resource *res) { -struct pci_host_bridge *bridge =find_pci_host_bridge (bus); +struct pci_host_bridge *bridge =pci_find_host_bridge (bus);struct resource_entry *window;resource_size_t offset =0 ;
@@ -187,7 +187,7 @@ static bool region_contains(struct pci_bus_region *region1,void pcibios_bus_to_resource (struct pci_bus *bus,struct resource *res,struct pci_bus_region *region) { -struct pci_host_bridge *bridge =find_pci_host_bridge (bus); +struct pci_host_bridge *bridge =pci_find_host_bridge (bus);struct resource_entry *window;resource_size_t offset =0 ;
Signature · 1 line
1.7.1
PATCH v7 29/31 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/host-bridge.c | 10 ++++++++++ include/linux/pci.h | 7 +------ 12 files changed, 11 insertions(+), 66 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
@@ -904,23 +904,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/host-bridge.c +10 -0
@@ -151,6 +151,16 @@ struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus)return to_pci_host_bridge (root_bus->bridge); } +#ifdef CONFIG_PCI_DOMAINS +int pci_domain_nr (struct pci_bus *bus) +{ +struct pci_host_bridge *host =pci_find_host_bridge (bus); + +return host->domain; +} +EXPORT_SYMBOL (pci_domain_nr); +#endif +void pci_set_host_bridge_release (struct pci_host_bridge *bridge,void (*release_fn)(struct pci_host_bridge *),void *release_data)
include/linux/pci.h +1 -6
@@ -1320,6 +1320,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 ; }
@@ -1332,12 +1333,6 @@ static inline int pci_get_new_domain_nr(void) { return -ENOSYS; }* architecture does not need custom management of PCI * 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; -} -#endif /* some architectures require additional setup to direct VGA traffic */ typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode,
Signature · 1 line
1.7.1
PATCH v7 29/31 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/host-bridge.c | 10 ++++++++++ include/linux/pci.h | 7 +------ 12 files changed, 11 insertions(+), 66 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
@@ -904,23 +904,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/host-bridge.c +10 -0
@@ -151,6 +151,16 @@ struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus)return to_pci_host_bridge (root_bus->bridge); } +#ifdef CONFIG_PCI_DOMAINS +int pci_domain_nr (struct pci_bus *bus) +{ +struct pci_host_bridge *host =pci_find_host_bridge (bus); + +return host->domain; +} +EXPORT_SYMBOL (pci_domain_nr); +#endif +void pci_set_host_bridge_release (struct pci_host_bridge *bridge,void (*release_fn)(struct pci_host_bridge *),void *release_data)
include/linux/pci.h +1 -6
@@ -1320,6 +1320,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 ; }
@@ -1332,12 +1333,6 @@ static inline int pci_get_new_domain_nr(void) { return -ENOSYS; }* architecture does not need custom management of PCI * 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; -} -#endif /* some architectures require additional setup to direct VGA traffic */ typedef int (*arch_set_vga_state_t)(struct pci_dev *pdev, bool decode,
Signature · 1 line
1.7.1
PATCH v7 30/31 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. Also move pci_host_assign_domain_nr() to drivers/pci/host-bridge.c for simplicity.
--- drivers/pci/host-bridge.c | 61 +++++++++++++++++++++++++++++++++++++++++ drivers/pci/pci.c | 67 --------------------------------------------- drivers/pci/pci.h | 13 --------- drivers/pci/probe.c | 11 ++----- include/linux/pci.h | 3 -- 5 files changed, 64 insertions(+), 91 deletions(-)
drivers/pci/host-bridge.c +61 -0
@@ -11,6 +11,8 @@static LIST_HEAD (pci_host_bridge_list);static DEFINE_MUTEX (pci_host_mutex); +void pci_host_assign_domain_nr (struct pci_host_bridge *host); +static void pci_release_host_bridge_dev (struct device *dev) {struct pci_host_bridge *bridge =to_pci_host_bridge (dev);
@@ -159,6 +161,65 @@ int pci_domain_nr(struct pci_bus *bus)return host->domain; }EXPORT_SYMBOL (pci_domain_nr); + +static atomic_t __domain_nr =ATOMIC_INIT (-1 ); + +int pci_get_new_domain_nr (void ) +{ +return atomic_inc_return (&__domain_nr); +} + +#ifdef CONFIG_PCI_DOMAINS_GENERIC +static int pci_assign_domain_nr (struct device *dev) +{ +static int use_dt_domains =-1 ; +int domain =of_get_pci_domain_nr (dev->of_node); + +/* +* Check DT domain and use_dt_domains values. +* +* If DT domain property is valid (domain >= 0) and +* use_dt_domains != 0, the DT assignment is valid since this means +* we have not previously allocated a domain number by using +* pci_get_new_domain_nr(); we should also update use_dt_domains to +* 1, to indicate that we have just assigned a domain number from +* DT. +* +* If DT domain property value is not valid (ie domain < 0), and we +* have not previously assigned a domain number from DT +* (use_dt_domains != 1) we should assign a domain number by +* using the: +* +* pci_get_new_domain_nr() +* +* API and update the use_dt_domains value to keep track of method we +* are using to assign domain numbers (use_dt_domains = 0). +* +* All other combinations imply we have a platform that is trying +* to mix domain numbers obtained from DT and pci_get_new_domain_nr(), +* which is a recipe for domain mishandling and it is prevented by +* invalidating the domain value (domain = -1) and printing a +* corresponding error. +*/ +if (domain >=0 && use_dt_domains) { + use_dt_domains =1 ; + }else if (domain <0 && use_dt_domains !=1 ) { + use_dt_domains =0 ; + domain =pci_get_new_domain_nr (); + }else { +dev_err (dev,"Node %s has inconsistent \"linux,pci-domain\" property in DT\n" , + dev->of_node->full_name); + domain =-1 ; + } + +return domain; +} + +void pci_host_assign_domain_nr (struct pci_host_bridge *host) +{ + host->domain =pci_assign_domain_nr (host->dev.parent); +} +#endif #endif void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
drivers/pci/pci.c +0 -67
73 lines not on this page · raw message
drivers/pci/pci.h +0 -13
@@ -321,19 +321,6 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe) }#endif -#ifdef CONFIG_PCI_DOMAINS_GENERIC -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 -struct pci_host_bridge *pci_create_host_bridge (struct device *parent,int domain,int bus,void *sysdata,struct list_head *resources,struct pci_host_bridge_ops *ops);
drivers/pci/probe.c +3 -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,6 @@ 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 +641,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,7 +1861,7 @@ 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 ;
@@ -1873,7 +1869,6 @@ static struct pci_bus *pci_create_root_bus( b->ops = ops; b->number = b->busn_res.start =pci_host_first_busnr (bridge); -pci_bus_assign_domain_nr (b, parent); bridge->bus = b; b->bridge =get_device (&bridge->dev);
include/linux/pci.h +0 -3
@@ -469,9 +469,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 v7 30/31 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. Also move pci_host_assign_domain_nr() to drivers/pci/host-bridge.c for simplicity.
--- drivers/pci/host-bridge.c | 61 +++++++++++++++++++++++++++++++++++++++++ drivers/pci/pci.c | 67 --------------------------------------------- drivers/pci/pci.h | 13 --------- drivers/pci/probe.c | 11 ++----- include/linux/pci.h | 3 -- 5 files changed, 64 insertions(+), 91 deletions(-)
drivers/pci/host-bridge.c +61 -0
@@ -11,6 +11,8 @@static LIST_HEAD (pci_host_bridge_list);static DEFINE_MUTEX (pci_host_mutex); +void pci_host_assign_domain_nr (struct pci_host_bridge *host); +static void pci_release_host_bridge_dev (struct device *dev) {struct pci_host_bridge *bridge =to_pci_host_bridge (dev);
@@ -159,6 +161,65 @@ int pci_domain_nr(struct pci_bus *bus)return host->domain; }EXPORT_SYMBOL (pci_domain_nr); + +static atomic_t __domain_nr =ATOMIC_INIT (-1 ); + +int pci_get_new_domain_nr (void ) +{ +return atomic_inc_return (&__domain_nr); +} + +#ifdef CONFIG_PCI_DOMAINS_GENERIC +static int pci_assign_domain_nr (struct device *dev) +{ +static int use_dt_domains =-1 ; +int domain =of_get_pci_domain_nr (dev->of_node); + +/* +* Check DT domain and use_dt_domains values. +* +* If DT domain property is valid (domain >= 0) and +* use_dt_domains != 0, the DT assignment is valid since this means +* we have not previously allocated a domain number by using +* pci_get_new_domain_nr(); we should also update use_dt_domains to +* 1, to indicate that we have just assigned a domain number from +* DT. +* +* If DT domain property value is not valid (ie domain < 0), and we +* have not previously assigned a domain number from DT +* (use_dt_domains != 1) we should assign a domain number by +* using the: +* +* pci_get_new_domain_nr() +* +* API and update the use_dt_domains value to keep track of method we +* are using to assign domain numbers (use_dt_domains = 0). +* +* All other combinations imply we have a platform that is trying +* to mix domain numbers obtained from DT and pci_get_new_domain_nr(), +* which is a recipe for domain mishandling and it is prevented by +* invalidating the domain value (domain = -1) and printing a +* corresponding error. +*/ +if (domain >=0 && use_dt_domains) { + use_dt_domains =1 ; + }else if (domain <0 && use_dt_domains !=1 ) { + use_dt_domains =0 ; + domain =pci_get_new_domain_nr (); + }else { +dev_err (dev,"Node %s has inconsistent \"linux,pci-domain\" property in DT\n" , + dev->of_node->full_name); + domain =-1 ; + } + +return domain; +} + +void pci_host_assign_domain_nr (struct pci_host_bridge *host) +{ + host->domain =pci_assign_domain_nr (host->dev.parent); +} +#endif #endif void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
drivers/pci/pci.c +0 -67
73 lines not on this page · raw message
drivers/pci/pci.h +0 -13
@@ -321,19 +321,6 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe) }#endif -#ifdef CONFIG_PCI_DOMAINS_GENERIC -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 -struct pci_host_bridge *pci_create_host_bridge (struct device *parent,int domain,int bus,void *sysdata,struct list_head *resources,struct pci_host_bridge_ops *ops);
drivers/pci/probe.c +3 -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,6 @@ 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 +641,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,7 +1861,7 @@ 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 ;
@@ -1873,7 +1869,6 @@ static struct pci_bus *pci_create_root_bus( b->ops = ops; b->number = b->busn_res.start =pci_host_first_busnr (bridge); -pci_bus_assign_domain_nr (b, parent); bridge->bus = b; b->bridge =get_device (&bridge->dev);
include/linux/pci.h +0 -3
@@ -469,9 +469,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 v7 31/31 PCI: Clean up CONFIG_PCI_DOMAINS_GENERIC
In reply to Yijing WangNow we could clean up CONFIG_PCI_DOMAINS_GENERIC.
--- arch/arm/Kconfig | 3 --- arch/arm64/Kconfig | 3 --- drivers/pci/host-bridge.c | 9 +++++---- drivers/pci/pci.c | 2 -- 4 files changed, 5 insertions(+), 12 deletions(-)
arch/arm/Kconfig +0 -3
@@ -1283,9 +1283,6 @@ config PCI_DOMAINS bool depends on PCI -config PCI_DOMAINS_GENERIC - def_bool PCI_DOMAINS - config PCI_NANOENGINE bool "BSE nanoEngine PCI support" depends on SA1100_NANOENGINE
arch/arm64/Kconfig +0 -3
@@ -242,9 +242,6 @@ config PCI config PCI_DOMAINS def_bool PCI -config PCI_DOMAINS_GENERIC - def_bool PCI - config PCI_SYSCALL def_bool PCI
drivers/pci/host-bridge.c +5 -4
@@ -4,6 +4,8 @@#include <linux/kernel.h> #include <linux/pci.h> +#include <linux/of_pci.h> +#include <linux/of.h> #include <linux/module.h> #include "pci.h"
@@ -82,12 +84,13 @@ struct pci_host_bridge *pci_create_host_bridge(resource_list_for_each_entry_safe (window, n, resources)list_move_tail (&window->node, &host->windows);/* -* If support CONFIG_PCI_DOMAINS_GENERIC, use +* If domain == -1, we need to use * pci_host_assign_domain_nr() to update domain * number. */ host->domain = domain; -pci_host_assign_domain_nr (host); +if (host->domain ==-1 ) +pci_host_assign_domain_nr (host);mutex_lock (&pci_host_mutex);list_for_each_entry (tmp, &pci_host_bridge_list, list) { if (tmp->domain != host->domain
@@ -169,7 +172,6 @@ int pci_get_new_domain_nr(void)return atomic_inc_return (&__domain_nr); } -#ifdef CONFIG_PCI_DOMAINS_GENERIC static int pci_assign_domain_nr (struct device *dev) {static int use_dt_domains =-1 ;
@@ -220,7 +222,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host) host->domain =pci_assign_domain_nr (host->dev.parent); }#endif -#endif void pci_set_host_bridge_release(struct pci_host_bridge *bridge, void (*release_fn)(struct pci_host_bridge *),
drivers/pci/pci.c +0 -2
@@ -10,8 +10,6 @@#include <linux/kernel.h> #include <linux/delay.h> #include <linux/init.h> -#include <linux/of.h> -#include <linux/of_pci.h> #include <linux/pci.h> #include <linux/pm.h> #include <linux/slab.h>
Signature · 1 line
1.7.1
PATCH v7 31/31 PCI: Clean up CONFIG_PCI_DOMAINS_GENERIC
In reply to Yijing WangNow we could clean up CONFIG_PCI_DOMAINS_GENERIC.
--- arch/arm/Kconfig | 3 --- arch/arm64/Kconfig | 3 --- drivers/pci/host-bridge.c | 9 +++++---- drivers/pci/pci.c | 2 -- 4 files changed, 5 insertions(+), 12 deletions(-)
arch/arm/Kconfig +0 -3
@@ -1283,9 +1283,6 @@ config PCI_DOMAINS bool depends on PCI -config PCI_DOMAINS_GENERIC - def_bool PCI_DOMAINS - config PCI_NANOENGINE bool "BSE nanoEngine PCI support" depends on SA1100_NANOENGINE
arch/arm64/Kconfig +0 -3
@@ -242,9 +242,6 @@ config PCI config PCI_DOMAINS def_bool PCI -config PCI_DOMAINS_GENERIC - def_bool PCI - config PCI_SYSCALL def_bool PCI
drivers/pci/host-bridge.c +5 -4
@@ -4,6 +4,8 @@#include <linux/kernel.h> #include <linux/pci.h> +#include <linux/of_pci.h> +#include <linux/of.h> #include <linux/module.h> #include "pci.h"
@@ -82,12 +84,13 @@ struct pci_host_bridge *pci_create_host_bridge(resource_list_for_each_entry_safe (window, n, resources)list_move_tail (&window->node, &host->windows);/* -* If support CONFIG_PCI_DOMAINS_GENERIC, use +* If domain == -1, we need to use * pci_host_assign_domain_nr() to update domain * number. */ host->domain = domain; -pci_host_assign_domain_nr (host); +if (host->domain ==-1 ) +pci_host_assign_domain_nr (host);mutex_lock (&pci_host_mutex);list_for_each_entry (tmp, &pci_host_bridge_list, list) { if (tmp->domain != host->domain
@@ -169,7 +172,6 @@ int pci_get_new_domain_nr(void)return atomic_inc_return (&__domain_nr); } -#ifdef CONFIG_PCI_DOMAINS_GENERIC static int pci_assign_domain_nr (struct device *dev) {static int use_dt_domains =-1 ;
@@ -220,7 +222,6 @@ void pci_host_assign_domain_nr(struct pci_host_bridge *host) host->domain =pci_assign_domain_nr (host->dev.parent); }#endif -#endif void pci_set_host_bridge_release(struct pci_host_bridge *bridge, void (*release_fn)(struct pci_host_bridge *),
drivers/pci/pci.c +0 -2
@@ -10,8 +10,6 @@#include <linux/kernel.h> #include <linux/delay.h> #include <linux/init.h> -#include <linux/of.h> -#include <linux/of_pci.h> #include <linux/pci.h> #include <linux/pm.h> #include <linux/slab.h>
Signature · 1 line
1.7.1