* [PATCH 1/7] PCI, pciehp: Separate pci_hp_add_bridge()
2012-05-07 20:29 [PATCH 0/7] PCI: hotplug bridge replated clean up Yinghai Lu
@ 2012-05-07 20:29 ` Yinghai Lu
2012-05-07 20:29 ` [PATCH 2/7] PCI, cpci_hotplug: Simplify configure_slot Yinghai Lu
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Yinghai Lu @ 2012-05-07 20:29 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: linux-pci, Yinghai Lu
Will use it for other pci hp hotplug support
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
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(-)
diff --git a/drivers/pci/hotplug-pci.c b/drivers/pci/hotplug-pci.c
index d3509cd..1da0cae 100644
--- a/drivers/pci/hotplug-pci.c
+++ b/drivers/pci/hotplug-pci.c
@@ -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)
{
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
index 47d9dc0..09cecaf 100644
--- a/drivers/pci/hotplug/pciehp_pci.c
+++ b/drivers/pci/hotplug/pciehp_pci.c
@@ -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);
}
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index e494347..f3e14ce 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -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
--
1.7.7
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/7] PCI, cpci_hotplug: Simplify configure_slot
2012-05-07 20:29 [PATCH 0/7] PCI: hotplug bridge replated clean up Yinghai Lu
2012-05-07 20:29 ` [PATCH 1/7] PCI, pciehp: Separate pci_hp_add_bridge() Yinghai Lu
@ 2012-05-07 20:29 ` Yinghai Lu
2012-05-07 20:29 ` [PATCH 3/7] PCI, shpchp: Simplify configure_device Yinghai Lu
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Yinghai Lu @ 2012-05-07 20:29 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: linux-pci, Yinghai Lu
For child p2p bridge hotplug support should use pci_scan_bridge instead.
Make it more simillar to pciehp, just use pci_hp_add_bridge()
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/hotplug/cpci_hotplug_pci.c | 35 +++++--------------------------
1 files changed, 6 insertions(+), 29 deletions(-)
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c
index ae853cc..dcc75c7 100644
--- a/drivers/pci/hotplug/cpci_hotplug_pci.c
+++ b/drivers/pci/hotplug/cpci_hotplug_pci.c
@@ -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;
--
1.7.7
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/7] PCI, shpchp: Simplify configure_device
2012-05-07 20:29 [PATCH 0/7] PCI: hotplug bridge replated clean up Yinghai Lu
2012-05-07 20:29 ` [PATCH 1/7] PCI, pciehp: Separate pci_hp_add_bridge() Yinghai Lu
2012-05-07 20:29 ` [PATCH 2/7] PCI, cpci_hotplug: Simplify configure_slot Yinghai Lu
@ 2012-05-07 20:29 ` Yinghai Lu
2012-05-07 20:29 ` [PATCH 4/7] PCI, cpqhp: Using pci_hp_add_bridge Yinghai Lu
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Yinghai Lu @ 2012-05-07 20:29 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: linux-pci, Yinghai Lu
For child p2p bridge hotplug support should use pci_scan_bridge instead.
Make it more simillar to pciehp, just use pci_hp_add_bridge()
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/hotplug/shpchp_pci.c | 45 ++++++++++++-------------------------
1 files changed, 15 insertions(+), 30 deletions(-)
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c
index df7e4bf..c627ed9 100644
--- a/drivers/pci/hotplug/shpchp_pci.c
+++ b/drivers/pci/hotplug/shpchp_pci.c
@@ -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;
}
--
1.7.7
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/7] PCI, cpqhp: Using pci_hp_add_bridge
2012-05-07 20:29 [PATCH 0/7] PCI: hotplug bridge replated clean up Yinghai Lu
` (2 preceding siblings ...)
2012-05-07 20:29 ` [PATCH 3/7] PCI, shpchp: Simplify configure_device Yinghai Lu
@ 2012-05-07 20:29 ` Yinghai Lu
2012-05-07 20:29 ` [PATCH 5/7] PCI, ibmhp: " Yinghai Lu
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Yinghai Lu @ 2012-05-07 20:29 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: linux-pci, Yinghai Lu
instead of open code with pci_add_new_bus()/do_scan_bus...
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/hotplug/cpqphp_pci.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c
index 1c84940..09801c6 100644
--- a/drivers/pci/hotplug/cpqphp_pci.c
+++ b/drivers/pci/hotplug/cpqphp_pci.c
@@ -83,7 +83,6 @@ static void __iomem *detect_HRT_floating_pointer(void __iomem *begin, void __iom
int 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);
--
1.7.7
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/7] PCI, ibmhp: Using pci_hp_add_bridge
2012-05-07 20:29 [PATCH 0/7] PCI: hotplug bridge replated clean up Yinghai Lu
` (3 preceding siblings ...)
2012-05-07 20:29 ` [PATCH 4/7] PCI, cpqhp: Using pci_hp_add_bridge Yinghai Lu
@ 2012-05-07 20:29 ` Yinghai Lu
2012-05-07 20:29 ` [PATCH 6/7] PCI, sgihp: " Yinghai Lu
2012-05-07 20:29 ` [PATCH 7/7] PCI, hotplug: remove pci_do_scan_bus() Yinghai Lu
6 siblings, 0 replies; 8+ messages in thread
From: Yinghai Lu @ 2012-05-07 20:29 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: linux-pci, Yinghai Lu
instead of open code with pci_add_new_bus()/do_scan_bus...
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/hotplug/ibmphp_core.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index 4fda7e6..7dccad5 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -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;
--
1.7.7
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/7] PCI, sgihp: Using pci_hp_add_bridge
2012-05-07 20:29 [PATCH 0/7] PCI: hotplug bridge replated clean up Yinghai Lu
` (4 preceding siblings ...)
2012-05-07 20:29 ` [PATCH 5/7] PCI, ibmhp: " Yinghai Lu
@ 2012-05-07 20:29 ` Yinghai Lu
2012-05-07 20:29 ` [PATCH 7/7] PCI, hotplug: remove pci_do_scan_bus() Yinghai Lu
6 siblings, 0 replies; 8+ messages in thread
From: Yinghai Lu @ 2012-05-07 20:29 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: linux-pci, Yinghai Lu
instead of open code with pci_add_new_bus()/do_scan_bus...
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/hotplug/sgi_hotplug.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index de57311..f64ca92 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -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);
}
--
1.7.7
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 7/7] PCI, hotplug: remove pci_do_scan_bus()
2012-05-07 20:29 [PATCH 0/7] PCI: hotplug bridge replated clean up Yinghai Lu
` (5 preceding siblings ...)
2012-05-07 20:29 ` [PATCH 6/7] PCI, sgihp: " Yinghai Lu
@ 2012-05-07 20:29 ` Yinghai Lu
6 siblings, 0 replies; 8+ messages in thread
From: Yinghai Lu @ 2012-05-07 20:29 UTC (permalink / raw)
To: Bjorn Helgaas; +Cc: linux-pci, Yinghai Lu
Now alll open code calling with that are gone.
So could get rid of pci_do_scan_bus()
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
drivers/pci/hotplug-pci.c | 15 ---------------
drivers/pci/pci.h | 1 -
2 files changed, 0 insertions(+), 16 deletions(-)
diff --git a/drivers/pci/hotplug-pci.c b/drivers/pci/hotplug-pci.c
index 1da0cae..01eae34 100644
--- a/drivers/pci/hotplug-pci.c
+++ b/drivers/pci/hotplug-pci.c
@@ -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);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index f3e14ce..1c56ea8 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -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);
--
1.7.7
^ permalink raw reply related [flat|nested] 8+ messages in thread