PCI: hotplug bridge replated clean up
Subsystems (2)
cover PCI: hotplug bridge replated clean up
Reduce the open code with create bus/scan bus.
Make them more like updated pciehp driver.
Need to apply it before for-pci-busn_res
could be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-hotplug
Yinghai Lu (7):
PCI, pciehp: Separate pci_hp_add_bridge()
PCI, cpci_hotplug: Simplify configure_slot
PCI, shpchp: Simplify configure_device
PCI, cpqhp: Using pci_hp_add_bridge
PCI, ibmhp: Using pci_hp_add_bridge
PCI, sgihp: Using pci_hp_add_bridge
PCI, hotplug: remove pci_do_scan_bus()
drivers/pci/hotplug-pci.c | 30 +++++++++++++-------- drivers/pci/hotplug/cpci_hotplug_pci.c | 35 ++++-------------------- drivers/pci/hotplug/cpqphp_pci.c | 8 +++--- drivers/pci/hotplug/ibmphp_core.c | 8 +++--- drivers/pci/hotplug/pciehp_pci.c | 28 +------------------ drivers/pci/hotplug/sgi_hotplug.c | 12 +++----- drivers/pci/hotplug/shpchp_pci.c | 45 ++++++++++--------------------- drivers/pci/pci.h | 2 +- 8 files changed, 56 insertions(+), 112 deletions(-)
Signature · 1 line
1.7.7
PATCH 1/7 PCI, pciehp: Separate pci_hp_add_bridge()
Will use it for other pci hp hotplug support
--- drivers/pci/hotplug-pci.c | 23 +++++++++++++++++++++++ drivers/pci/hotplug/pciehp_pci.c | 28 ++-------------------------- drivers/pci/pci.h | 1 + 3 files changed, 26 insertions(+), 26 deletions(-)
drivers/pci/hotplug-pci.c +23 -0
@@ -4,6 +4,29 @@#include <linux/export.h> #include "pci.h" +int __ref pci_hp_add_bridge (struct pci_dev *dev) +{ +struct pci_bus *parent = dev->bus; +int pass, busnr, start = parent->secondary; +int end = parent->subordinate; + +for (busnr = start; busnr <= end; busnr++) { +if (!pci_find_bus (pci_domain_nr (parent), busnr)) +break ; + } +if (busnr-- > end) { +printk (KERN_ERR "No bus number available for hot-added bridge %s\n" , +pci_name (dev)); +return -1 ; + } +for (pass =0 ; pass <2 ; pass++) + busnr =pci_scan_bridge (parent, dev, busnr, pass); +if (!dev->subordinate) +return -1 ; + +return 0 ; +} +EXPORT_SYMBOL_GPL (pci_hp_add_bridge);unsigned int __devinit pci_do_scan_bus (struct pci_bus *bus) {
drivers/pci/hotplug/pciehp_pci.c +2 -26
@@ -34,29 +34,6 @@#include "../pci.h" #include "pciehp.h" -static int __ref pciehp_add_bridge (struct pci_dev *dev) -{ -struct pci_bus *parent = dev->bus; -int pass, busnr, start = parent->secondary; -int end = parent->subordinate; - -for (busnr = start; busnr <= end; busnr++) { -if (!pci_find_bus (pci_domain_nr (parent), busnr)) -break ; - } -if (busnr-- > end) { -err ("No bus number available for hot-added bridge %s\n" , -pci_name (dev)); -return -1 ; - } -for (pass =0 ; pass <2 ; pass++) - busnr =pci_scan_bridge (parent, dev, busnr, pass); -if (!dev->subordinate) -return -1 ; - -return 0 ; -} -int pciehp_configure_device (struct slot *p_slot) {struct pci_dev *dev;
@@ -85,9 +62,8 @@ int pciehp_configure_device(struct slot *p_slot)if (!dev)continue ;if ((dev->hdr_type ==PCI_HEADER_TYPE_BRIDGE ) || - (dev->hdr_type ==PCI_HEADER_TYPE_CARDBUS )) { -pciehp_add_bridge (dev); - } + (dev->hdr_type ==PCI_HEADER_TYPE_CARDBUS )) +pci_hp_add_bridge (dev);pci_dev_put (dev); }
drivers/pci/pci.h +1 -0
@@ -124,6 +124,7 @@ static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; }#endif /* Functions for PCI Hotplug drivers to use */ +int pci_hp_add_bridge (struct pci_dev *dev);extern unsigned int pci_do_scan_bus (struct pci_bus *bus);#ifdef HAVE_PCI_LEGACY
Signature · 1 line
1.7.7
PATCH 2/7 PCI, cpci_hotplug: Simplify configure_slot
In reply to Yinghai LuFor child p2p bridge hotplug support should use pci_scan_bridge instead.
Make it more simillar to pciehp, just use pci_hp_add_bridge()
--- drivers/pci/hotplug/cpci_hotplug_pci.c | 35 +++++-------------------------- 1 files changed, 6 insertions(+), 29 deletions(-)
drivers/pci/hotplug/cpci_hotplug_pci.c +6 -29
@@ -285,42 +285,19 @@ int __ref cpci_configure_slot(struct slot *slot)for (fn =0 ; fn <8 ; fn++) {struct pci_dev *dev; - dev =pci_get_slot (parent,PCI_DEVFN (PCI_SLOT (slot->devfn), fn)); + dev =pci_get_slot (parent, +PCI_DEVFN (PCI_SLOT (slot->devfn), fn));if (!dev)continue ;if ((dev->hdr_type ==PCI_HEADER_TYPE_BRIDGE ) || - (dev->hdr_type ==PCI_HEADER_TYPE_CARDBUS )) { -/* Find an unused bus number for the new bridge */ -struct pci_bus *child; -unsigned char busnr, start = parent->secondary; -unsigned char end = parent->subordinate; - -for (busnr = start; busnr <= end; busnr++) { -if (!pci_find_bus (pci_domain_nr (parent), - busnr)) -break ; - } -if (busnr >= end) { -err ("No free bus for hot-added bridge\n" ); -pci_dev_put (dev); -continue ; - } - child =pci_add_new_bus (parent, dev, busnr); -if (!child) { -err ("Cannot add new bus for %s\n" , -pci_name (dev)); -pci_dev_put (dev); -continue ; - } - child->subordinate =pci_do_scan_bus (child); -pci_bus_size_bridges (child); - } + (dev->hdr_type ==PCI_HEADER_TYPE_CARDBUS )) +pci_hp_add_bridge (dev);pci_dev_put (dev); } -pci_bus_assign_resources (parent); +pci_assign_unassigned_bridge_resources (parent->self); +pci_bus_add_devices (parent); -pci_enable_bridges (parent);dbg ("%s - exit" , __func__);return 0 ;
Signature · 1 line
1.7.7
PATCH 3/7 PCI, shpchp: Simplify configure_device
In reply to Yinghai LuFor child p2p bridge hotplug support should use pci_scan_bridge instead.
Make it more simillar to pciehp, just use pci_hp_add_bridge()
--- drivers/pci/hotplug/shpchp_pci.c | 45 ++++++++++++------------------------- 1 files changed, 15 insertions(+), 30 deletions(-)
drivers/pci/hotplug/shpchp_pci.c +15 -30
@@ -37,9 +37,10 @@int __ref shpchp_configure_device (struct slot *p_slot) {struct pci_dev *dev; -struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate; -int num, fn;struct controller *ctrl = p_slot->ctrl; +struct pci_dev *bridge = ctrl->pci_dev; +struct pci_bus *parent = bridge->subordinate; +int num, fn; dev =pci_get_slot (parent,PCI_DEVFN (p_slot->device,0 ));if (dev) {
@@ -61,39 +62,23 @@ int __ref shpchp_configure_device(struct slot *p_slot)if (!dev)continue ;if ((dev->hdr_type ==PCI_HEADER_TYPE_BRIDGE ) || - (dev->hdr_type ==PCI_HEADER_TYPE_CARDBUS )) { -/* Find an unused bus number for the new bridge */ -struct pci_bus *child; -unsigned char busnr, start = parent->secondary; -unsigned char end = parent->subordinate; -for (busnr = start; busnr <= end; busnr++) { -if (!pci_find_bus (pci_domain_nr (parent), - busnr)) -break ; - } -if (busnr > end) { -ctrl_err (ctrl, -"No free bus for hot-added bridge\n" ); -pci_dev_put (dev); -continue ; - } - child =pci_add_new_bus (parent, dev, busnr); -if (!child) { -ctrl_err (ctrl,"Cannot add new bus for %s\n" , -pci_name (dev)); -pci_dev_put (dev); -continue ; - } - child->subordinate =pci_do_scan_bus (child); -pci_bus_size_bridges (child); - } + (dev->hdr_type ==PCI_HEADER_TYPE_CARDBUS )) +pci_hp_add_bridge (dev); +pci_dev_put (dev); + } + +pci_assign_unassigned_bridge_resources (bridge); + +for (fn =0 ; fn <8 ; fn++) { + dev =pci_get_slot (parent,PCI_DEVFN (p_slot->device, fn)); +if (!dev) +continue ;pci_configure_slot (dev);pci_dev_put (dev); } -pci_bus_assign_resources (parent);pci_bus_add_devices (parent); -pci_enable_bridges (parent); +return 0 ; }
Signature · 1 line
1.7.7
PATCH 4/7 PCI, cpqhp: Using pci_hp_add_bridge
In reply to Yinghai Luinstead of open code with pci_add_new_bus()/do_scan_bus...
--- drivers/pci/hotplug/cpqphp_pci.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/pci/hotplug/cpqphp_pci.c +4 -4
@@ -83,7 +83,6 @@ static void __iomem *detect_HRT_floating_pointer(void __iomem *begin, void __iomint cpqhp_configure_device (struct controller * ctrl,struct pci_func * func) { -unsigned char bus;struct pci_bus *child;int num;
@@ -106,9 +105,10 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func) }if (func->pci_dev->hdr_type ==PCI_HEADER_TYPE_BRIDGE ) { -pci_read_config_byte (func->pci_dev,PCI_SECONDARY_BUS , &bus); - child = (struct pci_bus *)pci_add_new_bus (func->pci_dev->bus, (func->pci_dev), bus); -pci_do_scan_bus (child); +pci_hp_add_bridge (func->pci_dev); + child = func->pci_dev->subordinate; +if (child) +pci_bus_add_devices (child); }pci_dev_put (func->pci_dev);
Signature · 1 line
1.7.7
PATCH 5/7 PCI, ibmhp: Using pci_hp_add_bridge
In reply to Yinghai Luinstead of open code with pci_add_new_bus()/do_scan_bus...
--- drivers/pci/hotplug/ibmphp_core.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/pci/hotplug/ibmphp_core.c +4 -4
@@ -775,7 +775,6 @@ static u8 bus_structure_fixup(u8 busno)static int ibm_configure_device (struct pci_func *func) { -unsigned char bus;struct pci_bus *child;int num;int flag =0 ;/* this is to make sure we don't double scan the bus,
@@ -805,9 +804,10 @@ static int ibm_configure_device(struct pci_func *func) } }if (!(flag) && (func->dev->hdr_type ==PCI_HEADER_TYPE_BRIDGE )) { -pci_read_config_byte (func->dev,PCI_SECONDARY_BUS , &bus); - child =pci_add_new_bus (func->dev->bus, func->dev, bus); -pci_do_scan_bus (child); +pci_hp_add_bridge (func->dev); + child = func->dev->subordinate; +if (child) +pci_bus_add_devices (child); }return 0 ;
Signature · 1 line
1.7.7
PATCH 6/7 PCI, sgihp: Using pci_hp_add_bridge
In reply to Yinghai Luinstead of open code with pci_add_new_bus()/do_scan_bus...
--- drivers/pci/hotplug/sgi_hotplug.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-)
drivers/pci/hotplug/sgi_hotplug.c +5 -7
@@ -397,13 +397,11 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)else sn_io_slot_fixup (dev);if (dev->hdr_type ==PCI_HEADER_TYPE_BRIDGE ) { -unsigned char sec_bus; -pci_read_config_byte (dev,PCI_SECONDARY_BUS , - &sec_bus); - new_bus =pci_add_new_bus (dev->bus, dev, - sec_bus); -pci_scan_child_bus (new_bus); - new_ppb =1 ; +pci_hp_add_bridge (dev); +if (dev->subordinate) { + new_bus = dev->subordinate; + new_ppb =1 ; + } }pci_dev_put (dev); }
Signature · 1 line
1.7.7
PATCH 7/7 PCI, hotplug: remove pci_do_scan_bus()
In reply to Yinghai LuNow alll open code calling with that are gone.
So could get rid of pci_do_scan_bus()
--- drivers/pci/hotplug-pci.c | 15 --------------- drivers/pci/pci.h | 1 - 2 files changed, 0 insertions(+), 16 deletions(-)
drivers/pci/hotplug-pci.c +0 -15
@@ -27,18 +27,3 @@ int __ref pci_hp_add_bridge(struct pci_dev *dev)return 0 ; }EXPORT_SYMBOL_GPL (pci_hp_add_bridge); - -unsigned int __devinit pci_do_scan_bus (struct pci_bus *bus) -{ -unsigned int max; - - max =pci_scan_child_bus (bus); - -/* -* Make the discovered devices available. -*/ -pci_bus_add_devices (bus); - -return max; -} -EXPORT_SYMBOL (pci_do_scan_bus);
drivers/pci/pci.h +0 -1
@@ -125,7 +125,6 @@ static inline int pci_proc_detach_bus(struct pci_bus *bus) { return 0; }/* Functions for PCI Hotplug drivers to use */ int pci_hp_add_bridge (struct pci_dev *dev); -extern unsigned int pci_do_scan_bus (struct pci_bus *bus);#ifdef HAVE_PCI_LEGACY extern void pci_create_legacy_files (struct pci_bus *bus);
Signature · 1 line
1.7.7