All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver
@ 2013-01-21 21:20 Yinghai Lu
  2013-01-21 21:20 ` [PATCH v10 01/11] PCI, acpiphp: Add is_hotplug_bridge detection Yinghai Lu
                   ` (11 more replies)
  0 siblings, 12 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-21 21:20 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu

It includes
1. preparing patches for pci root bus hotadd/hotremove support
2. move root bus hotadd from acpiphp to pci_root.c
3. add hot-remove support
4. add acpi_hp_work to be shared with acpiphp and root-bus hotplug
5. add match_driver to add pci device to device tree early but
   not attach driver for hotplug path.

based on pci/next + pm/acpi-scan

could get from
        git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-root-bus-hotplug

-v9: merges several patches together for easy review, requested by Rafael.
-v10: address comments from Rafael.

Jiang Liu (2):
  PCI: Fix a device reference count leakage issue in pci_dev_present()
  PCI: make PCI device create/destroy logic symmetric

Tang Chen (1):
  PCI, ACPI: debug print for installation of acpi root bridge's
    notifier

Yinghai Lu (8):
  PCI, acpiphp: Add is_hotplug_bridge detection
  PCI: Add root bus children dev's res to fail list
  PCI: Set dev_node early for pci_dev
  PCI, ACPI, acpiphp: Rename alloc_acpiphp_hp_work() to alloc_acpi_hp_work
  PCI, acpiphp: Move and enhance hotplug support of pci host bridge
  PCI, acpiphp: Don't bailout even no slots found yet.
  PCI: Skip attaching driver in device_add()
  PCI: Put pci dev to device tree as early as possible

 drivers/acpi/internal.h            |    1 +
 drivers/acpi/osl.c                 |   24 +++++-
 drivers/acpi/pci_root.c            |  130 +++++++++++++++++++++++++++++++
 drivers/acpi/scan.c                |    3 +
 drivers/pci/bus.c                  |   87 +++++----------------
 drivers/pci/hotplug/acpiphp.h      |    1 -
 drivers/pci/hotplug/acpiphp_core.c |   23 +-----
 drivers/pci/hotplug/acpiphp_glue.c |  150 +++++++++++-------------------------
 drivers/pci/iov.c                  |    9 +--
 drivers/pci/pci-driver.c           |    6 +-
 drivers/pci/pci.h                  |    1 -
 drivers/pci/probe.c                |   35 +++++++--
 drivers/pci/remove.c               |    4 +-
 drivers/pci/search.c               |   10 +--
 drivers/pci/setup-bus.c            |    2 +-
 include/acpi/acpi_bus.h            |    9 +++
 include/acpi/acpiosxf.h            |    2 -
 include/linux/pci.h                |    1 +
 18 files changed, 277 insertions(+), 221 deletions(-)

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 122+ messages in thread

* [PATCH v10 01/11] PCI, acpiphp: Add is_hotplug_bridge detection
  2013-01-21 21:20 [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Yinghai Lu
@ 2013-01-21 21:20 ` Yinghai Lu
  2013-01-21 21:20 ` [PATCH v10 02/11] PCI: Add root bus children dev's res to fail list Yinghai Lu
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-21 21:20 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu

When system support hotplug bridge with children hotplug slots, we need
to make sure that parent bridge get preallocated resource so later when
device is plugged into children slot, those children devices will get
resource allocated.

We do not meet this problem, because for pcie hotplug card, when acpiphp
is used, pci_scan_bridge will set that for us when detect hotplug bit in
slot cap.

Reported-and-tested-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: Jason Baron <jbaron@redhat.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/pci/hotplug/acpiphp_glue.c |   27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 9e2b1f6..b94879d 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -797,6 +797,29 @@ static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
 	}
 }
 
+static void check_hotplug_bridge(struct acpiphp_slot *slot, struct pci_dev *dev)
+{
+	struct acpiphp_func *func;
+
+	if (!dev->subordinate)
+		return;
+
+	/* quirk, or pcie could set it already */
+	if (dev->is_hotplug_bridge)
+		return;
+
+	if (PCI_SLOT(dev->devfn) != slot->device)
+		return;
+
+	list_for_each_entry(func, &slot->funcs, sibling) {
+		if (PCI_FUNC(dev->devfn) == func->function) {
+			/* check if this bridge has ejectable slots */
+			if ((detect_ejectable_slots(func->handle) > 0))
+				dev->is_hotplug_bridge = 1;
+			break;
+		}
+	}
+}
 /**
  * enable_device - enable, configure a slot
  * @slot: slot to be enabled
@@ -831,8 +854,10 @@ static int __ref enable_device(struct acpiphp_slot *slot)
 			if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
 			    dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
 				max = pci_scan_bridge(bus, dev, max, pass);
-				if (pass && dev->subordinate)
+				if (pass && dev->subordinate) {
+					check_hotplug_bridge(slot, dev);
 					pci_bus_size_bridges(dev->subordinate);
+				}
 			}
 		}
 	}
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v10 02/11] PCI: Add root bus children dev's res to fail list
  2013-01-21 21:20 [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Yinghai Lu
  2013-01-21 21:20 ` [PATCH v10 01/11] PCI, acpiphp: Add is_hotplug_bridge detection Yinghai Lu
@ 2013-01-21 21:20 ` Yinghai Lu
  2013-01-21 21:20 ` [PATCH v10 03/11] PCI: Set dev_node early for pci_dev Yinghai Lu
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-21 21:20 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu

We can stop trying according to try_number now and do not need to use
root_bus checking as stop sign.

In extreme case we could need to reallocate resource for device just
under root bus. For pci root bus hot-add, we need to retry to assign
resources to pci devices just under pci root bus.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/pci/setup-bus.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 6d3591d..7e8739e 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -283,7 +283,7 @@ static void assign_requested_resources_sorted(struct list_head *head,
 		idx = res - &dev_res->dev->resource[0];
 		if (resource_size(res) &&
 		    pci_assign_resource(dev_res->dev, idx)) {
-			if (fail_head && !pci_is_root_bus(dev_res->dev->bus)) {
+			if (fail_head) {
 				/*
 				 * if the failed res is for ROM BAR, and it will
 				 * be enabled later, don't add it to the list
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v10 03/11] PCI: Set dev_node early for pci_dev
  2013-01-21 21:20 [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Yinghai Lu
  2013-01-21 21:20 ` [PATCH v10 01/11] PCI, acpiphp: Add is_hotplug_bridge detection Yinghai Lu
  2013-01-21 21:20 ` [PATCH v10 02/11] PCI: Add root bus children dev's res to fail list Yinghai Lu
@ 2013-01-21 21:20 ` Yinghai Lu
  2013-01-21 21:20 ` [PATCH v10 04/11] PCI: Fix a device reference count leakage issue in pci_dev_present() Yinghai Lu
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-21 21:20 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu

Otherwise irq_desc for pci bridge with hot-added ioapic can not be on
local node.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/pci/probe.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index bbe4be7..dcef3b9 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1300,6 +1300,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
 	dev->dev.release = pci_release_dev;
 	pci_dev_get(dev);
 
+	set_dev_node(&dev->dev, pcibus_to_node(bus));
 	dev->dev.dma_mask = &dev->dma_mask;
 	dev->dev.dma_parms = &dev->dma_parms;
 	dev->dev.coherent_dma_mask = 0xffffffffull;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v10 04/11] PCI: Fix a device reference count leakage issue in pci_dev_present()
  2013-01-21 21:20 [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Yinghai Lu
                   ` (2 preceding siblings ...)
  2013-01-21 21:20 ` [PATCH v10 03/11] PCI: Set dev_node early for pci_dev Yinghai Lu
@ 2013-01-21 21:20 ` Yinghai Lu
  2013-01-21 21:20 ` [PATCH v10 05/11] PCI: make PCI device create/destroy logic symmetric Yinghai Lu
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-21 21:20 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu

From: Jiang Liu <jiang.liu@huawei.com>

Function pci_get_dev_by_id() will hold a reference count on the pci device
returned, so pci_dev_present() should release the corresponding reference
count to avoid memory leakage.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/search.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index bf969ba..d0627fa 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -319,13 +319,13 @@ int pci_dev_present(const struct pci_device_id *ids)
 	WARN_ON(in_interrupt());
 	while (ids->vendor || ids->subvendor || ids->class_mask) {
 		found = pci_get_dev_by_id(ids, NULL);
-		if (found)
-			goto exit;
+		if (found) {
+			pci_dev_put(found);
+			return 1;
+		}
 		ids++;
 	}
-exit:
-	if (found)
-		return 1;
+
 	return 0;
 }
 EXPORT_SYMBOL(pci_dev_present);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v10 05/11] PCI: make PCI device create/destroy logic symmetric
  2013-01-21 21:20 [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Yinghai Lu
                   ` (3 preceding siblings ...)
  2013-01-21 21:20 ` [PATCH v10 04/11] PCI: Fix a device reference count leakage issue in pci_dev_present() Yinghai Lu
@ 2013-01-21 21:20 ` Yinghai Lu
  2013-01-21 21:20 ` [PATCH v10 06/11] PCI, ACPI, acpiphp: Rename alloc_acpiphp_hp_work() to alloc_acpi_hp_work Yinghai Lu
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-21 21:20 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi

From: Jiang Liu <jiang.liu@huawei.com>

According to device model documentation, the way to create/destroy PCI
devices should be symmetric.

/**
 * device_del - delete device from system.
 * @dev: device.
 *
 * This is the first part of the device unregistration
 * sequence. This removes the device from the lists we control
 * from here, has it removed from the other driver model
 * subsystems it was added to in device_add(), and removes it
 * from the kobject hierarchy.
 *
 * NOTE: this should be called manually _iff_ device_add() was
 * also called manually.
 */

The rule is to either use
1) device_register()/device_unregister()
or
2) device_initialize()/device_add()/device_del()/put_device().

So change PCI core logic to follow the rule and get rid of the redundant
pci_dev_get()/pci_dev_put() pair.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/pci/probe.c  |    1 -
 drivers/pci/remove.c |    4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index dcef3b9..9588207 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1298,7 +1298,6 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
 {
 	device_initialize(&dev->dev);
 	dev->dev.release = pci_release_dev;
-	pci_dev_get(dev);
 
 	set_dev_node(&dev->dev, pcibus_to_node(bus));
 	dev->dev.dma_mask = &dev->dma_mask;
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index 7c0fd92..fc38c48 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -22,7 +22,7 @@ static void pci_stop_dev(struct pci_dev *dev)
 	if (dev->is_added) {
 		pci_proc_detach_device(dev);
 		pci_remove_sysfs_dev_files(dev);
-		device_unregister(&dev->dev);
+		device_del(&dev->dev);
 		dev->is_added = 0;
 	}
 
@@ -37,7 +37,7 @@ static void pci_destroy_dev(struct pci_dev *dev)
 	up_write(&pci_bus_sem);
 
 	pci_free_resources(dev);
-	pci_dev_put(dev);
+	put_device(&dev->dev);
 }
 
 void pci_remove_bus(struct pci_bus *bus)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v10 06/11] PCI, ACPI, acpiphp: Rename alloc_acpiphp_hp_work() to alloc_acpi_hp_work
  2013-01-21 21:20 [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Yinghai Lu
                   ` (4 preceding siblings ...)
  2013-01-21 21:20 ` [PATCH v10 05/11] PCI: make PCI device create/destroy logic symmetric Yinghai Lu
@ 2013-01-21 21:20 ` Yinghai Lu
  2013-01-21 21:20 ` [PATCH v10 07/11] PCI, acpiphp: Move and enhance hotplug support of pci host bridge Yinghai Lu
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-21 21:20 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu

Will need to use it for pci root bridge hotplug support, rename
*acpiphp* to *acpi* and move to osc.c.
Also make kacpi_hotplug_wq static after that.

-v2: Change export to _GPL, and move declaration of alloc_acpi_hp_work
     to acpi_bus.h according to Rafael.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
---
 drivers/acpi/osl.c                 |   24 +++++++++++++++++++--
 drivers/pci/hotplug/acpiphp_glue.c |   42 ++++++------------------------------
 include/acpi/acpi_bus.h            |    9 ++++++++
 include/acpi/acpiosxf.h            |    2 --
 4 files changed, 37 insertions(+), 40 deletions(-)

diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 3ff2678..59ec5f5 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -84,8 +84,7 @@ static acpi_osd_handler acpi_irq_handler;
 static void *acpi_irq_context;
 static struct workqueue_struct *kacpid_wq;
 static struct workqueue_struct *kacpi_notify_wq;
-struct workqueue_struct *kacpi_hotplug_wq;
-EXPORT_SYMBOL(kacpi_hotplug_wq);
+static struct workqueue_struct *kacpi_hotplug_wq;
 
 /*
  * This list of permanent mappings is for memory that may be accessed from
@@ -1778,3 +1777,24 @@ void acpi_os_set_prepare_sleep(int (*func)(u8 sleep_state,
 {
 	__acpi_os_prepare_sleep = func;
 }
+
+void alloc_acpi_hp_work(acpi_handle handle, u32 type, void *context,
+			void (*func)(struct work_struct *work))
+{
+	struct acpi_hp_work *hp_work;
+	int ret;
+
+	hp_work = kmalloc(sizeof(*hp_work), GFP_KERNEL);
+	if (!hp_work)
+		return;
+
+	hp_work->handle = handle;
+	hp_work->type = type;
+	hp_work->context = context;
+
+	INIT_WORK(&hp_work->work, func);
+	ret = queue_work(kacpi_hotplug_wq, &hp_work->work);
+	if (!ret)
+		kfree(hp_work);
+}
+EXPORT_SYMBOL_GPL(alloc_acpi_hp_work);
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index b94879d..bf338d2 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -1203,34 +1203,6 @@ check_sub_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
 	return AE_OK ;
 }
 
-struct acpiphp_hp_work {
-	struct work_struct work;
-	acpi_handle handle;
-	u32 type;
-	void *context;
-};
-
-static void alloc_acpiphp_hp_work(acpi_handle handle, u32 type,
-				  void *context,
-				  void (*func)(struct work_struct *work))
-{
-	struct acpiphp_hp_work *hp_work;
-	int ret;
-
-	hp_work = kmalloc(sizeof(*hp_work), GFP_KERNEL);
-	if (!hp_work)
-		return;
-
-	hp_work->handle = handle;
-	hp_work->type = type;
-	hp_work->context = context;
-
-	INIT_WORK(&hp_work->work, func);
-	ret = queue_work(kacpi_hotplug_wq, &hp_work->work);
-	if (!ret)
-		kfree(hp_work);
-}
-
 static void _handle_hotplug_event_bridge(struct work_struct *work)
 {
 	struct acpiphp_bridge *bridge;
@@ -1239,11 +1211,11 @@ static void _handle_hotplug_event_bridge(struct work_struct *work)
 				      .pointer = objname };
 	struct acpi_device *device;
 	int num_sub_bridges = 0;
-	struct acpiphp_hp_work *hp_work;
+	struct acpi_hp_work *hp_work;
 	acpi_handle handle;
 	u32 type;
 
-	hp_work = container_of(work, struct acpiphp_hp_work, work);
+	hp_work = container_of(work, struct acpi_hp_work, work);
 	handle = hp_work->handle;
 	type = hp_work->type;
 
@@ -1346,8 +1318,7 @@ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type,
 	 * For now just re-add this work to the kacpi_hotplug_wq so we
 	 * don't deadlock on hotplug actions.
 	 */
-	alloc_acpiphp_hp_work(handle, type, context,
-			      _handle_hotplug_event_bridge);
+	alloc_acpi_hp_work(handle, type, context, _handle_hotplug_event_bridge);
 }
 
 static void _handle_hotplug_event_func(struct work_struct *work)
@@ -1356,12 +1327,12 @@ static void _handle_hotplug_event_func(struct work_struct *work)
 	char objname[64];
 	struct acpi_buffer buffer = { .length = sizeof(objname),
 				      .pointer = objname };
-	struct acpiphp_hp_work *hp_work;
+	struct acpi_hp_work *hp_work;
 	acpi_handle handle;
 	u32 type;
 	void *context;
 
-	hp_work = container_of(work, struct acpiphp_hp_work, work);
+	hp_work = container_of(work, struct acpi_hp_work, work);
 	handle = hp_work->handle;
 	type = hp_work->type;
 	context = hp_work->context;
@@ -1422,8 +1393,7 @@ static void handle_hotplug_event_func(acpi_handle handle, u32 type,
 	 * For now just re-add this work to the kacpi_hotplug_wq so we
 	 * don't deadlock on hotplug actions.
 	 */
-	alloc_acpiphp_hp_work(handle, type, context,
-			      _handle_hotplug_event_func);
+	alloc_acpi_hp_work(handle, type, context, _handle_hotplug_event_func);
 }
 
 static acpi_status
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 526d663..5ce8d5e8 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -310,6 +310,15 @@ struct acpi_eject_event {
 	u32		event;
 };
 
+struct acpi_hp_work {
+	struct work_struct work;
+	acpi_handle handle;
+	u32 type;
+	void *context;
+};
+void alloc_acpi_hp_work(acpi_handle handle, u32 type, void *context,
+			void (*func)(struct work_struct *work));
+
 extern struct kobject *acpi_kobj;
 extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
 void acpi_bus_private_data_handler(acpi_handle, void *);
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
index 4315274..66f1fd7 100644
--- a/include/acpi/acpiosxf.h
+++ b/include/acpi/acpiosxf.h
@@ -193,8 +193,6 @@ void acpi_os_fixed_event_count(u32 fixed_event_number);
 /*
  * Threads and Scheduling
  */
-extern struct workqueue_struct *kacpi_hotplug_wq;
-
 acpi_thread_id acpi_os_get_thread_id(void);
 
 acpi_status
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v10 07/11] PCI, acpiphp: Move and enhance hotplug support of pci host bridge
  2013-01-21 21:20 [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Yinghai Lu
                   ` (5 preceding siblings ...)
  2013-01-21 21:20 ` [PATCH v10 06/11] PCI, ACPI, acpiphp: Rename alloc_acpiphp_hp_work() to alloc_acpi_hp_work Yinghai Lu
@ 2013-01-21 21:20 ` Yinghai Lu
  2013-01-21 21:20 ` [PATCH v10 08/11] PCI, ACPI: debug print for installation of acpi root bridge's notifier Yinghai Lu
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-21 21:20 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu

We have partial hot-add support in acpiphp driver, and it is confusing.

Move host bridge hot-add support to pci_root.c, and keep acpiphp simple,
also add hot-remove support in pci_root.c.

How to test it: if sci_emu patch is applied,

Find out root bus number to acpi root name mapping from dmesg or /sys

  echo "\_SB.PCIB 3" > /sys/kernel/debug/acpi/sci_notify
to remove root bus

  echo "\_SB.PCIB 1" > /sys/kernel/debug/acpi/sci_notify
to add back root bus

-v2: put back pci_root_hp change in one patch
-v3: add pcibios_resource_survey_bus() calling
-v4: remove not needed code with remove_bridge
-v5: put back support for acpiphp support for slots just on root bus.
-v6: change some functions to *_p2p_* to make it more clean.
-v7: split hot_added change out.
-v8: Move to pci_root.c instead of adding another file requested by Bjorn.
-v9: Fold three following patches into this one for easy review:
	a: Add missing hot_remove support for root device.
	b: Tang Chen noticed that hotplug through container will not update
	   acpi_root_bridge list. After closely checking, we don't need
	   that for struct for tracking and could use acpi_pci_root directly.
	c: Tang Chen found handle_root_bridge_removal is very similiar to
	   acpi_bus_hot_remove_device().  Change to handle_root_bridge_removal
	   to use acpi_bus_hot_remove_device.
-v10: According to Rafael:
	a. don't use __initcall for acpi_pci_root_hp_init.
	b. bail out on hot add path if acpi device exists.
	c. don't use fixed size buffer with root bridge handle name.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/acpi/internal.h            |    1 +
 drivers/acpi/pci_root.c            |  124 ++++++++++++++++++++++++++++++++++++
 drivers/acpi/scan.c                |    3 +
 drivers/pci/hotplug/acpiphp_glue.c |   59 +++++------------
 4 files changed, 143 insertions(+), 44 deletions(-)

diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index e050254..0f24148 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -68,6 +68,7 @@ struct acpi_ec {
 extern struct acpi_ec *first_ec;
 
 int acpi_pci_root_init(void);
+void acpi_pci_root_hp_init(void);
 int acpi_ec_init(void);
 int acpi_ec_ecdt_probe(void);
 int acpi_boot_ec_enable(void);
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index bf5108a..a2d2c4c 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -655,3 +655,127 @@ int __init acpi_pci_root_init(void)
 
 	return 0;
 }
+/* Support root bridge hotplug */
+
+static void handle_root_bridge_insertion(acpi_handle handle)
+{
+	struct acpi_device *device;
+
+	if (!acpi_bus_get_device(handle, &device)) {
+		printk(KERN_DEBUG "acpi device exists...\n");
+		return;
+	}
+
+	if (acpi_bus_scan(handle))
+		printk(KERN_ERR "cannot add bridge to acpi list\n");
+}
+
+static void handle_root_bridge_removal(struct acpi_device *device)
+{
+	struct acpi_eject_event *ej_event;
+
+	ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL);
+	if (!ej_event) {
+		/* Inform firmware the hot-remove operation has error */
+		(void) acpi_evaluate_hotplug_ost(device->handle,
+					ACPI_NOTIFY_EJECT_REQUEST,
+					ACPI_OST_SC_NON_SPECIFIC_FAILURE,
+					NULL);
+		return;
+	}
+
+	ej_event->device = device;
+	ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
+
+	acpi_bus_hot_remove_device(ej_event);
+}
+
+static void _handle_hotplug_event_root(struct work_struct *work)
+{
+	struct acpi_pci_root *root;
+	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER };
+	struct acpi_hp_work *hp_work;
+	acpi_handle handle;
+	u32 type;
+
+	hp_work = container_of(work, struct acpi_hp_work, work);
+	handle = hp_work->handle;
+	type = hp_work->type;
+
+	root = acpi_pci_find_root(handle);
+
+	acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
+
+	switch (type) {
+	case ACPI_NOTIFY_BUS_CHECK:
+		/* bus enumerate */
+		printk(KERN_DEBUG "%s: Bus check notify on %s\n", __func__,
+				 (char *)buffer.pointer);
+		if (!root)
+			handle_root_bridge_insertion(handle);
+
+		break;
+
+	case ACPI_NOTIFY_DEVICE_CHECK:
+		/* device check */
+		printk(KERN_DEBUG "%s: Device check notify on %s\n", __func__,
+				 (char *)buffer.pointer);
+		if (!root)
+			handle_root_bridge_insertion(handle);
+		break;
+
+	case ACPI_NOTIFY_EJECT_REQUEST:
+		/* request device eject */
+		printk(KERN_DEBUG "%s: Device eject notify on %s\n", __func__,
+				 (char *)buffer.pointer);
+		if (root)
+			handle_root_bridge_removal(root->device);
+		break;
+	default:
+		printk(KERN_WARNING "notify_handler: unknown event type 0x%x for %s\n",
+				 type, (char *)buffer.pointer);
+		break;
+	}
+
+	kfree(hp_work); /* allocated in handle_hotplug_event_bridge */
+	kfree(buffer.pointer);
+}
+
+static void handle_hotplug_event_root(acpi_handle handle, u32 type,
+					void *context)
+{
+	alloc_acpi_hp_work(handle, type, context,
+				_handle_hotplug_event_root);
+}
+
+static acpi_status __init
+find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+	char objname[64];
+	struct acpi_buffer buffer = { .length = sizeof(objname),
+				      .pointer = objname };
+	int *count = (int *)context;
+
+	if (!acpi_is_root_bridge(handle))
+		return AE_OK;
+
+	(*count)++;
+
+	acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
+
+	acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
+				handle_hotplug_event_root, NULL);
+	printk(KERN_DEBUG "acpi root: %s notify handler installed\n", objname);
+
+	return AE_OK;
+}
+
+void __init acpi_pci_root_hp_init(void)
+{
+	int num = 0;
+
+	acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+		ACPI_UINT32_MAX, find_root_bridges, NULL, &num, NULL);
+
+	printk(KERN_DEBUG "Found %d acpi root devices\n", num);
+}
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 7c43bdc..bc2f337 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1706,5 +1706,8 @@ int __init acpi_scan_init(void)
 	}
 
 	acpi_update_all_gpes();
+
+	acpi_pci_root_hp_init();
+
 	return 0;
 }
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index bf338d2..c4a6301 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -543,10 +543,13 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
 	acpi_status status;
 	acpi_handle handle = bridge->handle;
 
-	status = acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
+	if (bridge->type != BRIDGE_TYPE_HOST) {
+		status = acpi_remove_notify_handler(handle,
+					    ACPI_SYSTEM_NOTIFY,
 					    handle_hotplug_event_bridge);
-	if (ACPI_FAILURE(status))
-		err("failed to remove notify handler\n");
+		if (ACPI_FAILURE(status))
+			err("failed to remove notify handler\n");
+	}
 
 	if ((bridge->type != BRIDGE_TYPE_HOST) &&
 	    ((bridge->flags & BRIDGE_HAS_EJ0) && bridge->func)) {
@@ -630,9 +633,6 @@ static void remove_bridge(struct acpi_pci_root *root)
 	bridge = acpiphp_handle_to_bridge(handle);
 	if (bridge)
 		cleanup_bridge(bridge);
-	else
-		acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
-					   handle_hotplug_event_bridge);
 }
 
 static int power_on_slot(struct acpiphp_slot *slot)
@@ -1123,18 +1123,12 @@ static void acpiphp_sanitize_bus(struct pci_bus *bus)
 }
 
 /* Program resources in newly inserted bridge */
-static int acpiphp_configure_bridge (acpi_handle handle)
+static int acpiphp_configure_p2p_bridge(acpi_handle handle)
 {
-	struct pci_bus *bus;
+	struct pci_dev *pdev = acpi_get_pci_dev(handle);
+	struct pci_bus *bus = pdev->subordinate;
 
-	if (acpi_is_root_bridge(handle)) {
-		struct acpi_pci_root *root = acpi_pci_find_root(handle);
-		bus = root->bus;
-	} else {
-		struct pci_dev *pdev = acpi_get_pci_dev(handle);
-		bus = pdev->subordinate;
-		pci_dev_put(pdev);
-	}
+	pci_dev_put(pdev);
 
 	pci_bus_size_bridges(bus);
 	pci_bus_assign_resources(bus);
@@ -1144,7 +1138,7 @@ static int acpiphp_configure_bridge (acpi_handle handle)
 	return 0;
 }
 
-static void handle_bridge_insertion(acpi_handle handle, u32 type)
+static void handle_p2p_bridge_insertion(acpi_handle handle, u32 type)
 {
 	struct acpi_device *device;
 
@@ -1162,8 +1156,8 @@ static void handle_bridge_insertion(acpi_handle handle, u32 type)
 		err("ACPI device object missing\n");
 		return;
 	}
-	if (!acpiphp_configure_bridge(handle))
-		add_bridge(handle);
+	if (!acpiphp_configure_p2p_bridge(handle))
+		add_p2p_bridge(handle);
 	else
 		err("cannot configure and start bridge\n");
 
@@ -1221,7 +1215,7 @@ static void _handle_hotplug_event_bridge(struct work_struct *work)
 
 	if (acpi_bus_get_device(handle, &device)) {
 		/* This bridge must have just been physically inserted */
-		handle_bridge_insertion(handle, type);
+		handle_p2p_bridge_insertion(handle, type);
 		goto out;
 	}
 
@@ -1396,21 +1390,6 @@ static void handle_hotplug_event_func(acpi_handle handle, u32 type,
 	alloc_acpi_hp_work(handle, type, context, _handle_hotplug_event_func);
 }
 
-static acpi_status
-find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
-{
-	int *count = (int *)context;
-
-	if (!acpi_is_root_bridge(handle))
-		return AE_OK;
-
-	(*count)++;
-	acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
-				    handle_hotplug_event_bridge, NULL);
-
-	return AE_OK ;
-}
-
 static struct acpi_pci_driver acpi_pci_hp_driver = {
 	.add =		add_bridge,
 	.remove =	remove_bridge,
@@ -1421,15 +1400,7 @@ static struct acpi_pci_driver acpi_pci_hp_driver = {
  */
 int __init acpiphp_glue_init(void)
 {
-	int num = 0;
-
-	acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
-			ACPI_UINT32_MAX, find_root_bridges, NULL, &num, NULL);
-
-	if (num <= 0)
-		return -1;
-	else
-		acpi_pci_register_driver(&acpi_pci_hp_driver);
+	acpi_pci_register_driver(&acpi_pci_hp_driver);
 
 	return 0;
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v10 08/11] PCI, ACPI: debug print for installation of acpi root bridge's notifier
  2013-01-21 21:20 [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Yinghai Lu
                   ` (6 preceding siblings ...)
  2013-01-21 21:20 ` [PATCH v10 07/11] PCI, acpiphp: Move and enhance hotplug support of pci host bridge Yinghai Lu
@ 2013-01-21 21:20 ` Yinghai Lu
  2013-01-21 21:20 ` [PATCH v10 09/11] PCI, acpiphp: Don't bailout even no slots found yet Yinghai Lu
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-21 21:20 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Tang Chen, Yinghai Lu

From: Tang Chen <tangchen@cn.fujitsu.com>

acpi_install_notify_handler() could fail. So check the exit status
and give a better debug info.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/acpi/pci_root.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index a2d2c4c..417487a 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -751,6 +751,7 @@ static void handle_hotplug_event_root(acpi_handle handle, u32 type,
 static acpi_status __init
 find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
 {
+	acpi_status status;
 	char objname[64];
 	struct acpi_buffer buffer = { .length = sizeof(objname),
 				      .pointer = objname };
@@ -763,9 +764,14 @@ find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
 
 	acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
 
-	acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
-				handle_hotplug_event_root, NULL);
-	printk(KERN_DEBUG "acpi root: %s notify handler installed\n", objname);
+	status = acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
+					handle_hotplug_event_root, NULL);
+	if (ACPI_FAILURE(status))
+		printk(KERN_DEBUG "acpi root: %s notify handler is not installed, exit status: %u\n",
+				  objname, (unsigned int)status);
+	else
+		printk(KERN_DEBUG "acpi root: %s notify handler is installed\n",
+				 objname);
 
 	return AE_OK;
 }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v10 09/11] PCI, acpiphp: Don't bailout even no slots found yet.
  2013-01-21 21:20 [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Yinghai Lu
                   ` (7 preceding siblings ...)
  2013-01-21 21:20 ` [PATCH v10 08/11] PCI, ACPI: debug print for installation of acpi root bridge's notifier Yinghai Lu
@ 2013-01-21 21:20 ` Yinghai Lu
  2013-01-21 21:20 ` [PATCH v10 10/11] PCI: Skip attaching driver in device_add() Yinghai Lu
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-21 21:20 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu

Could have root bus hot added later and there may be slots that need acpiphp.

The result returned by acpiphp_get_num_slots() is meaningless, because
the bridge the slots are under may be added after this function has been
called, so drop acpiphp_get_num_slots() and the code using it.

-v2: add changelog about why we could get rid of acpiphp_get_name_slots()
     from Rafael.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/pci/hotplug/acpiphp.h      |    1 -
 drivers/pci/hotplug/acpiphp_core.c |   23 ++---------------------
 drivers/pci/hotplug/acpiphp_glue.c |   22 ----------------------
 3 files changed, 2 insertions(+), 44 deletions(-)

diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index a1afb5b..b3ead7a 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -193,7 +193,6 @@ extern void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot);
 /* acpiphp_glue.c */
 extern int acpiphp_glue_init (void);
 extern void acpiphp_glue_exit (void);
-extern int acpiphp_get_num_slots (void);
 typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
 
 extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index 96316b7..c2fd309 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -50,7 +50,6 @@
 bool acpiphp_debug;
 
 /* local variables */
-static int num_slots;
 static struct acpiphp_attention_info *attention_info;
 
 #define DRIVER_VERSION	"0.5"
@@ -272,25 +271,6 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	return 0;
 }
 
-static int __init init_acpi(void)
-{
-	int retval;
-
-	/* initialize internal data structure etc. */
-	retval = acpiphp_glue_init();
-
-	/* read initial number of slots */
-	if (!retval) {
-		num_slots = acpiphp_get_num_slots();
-		if (num_slots == 0) {
-			acpiphp_glue_exit();
-			retval = -ENODEV;
-		}
-	}
-
-	return retval;
-}
-
 /**
  * release_slot - free up the memory used by a slot
  * @hotplug_slot: slot to free
@@ -379,7 +359,8 @@ static int __init acpiphp_init(void)
 		return 0;
 
 	/* read all the ACPI info from the system */
-	return init_acpi();
+	/* initialize internal data structure etc. */
+	return acpiphp_glue_init();
 }
 
 
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index c4a6301..bd784ff 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -1416,28 +1416,6 @@ void  acpiphp_glue_exit(void)
 	acpi_pci_unregister_driver(&acpi_pci_hp_driver);
 }
 
-
-/**
- * acpiphp_get_num_slots - count number of slots in a system
- */
-int __init acpiphp_get_num_slots(void)
-{
-	struct acpiphp_bridge *bridge;
-	int num_slots = 0;
-
-	list_for_each_entry(bridge, &bridge_list, list) {
-		dbg("Bus %04x:%02x has %d slot%s\n",
-				pci_domain_nr(bridge->pci_bus),
-				bridge->pci_bus->number, bridge->nr_slots,
-				bridge->nr_slots == 1 ? "" : "s");
-		num_slots += bridge->nr_slots;
-	}
-
-	dbg("Total %d slots\n", num_slots);
-	return num_slots;
-}
-
-
 /**
  * acpiphp_enable_slot - power on slot
  * @slot: ACPI PHP slot
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v10 10/11] PCI: Skip attaching driver in device_add()
  2013-01-21 21:20 [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Yinghai Lu
                   ` (8 preceding siblings ...)
  2013-01-21 21:20 ` [PATCH v10 09/11] PCI, acpiphp: Don't bailout even no slots found yet Yinghai Lu
@ 2013-01-21 21:20 ` Yinghai Lu
  2013-01-21 21:20 ` [PATCH v10 11/11] PCI: Put pci dev to device tree as early as possible Yinghai Lu
  2013-01-22 22:09 ` [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Rafael J. Wysocki
  11 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-21 21:20 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu

We want to add pci device to device tree as early as possible but
delay attach driver in next following path.

To make that patch smaller, in this patch:

We add match_driver field in pci_dev and default vaule is false, it will
make pci_bus_match fail, so device_add  will skip attaching driver,
then pci_bus_attach_device() will set match_driver to true so
pci_bus_match will return true and device_attach will attach driver
to pci device.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/pci/bus.c        |   10 ++++++++++
 drivers/pci/pci-driver.c |    6 +++++-
 include/linux/pci.h      |    1 +
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 847f3ca..18c1c6d 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -160,6 +160,15 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
 
 void __weak pcibios_resource_survey_bus(struct pci_bus *bus) { }
 
+static void pci_bus_attach_device(struct pci_dev *dev)
+{
+	int ret;
+
+	dev->match_driver = true;
+	ret = device_attach(&dev->dev);
+	WARN_ON(ret < 0);
+}
+
 /**
  * pci_bus_add_device - add a single device
  * @dev: device to add
@@ -181,6 +190,7 @@ int pci_bus_add_device(struct pci_dev *dev)
 	if (retval)
 		return retval;
 
+	pci_bus_attach_device(dev);
 	dev->is_added = 1;
 	pci_proc_attach_device(dev);
 	pci_create_sysfs_dev_files(dev);
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index f79cbcd..acdcc3c 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1186,9 +1186,13 @@ pci_dev_driver(const struct pci_dev *dev)
 static int pci_bus_match(struct device *dev, struct device_driver *drv)
 {
 	struct pci_dev *pci_dev = to_pci_dev(dev);
-	struct pci_driver *pci_drv = to_pci_driver(drv);
+	struct pci_driver *pci_drv;
 	const struct pci_device_id *found_id;
 
+	if (!pci_dev->match_driver)
+		return 0;
+
+	pci_drv = to_pci_driver(drv);
 	found_id = pci_match_device(pci_drv, pci_dev);
 	if (found_id)
 		return 1;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 6860f4d..e2aed11 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -286,6 +286,7 @@ struct pci_dev {
 	unsigned int	irq;
 	struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */
 
+	bool match_driver;
 	/* These fields are used by common fixups */
 	unsigned int	transparent:1;	/* Transparent PCI bridge */
 	unsigned int	multifunction:1;/* Part of multi-function device */
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v10 11/11] PCI: Put pci dev to device tree as early as possible
  2013-01-21 21:20 [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Yinghai Lu
                   ` (9 preceding siblings ...)
  2013-01-21 21:20 ` [PATCH v10 10/11] PCI: Skip attaching driver in device_add() Yinghai Lu
@ 2013-01-21 21:20 ` Yinghai Lu
  2013-01-22 22:09 ` [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Rafael J. Wysocki
  11 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-21 21:20 UTC (permalink / raw)
  To: Bjorn Helgaas, Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu
  Cc: linux-pci, linux-kernel, linux-acpi, Yinghai Lu

We want to put created pci device in the device tree as soon as possible.
- just after we find it and create pci_dev struct for it.
so for_pci_dev iteration will not miss them.

But at that time, we can not load driver for them yet. Need to be after
pci_assign_unsigned_resources() etc to make sure all pci devices get
resource allocated at first.

Move out device registering out of pci_bus_add_devices, and
new pci_bus_add_devices() will do the device_attach work to load pci drivers

Also remove unattached child bus handling in pci_bus_add_devices().
Because that is not needed, child bus via pci_add_new_bus() is already
in parent bus children list.

-v2: replace pci_bus_add_child() with ->is_added directly according to
	Rafael.
     Move pci_create_sysfs_dev_files() back in pci_bus_add_dev(), as we
       need to wait assign unassigned resources done to create resource
       files in /sys.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/bus.c   |   79 ++++++++-------------------------------------------
 drivers/pci/iov.c   |    9 +-----
 drivers/pci/pci.h   |    1 -
 drivers/pci/probe.c |   33 ++++++++++++++++-----
 4 files changed, 39 insertions(+), 83 deletions(-)

diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 18c1c6d..5665c9a 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -170,69 +170,30 @@ static void pci_bus_attach_device(struct pci_dev *dev)
 }
 
 /**
- * pci_bus_add_device - add a single device
+ * pci_bus_add_device - start driver for a single device
  * @dev: device to add
  *
- * This adds a single pci device to the global
- * device list and adds sysfs and procfs entries
+ * This adds add sysfs entries and start device drivers
  */
 int pci_bus_add_device(struct pci_dev *dev)
 {
-	int retval;
-
-	pci_fixup_device(pci_fixup_final, dev);
-
-	retval = pcibios_add_device(dev);
-	if (retval)
-		return retval;
-
-	retval = device_add(&dev->dev);
-	if (retval)
-		return retval;
+	/*
+	 * Can not put in pci_device_add yet because pci resources
+	 * are not assigned yet for some pci devices.
+	 */
+	pci_create_sysfs_dev_files(dev);
 
 	pci_bus_attach_device(dev);
 	dev->is_added = 1;
-	pci_proc_attach_device(dev);
-	pci_create_sysfs_dev_files(dev);
-	return 0;
-}
-
-/**
- * pci_bus_add_child - add a child bus
- * @bus: bus to add
- *
- * This adds sysfs entries for a single bus
- */
-int pci_bus_add_child(struct pci_bus *bus)
-{
-	int retval;
-
-	if (bus->bridge)
-		bus->dev.parent = bus->bridge;
-
-	retval = device_register(&bus->dev);
-	if (retval)
-		return retval;
-
-	bus->is_added = 1;
-
-	/* Create legacy_io and legacy_mem files for this bus */
-	pci_create_legacy_files(bus);
 
-	return retval;
+	return 0;
 }
 
 /**
- * pci_bus_add_devices - insert newly discovered PCI devices
+ * pci_bus_add_devices - start driver for PCI devices
  * @bus: bus to check for new devices
  *
- * Add newly discovered PCI devices (which are on the bus->devices
- * list) to the global PCI device list, add the sysfs and procfs
- * entries.  Where a bridge is found, add the discovered bus to
- * the parents list of child buses, and recurse (breadth-first
- * to be compatible with 2.4)
- *
- * Call hotplug for each new devices.
+ * Start driver for PCI devices and add some sysfs entries.
  */
 void pci_bus_add_devices(const struct pci_bus *bus)
 {
@@ -245,36 +206,20 @@ void pci_bus_add_devices(const struct pci_bus *bus)
 		if (dev->is_added)
 			continue;
 		retval = pci_bus_add_device(dev);
-		if (retval)
-			dev_err(&dev->dev, "Error adding device, continuing\n");
 	}
 
 	list_for_each_entry(dev, &bus->devices, bus_list) {
 		BUG_ON(!dev->is_added);
 
 		child = dev->subordinate;
-		/*
-		 * If there is an unattached subordinate bus, attach
-		 * it and then scan for unattached PCI devices.
-		 */
+
 		if (!child)
 			continue;
-		if (list_empty(&child->node)) {
-			down_write(&pci_bus_sem);
-			list_add_tail(&child->node, &dev->bus->children);
-			up_write(&pci_bus_sem);
-		}
 		pci_bus_add_devices(child);
 
-		/*
-		 * register the bus with sysfs as the parent is now
-		 * properly registered.
-		 */
 		if (child->is_added)
 			continue;
-		retval = pci_bus_add_child(child);
-		if (retval)
-			dev_err(&dev->dev, "Error adding bus, continuing\n");
+		child->is_added = 1;
 	}
 }
 
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index bafd2bb..f8720af 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -48,12 +48,7 @@ static struct pci_bus *virtfn_add_bus(struct pci_bus *bus, int busnr)
 		return NULL;
 
 	pci_bus_insert_busn_res(child, busnr, busnr);
-	child->dev.parent = bus->bridge;
-	rc = pci_bus_add_child(child);
-	if (rc) {
-		pci_remove_bus(child);
-		return NULL;
-	}
+	bus->is_added = 1;
 
 	return child;
 }
@@ -123,8 +118,6 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
 	virtfn->is_virtfn = 1;
 
 	rc = pci_bus_add_device(virtfn);
-	if (rc)
-		goto failed1;
 	sprintf(buf, "virtfn%u", id);
 	rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf);
 	if (rc)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index adfd172..d295e7b 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -203,7 +203,6 @@ extern int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
 				struct resource *res, unsigned int reg);
 extern int pci_resource_bar(struct pci_dev *dev, int resno,
 			    enum pci_bar_type *type);
-extern int pci_bus_add_child(struct pci_bus *bus);
 extern void pci_enable_ari(struct pci_dev *dev);
 /**
  * pci_ari_enabled - query ARI forwarding status
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 9588207..30cf9e3 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -623,6 +623,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
 {
 	struct pci_bus *child;
 	int i;
+	int ret;
 
 	/*
 	 * Allocate a new bus, and inherit stuff from the parent..
@@ -637,8 +638,7 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
 	child->bus_flags = parent->bus_flags;
 
 	/* initialize some portions of the bus device, but don't register it
-	 * now as the parent is not properly set up yet.  This device will get
-	 * registered later in pci_bus_add_devices()
+	 * now as the parent is not properly set up yet.
 	 */
 	child->dev.class = &pcibus_class;
 	dev_set_name(&child->dev, "%04x:%02x", pci_domain_nr(child), busnr);
@@ -651,11 +651,14 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
 	child->primary = parent->busn_res.start;
 	child->busn_res.end = 0xff;
 
-	if (!bridge)
-		return child;
+	if (!bridge) {
+		child->dev.parent = parent->bridge;
+		goto add_dev;
+	}
 
 	child->self = bridge;
 	child->bridge = get_device(&bridge->dev);
+	child->dev.parent = child->bridge;
 	pci_set_bus_of_node(child);
 	pci_set_bus_speed(child);
 
@@ -666,6 +669,13 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
 	}
 	bridge->subordinate = child;
 
+add_dev:
+	ret = device_register(&child->dev);
+	WARN_ON(ret < 0);
+
+	/* Create legacy_io and legacy_mem files for this bus */
+	pci_create_legacy_files(child);
+
 	return child;
 }
 
@@ -1296,6 +1306,8 @@ static void pci_init_capabilities(struct pci_dev *dev)
 
 void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
 {
+	int ret;
+
 	device_initialize(&dev->dev);
 	dev->dev.release = pci_release_dev;
 
@@ -1326,6 +1338,15 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
 	down_write(&pci_bus_sem);
 	list_add_tail(&dev->bus_list, &bus->devices);
 	up_write(&pci_bus_sem);
+
+	pci_fixup_device(pci_fixup_final, dev);
+	ret = pcibios_add_device(dev);
+	WARN_ON(ret < 0);
+	/* notifier could use pci capabilities */
+	ret = device_add(&dev->dev);
+	WARN_ON(ret < 0);
+
+	pci_proc_attach_device(dev);
 }
 
 struct pci_dev *__ref pci_scan_single_device(struct pci_bus *bus, int devfn)
@@ -1656,13 +1677,13 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	char bus_addr[64];
 	char *fmt;
 
-
 	b = pci_alloc_bus();
 	if (!b)
 		return NULL;
 
 	b->sysdata = sysdata;
 	b->ops = ops;
+	b->number = b->busn_res.start = bus;
 	b2 = pci_find_bus(pci_domain_nr(b), bus);
 	if (b2) {
 		/* If we already got to this bus through a different bridge, ignore it */
@@ -1701,8 +1722,6 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 	/* Create legacy_io and legacy_mem files for this bus */
 	pci_create_legacy_files(b);
 
-	b->number = b->busn_res.start = bus;
-
 	if (parent)
 		dev_info(parent, "PCI host bridge to bus %s\n", dev_name(&b->dev));
 	else
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* Re: [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver
  2013-01-21 21:20 [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Yinghai Lu
                   ` (10 preceding siblings ...)
  2013-01-21 21:20 ` [PATCH v10 11/11] PCI: Put pci dev to device tree as early as possible Yinghai Lu
@ 2013-01-22 22:09 ` Rafael J. Wysocki
  2013-01-22 22:19   ` Yinghai Lu
  11 siblings, 1 reply; 122+ messages in thread
From: Rafael J. Wysocki @ 2013-01-22 22:09 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Bjorn Helgaas, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi

On Monday, January 21, 2013 01:20:41 PM Yinghai Lu wrote:
> It includes
> 1. preparing patches for pci root bus hotadd/hotremove support
> 2. move root bus hotadd from acpiphp to pci_root.c
> 3. add hot-remove support
> 4. add acpi_hp_work to be shared with acpiphp and root-bus hotplug
> 5. add match_driver to add pci device to device tree early but
>    not attach driver for hotplug path.
> 
> based on pci/next + pm/acpi-scan
> 
> could get from
>         git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-root-bus-hotplug
> 
> -v9: merges several patches together for easy review, requested by Rafael.
> -v10: address comments from Rafael.
> 
> Jiang Liu (2):
>   PCI: Fix a device reference count leakage issue in pci_dev_present()
>   PCI: make PCI device create/destroy logic symmetric
> 
> Tang Chen (1):
>   PCI, ACPI: debug print for installation of acpi root bridge's
>     notifier
> 
> Yinghai Lu (8):
>   PCI, acpiphp: Add is_hotplug_bridge detection
>   PCI: Add root bus children dev's res to fail list
>   PCI: Set dev_node early for pci_dev
>   PCI, ACPI, acpiphp: Rename alloc_acpiphp_hp_work() to alloc_acpi_hp_work
>   PCI, acpiphp: Move and enhance hotplug support of pci host bridge
>   PCI, acpiphp: Don't bailout even no slots found yet.
>   PCI: Skip attaching driver in device_add()
>   PCI: Put pci dev to device tree as early as possible

OK

Please feel free to add

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

to all of the patches in this series I haven't acked already.

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver
  2013-01-22 22:09 ` [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Rafael J. Wysocki
@ 2013-01-22 22:19   ` Yinghai Lu
  2013-01-26  0:04     ` Bjorn Helgaas
  0 siblings, 1 reply; 122+ messages in thread
From: Yinghai Lu @ 2013-01-22 22:19 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Bjorn Helgaas, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi

On Tue, Jan 22, 2013 at 2:09 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> On Monday, January 21, 2013 01:20:41 PM Yinghai Lu wrote:
>> It includes
>> 1. preparing patches for pci root bus hotadd/hotremove support
>> 2. move root bus hotadd from acpiphp to pci_root.c
>> 3. add hot-remove support
>> 4. add acpi_hp_work to be shared with acpiphp and root-bus hotplug
>> 5. add match_driver to add pci device to device tree early but
>>    not attach driver for hotplug path.
>>
>> based on pci/next + pm/acpi-scan
>>
>> could get from
>>         git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-root-bus-hotplug
>>
>> -v9: merges several patches together for easy review, requested by Rafael.
>> -v10: address comments from Rafael.
>>
>> Jiang Liu (2):
>>   PCI: Fix a device reference count leakage issue in pci_dev_present()
>>   PCI: make PCI device create/destroy logic symmetric
>>
>> Tang Chen (1):
>>   PCI, ACPI: debug print for installation of acpi root bridge's
>>     notifier
>>
>> Yinghai Lu (8):
>>   PCI, acpiphp: Add is_hotplug_bridge detection
>>   PCI: Add root bus children dev's res to fail list
>>   PCI: Set dev_node early for pci_dev
>>   PCI, ACPI, acpiphp: Rename alloc_acpiphp_hp_work() to alloc_acpi_hp_work
>>   PCI, acpiphp: Move and enhance hotplug support of pci host bridge
>>   PCI, acpiphp: Don't bailout even no slots found yet.
>>   PCI: Skip attaching driver in device_add()
>>   PCI: Put pci dev to device tree as early as possible
>
> OK
>
> Please feel free to add
>
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> to all of the patches in this series I haven't acked already.

Thanks a lot for reviewing.

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver
  2013-01-22 22:19   ` Yinghai Lu
@ 2013-01-26  0:04     ` Bjorn Helgaas
  2013-01-26  1:24         ` Jiang Liu
  2013-01-26 23:34       ` Yinghai Lu
  0 siblings, 2 replies; 122+ messages in thread
From: Bjorn Helgaas @ 2013-01-26  0:04 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi

On Tue, Jan 22, 2013 at 3:19 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Tue, Jan 22, 2013 at 2:09 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
>> On Monday, January 21, 2013 01:20:41 PM Yinghai Lu wrote:
>>> It includes
>>> 1. preparing patches for pci root bus hotadd/hotremove support
>>> 2. move root bus hotadd from acpiphp to pci_root.c
>>> 3. add hot-remove support
>>> 4. add acpi_hp_work to be shared with acpiphp and root-bus hotplug
>>> 5. add match_driver to add pci device to device tree early but
>>>    not attach driver for hotplug path.
>>>
>>> based on pci/next + pm/acpi-scan
>>>
>>> could get from
>>>         git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-root-bus-hotplug
>>>
>>> -v9: merges several patches together for easy review, requested by Rafael.
>>> -v10: address comments from Rafael.
>>>
>>> Jiang Liu (2):
>>>   PCI: Fix a device reference count leakage issue in pci_dev_present()
>>>   PCI: make PCI device create/destroy logic symmetric
>>>
>>> Tang Chen (1):
>>>   PCI, ACPI: debug print for installation of acpi root bridge's
>>>     notifier
>>>
>>> Yinghai Lu (8):
>>>   PCI, acpiphp: Add is_hotplug_bridge detection
>>>   PCI: Add root bus children dev's res to fail list
>>>   PCI: Set dev_node early for pci_dev
>>>   PCI, ACPI, acpiphp: Rename alloc_acpiphp_hp_work() to alloc_acpi_hp_work
>>>   PCI, acpiphp: Move and enhance hotplug support of pci host bridge
>>>   PCI, acpiphp: Don't bailout even no slots found yet.
>>>   PCI: Skip attaching driver in device_add()
>>>   PCI: Put pci dev to device tree as early as possible
>>
>> OK
>>
>> Please feel free to add
>>
>> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>
>> to all of the patches in this series I haven't acked already.

I first pulled in
"git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
acpi-scan" again (to pci/acpi-scan2), added your acks, Rafael, and put
this series on a pci/yinghai-root-bus branch based on pci/acpi-scan2.

I reworked some of the changelogs a bit, but I don't think I made any
code changes except that in [10/11] I just inlined the
pci_bus_attach_device() code rather than making a new function, since
it's small, there's only one caller, and I didn't think we needed any
more pci_* and pci_bus_* functions than we already have.

Let me know if I messed anything up.

Bjorn

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver
  2013-01-26  0:04     ` Bjorn Helgaas
@ 2013-01-26  1:24         ` Jiang Liu
  2013-01-26 23:34       ` Yinghai Lu
  1 sibling, 0 replies; 122+ messages in thread
From: Jiang Liu @ 2013-01-26  1:24 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yinghai Lu, Rafael J. Wysocki, Len Brown, Taku Izumi, linux-pci,
	linux-kernel, linux-acpi

On 2013-1-26 8:04, Bjorn Helgaas wrote:
> On Tue, Jan 22, 2013 at 3:19 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>> On Tue, Jan 22, 2013 at 2:09 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
>>> On Monday, January 21, 2013 01:20:41 PM Yinghai Lu wrote:
>>>> It includes
>>>> 1. preparing patches for pci root bus hotadd/hotremove support
>>>> 2. move root bus hotadd from acpiphp to pci_root.c
>>>> 3. add hot-remove support
>>>> 4. add acpi_hp_work to be shared with acpiphp and root-bus hotplug
>>>> 5. add match_driver to add pci device to device tree early but
>>>>    not attach driver for hotplug path.
>>>>
>>>> based on pci/next + pm/acpi-scan
>>>>
>>>> could get from
>>>>         git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-root-bus-hotplug
>>>>
>>>> -v9: merges several patches together for easy review, requested by Rafael.
>>>> -v10: address comments from Rafael.
>>>>
>>>> Jiang Liu (2):
>>>>   PCI: Fix a device reference count leakage issue in pci_dev_present()
>>>>   PCI: make PCI device create/destroy logic symmetric
>>>>
>>>> Tang Chen (1):
>>>>   PCI, ACPI: debug print for installation of acpi root bridge's
>>>>     notifier
>>>>
>>>> Yinghai Lu (8):
>>>>   PCI, acpiphp: Add is_hotplug_bridge detection
>>>>   PCI: Add root bus children dev's res to fail list
>>>>   PCI: Set dev_node early for pci_dev
>>>>   PCI, ACPI, acpiphp: Rename alloc_acpiphp_hp_work() to alloc_acpi_hp_work
>>>>   PCI, acpiphp: Move and enhance hotplug support of pci host bridge
>>>>   PCI, acpiphp: Don't bailout even no slots found yet.
>>>>   PCI: Skip attaching driver in device_add()
>>>>   PCI: Put pci dev to device tree as early as possible
>>>
>>> OK
>>>
>>> Please feel free to add
>>>
>>> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>>
>>> to all of the patches in this series I haven't acked already.
> 
> I first pulled in
> "git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
> acpi-scan" again (to pci/acpi-scan2), added your acks, Rafael, and put
> this series on a pci/yinghai-root-bus branch based on pci/acpi-scan2.
> 
> I reworked some of the changelogs a bit, but I don't think I made any
> code changes except that in [10/11] I just inlined the
> pci_bus_attach_device() code rather than making a new function, since
> it's small, there's only one caller, and I didn't think we needed any
> more pci_* and pci_bus_* functions than we already have.
> 
> Let me know if I messed anything up.
Great, so I could rebase my PCI notification related work to this branch.
I'm trying to resolve conflicts between acpi-scan and pci-root-bus-hotplug
last night.

Thanks!

> 
> Bjorn
> 
> .
> 

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver
@ 2013-01-26  1:24         ` Jiang Liu
  0 siblings, 0 replies; 122+ messages in thread
From: Jiang Liu @ 2013-01-26  1:24 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yinghai Lu, Rafael J. Wysocki, Len Brown, Taku Izumi, linux-pci,
	linux-kernel, linux-acpi

On 2013-1-26 8:04, Bjorn Helgaas wrote:
> On Tue, Jan 22, 2013 at 3:19 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>> On Tue, Jan 22, 2013 at 2:09 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
>>> On Monday, January 21, 2013 01:20:41 PM Yinghai Lu wrote:
>>>> It includes
>>>> 1. preparing patches for pci root bus hotadd/hotremove support
>>>> 2. move root bus hotadd from acpiphp to pci_root.c
>>>> 3. add hot-remove support
>>>> 4. add acpi_hp_work to be shared with acpiphp and root-bus hotplug
>>>> 5. add match_driver to add pci device to device tree early but
>>>>    not attach driver for hotplug path.
>>>>
>>>> based on pci/next + pm/acpi-scan
>>>>
>>>> could get from
>>>>         git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-root-bus-hotplug
>>>>
>>>> -v9: merges several patches together for easy review, requested by Rafael.
>>>> -v10: address comments from Rafael.
>>>>
>>>> Jiang Liu (2):
>>>>   PCI: Fix a device reference count leakage issue in pci_dev_present()
>>>>   PCI: make PCI device create/destroy logic symmetric
>>>>
>>>> Tang Chen (1):
>>>>   PCI, ACPI: debug print for installation of acpi root bridge's
>>>>     notifier
>>>>
>>>> Yinghai Lu (8):
>>>>   PCI, acpiphp: Add is_hotplug_bridge detection
>>>>   PCI: Add root bus children dev's res to fail list
>>>>   PCI: Set dev_node early for pci_dev
>>>>   PCI, ACPI, acpiphp: Rename alloc_acpiphp_hp_work() to alloc_acpi_hp_work
>>>>   PCI, acpiphp: Move and enhance hotplug support of pci host bridge
>>>>   PCI, acpiphp: Don't bailout even no slots found yet.
>>>>   PCI: Skip attaching driver in device_add()
>>>>   PCI: Put pci dev to device tree as early as possible
>>>
>>> OK
>>>
>>> Please feel free to add
>>>
>>> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>>
>>> to all of the patches in this series I haven't acked already.
> 
> I first pulled in
> "git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
> acpi-scan" again (to pci/acpi-scan2), added your acks, Rafael, and put
> this series on a pci/yinghai-root-bus branch based on pci/acpi-scan2.
> 
> I reworked some of the changelogs a bit, but I don't think I made any
> code changes except that in [10/11] I just inlined the
> pci_bus_attach_device() code rather than making a new function, since
> it's small, there's only one caller, and I didn't think we needed any
> more pci_* and pci_bus_* functions than we already have.
> 
> Let me know if I messed anything up.
Great, so I could rebase my PCI notification related work to this branch.
I'm trying to resolve conflicts between acpi-scan and pci-root-bus-hotplug
last night.

Thanks!

> 
> Bjorn
> 
> .
> 



^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver
  2013-01-26  0:04     ` Bjorn Helgaas
  2013-01-26  1:24         ` Jiang Liu
@ 2013-01-26 23:34       ` Yinghai Lu
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
  1 sibling, 1 reply; 122+ messages in thread
From: Yinghai Lu @ 2013-01-26 23:34 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Rafael J. Wysocki, Len Brown, Taku Izumi, Jiang Liu, linux-pci,
	linux-kernel, linux-acpi

On Fri, Jan 25, 2013 at 4:04 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Tue, Jan 22, 2013 at 3:19 PM, Yinghai Lu <yinghai@kernel.org> wrote:

> I first pulled in
> "git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git
> acpi-scan" again (to pci/acpi-scan2), added your acks, Rafael, and put
> this series on a pci/yinghai-root-bus branch based on pci/acpi-scan2.
>
> I reworked some of the changelogs a bit, but I don't think I made any
> code changes except that in [10/11] I just inlined the
> pci_bus_attach_device() code rather than making a new function, since
> it's small, there's only one caller, and I didn't think we needed any
> more pci_* and pci_bus_* functions than we already have.
>
> Let me know if I messed anything up.

Great, thanks for lot.

After that hit pci/next, will send out

for-pci-for-each-host-bridge

and

for-pci-for-each-add-res.

Thanks

Yinghai

^ permalink raw reply	[flat|nested] 122+ messages in thread

* [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus
  2013-01-26 23:34       ` Yinghai Lu
@ 2013-01-27  5:36         ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 01/22] PCI: Rename pci_release_bus_bridge_dev to pci_release_host_bridge_dev Yinghai Lu
                             ` (21 more replies)
  0 siblings, 22 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu

We could add bus_type for pci_host_bridge, and generic code in driver
core to loop pci_host_bridge and could remove pci_root_buses list,
as host_bridge->bus is the root bus.

based on pci/next

could get from
        git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-for-each-host-bridge

-v2: updated after pci_root_bus_hotplug get into pci/next

Yinghai Lu (22):
  PCI: Rename pci_release_bus_bridge_dev to pci_release_host_bridge_dev
  PCI: Add dummy bus_type for pci_host_bridge
  PCI, libata: remove find_bridge in acpi_bus_type
  PCI, ACPI: Update comments for find_bridge in acpi_bus_type
  PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge
  PCI, hotplug: Kill pci_find_next_bus in sgi_hotplug
  PCI: Kill pci_find_next_bus in pci_sysfs
  PCI, edac: Kill pci_find_next_bus in edac
  PCI, x86: Kill pci_find_next_bus in pcibios_scan_root
  PCI, x86: Kill pci_root_buses in resources reservations
  PCI, drm: Kill pci_root_buses in alpha hose setting
  PCI: Kill pci_root_buses in setup-bus
  PCI, sparc: Kill pci_find_next_bus
  PCI, ia64: Kill pci_find_next_bus
  PCI, alpha: Kill pci_root_buses
  PCI, arm: Kill pci_root_buses
  PCI, frv: Kill pci_root_buses in resources reservations
  PCI, microblaze: Kill pci_root_buses in resources reservations
  PCI, mn10300: Kill pci_root_buses in resources reservations
  PCI, powerpc: Kill pci_root_buses in resources reservations
  PCI: Kill pci_find_next_bus
  PCI: Kill pci_root_buses

 arch/alpha/kernel/pci.c                 |    6 +--
 arch/arm/kernel/bios32.c                |    9 ++---
 arch/frv/mb93090-mb00/pci-frv.c         |   37 +++++++++---------
 arch/ia64/hp/common/sba_iommu.c         |    7 ++--
 arch/ia64/sn/kernel/io_common.c         |    5 ++-
 arch/microblaze/pci/pci-common.c        |   10 ++---
 arch/mn10300/unit-asb2305/pci-asb2305.c |   62 ++++++++++++++++---------------
 arch/powerpc/kernel/pci-common.c        |   13 +++----
 arch/powerpc/kernel/pci_64.c            |    8 ++--
 arch/sparc/kernel/pci.c                 |    6 ++-
 arch/x86/pci/common.c                   |    9 +++--
 arch/x86/pci/i386.c                     |   20 +++++-----
 drivers/ata/libata-acpi.c               |    6 ---
 drivers/edac/i7core_edac.c              |    6 +--
 drivers/gpu/drm/drm_fops.c              |   10 +++--
 drivers/pci/hotplug/sgi_hotplug.c       |    6 ++-
 drivers/pci/pci-driver.c                |   11 +++++-
 drivers/pci/pci-sysfs.c                 |    6 +--
 drivers/pci/probe.c                     |   13 ++-----
 drivers/pci/search.c                    |   61 +++++++++++++++---------------
 drivers/pci/setup-bus.c                 |   24 ++++++------
 include/acpi/acpi_bus.h                 |    2 +-
 include/linux/pci.h                     |   18 +++++----
 23 files changed, 187 insertions(+), 168 deletions(-)

-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 122+ messages in thread

* [PATCH v2 01/22] PCI: Rename pci_release_bus_bridge_dev to pci_release_host_bridge_dev
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27 22:26             ` Rafael J. Wysocki
  2013-01-27  5:36           ` [PATCH v2 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
                             ` (20 subsequent siblings)
  21 siblings, 1 reply; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu

It is with host bridge, so change the name to reflect the fact.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/probe.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index b494066..ef50154 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1187,7 +1187,7 @@ int pci_cfg_space_size(struct pci_dev *dev)
 	return PCI_CFG_SPACE_SIZE;
 }
 
-static void pci_release_bus_bridge_dev(struct device *dev)
+static void pci_release_host_bridge_dev(struct device *dev)
 {
 	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
 
@@ -1692,7 +1692,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 		goto err_out;
 
 	bridge->dev.parent = parent;
-	bridge->dev.release = pci_release_bus_bridge_dev;
+	bridge->dev.release = pci_release_host_bridge_dev;
 	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
 	error = pcibios_root_bridge_prepare(bridge);
 	if (error)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 02/22] PCI: Add dummy bus_type for pci_host_bridge
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 01/22] PCI: Rename pci_release_bus_bridge_dev to pci_release_host_bridge_dev Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 03/22] PCI, libata: remove find_bridge in acpi_bus_type Yinghai Lu
                             ` (19 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu

Need to use it for looping registered host_bridge, and kill root_bus list.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/pci-driver.c |   11 ++++++++++-
 drivers/pci/probe.c      |    1 +
 include/linux/pci.h      |    2 ++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index acdcc3c..9fb004b 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1278,11 +1278,20 @@ struct bus_type pci_bus_type = {
 	.pm		= PCI_PM_OPS_PTR,
 };
 
+struct bus_type pci_host_bridge_bus_type = {
+	.name           = "pci_host_bridge",
+};
+
+static int __init pci_host_bridge_driver_init(void)
+{
+	return bus_register(&pci_host_bridge_bus_type);
+}
+postcore_initcall(pci_host_bridge_driver_init);
+
 static int __init pci_driver_init(void)
 {
 	return bus_register(&pci_bus_type);
 }
-
 postcore_initcall(pci_driver_init);
 
 EXPORT_SYMBOL_GPL(pci_add_dynid);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index ef50154..04ecf0d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1692,6 +1692,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 		goto err_out;
 
 	bridge->dev.parent = parent;
+	bridge->dev.bus = &pci_host_bridge_bus_type;
 	bridge->dev.release = pci_release_host_bridge_dev;
 	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
 	error = pcibios_root_bridge_prepare(bridge);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 056d3d6..9da06ec 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -669,6 +669,7 @@ enum pcie_bus_config_types {
 
 extern enum pcie_bus_config_types pcie_bus_config;
 
+extern struct bus_type pci_host_bridge_bus_type;
 extern struct bus_type pci_bus_type;
 
 /* Do NOT directly access these two variables, unless you are arch specific pci
@@ -740,6 +741,7 @@ void pci_stop_root_bus(struct pci_bus *bus);
 void pci_remove_root_bus(struct pci_bus *bus);
 void pci_setup_cardbus(struct pci_bus *bus);
 extern void pci_sort_breadthfirst(void);
+#define dev_is_pci_host_bridge(d) ((d)->bus == &pci_host_bridge_bus_type)
 #define dev_is_pci(d) ((d)->bus == &pci_bus_type)
 #define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false))
 #define dev_num_vf(d) ((dev_is_pci(d) ? pci_num_vf(to_pci_dev(d)) : 0))
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 03/22] PCI, libata: remove find_bridge in acpi_bus_type
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 01/22] PCI: Rename pci_release_bus_bridge_dev to pci_release_host_bridge_dev Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 04/22] PCI, ACPI: Update comments for " Yinghai Lu
                             ` (18 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, Jeff Garzik, linux-ide

The struct member is not used anymore, remove it.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: linux-ide@vger.kernel.org
Acked-by: Jeff Garzik <jgarzik@redhat.com>
---
 drivers/ata/libata-acpi.c |    6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index ef01ac0..7038225 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -1177,13 +1177,7 @@ static int ata_acpi_find_device(struct device *dev, acpi_handle *handle)
 		return -ENODEV;
 }
 
-static int ata_acpi_find_dummy(struct device *dev, acpi_handle *handle)
-{
-	return -ENODEV;
-}
-
 static struct acpi_bus_type ata_acpi_bus = {
-	.find_bridge = ata_acpi_find_dummy,
 	.find_device = ata_acpi_find_device,
 };
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 04/22] PCI, ACPI: Update comments for find_bridge in acpi_bus_type
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
                             ` (2 preceding siblings ...)
  2013-01-27  5:36           ` [PATCH v2 03/22] PCI, libata: remove find_bridge in acpi_bus_type Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge Yinghai Lu
                             ` (17 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, Len Brown, linux-acpi

only device that does not have bus_type, will go to that path...

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
---
 include/acpi/acpi_bus.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 5ce8d5e8..c499d94 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -385,7 +385,7 @@ struct acpi_bus_type {
 	struct bus_type *bus;
 	/* For general devices under the bus */
 	int (*find_device) (struct device *, acpi_handle *);
-	/* For bridges, such as PCI root bridge, IDE controller */
+	/* For bridges that does not have bus_type, such as usb_port */
 	int (*find_bridge) (struct device *, acpi_handle *);
 	void (*setup)(struct device *);
 	void (*cleanup)(struct device *);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
                             ` (3 preceding siblings ...)
  2013-01-27  5:36           ` [PATCH v2 04/22] PCI, ACPI: Update comments for " Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 06/22] PCI, hotplug: Kill pci_find_next_bus in sgi_hotplug Yinghai Lu
                             ` (16 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu

use bus_find_device to loop host_bridges.

-v2: fixes compiling error when CONFIG_PCI is not defined that Fengguang Wu found.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/search.c |   24 ++++++++++++++++++++++++
 include/linux/pci.h  |    9 +++++++++
 2 files changed, 33 insertions(+)

diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index d0627fa..db0c3a9 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -178,6 +178,30 @@ struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
 }
 EXPORT_SYMBOL(pci_get_domain_bus_and_slot);
 
+static int match_pci_host_bridge(struct device *dev, void *data)
+{
+	return 1;
+}
+
+struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from)
+{
+	struct device *dev;
+	struct device *dev_start = NULL;
+	struct pci_host_bridge *bridge = NULL;
+
+	WARN_ON(in_interrupt());
+	if (from)
+		dev_start = &from->dev;
+	dev = bus_find_device(&pci_host_bridge_bus_type, dev_start, NULL,
+			      match_pci_host_bridge);
+	if (dev)
+		bridge = to_pci_host_bridge(dev);
+	if (from)
+		put_device(&from->dev);
+	return bridge;
+}
+EXPORT_SYMBOL_GPL(pci_get_next_host_bridge);
+
 static int match_pci_dev_by_id(struct device *dev, void *data)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9da06ec..67879cb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -375,6 +375,8 @@ struct pci_host_bridge {
 };
 
 #define	to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev)
+#define for_each_pci_host_bridge(d) while ((d = pci_get_next_host_bridge(d)) != NULL)
+
 void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 		     void (*release_fn)(struct pci_host_bridge *),
 		     void *release_data);
@@ -763,6 +765,7 @@ int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
 int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
 struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
 
+struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from);
 struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
 				struct pci_dev *from);
 struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
@@ -1418,6 +1421,12 @@ static inline int pci_domain_nr(struct pci_bus *bus)
 static inline struct pci_dev *pci_dev_get(struct pci_dev *dev)
 { return NULL; }
 
+static inline struct pci_host_bridge *pci_get_next_host_bridge(
+			struct pci_host_bridge *host_bridge)
+{
+	return NULL;
+}
+
 #define dev_is_pci(d) (false)
 #define dev_is_pf(d) (false)
 #define dev_num_vf(d) (0)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 06/22] PCI, hotplug: Kill pci_find_next_bus in sgi_hotplug
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
                             ` (4 preceding siblings ...)
  2013-01-27  5:36           ` [PATCH v2 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 07/22] PCI: Kill pci_find_next_bus in pci_sysfs Yinghai Lu
                             ` (15 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/hotplug/sgi_hotplug.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index 180e760..ea81618 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -669,7 +669,7 @@ alloc_err:
 
 static int __init sn_pci_hotplug_init(void)
 {
-	struct pci_bus *pci_bus = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
 	int rc;
 	int registered = 0;
 
@@ -681,7 +681,9 @@ static int __init sn_pci_hotplug_init(void)
 
 	INIT_LIST_HEAD(&sn_hp_list);
 
-	while ((pci_bus = pci_find_next_bus(pci_bus))) {
+	for_each_pci_host_bridge(host_bridge) {
+		struct pci_bus *pci_bus = host_bridge->bus;
+
 		if (!pci_bus->sysdata)
 			continue;
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 07/22] PCI: Kill pci_find_next_bus in pci_sysfs
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
                             ` (5 preceding siblings ...)
  2013-01-27  5:36           ` [PATCH v2 06/22] PCI, hotplug: Kill pci_find_next_bus in sgi_hotplug Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 08/22] PCI, edac: Kill pci_find_next_bus in edac Yinghai Lu
                             ` (14 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/pci-sysfs.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 9c6e9bb..6f41daf 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -289,15 +289,15 @@ static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf,
 				size_t count)
 {
 	unsigned long val;
-	struct pci_bus *b = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	if (strict_strtoul(buf, 0, &val) < 0)
 		return -EINVAL;
 
 	if (val) {
 		mutex_lock(&pci_remove_rescan_mutex);
-		while ((b = pci_find_next_bus(b)) != NULL)
-			pci_rescan_bus(b);
+		for_each_pci_host_bridge(host_bridge)
+			pci_rescan_bus(host_bridge->bus);
 		mutex_unlock(&pci_remove_rescan_mutex);
 	}
 	return count;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 08/22] PCI, edac: Kill pci_find_next_bus in edac
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
                             ` (6 preceding siblings ...)
  2013-01-27  5:36           ` [PATCH v2 07/22] PCI: Kill pci_find_next_bus in pci_sysfs Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 09/22] PCI, x86: Kill pci_find_next_bus in pcibios_scan_root Yinghai Lu
                             ` (13 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, Mauro Carvalho Chehab, Doug Thompson, linux-edac

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac@vger.kernel.org
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/edac/i7core_edac.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 10c8c00..be6ef4f 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -1294,10 +1294,10 @@ static void __init i7core_xeon_pci_fixup(const struct pci_id_table *table)
 static unsigned i7core_pci_lastbus(void)
 {
 	int last_bus = 0, bus;
-	struct pci_bus *b = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
 
-	while ((b = pci_find_next_bus(b)) != NULL) {
-		bus = b->number;
+	for_each_pci_host_bridge(host_bridge) {
+		bus = host_bridge->bus->number;
 		edac_dbg(0, "Found bus %d\n", bus);
 		if (bus > last_bus)
 			last_bus = bus;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 09/22] PCI, x86: Kill pci_find_next_bus in pcibios_scan_root
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
                             ` (7 preceding siblings ...)
  2013-01-27  5:36           ` [PATCH v2 08/22] PCI, edac: Kill pci_find_next_bus in edac Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 10/22] PCI, x86: Kill pci_root_buses in resources reservations Yinghai Lu
                             ` (12 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, x86

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: x86@kernel.org
---
 arch/x86/pci/common.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 505731b..b4b4032 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -447,11 +447,14 @@ void __init dmi_check_pciprobe(void)
 
 struct pci_bus * __devinit pcibios_scan_root(int busnum)
 {
-	struct pci_bus *bus = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
+	struct pci_bus *bus;
 
-	while ((bus = pci_find_next_bus(bus)) != NULL) {
-		if (bus->number == busnum) {
+	for_each_pci_host_bridge(host_bridge) {
+		if (host_bridge->bus->number == busnum) {
 			/* Already scanned */
+			bus = host_bridge->bus;
+			put_device(&host_bridge->dev);
 			return bus;
 		}
 	}
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 10/22] PCI, x86: Kill pci_root_buses in resources reservations
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
                             ` (8 preceding siblings ...)
  2013-01-27  5:36           ` [PATCH v2 09/22] PCI, x86: Kill pci_find_next_bus in pcibios_scan_root Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 11/22] PCI, drm: Kill pci_root_buses in alpha hose setting Yinghai Lu
                             ` (11 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, x86

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: x86@kernel.org
---
 arch/x86/pci/i386.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 94919e3..b13e0af 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -340,11 +340,11 @@ static void pcibios_allocate_rom_resources(struct pci_bus *bus)
 
 static int __init pcibios_assign_resources(void)
 {
-	struct pci_bus *bus;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	if (!(pci_probe & PCI_ASSIGN_ROMS))
-		list_for_each_entry(bus, &pci_root_buses, node)
-			pcibios_allocate_rom_resources(bus);
+		for_each_pci_host_bridge(host_bridge)
+			pcibios_allocate_rom_resources(host_bridge->bus);
 
 	pci_assign_unassigned_resources();
 	pcibios_fw_addr_list_del();
@@ -367,17 +367,17 @@ void pcibios_resource_survey_bus(struct pci_bus *bus)
 
 void __init pcibios_resource_survey(void)
 {
-	struct pci_bus *bus;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	DBG("PCI: Allocating resources\n");
 
-	list_for_each_entry(bus, &pci_root_buses, node)
-		pcibios_allocate_bus_resources(bus);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_bus_resources(host_bridge->bus);
 
-	list_for_each_entry(bus, &pci_root_buses, node)
-		pcibios_allocate_resources(bus, 0);
-	list_for_each_entry(bus, &pci_root_buses, node)
-		pcibios_allocate_resources(bus, 1);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_resources(host_bridge->bus, 0);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_resources(host_bridge->bus, 1);
 
 	e820_reserve_resources_late();
 	/*
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 11/22] PCI, drm: Kill pci_root_buses in alpha hose setting
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
                             ` (9 preceding siblings ...)
  2013-01-27  5:36           ` [PATCH v2 10/22] PCI, x86: Kill pci_root_buses in resources reservations Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 12/22] PCI: Kill pci_root_buses in setup-bus Yinghai Lu
                             ` (10 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, David Airlie, dri-devel

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
---
 drivers/gpu/drm/drm_fops.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 133b413..b92a9cc 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -356,9 +356,13 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
 			pci_dev_put(pci_dev);
 		}
 		if (!dev->hose) {
-			struct pci_bus *b = pci_bus_b(pci_root_buses.next);
-			if (b)
-				dev->hose = b->sysdata;
+			struct pci_host_bridge *host_bridge;
+
+			host_bridge = pci_next_host_bridge(NULL);
+			if (host_bridge) {
+				dev->hose = host_bridge->bus->sysdata;
+				put_device(&host_bridge->dev);
+			}
 		}
 	}
 #endif
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 12/22] PCI: Kill pci_root_buses in setup-bus
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
                             ` (10 preceding siblings ...)
  2013-01-27  5:36           ` [PATCH v2 11/22] PCI, drm: Kill pci_root_buses in alpha hose setting Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36             ` Yinghai Lu
                             ` (9 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/setup-bus.c |   24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 7e8739e..8c0870b 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1318,12 +1318,12 @@ static int __init pci_bus_get_depth(struct pci_bus *bus)
 static int __init pci_get_max_depth(void)
 {
 	int depth = 0;
-	struct pci_bus *bus;
+	struct pci_host_bridge *host_bridge = NULL;
 
-	list_for_each_entry(bus, &pci_root_buses, node) {
+	for_each_pci_host_bridge(host_bridge) {
 		int ret;
 
-		ret = pci_bus_get_depth(bus);
+		ret = pci_bus_get_depth(host_bridge->bus);
 		if (ret > depth)
 			depth = ret;
 	}
@@ -1393,6 +1393,7 @@ void __init
 pci_assign_unassigned_resources(void)
 {
 	struct pci_bus *bus;
+	struct pci_host_bridge *host_bridge = NULL;
 	LIST_HEAD(realloc_head); /* list of resources that
 					want additional resources */
 	struct list_head *add_list = NULL;
@@ -1423,12 +1424,13 @@ again:
 		add_list = &realloc_head;
 	/* Depth first, calculate sizes and alignments of all
 	   subordinate buses. */
-	list_for_each_entry(bus, &pci_root_buses, node)
-		__pci_bus_size_bridges(bus, add_list);
+	for_each_pci_host_bridge(host_bridge)
+		__pci_bus_size_bridges(host_bridge->bus, add_list);
 
 	/* Depth last, allocate resources and update the hardware. */
-	list_for_each_entry(bus, &pci_root_buses, node)
-		__pci_bus_assign_resources(bus, add_list, &fail_head);
+	for_each_pci_host_bridge(host_bridge)
+		__pci_bus_assign_resources(host_bridge->bus, add_list,
+						 &fail_head);
 	if (add_list)
 		BUG_ON(!list_empty(add_list));
 	tried_times++;
@@ -1480,12 +1482,12 @@ again:
 
 enable_and_dump:
 	/* Depth last, update the hardware. */
-	list_for_each_entry(bus, &pci_root_buses, node)
-		pci_enable_bridges(bus);
+	for_each_pci_host_bridge(host_bridge)
+		pci_enable_bridges(host_bridge->bus);
 
 	/* dump the resource on buses */
-	list_for_each_entry(bus, &pci_root_buses, node)
-		pci_bus_dump_resources(bus);
+	for_each_pci_host_bridge(host_bridge)
+		pci_bus_dump_resources(host_bridge->bus);
 }
 
 void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 13/22] PCI, sparc: Kill pci_find_next_bus
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
@ 2013-01-27  5:36             ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
                               ` (20 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, David S. Miller, sparclinux

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Acked-by: David S. Miller <davem@davemloft.net>
---
 arch/sparc/kernel/pci.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 75b31bc..403f6e0 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -997,11 +997,13 @@ static void __devinit pci_bus_slot_names(struct device_node *node,
 
 static int __init of_pci_slot_init(void)
 {
-	struct pci_bus *pbus = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
+	struct pci_bus *pbus;
 
-	while ((pbus = pci_find_next_bus(pbus)) != NULL) {
+	for_each_pci_host_bridge(host_bridge) {
 		struct device_node *node;
 
+		pbus = host_bridge->bus;
 		if (pbus->self) {
 			/* PCI->PCI bridge */
 			node = pbus->self->dev.of_node;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 13/22] PCI, sparc: Kill pci_find_next_bus
@ 2013-01-27  5:36             ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, David S. Miller, sparclinux

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Acked-by: David S. Miller <davem@davemloft.net>
---
 arch/sparc/kernel/pci.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 75b31bc..403f6e0 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -997,11 +997,13 @@ static void __devinit pci_bus_slot_names(struct device_node *node,
 
 static int __init of_pci_slot_init(void)
 {
-	struct pci_bus *pbus = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
+	struct pci_bus *pbus;
 
-	while ((pbus = pci_find_next_bus(pbus)) != NULL) {
+	for_each_pci_host_bridge(host_bridge) {
 		struct device_node *node;
 
+		pbus = host_bridge->bus;
 		if (pbus->self) {
 			/* PCI->PCI bridge */
 			node = pbus->self->dev.of_node;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 14/22] PCI, ia64: Kill pci_find_next_bus
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
@ 2013-01-27  5:36             ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
                               ` (20 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, Tony Luck, Fenghua Yu, linux-ia64, linux-altix

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-altix@sgi.com
---
 arch/ia64/hp/common/sba_iommu.c |    7 ++++---
 arch/ia64/sn/kernel/io_common.c |    5 +++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index bcda5b2..0f27a37 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -2155,9 +2155,10 @@ sba_init(void)
 
 #ifdef CONFIG_PCI
 	{
-		struct pci_bus *b = NULL;
-		while ((b = pci_find_next_bus(b)) != NULL)
-			sba_connect_bus(b);
+		struct pci_host_bridge *host_bridge = NULL;
+
+		for_each_pci_host_bridge(host_bridge)
+			sba_connect_bus(host_bridge->bus);
 	}
 #endif
 
diff --git a/arch/ia64/sn/kernel/io_common.c b/arch/ia64/sn/kernel/io_common.c
index 8630875..131938b 100644
--- a/arch/ia64/sn/kernel/io_common.c
+++ b/arch/ia64/sn/kernel/io_common.c
@@ -516,6 +516,7 @@ arch_initcall(sn_io_early_init);
 int __init
 sn_io_late_init(void)
 {
+	struct pci_host_bridge *host_bridge = NULL;
 	struct pci_bus *bus;
 	struct pcibus_bussoft *bussoft;
 	cnodeid_t cnode;
@@ -530,8 +531,8 @@ sn_io_late_init(void)
 	 * PIC, TIOCP, TIOCE (TIOCA does it during bus fixup using
 	 * info from the PROM).
 	 */
-	bus = NULL;
-	while ((bus = pci_find_next_bus(bus)) != NULL) {
+	for_each_pci_host_bridge(host_bridge) {
+		bus = host_bridge->bus;
 		bussoft = SN_PCIBUS_BUSSOFT(bus);
 		nasid = NASID_GET(bussoft->bs_base);
 		cnode = nasid_to_cnodeid(nasid);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 14/22] PCI, ia64: Kill pci_find_next_bus
@ 2013-01-27  5:36             ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, Tony Luck, Fenghua Yu, linux-ia64, linux-altix

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-altix@sgi.com
---
 arch/ia64/hp/common/sba_iommu.c |    7 ++++---
 arch/ia64/sn/kernel/io_common.c |    5 +++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index bcda5b2..0f27a37 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -2155,9 +2155,10 @@ sba_init(void)
 
 #ifdef CONFIG_PCI
 	{
-		struct pci_bus *b = NULL;
-		while ((b = pci_find_next_bus(b)) != NULL)
-			sba_connect_bus(b);
+		struct pci_host_bridge *host_bridge = NULL;
+
+		for_each_pci_host_bridge(host_bridge)
+			sba_connect_bus(host_bridge->bus);
 	}
 #endif
 
diff --git a/arch/ia64/sn/kernel/io_common.c b/arch/ia64/sn/kernel/io_common.c
index 8630875..131938b 100644
--- a/arch/ia64/sn/kernel/io_common.c
+++ b/arch/ia64/sn/kernel/io_common.c
@@ -516,6 +516,7 @@ arch_initcall(sn_io_early_init);
 int __init
 sn_io_late_init(void)
 {
+	struct pci_host_bridge *host_bridge = NULL;
 	struct pci_bus *bus;
 	struct pcibus_bussoft *bussoft;
 	cnodeid_t cnode;
@@ -530,8 +531,8 @@ sn_io_late_init(void)
 	 * PIC, TIOCP, TIOCE (TIOCA does it during bus fixup using
 	 * info from the PROM).
 	 */
-	bus = NULL;
-	while ((bus = pci_find_next_bus(bus)) != NULL) {
+	for_each_pci_host_bridge(host_bridge) {
+		bus = host_bridge->bus;
 		bussoft = SN_PCIBUS_BUSSOFT(bus);
 		nasid = NASID_GET(bussoft->bs_base);
 		cnode = nasid_to_cnodeid(nasid);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 15/22] PCI, alpha: Kill pci_root_buses
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
                             ` (13 preceding siblings ...)
  2013-01-27  5:36             ` Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36             ` Yinghai Lu
                             ` (6 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, Richard Henderson, Ivan Kokshaysky,
	Matt Turner, linux-alpha

-v2: Fix typo that is found by Fengguang

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha@vger.kernel.org
---
 arch/alpha/kernel/pci.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index ef75714..6c55e16 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -305,10 +305,10 @@ pcibios_claim_one_bus(struct pci_bus *b)
 static void __init
 pcibios_claim_console_setup(void)
 {
-	struct pci_bus *b;
+	struct pci_host_bridge *host_bridge = NULL;
 
-	list_for_each_entry(b, &pci_root_buses, node)
-		pcibios_claim_one_bus(b);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_claim_one_bus(host_bridge->bus);
 }
 
 void __init
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 16/22] PCI, arm: Kill pci_root_buses
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
@ 2013-01-27  5:36             ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
                               ` (20 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, Russell King, linux-arm-kernel

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
---
 arch/arm/kernel/bios32.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index 9b72261..d0befe4 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -57,13 +57,10 @@ static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, in
 
 void pcibios_report_status(u_int status_mask, int warn)
 {
-	struct list_head *l;
+	struct pci_host_bridge *host_bridge = NULL;
 
-	list_for_each(l, &pci_root_buses) {
-		struct pci_bus *bus = pci_bus_b(l);
-
-		pcibios_bus_report_status(bus, status_mask, warn);
-	}
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_bus_report_status(host_bridge->bus, status_mask, warn);
 }
 
 /*
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 16/22] PCI, arm: Kill pci_root_buses
@ 2013-01-27  5:36             ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: linux-arm-kernel

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
---
 arch/arm/kernel/bios32.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index 9b72261..d0befe4 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -57,13 +57,10 @@ static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, in
 
 void pcibios_report_status(u_int status_mask, int warn)
 {
-	struct list_head *l;
+	struct pci_host_bridge *host_bridge = NULL;
 
-	list_for_each(l, &pci_root_buses) {
-		struct pci_bus *bus = pci_bus_b(l);
-
-		pcibios_bus_report_status(bus, status_mask, warn);
-	}
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_bus_report_status(host_bridge->bus, status_mask, warn);
 }
 
 /*
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 17/22] PCI, frv: Kill pci_root_buses in resources reservations
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
                             ` (15 preceding siblings ...)
  2013-01-27  5:36             ` Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 18/22] PCI, microblaze: " Yinghai Lu
                             ` (4 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, David Howells

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: David Howells <dhowells@redhat.com>
---
 arch/frv/mb93090-mb00/pci-frv.c |   37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/arch/frv/mb93090-mb00/pci-frv.c b/arch/frv/mb93090-mb00/pci-frv.c
index c281217..2a127f9 100644
--- a/arch/frv/mb93090-mb00/pci-frv.c
+++ b/arch/frv/mb93090-mb00/pci-frv.c
@@ -78,27 +78,26 @@ pcibios_align_resource(void *data, const struct resource *res,
  *	    as well.
  */
 
-static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
+static void __init pcibios_allocate_bridge_resources(struct pci_dev *dev)
 {
-	struct list_head *ln;
-	struct pci_bus *bus;
-	struct pci_dev *dev;
 	int idx;
 	struct resource *r;
+	for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
+		r = &dev->resource[idx];
+		if (!r->start)
+			continue;
+		pci_claim_resource(dev, idx);
+	}
+}
+static void __init pcibios_allocate_bus_resources(struct pci_bus *bus)
+{
+	struct pci_bus *child;
 
 	/* Depth-First Search on bus tree */
-	for (ln=bus_list->next; ln != bus_list; ln=ln->next) {
-		bus = pci_bus_b(ln);
-		if ((dev = bus->self)) {
-			for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
-				r = &dev->resource[idx];
-				if (!r->start)
-					continue;
-				pci_claim_resource(dev, idx);
-			}
-		}
-		pcibios_allocate_bus_resources(&bus->children);
-	}
+	if (bus->self)
+		pcibios_allocate_bridge_resources(bus->self);
+	list_for_each_entry(child, &bus->children, node)
+		pcibios_allocate_bus_resources(child);
 }
 
 static void __init pcibios_allocate_resources(int pass)
@@ -188,8 +187,12 @@ static void __init pcibios_assign_resources(void)
 
 void __init pcibios_resource_survey(void)
 {
+	struct pci_host_bridge *host_bridge = NULL;
+
 	DBG("PCI: Allocating resources\n");
-	pcibios_allocate_bus_resources(&pci_root_buses);
+
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_bus_resources(host_bridge->bus);
 	pcibios_allocate_resources(0);
 	pcibios_allocate_resources(1);
 	pcibios_assign_resources();
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 18/22] PCI, microblaze: Kill pci_root_buses in resources reservations
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
                             ` (16 preceding siblings ...)
  2013-01-27  5:36           ` [PATCH v2 17/22] PCI, frv: Kill pci_root_buses in resources reservations Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 19/22] PCI, mn10300: " Yinghai Lu
                             ` (3 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, Michal Simek, microblaze-uclinux

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux@itee.uq.edu.au
---
 arch/microblaze/pci/pci-common.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index a1c5b99..51f6651 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1323,13 +1323,13 @@ static void __init pcibios_reserve_legacy_regions(struct pci_bus *bus)
 
 void __init pcibios_resource_survey(void)
 {
-	struct pci_bus *b;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	/* Allocate and assign resources. If we re-assign everything, then
 	 * we skip the allocate phase
 	 */
-	list_for_each_entry(b, &pci_root_buses, node)
-		pcibios_allocate_bus_resources(b);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_bus_resources(host_bridge->bus);
 
 	pcibios_allocate_resources(0);
 	pcibios_allocate_resources(1);
@@ -1338,8 +1338,8 @@ void __init pcibios_resource_survey(void)
 	 * the low IO area and the VGA memory area if they intersect the
 	 * bus available resources to avoid allocating things on top of them
 	 */
-	list_for_each_entry(b, &pci_root_buses, node)
-		pcibios_reserve_legacy_regions(b);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_reserve_legacy_regions(host_bridge->bus);
 
 	/* Now proceed to assigning things that were left unassigned */
 	pr_debug("PCI: Assigning unassigned resources...\n");
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 19/22] PCI, mn10300: Kill pci_root_buses in resources reservations
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
                             ` (17 preceding siblings ...)
  2013-01-27  5:36           ` [PATCH v2 18/22] PCI, microblaze: " Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36             ` Yinghai Lu
                             ` (2 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, David Howells, Koichi Yasutake, linux-am33-list

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list@redhat.com
---
 arch/mn10300/unit-asb2305/pci-asb2305.c |   62 ++++++++++++++++---------------
 1 file changed, 33 insertions(+), 29 deletions(-)

diff --git a/arch/mn10300/unit-asb2305/pci-asb2305.c b/arch/mn10300/unit-asb2305/pci-asb2305.c
index c4e2e79..87c945d 100644
--- a/arch/mn10300/unit-asb2305/pci-asb2305.c
+++ b/arch/mn10300/unit-asb2305/pci-asb2305.c
@@ -88,42 +88,42 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,
  *	    requested by the user, configure expansion ROM address
  *	    as well.
  */
-static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
+static void __init pcibios_allocate_bridge_resources(struct pci_dev *dev)
 {
-	struct pci_bus *bus;
-	struct pci_dev *dev;
 	int idx;
 	struct resource *r;
 
-	/* Depth-First Search on bus tree */
-	list_for_each_entry(bus, bus_list, node) {
-		dev = bus->self;
-		if (dev) {
-			for (idx = PCI_BRIDGE_RESOURCES;
-			     idx < PCI_NUM_RESOURCES;
-			     idx++) {
-				r = &dev->resource[idx];
-				if (!r->flags)
-					continue;
-				if (!r->start ||
-				    pci_claim_resource(dev, idx) < 0) {
-					printk(KERN_ERR "PCI:"
-					       " Cannot allocate resource"
-					       " region %d of bridge %s\n",
-					       idx, pci_name(dev));
-					/* Something is wrong with the region.
-					 * Invalidate the resource to prevent
-					 * child resource allocations in this
-					 * range. */
-					r->start = r->end = 0;
-					r->flags = 0;
-				}
-			}
+	for (idx = PCI_BRIDGE_RESOURCES;
+	     idx < PCI_NUM_RESOURCES;
+	     idx++) {
+		r = &dev->resource[idx];
+		if (!r->flags)
+			continue;
+		if (!r->start ||
+		    pci_claim_resource(dev, idx) < 0) {
+			pr_err("PCI: Cannot allocate resource region %d of bridge %s\n",
+			       idx, pci_name(dev));
+			/* Something is wrong with the region.
+			 * Invalidate the resource to prevent
+			 * child resource allocations in this
+			 * range. */
+			r->start = r->end = 0;
+			r->flags = 0;
 		}
-		pcibios_allocate_bus_resources(&bus->children);
 	}
 }
 
+static void pcibios_allocate_bus_resources(struct pci_bus *bus)
+{
+	struct pci_bus *child;
+
+	/* Depth-First Search on bus tree */
+	if (bus->self)
+		pcibios_allocate_bridge_resources(bus->self);
+	list_for_each_entry(child, &bus->children, node)
+		pcibios_allocate_bus_resources(child);
+}
+
 static void __init pcibios_allocate_resources(int pass)
 {
 	struct pci_dev *dev = NULL;
@@ -207,8 +207,12 @@ fs_initcall(pcibios_assign_resources);
 
 void __init pcibios_resource_survey(void)
 {
+	struct pci_host_bridge *host_bridge = NULL;
+
 	DBG("PCI: Allocating resources\n");
-	pcibios_allocate_bus_resources(&pci_root_buses);
+
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_bus_resources(host_bridge->bus);
 	pcibios_allocate_resources(0);
 	pcibios_allocate_resources(1);
 }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 20/22] PCI, powerpc: Kill pci_root_buses in resources reservations
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
@ 2013-01-27  5:36             ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
                               ` (20 subsequent siblings)
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, Benjamin Herrenschmidt, Paul Mackerras,
	linuxppc-dev

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 arch/powerpc/kernel/pci-common.c |   13 ++++++-------
 arch/powerpc/kernel/pci_64.c     |    8 ++++----
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index abc0d08..9ccecbe 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1398,11 +1398,11 @@ static void __init pcibios_reserve_legacy_regions(struct pci_bus *bus)
 
 void __init pcibios_resource_survey(void)
 {
-	struct pci_bus *b;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	/* Allocate and assign resources */
-	list_for_each_entry(b, &pci_root_buses, node)
-		pcibios_allocate_bus_resources(b);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_bus_resources(host_bridge->bus);
 	pcibios_allocate_resources(0);
 	pcibios_allocate_resources(1);
 
@@ -1410,10 +1410,9 @@ void __init pcibios_resource_survey(void)
 	 * the low IO area and the VGA memory area if they intersect the
 	 * bus available resources to avoid allocating things on top of them
 	 */
-	if (!pci_has_flag(PCI_PROBE_ONLY)) {
-		list_for_each_entry(b, &pci_root_buses, node)
-			pcibios_reserve_legacy_regions(b);
-	}
+	if (!pci_has_flag(PCI_PROBE_ONLY))
+		for_each_pci_host_bridge(host_bridge)
+			pcibios_reserve_legacy_regions(host_bridge->bus);
 
 	/* Now, if the platform didn't decide to blindly trust the firmware,
 	 * we proceed to assigning things that were left unassigned
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 2cbe676..f848325 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -208,9 +208,9 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
 			  unsigned long in_devfn)
 {
 	struct pci_controller* hose;
-	struct list_head *ln;
-	struct pci_bus *bus = NULL;
+	struct pci_bus *bus;
 	struct device_node *hose_node;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	/* Argh ! Please forgive me for that hack, but that's the
 	 * simplest way to get existing XFree to not lockup on some
@@ -230,8 +230,8 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
 	 * used on pre-domains setup. We return the first match
 	 */
 
-	for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
-		bus = pci_bus_b(ln);
+	for_each_pci_host_bridge(host_bridge) {
+		bus = host_bridge->bus;
 		if (in_bus >= bus->number && in_bus <= bus->busn_res.end)
 			break;
 		bus = NULL;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 20/22] PCI, powerpc: Kill pci_root_buses in resources reservations
@ 2013-01-27  5:36             ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu, linuxppc-dev, Paul Mackerras

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 arch/powerpc/kernel/pci-common.c |   13 ++++++-------
 arch/powerpc/kernel/pci_64.c     |    8 ++++----
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index abc0d08..9ccecbe 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1398,11 +1398,11 @@ static void __init pcibios_reserve_legacy_regions(struct pci_bus *bus)
 
 void __init pcibios_resource_survey(void)
 {
-	struct pci_bus *b;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	/* Allocate and assign resources */
-	list_for_each_entry(b, &pci_root_buses, node)
-		pcibios_allocate_bus_resources(b);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_bus_resources(host_bridge->bus);
 	pcibios_allocate_resources(0);
 	pcibios_allocate_resources(1);
 
@@ -1410,10 +1410,9 @@ void __init pcibios_resource_survey(void)
 	 * the low IO area and the VGA memory area if they intersect the
 	 * bus available resources to avoid allocating things on top of them
 	 */
-	if (!pci_has_flag(PCI_PROBE_ONLY)) {
-		list_for_each_entry(b, &pci_root_buses, node)
-			pcibios_reserve_legacy_regions(b);
-	}
+	if (!pci_has_flag(PCI_PROBE_ONLY))
+		for_each_pci_host_bridge(host_bridge)
+			pcibios_reserve_legacy_regions(host_bridge->bus);
 
 	/* Now, if the platform didn't decide to blindly trust the firmware,
 	 * we proceed to assigning things that were left unassigned
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 2cbe676..f848325 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -208,9 +208,9 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
 			  unsigned long in_devfn)
 {
 	struct pci_controller* hose;
-	struct list_head *ln;
-	struct pci_bus *bus = NULL;
+	struct pci_bus *bus;
 	struct device_node *hose_node;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	/* Argh ! Please forgive me for that hack, but that's the
 	 * simplest way to get existing XFree to not lockup on some
@@ -230,8 +230,8 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
 	 * used on pre-domains setup. We return the first match
 	 */
 
-	for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
-		bus = pci_bus_b(ln);
+	for_each_pci_host_bridge(host_bridge) {
+		bus = host_bridge->bus;
 		if (in_bus >= bus->number && in_bus <= bus->busn_res.end)
 			break;
 		bus = NULL;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 21/22] PCI: Kill pci_find_next_bus
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
                             ` (19 preceding siblings ...)
  2013-01-27  5:36             ` Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  2013-01-27  5:36           ` [PATCH v2 22/22] PCI: Kill pci_root_buses Yinghai Lu
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/search.c |   37 +++++++------------------------------
 include/linux/pci.h  |    4 ----
 2 files changed, 7 insertions(+), 34 deletions(-)

diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index db0c3a9..329c533 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -79,44 +79,22 @@ static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr)
  */
 struct pci_bus * pci_find_bus(int domain, int busnr)
 {
-	struct pci_bus *bus = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
 	struct pci_bus *tmp_bus;
 
-	while ((bus = pci_find_next_bus(bus)) != NULL)  {
-		if (pci_domain_nr(bus) != domain)
+	for_each_pci_host_bridge(host_bridge) {
+		if (pci_domain_nr(host_bridge->bus) != domain)
 			continue;
-		tmp_bus = pci_do_find_bus(bus, busnr);
-		if (tmp_bus)
+		tmp_bus = pci_do_find_bus(host_bridge->bus, busnr);
+		if (tmp_bus) {
+			put_device(&host_bridge->dev);
 			return tmp_bus;
+		}
 	}
 	return NULL;
 }
 
 /**
- * pci_find_next_bus - begin or continue searching for a PCI bus
- * @from: Previous PCI bus found, or %NULL for new search.
- *
- * Iterates through the list of known PCI busses.  A new search is
- * initiated by passing %NULL as the @from argument.  Otherwise if
- * @from is not %NULL, searches continue from next device on the
- * global list.
- */
-struct pci_bus * 
-pci_find_next_bus(const struct pci_bus *from)
-{
-	struct list_head *n;
-	struct pci_bus *b = NULL;
-
-	WARN_ON(in_interrupt());
-	down_read(&pci_bus_sem);
-	n = from ? from->node.next : pci_root_buses.next;
-	if (n != &pci_root_buses)
-		b = pci_bus_b(n);
-	up_read(&pci_bus_sem);
-	return b;
-}
-
-/**
  * pci_get_slot - locate PCI device for a given PCI slot
  * @bus: PCI bus on which desired PCI device resides
  * @devfn: encodes number of PCI slot in which the desired PCI 
@@ -356,7 +334,6 @@ EXPORT_SYMBOL(pci_dev_present);
 
 /* For boot time work */
 EXPORT_SYMBOL(pci_find_bus);
-EXPORT_SYMBOL(pci_find_next_bus);
 /* For everyone */
 EXPORT_SYMBOL(pci_get_device);
 EXPORT_SYMBOL(pci_get_subsys);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 67879cb..bb07db2 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -763,7 +763,6 @@ int pci_find_ext_capability(struct pci_dev *dev, int cap);
 int pci_find_next_ext_capability(struct pci_dev *dev, int pos, int cap);
 int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
 int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
-struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
 
 struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from);
 struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
@@ -1404,9 +1403,6 @@ static inline int pci_block_cfg_access_in_atomic(struct pci_dev *dev)
 static inline void pci_unblock_cfg_access(struct pci_dev *dev)
 { }
 
-static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
-{ return NULL; }
-
 static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
 						unsigned int devfn)
 { return NULL; }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v2 22/22] PCI: Kill pci_root_buses
  2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
                             ` (20 preceding siblings ...)
  2013-01-27  5:36           ` [PATCH v2 21/22] PCI: Kill pci_find_next_bus Yinghai Lu
@ 2013-01-27  5:36           ` Yinghai Lu
  21 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27  5:36 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi
  Cc: linux-pci, Yinghai Lu

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/probe.c |    8 --------
 include/linux/pci.h |    3 ---
 2 files changed, 11 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 04ecf0d..8420b9d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -23,10 +23,6 @@ struct resource busn_resource = {
 	.flags	= IORESOURCE_BUS,
 };
 
-/* Ugh.  Need to stop exporting this to modules. */
-LIST_HEAD(pci_root_buses);
-EXPORT_SYMBOL(pci_root_buses);
-
 static LIST_HEAD(pci_domain_busn_res_list);
 
 struct pci_domain_busn_res {
@@ -1746,10 +1742,6 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 		dev_info(&b->dev, "root bus resource %pR%s\n", res, bus_addr);
 	}
 
-	down_write(&pci_bus_sem);
-	list_add_tail(&b->node, &pci_root_buses);
-	up_write(&pci_bus_sem);
-
 	return b;
 
 class_dev_reg_err:
diff --git a/include/linux/pci.h b/include/linux/pci.h
index bb07db2..b42721b 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -674,9 +674,6 @@ extern enum pcie_bus_config_types pcie_bus_config;
 extern struct bus_type pci_host_bridge_bus_type;
 extern struct bus_type pci_bus_type;
 
-/* Do NOT directly access these two variables, unless you are arch specific pci
- * code, or pci core code. */
-extern struct list_head pci_root_buses;	/* list of all known PCI buses */
 /* Some device drivers need know if pci is initiated */
 extern int no_pci_devices(void);
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* Re: [PATCH v2 16/22] PCI, arm: Kill pci_root_buses
  2013-01-27  5:36             ` Yinghai Lu
@ 2013-01-27 17:38               ` Russell King - ARM Linux
  -1 siblings, 0 replies; 122+ messages in thread
From: Russell King - ARM Linux @ 2013-01-27 17:38 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi,
	linux-pci, linux-arm-kernel

On Sat, Jan 26, 2013 at 09:36:37PM -0800, Yinghai Lu wrote:
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: linux-arm-kernel@lists.infradead.org

So... what's this about.  This email is all I've recieved, and the only
thing that I have to go on is one single subject line and not description
about what's going on.  I guess there's some other patch introducing this
for_each_pci_host_bridge() macro somewhere?  I guess that's part of this
patch set?

Yet... I guess you want an ack for this or something... which would be
irresponsible to give without knowing the purpose behind this, the
reasoning, or even being able to tell whether the replacement code is
functionally equivalent.

So, no ack (or nack) at the moment.

> ---
>  arch/arm/kernel/bios32.c |    9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
> index 9b72261..d0befe4 100644
> --- a/arch/arm/kernel/bios32.c
> +++ b/arch/arm/kernel/bios32.c
> @@ -57,13 +57,10 @@ static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, in
>  
>  void pcibios_report_status(u_int status_mask, int warn)
>  {
> -	struct list_head *l;
> +	struct pci_host_bridge *host_bridge = NULL;
>  
> -	list_for_each(l, &pci_root_buses) {
> -		struct pci_bus *bus = pci_bus_b(l);
> -
> -		pcibios_bus_report_status(bus, status_mask, warn);
> -	}
> +	for_each_pci_host_bridge(host_bridge)
> +		pcibios_bus_report_status(host_bridge->bus, status_mask, warn);
>  }
>  
>  /*
> -- 
> 1.7.10.4
> 

^ permalink raw reply	[flat|nested] 122+ messages in thread

* [PATCH v2 16/22] PCI, arm: Kill pci_root_buses
@ 2013-01-27 17:38               ` Russell King - ARM Linux
  0 siblings, 0 replies; 122+ messages in thread
From: Russell King - ARM Linux @ 2013-01-27 17:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Jan 26, 2013 at 09:36:37PM -0800, Yinghai Lu wrote:
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: linux-arm-kernel at lists.infradead.org

So... what's this about.  This email is all I've recieved, and the only
thing that I have to go on is one single subject line and not description
about what's going on.  I guess there's some other patch introducing this
for_each_pci_host_bridge() macro somewhere?  I guess that's part of this
patch set?

Yet... I guess you want an ack for this or something... which would be
irresponsible to give without knowing the purpose behind this, the
reasoning, or even being able to tell whether the replacement code is
functionally equivalent.

So, no ack (or nack) at the moment.

> ---
>  arch/arm/kernel/bios32.c |    9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
> index 9b72261..d0befe4 100644
> --- a/arch/arm/kernel/bios32.c
> +++ b/arch/arm/kernel/bios32.c
> @@ -57,13 +57,10 @@ static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, in
>  
>  void pcibios_report_status(u_int status_mask, int warn)
>  {
> -	struct list_head *l;
> +	struct pci_host_bridge *host_bridge = NULL;
>  
> -	list_for_each(l, &pci_root_buses) {
> -		struct pci_bus *bus = pci_bus_b(l);
> -
> -		pcibios_bus_report_status(bus, status_mask, warn);
> -	}
> +	for_each_pci_host_bridge(host_bridge)
> +		pcibios_bus_report_status(host_bridge->bus, status_mask, warn);
>  }
>  
>  /*
> -- 
> 1.7.10.4
> 

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v2 16/22] PCI, arm: Kill pci_root_buses
  2013-01-27 17:38               ` Russell King - ARM Linux
@ 2013-01-27 18:22                 ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 18:22 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi,
	linux-pci, linux-arm-kernel

On Sun, Jan 27, 2013 at 9:38 AM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Sat, Jan 26, 2013 at 09:36:37PM -0800, Yinghai Lu wrote:
>> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
>> Cc: Russell King <linux@arm.linux.org.uk>
>> Cc: linux-arm-kernel@lists.infradead.org
>
> So... what's this about.  This email is all I've recieved, and the only
> thing that I have to go on is one single subject line and not description
> about what's going on.  I guess there's some other patch introducing this
> for_each_pci_host_bridge() macro somewhere?  I guess that's part of this
> patch set?

yes.

sorry for not put you in the cc list of the whole patchset. will do
that next reversion.

>
> Yet... I guess you want an ack for this or something... which would be
> irresponsible to give without knowing the purpose behind this, the
> reasoning, or even being able to tell whether the replacement code is
> functionally equivalent.

the purpose is to make iteration for root bus to be root-bus
hotplug safe.

will update change log.

>
> So, no ack (or nack) at the moment.
>
>> ---
>>  arch/arm/kernel/bios32.c |    9 +++------
>>  1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
>> index 9b72261..d0befe4 100644
>> --- a/arch/arm/kernel/bios32.c
>> +++ b/arch/arm/kernel/bios32.c
>> @@ -57,13 +57,10 @@ static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, in
>>
>>  void pcibios_report_status(u_int status_mask, int warn)
>>  {
>> -     struct list_head *l;
>> +     struct pci_host_bridge *host_bridge = NULL;
>>
>> -     list_for_each(l, &pci_root_buses) {
>> -             struct pci_bus *bus = pci_bus_b(l);
>> -
>> -             pcibios_bus_report_status(bus, status_mask, warn);
>> -     }
>> +     for_each_pci_host_bridge(host_bridge)
>> +             pcibios_bus_report_status(host_bridge->bus, status_mask, warn);
>>  }
>>
>>  /*
>> --
>> 1.7.10.4
>>

^ permalink raw reply	[flat|nested] 122+ messages in thread

* [PATCH v2 16/22] PCI, arm: Kill pci_root_buses
@ 2013-01-27 18:22                 ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 18:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Jan 27, 2013 at 9:38 AM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Sat, Jan 26, 2013 at 09:36:37PM -0800, Yinghai Lu wrote:
>> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
>> Cc: Russell King <linux@arm.linux.org.uk>
>> Cc: linux-arm-kernel at lists.infradead.org
>
> So... what's this about.  This email is all I've recieved, and the only
> thing that I have to go on is one single subject line and not description
> about what's going on.  I guess there's some other patch introducing this
> for_each_pci_host_bridge() macro somewhere?  I guess that's part of this
> patch set?

yes.

sorry for not put you in the cc list of the whole patchset. will do
that next reversion.

>
> Yet... I guess you want an ack for this or something... which would be
> irresponsible to give without knowing the purpose behind this, the
> reasoning, or even being able to tell whether the replacement code is
> functionally equivalent.

the purpose is to make iteration for root bus to be root-bus
hotplug safe.

will update change log.

>
> So, no ack (or nack) at the moment.
>
>> ---
>>  arch/arm/kernel/bios32.c |    9 +++------
>>  1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
>> index 9b72261..d0befe4 100644
>> --- a/arch/arm/kernel/bios32.c
>> +++ b/arch/arm/kernel/bios32.c
>> @@ -57,13 +57,10 @@ static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, in
>>
>>  void pcibios_report_status(u_int status_mask, int warn)
>>  {
>> -     struct list_head *l;
>> +     struct pci_host_bridge *host_bridge = NULL;
>>
>> -     list_for_each(l, &pci_root_buses) {
>> -             struct pci_bus *bus = pci_bus_b(l);
>> -
>> -             pcibios_bus_report_status(bus, status_mask, warn);
>> -     }
>> +     for_each_pci_host_bridge(host_bridge)
>> +             pcibios_bus_report_status(host_bridge->bus, status_mask, warn);
>>  }
>>
>>  /*
>> --
>> 1.7.10.4
>>

^ permalink raw reply	[flat|nested] 122+ messages in thread

* [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-01-27 18:22                 ` Yinghai Lu
  (?)
@ 2013-01-27 19:23                   ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: linux-ia64, Mauro Carvalho Chehab, David Airlie, linux-pci,
	dri-devel, David Howells, Paul Mackerras, sparclinux,
	linux-am33-list, Russell King, x86, linux-altix, Doug Thompson,
	Matt Turner, linux-edac, Fenghua Yu, microblaze-uclinux,
	Ivan Kokshaysky, Yinghai Lu, linux-arm-kernel, Richard Henderson,
	Michal Simek, Tony Luck, Greg Kroah-Hartman, linux-alpha,
	Koichi Yasutake, linuxppc-dev, David S. Miller

Now we have pci_root_buses list, and there is lots of iteration with
list_of_each of it, that is not safe after we add pci root bus hotplug
support after booting stage.

Add pci_get_next_host_bridge and use bus_find_device in driver core to
iterate host bridge and the same time get root bus.

We replace searching root bus with searching host_bridge,
as host_bridge->bus is the root bus.
After those replacing, we even could kill pci_root_buses list.

based on pci/next

could get from
        git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-for-each-host-bridge

-v2: updated after pci_root_bus_hotplug get into pci/next
-v3: update changelog and add cc for pci core change for arch guys.

Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac@vger.kernel.org
Cc: x86@kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-altix@sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha@vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux@itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list@redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org


Yinghai Lu (22):
  PCI: Rename pci_release_bus_bridge_dev to pci_release_host_bridge_dev
  PCI: Add dummy bus_type for pci_host_bridge
  PCI, libata: remove find_bridge in acpi_bus_type
  PCI, ACPI: Update comments for find_bridge in acpi_bus_type
  PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge
  PCI, hotplug: Kill pci_find_next_bus in sgi_hotplug
  PCI: Kill pci_find_next_bus in pci_sysfs
  PCI, edac: Kill pci_find_next_bus in edac
  PCI, x86: Kill pci_find_next_bus in pcibios_scan_root
  PCI, x86: Kill pci_root_buses in resources reservations
  PCI, drm: Kill pci_root_buses in alpha hose setting
  PCI: Kill pci_root_buses in setup-bus
  PCI, sparc: Kill pci_find_next_bus
  PCI, ia64: Kill pci_find_next_bus
  PCI, alpha: Kill pci_root_buses
  PCI, arm: Kill pci_root_buses
  PCI, frv: Kill pci_root_buses in resources reservations
  PCI, microblaze: Kill pci_root_buses in resources reservations
  PCI, mn10300: Kill pci_root_buses in resources reservations
  PCI, powerpc: Kill pci_root_buses in resources reservations
  PCI: Kill pci_find_next_bus
  PCI: Kill pci_root_buses

 arch/alpha/kernel/pci.c                 |    6 +--
 arch/arm/kernel/bios32.c                |    9 ++---
 arch/frv/mb93090-mb00/pci-frv.c         |   37 +++++++++---------
 arch/ia64/hp/common/sba_iommu.c         |    7 ++--
 arch/ia64/sn/kernel/io_common.c         |    5 ++-
 arch/microblaze/pci/pci-common.c        |   10 ++---
 arch/mn10300/unit-asb2305/pci-asb2305.c |   62 ++++++++++++++++---------------
 arch/powerpc/kernel/pci-common.c        |   13 +++----
 arch/powerpc/kernel/pci_64.c            |    8 ++--
 arch/sparc/kernel/pci.c                 |    6 ++-
 arch/x86/pci/common.c                   |    9 +++--
 arch/x86/pci/i386.c                     |   20 +++++-----
 drivers/ata/libata-acpi.c               |    6 ---
 drivers/edac/i7core_edac.c              |    6 +--
 drivers/gpu/drm/drm_fops.c              |   10 +++--
 drivers/pci/hotplug/sgi_hotplug.c       |    6 ++-
 drivers/pci/pci-driver.c                |   11 +++++-
 drivers/pci/pci-sysfs.c                 |    6 +--
 drivers/pci/probe.c                     |   13 ++-----
 drivers/pci/search.c                    |   61 +++++++++++++++---------------
 drivers/pci/setup-bus.c                 |   24 ++++++------
 include/acpi/acpi_bus.h                 |    2 +-
 include/linux/pci.h                     |   18 +++++----
 23 files changed, 187 insertions(+), 168 deletions(-)

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 122+ messages in thread

* [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
@ 2013-01-27 19:23                   ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: linux-arm-kernel

Now we have pci_root_buses list, and there is lots of iteration with
list_of_each of it, that is not safe after we add pci root bus hotplug
support after booting stage.

Add pci_get_next_host_bridge and use bus_find_device in driver core to
iterate host bridge and the same time get root bus.

We replace searching root bus with searching host_bridge,
as host_bridge->bus is the root bus.
After those replacing, we even could kill pci_root_buses list.

based on pci/next

could get from
        git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-for-each-host-bridge

-v2: updated after pci_root_bus_hotplug get into pci/next
-v3: update changelog and add cc for pci core change for arch guys.

Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac at vger.kernel.org
Cc: x86 at kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel at lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux at vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64 at vger.kernel.org
Cc: linux-altix at sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha at vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list at redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev at lists.ozlabs.org


Yinghai Lu (22):
  PCI: Rename pci_release_bus_bridge_dev to pci_release_host_bridge_dev
  PCI: Add dummy bus_type for pci_host_bridge
  PCI, libata: remove find_bridge in acpi_bus_type
  PCI, ACPI: Update comments for find_bridge in acpi_bus_type
  PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge
  PCI, hotplug: Kill pci_find_next_bus in sgi_hotplug
  PCI: Kill pci_find_next_bus in pci_sysfs
  PCI, edac: Kill pci_find_next_bus in edac
  PCI, x86: Kill pci_find_next_bus in pcibios_scan_root
  PCI, x86: Kill pci_root_buses in resources reservations
  PCI, drm: Kill pci_root_buses in alpha hose setting
  PCI: Kill pci_root_buses in setup-bus
  PCI, sparc: Kill pci_find_next_bus
  PCI, ia64: Kill pci_find_next_bus
  PCI, alpha: Kill pci_root_buses
  PCI, arm: Kill pci_root_buses
  PCI, frv: Kill pci_root_buses in resources reservations
  PCI, microblaze: Kill pci_root_buses in resources reservations
  PCI, mn10300: Kill pci_root_buses in resources reservations
  PCI, powerpc: Kill pci_root_buses in resources reservations
  PCI: Kill pci_find_next_bus
  PCI: Kill pci_root_buses

 arch/alpha/kernel/pci.c                 |    6 +--
 arch/arm/kernel/bios32.c                |    9 ++---
 arch/frv/mb93090-mb00/pci-frv.c         |   37 +++++++++---------
 arch/ia64/hp/common/sba_iommu.c         |    7 ++--
 arch/ia64/sn/kernel/io_common.c         |    5 ++-
 arch/microblaze/pci/pci-common.c        |   10 ++---
 arch/mn10300/unit-asb2305/pci-asb2305.c |   62 ++++++++++++++++---------------
 arch/powerpc/kernel/pci-common.c        |   13 +++----
 arch/powerpc/kernel/pci_64.c            |    8 ++--
 arch/sparc/kernel/pci.c                 |    6 ++-
 arch/x86/pci/common.c                   |    9 +++--
 arch/x86/pci/i386.c                     |   20 +++++-----
 drivers/ata/libata-acpi.c               |    6 ---
 drivers/edac/i7core_edac.c              |    6 +--
 drivers/gpu/drm/drm_fops.c              |   10 +++--
 drivers/pci/hotplug/sgi_hotplug.c       |    6 ++-
 drivers/pci/pci-driver.c                |   11 +++++-
 drivers/pci/pci-sysfs.c                 |    6 +--
 drivers/pci/probe.c                     |   13 ++-----
 drivers/pci/search.c                    |   61 +++++++++++++++---------------
 drivers/pci/setup-bus.c                 |   24 ++++++------
 include/acpi/acpi_bus.h                 |    2 +-
 include/linux/pci.h                     |   18 +++++----
 23 files changed, 187 insertions(+), 168 deletions(-)

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 122+ messages in thread

* [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
@ 2013-01-27 19:23                   ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: linux-ia64, Mauro Carvalho Chehab, David Airlie, linux-pci,
	dri-devel, David Howells, Paul Mackerras, sparclinux,
	linux-am33-list, Russell King, x86, linux-altix, Doug Thompson,
	Matt Turner, linux-edac, Fenghua Yu, microblaze-uclinux,
	Ivan Kokshaysky, Yinghai Lu, linux-arm-kernel, Richard Henderson,
	Michal Simek, Tony Luck, Greg Kroah-Hartman,
	Benjamin Herrenschmidt, linux-alpha

Now we have pci_root_buses list, and there is lots of iteration with
list_of_each of it, that is not safe after we add pci root bus hotplug
support after booting stage.

Add pci_get_next_host_bridge and use bus_find_device in driver core to
iterate host bridge and the same time get root bus.

We replace searching root bus with searching host_bridge,
as host_bridge->bus is the root bus.
After those replacing, we even could kill pci_root_buses list.

based on pci/next

could get from
        git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-for-each-host-bridge

-v2: updated after pci_root_bus_hotplug get into pci/next
-v3: update changelog and add cc for pci core change for arch guys.

Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac@vger.kernel.org
Cc: x86@kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-altix@sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha@vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux@itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list@redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org


Yinghai Lu (22):
  PCI: Rename pci_release_bus_bridge_dev to pci_release_host_bridge_dev
  PCI: Add dummy bus_type for pci_host_bridge
  PCI, libata: remove find_bridge in acpi_bus_type
  PCI, ACPI: Update comments for find_bridge in acpi_bus_type
  PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge
  PCI, hotplug: Kill pci_find_next_bus in sgi_hotplug
  PCI: Kill pci_find_next_bus in pci_sysfs
  PCI, edac: Kill pci_find_next_bus in edac
  PCI, x86: Kill pci_find_next_bus in pcibios_scan_root
  PCI, x86: Kill pci_root_buses in resources reservations
  PCI, drm: Kill pci_root_buses in alpha hose setting
  PCI: Kill pci_root_buses in setup-bus
  PCI, sparc: Kill pci_find_next_bus
  PCI, ia64: Kill pci_find_next_bus
  PCI, alpha: Kill pci_root_buses
  PCI, arm: Kill pci_root_buses
  PCI, frv: Kill pci_root_buses in resources reservations
  PCI, microblaze: Kill pci_root_buses in resources reservations
  PCI, mn10300: Kill pci_root_buses in resources reservations
  PCI, powerpc: Kill pci_root_buses in resources reservations
  PCI: Kill pci_find_next_bus
  PCI: Kill pci_root_buses

 arch/alpha/kernel/pci.c                 |    6 +--
 arch/arm/kernel/bios32.c                |    9 ++---
 arch/frv/mb93090-mb00/pci-frv.c         |   37 +++++++++---------
 arch/ia64/hp/common/sba_iommu.c         |    7 ++--
 arch/ia64/sn/kernel/io_common.c         |    5 ++-
 arch/microblaze/pci/pci-common.c        |   10 ++---
 arch/mn10300/unit-asb2305/pci-asb2305.c |   62 ++++++++++++++++---------------
 arch/powerpc/kernel/pci-common.c        |   13 +++----
 arch/powerpc/kernel/pci_64.c            |    8 ++--
 arch/sparc/kernel/pci.c                 |    6 ++-
 arch/x86/pci/common.c                   |    9 +++--
 arch/x86/pci/i386.c                     |   20 +++++-----
 drivers/ata/libata-acpi.c               |    6 ---
 drivers/edac/i7core_edac.c              |    6 +--
 drivers/gpu/drm/drm_fops.c              |   10 +++--
 drivers/pci/hotplug/sgi_hotplug.c       |    6 ++-
 drivers/pci/pci-driver.c                |   11 +++++-
 drivers/pci/pci-sysfs.c                 |    6 +--
 drivers/pci/probe.c                     |   13 ++-----
 drivers/pci/search.c                    |   61 +++++++++++++++---------------
 drivers/pci/setup-bus.c                 |   24 ++++++------
 include/acpi/acpi_bus.h                 |    2 +-
 include/linux/pci.h                     |   18 +++++----
 23 files changed, 187 insertions(+), 168 deletions(-)

-- 
1.7.10.4

^ permalink raw reply	[flat|nested] 122+ messages in thread

* [PATCH v3 01/22] PCI: Rename pci_release_bus_bridge_dev to pci_release_host_bridge_dev
  2013-01-27 19:23                   ` Yinghai Lu
  (?)
  (?)
@ 2013-01-27 19:23                   ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu

It is with host bridge, so change the name to reflect the fact.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/probe.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index b494066..ef50154 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1187,7 +1187,7 @@ int pci_cfg_space_size(struct pci_dev *dev)
 	return PCI_CFG_SPACE_SIZE;
 }
 
-static void pci_release_bus_bridge_dev(struct device *dev)
+static void pci_release_host_bridge_dev(struct device *dev)
 {
 	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
 
@@ -1692,7 +1692,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 		goto err_out;
 
 	bridge->dev.parent = parent;
-	bridge->dev.release = pci_release_bus_bridge_dev;
+	bridge->dev.release = pci_release_host_bridge_dev;
 	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
 	error = pcibios_root_bridge_prepare(bridge);
 	if (error)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 02/22] PCI: Add dummy bus_type for pci_host_bridge
  2013-01-27 19:23                   ` Yinghai Lu
  (?)
@ 2013-01-27 19:23                     ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: linux-ia64, Mauro Carvalho Chehab, David Airlie, linux-pci,
	dri-devel, David Howells, Paul Mackerras, sparclinux,
	linux-am33-list, Russell King, x86, linux-altix, Doug Thompson,
	Matt Turner, linux-edac, Fenghua Yu, microblaze-uclinux,
	Ivan Kokshaysky, Yinghai Lu, linux-arm-kernel, Richard Henderson,
	Michal Simek, Tony Luck, Greg Kroah-Hartman, linux-alpha,
	Koichi Yasutake, linuxppc-dev, David S. Miller

Need to use it for looping registered host_bridge, and kill
pci_root_buses list.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac@vger.kernel.org
Cc: x86@kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-altix@sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha@vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux@itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list@redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 drivers/pci/pci-driver.c |   11 ++++++++++-
 drivers/pci/probe.c      |    1 +
 include/linux/pci.h      |    2 ++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index acdcc3c..9fb004b 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1278,11 +1278,20 @@ struct bus_type pci_bus_type = {
 	.pm		= PCI_PM_OPS_PTR,
 };
 
+struct bus_type pci_host_bridge_bus_type = {
+	.name           = "pci_host_bridge",
+};
+
+static int __init pci_host_bridge_driver_init(void)
+{
+	return bus_register(&pci_host_bridge_bus_type);
+}
+postcore_initcall(pci_host_bridge_driver_init);
+
 static int __init pci_driver_init(void)
 {
 	return bus_register(&pci_bus_type);
 }
-
 postcore_initcall(pci_driver_init);
 
 EXPORT_SYMBOL_GPL(pci_add_dynid);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index ef50154..04ecf0d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1692,6 +1692,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 		goto err_out;
 
 	bridge->dev.parent = parent;
+	bridge->dev.bus = &pci_host_bridge_bus_type;
 	bridge->dev.release = pci_release_host_bridge_dev;
 	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
 	error = pcibios_root_bridge_prepare(bridge);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 056d3d6..9da06ec 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -669,6 +669,7 @@ enum pcie_bus_config_types {
 
 extern enum pcie_bus_config_types pcie_bus_config;
 
+extern struct bus_type pci_host_bridge_bus_type;
 extern struct bus_type pci_bus_type;
 
 /* Do NOT directly access these two variables, unless you are arch specific pci
@@ -740,6 +741,7 @@ void pci_stop_root_bus(struct pci_bus *bus);
 void pci_remove_root_bus(struct pci_bus *bus);
 void pci_setup_cardbus(struct pci_bus *bus);
 extern void pci_sort_breadthfirst(void);
+#define dev_is_pci_host_bridge(d) ((d)->bus == &pci_host_bridge_bus_type)
 #define dev_is_pci(d) ((d)->bus == &pci_bus_type)
 #define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false))
 #define dev_num_vf(d) ((dev_is_pci(d) ? pci_num_vf(to_pci_dev(d)) : 0))
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 02/22] PCI: Add dummy bus_type for pci_host_bridge
@ 2013-01-27 19:23                     ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: linux-arm-kernel

Need to use it for looping registered host_bridge, and kill
pci_root_buses list.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac at vger.kernel.org
Cc: x86 at kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel at lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux at vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64 at vger.kernel.org
Cc: linux-altix at sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha at vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list at redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev at lists.ozlabs.org
---
 drivers/pci/pci-driver.c |   11 ++++++++++-
 drivers/pci/probe.c      |    1 +
 include/linux/pci.h      |    2 ++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index acdcc3c..9fb004b 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1278,11 +1278,20 @@ struct bus_type pci_bus_type = {
 	.pm		= PCI_PM_OPS_PTR,
 };
 
+struct bus_type pci_host_bridge_bus_type = {
+	.name           = "pci_host_bridge",
+};
+
+static int __init pci_host_bridge_driver_init(void)
+{
+	return bus_register(&pci_host_bridge_bus_type);
+}
+postcore_initcall(pci_host_bridge_driver_init);
+
 static int __init pci_driver_init(void)
 {
 	return bus_register(&pci_bus_type);
 }
-
 postcore_initcall(pci_driver_init);
 
 EXPORT_SYMBOL_GPL(pci_add_dynid);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index ef50154..04ecf0d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1692,6 +1692,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 		goto err_out;
 
 	bridge->dev.parent = parent;
+	bridge->dev.bus = &pci_host_bridge_bus_type;
 	bridge->dev.release = pci_release_host_bridge_dev;
 	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
 	error = pcibios_root_bridge_prepare(bridge);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 056d3d6..9da06ec 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -669,6 +669,7 @@ enum pcie_bus_config_types {
 
 extern enum pcie_bus_config_types pcie_bus_config;
 
+extern struct bus_type pci_host_bridge_bus_type;
 extern struct bus_type pci_bus_type;
 
 /* Do NOT directly access these two variables, unless you are arch specific pci
@@ -740,6 +741,7 @@ void pci_stop_root_bus(struct pci_bus *bus);
 void pci_remove_root_bus(struct pci_bus *bus);
 void pci_setup_cardbus(struct pci_bus *bus);
 extern void pci_sort_breadthfirst(void);
+#define dev_is_pci_host_bridge(d) ((d)->bus == &pci_host_bridge_bus_type)
 #define dev_is_pci(d) ((d)->bus == &pci_bus_type)
 #define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false))
 #define dev_num_vf(d) ((dev_is_pci(d) ? pci_num_vf(to_pci_dev(d)) : 0))
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 02/22] PCI: Add dummy bus_type for pci_host_bridge
@ 2013-01-27 19:23                     ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: linux-ia64, Mauro Carvalho Chehab, David Airlie, linux-pci,
	dri-devel, David Howells, Paul Mackerras, sparclinux,
	linux-am33-list, Russell King, x86, linux-altix, Doug Thompson,
	Matt Turner, linux-edac, Fenghua Yu, microblaze-uclinux,
	Ivan Kokshaysky, Yinghai Lu, linux-arm-kernel, Richard Henderson,
	Michal Simek, Tony Luck, Greg Kroah-Hartman,
	Benjamin Herrenschmidt, linux-alpha

Need to use it for looping registered host_bridge, and kill
pci_root_buses list.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac@vger.kernel.org
Cc: x86@kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-altix@sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha@vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux@itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list@redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 drivers/pci/pci-driver.c |   11 ++++++++++-
 drivers/pci/probe.c      |    1 +
 include/linux/pci.h      |    2 ++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index acdcc3c..9fb004b 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1278,11 +1278,20 @@ struct bus_type pci_bus_type = {
 	.pm		= PCI_PM_OPS_PTR,
 };
 
+struct bus_type pci_host_bridge_bus_type = {
+	.name           = "pci_host_bridge",
+};
+
+static int __init pci_host_bridge_driver_init(void)
+{
+	return bus_register(&pci_host_bridge_bus_type);
+}
+postcore_initcall(pci_host_bridge_driver_init);
+
 static int __init pci_driver_init(void)
 {
 	return bus_register(&pci_bus_type);
 }
-
 postcore_initcall(pci_driver_init);
 
 EXPORT_SYMBOL_GPL(pci_add_dynid);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index ef50154..04ecf0d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1692,6 +1692,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 		goto err_out;
 
 	bridge->dev.parent = parent;
+	bridge->dev.bus = &pci_host_bridge_bus_type;
 	bridge->dev.release = pci_release_host_bridge_dev;
 	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
 	error = pcibios_root_bridge_prepare(bridge);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 056d3d6..9da06ec 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -669,6 +669,7 @@ enum pcie_bus_config_types {
 
 extern enum pcie_bus_config_types pcie_bus_config;
 
+extern struct bus_type pci_host_bridge_bus_type;
 extern struct bus_type pci_bus_type;
 
 /* Do NOT directly access these two variables, unless you are arch specific pci
@@ -740,6 +741,7 @@ void pci_stop_root_bus(struct pci_bus *bus);
 void pci_remove_root_bus(struct pci_bus *bus);
 void pci_setup_cardbus(struct pci_bus *bus);
 extern void pci_sort_breadthfirst(void);
+#define dev_is_pci_host_bridge(d) ((d)->bus == &pci_host_bridge_bus_type)
 #define dev_is_pci(d) ((d)->bus == &pci_bus_type)
 #define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false))
 #define dev_num_vf(d) ((dev_is_pci(d) ? pci_num_vf(to_pci_dev(d)) : 0))
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 03/22] PCI, libata: remove find_bridge in acpi_bus_type
  2013-01-27 19:23                   ` Yinghai Lu
                                     ` (3 preceding siblings ...)
  (?)
@ 2013-01-27 19:23                   ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu, Jeff Garzik, linux-ide

The struct member is not used anymore, remove it.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: linux-ide@vger.kernel.org
Acked-by: Jeff Garzik <jgarzik@redhat.com>
---
 drivers/ata/libata-acpi.c |    6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index ef01ac0..7038225 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -1177,13 +1177,7 @@ static int ata_acpi_find_device(struct device *dev, acpi_handle *handle)
 		return -ENODEV;
 }
 
-static int ata_acpi_find_dummy(struct device *dev, acpi_handle *handle)
-{
-	return -ENODEV;
-}
-
 static struct acpi_bus_type ata_acpi_bus = {
-	.find_bridge = ata_acpi_find_dummy,
 	.find_device = ata_acpi_find_device,
 };
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 04/22] PCI, ACPI: Update comments for find_bridge in acpi_bus_type
  2013-01-27 19:23                   ` Yinghai Lu
                                     ` (4 preceding siblings ...)
  (?)
@ 2013-01-27 19:23                   ` Yinghai Lu
  2013-01-27 22:32                     ` Rafael J. Wysocki
  -1 siblings, 1 reply; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu, Len Brown, linux-acpi

only device that does not have bus_type, will go to that path...

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: linux-acpi@vger.kernel.org
---
 include/acpi/acpi_bus.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 5ce8d5e8..c499d94 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -385,7 +385,7 @@ struct acpi_bus_type {
 	struct bus_type *bus;
 	/* For general devices under the bus */
 	int (*find_device) (struct device *, acpi_handle *);
-	/* For bridges, such as PCI root bridge, IDE controller */
+	/* For bridges that does not have bus_type, such as usb_port */
 	int (*find_bridge) (struct device *, acpi_handle *);
 	void (*setup)(struct device *);
 	void (*cleanup)(struct device *);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge
  2013-01-27 19:23                   ` Yinghai Lu
  (?)
@ 2013-01-27 19:23                     ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: linux-ia64, Mauro Carvalho Chehab, David Airlie, linux-pci,
	dri-devel, David Howells, Paul Mackerras, sparclinux,
	linux-am33-list, Russell King, x86, linux-altix, Doug Thompson,
	Matt Turner, linux-edac, Fenghua Yu, microblaze-uclinux,
	Ivan Kokshaysky, Yinghai Lu, linux-arm-kernel, Richard Henderson,
	Michal Simek, Tony Luck, Greg Kroah-Hartman, linux-alpha,
	Koichi Yasutake, linuxppc-dev, David S. Miller

Now we have pci_root_buses list, and there is lots of iteration with
list_of_each of it, that is not safe after we add pci root bus hotplug
support after booting stage.

Also pci_find_next_bus is pretty misleading name, and it is only finding
next root bus instead of regular pci bus.

Add pci_get_next_host_bridge and use bus_find_device in driver core to
iterate host bridge and the same time get root bus.

In folllowing patches will replace searching root bus with searching host_bridge.
after using with that host-bridge, will need to call put device to release
reference if break early from the loop.

After those replacing, we even could kill pci_root_buses list.

-v2: fixes compiling error when CONFIG_PCI is not defined that Fengguang Wu found.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac@vger.kernel.org
Cc: x86@kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-altix@sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha@vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux@itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list@redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 drivers/pci/search.c |   24 ++++++++++++++++++++++++
 include/linux/pci.h  |    9 +++++++++
 2 files changed, 33 insertions(+)

diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index d0627fa..db0c3a9 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -178,6 +178,30 @@ struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
 }
 EXPORT_SYMBOL(pci_get_domain_bus_and_slot);
 
+static int match_pci_host_bridge(struct device *dev, void *data)
+{
+	return 1;
+}
+
+struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from)
+{
+	struct device *dev;
+	struct device *dev_start = NULL;
+	struct pci_host_bridge *bridge = NULL;
+
+	WARN_ON(in_interrupt());
+	if (from)
+		dev_start = &from->dev;
+	dev = bus_find_device(&pci_host_bridge_bus_type, dev_start, NULL,
+			      match_pci_host_bridge);
+	if (dev)
+		bridge = to_pci_host_bridge(dev);
+	if (from)
+		put_device(&from->dev);
+	return bridge;
+}
+EXPORT_SYMBOL_GPL(pci_get_next_host_bridge);
+
 static int match_pci_dev_by_id(struct device *dev, void *data)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9da06ec..67879cb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -375,6 +375,8 @@ struct pci_host_bridge {
 };
 
 #define	to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev)
+#define for_each_pci_host_bridge(d) while ((d = pci_get_next_host_bridge(d)) != NULL)
+
 void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 		     void (*release_fn)(struct pci_host_bridge *),
 		     void *release_data);
@@ -763,6 +765,7 @@ int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
 int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
 struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
 
+struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from);
 struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
 				struct pci_dev *from);
 struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
@@ -1418,6 +1421,12 @@ static inline int pci_domain_nr(struct pci_bus *bus)
 static inline struct pci_dev *pci_dev_get(struct pci_dev *dev)
 { return NULL; }
 
+static inline struct pci_host_bridge *pci_get_next_host_bridge(
+			struct pci_host_bridge *host_bridge)
+{
+	return NULL;
+}
+
 #define dev_is_pci(d) (false)
 #define dev_is_pf(d) (false)
 #define dev_num_vf(d) (0)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge
@ 2013-01-27 19:23                     ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: linux-arm-kernel

Now we have pci_root_buses list, and there is lots of iteration with
list_of_each of it, that is not safe after we add pci root bus hotplug
support after booting stage.

Also pci_find_next_bus is pretty misleading name, and it is only finding
next root bus instead of regular pci bus.

Add pci_get_next_host_bridge and use bus_find_device in driver core to
iterate host bridge and the same time get root bus.

In folllowing patches will replace searching root bus with searching host_bridge.
after using with that host-bridge, will need to call put device to release
reference if break early from the loop.

After those replacing, we even could kill pci_root_buses list.

-v2: fixes compiling error when CONFIG_PCI is not defined that Fengguang Wu found.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac at vger.kernel.org
Cc: x86 at kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel at lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux at vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64 at vger.kernel.org
Cc: linux-altix at sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha at vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list at redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev at lists.ozlabs.org
---
 drivers/pci/search.c |   24 ++++++++++++++++++++++++
 include/linux/pci.h  |    9 +++++++++
 2 files changed, 33 insertions(+)

diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index d0627fa..db0c3a9 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -178,6 +178,30 @@ struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
 }
 EXPORT_SYMBOL(pci_get_domain_bus_and_slot);
 
+static int match_pci_host_bridge(struct device *dev, void *data)
+{
+	return 1;
+}
+
+struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from)
+{
+	struct device *dev;
+	struct device *dev_start = NULL;
+	struct pci_host_bridge *bridge = NULL;
+
+	WARN_ON(in_interrupt());
+	if (from)
+		dev_start = &from->dev;
+	dev = bus_find_device(&pci_host_bridge_bus_type, dev_start, NULL,
+			      match_pci_host_bridge);
+	if (dev)
+		bridge = to_pci_host_bridge(dev);
+	if (from)
+		put_device(&from->dev);
+	return bridge;
+}
+EXPORT_SYMBOL_GPL(pci_get_next_host_bridge);
+
 static int match_pci_dev_by_id(struct device *dev, void *data)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9da06ec..67879cb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -375,6 +375,8 @@ struct pci_host_bridge {
 };
 
 #define	to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev)
+#define for_each_pci_host_bridge(d) while ((d = pci_get_next_host_bridge(d)) != NULL)
+
 void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 		     void (*release_fn)(struct pci_host_bridge *),
 		     void *release_data);
@@ -763,6 +765,7 @@ int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
 int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
 struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
 
+struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from);
 struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
 				struct pci_dev *from);
 struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
@@ -1418,6 +1421,12 @@ static inline int pci_domain_nr(struct pci_bus *bus)
 static inline struct pci_dev *pci_dev_get(struct pci_dev *dev)
 { return NULL; }
 
+static inline struct pci_host_bridge *pci_get_next_host_bridge(
+			struct pci_host_bridge *host_bridge)
+{
+	return NULL;
+}
+
 #define dev_is_pci(d) (false)
 #define dev_is_pf(d) (false)
 #define dev_num_vf(d) (0)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge
@ 2013-01-27 19:23                     ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: linux-ia64, Mauro Carvalho Chehab, David Airlie, linux-pci,
	dri-devel, David Howells, Paul Mackerras, sparclinux,
	linux-am33-list, Russell King, x86, linux-altix, Doug Thompson,
	Matt Turner, linux-edac, Fenghua Yu, microblaze-uclinux,
	Ivan Kokshaysky, Yinghai Lu, linux-arm-kernel, Richard Henderson,
	Michal Simek, Tony Luck, Greg Kroah-Hartman,
	Benjamin Herrenschmidt, linux-alpha

Now we have pci_root_buses list, and there is lots of iteration with
list_of_each of it, that is not safe after we add pci root bus hotplug
support after booting stage.

Also pci_find_next_bus is pretty misleading name, and it is only finding
next root bus instead of regular pci bus.

Add pci_get_next_host_bridge and use bus_find_device in driver core to
iterate host bridge and the same time get root bus.

In folllowing patches will replace searching root bus with searching host_bridge.
after using with that host-bridge, will need to call put device to release
reference if break early from the loop.

After those replacing, we even could kill pci_root_buses list.

-v2: fixes compiling error when CONFIG_PCI is not defined that Fengguang Wu found.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac@vger.kernel.org
Cc: x86@kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-altix@sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha@vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux@itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list@redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 drivers/pci/search.c |   24 ++++++++++++++++++++++++
 include/linux/pci.h  |    9 +++++++++
 2 files changed, 33 insertions(+)

diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index d0627fa..db0c3a9 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -178,6 +178,30 @@ struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
 }
 EXPORT_SYMBOL(pci_get_domain_bus_and_slot);
 
+static int match_pci_host_bridge(struct device *dev, void *data)
+{
+	return 1;
+}
+
+struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from)
+{
+	struct device *dev;
+	struct device *dev_start = NULL;
+	struct pci_host_bridge *bridge = NULL;
+
+	WARN_ON(in_interrupt());
+	if (from)
+		dev_start = &from->dev;
+	dev = bus_find_device(&pci_host_bridge_bus_type, dev_start, NULL,
+			      match_pci_host_bridge);
+	if (dev)
+		bridge = to_pci_host_bridge(dev);
+	if (from)
+		put_device(&from->dev);
+	return bridge;
+}
+EXPORT_SYMBOL_GPL(pci_get_next_host_bridge);
+
 static int match_pci_dev_by_id(struct device *dev, void *data)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9da06ec..67879cb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -375,6 +375,8 @@ struct pci_host_bridge {
 };
 
 #define	to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev)
+#define for_each_pci_host_bridge(d) while ((d = pci_get_next_host_bridge(d)) != NULL)
+
 void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 		     void (*release_fn)(struct pci_host_bridge *),
 		     void *release_data);
@@ -763,6 +765,7 @@ int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
 int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
 struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
 
+struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from);
 struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
 				struct pci_dev *from);
 struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
@@ -1418,6 +1421,12 @@ static inline int pci_domain_nr(struct pci_bus *bus)
 static inline struct pci_dev *pci_dev_get(struct pci_dev *dev)
 { return NULL; }
 
+static inline struct pci_host_bridge *pci_get_next_host_bridge(
+			struct pci_host_bridge *host_bridge)
+{
+	return NULL;
+}
+
 #define dev_is_pci(d) (false)
 #define dev_is_pf(d) (false)
 #define dev_num_vf(d) (0)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 06/22] PCI, hotplug: Kill pci_find_next_bus in sgi_hotplug
  2013-01-27 19:23                   ` Yinghai Lu
                                     ` (6 preceding siblings ...)
  (?)
@ 2013-01-27 19:23                   ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu

Replace that with hotplug-safe version for iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/hotplug/sgi_hotplug.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index 180e760..ea81618 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -669,7 +669,7 @@ alloc_err:
 
 static int __init sn_pci_hotplug_init(void)
 {
-	struct pci_bus *pci_bus = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
 	int rc;
 	int registered = 0;
 
@@ -681,7 +681,9 @@ static int __init sn_pci_hotplug_init(void)
 
 	INIT_LIST_HEAD(&sn_hp_list);
 
-	while ((pci_bus = pci_find_next_bus(pci_bus))) {
+	for_each_pci_host_bridge(host_bridge) {
+		struct pci_bus *pci_bus = host_bridge->bus;
+
 		if (!pci_bus->sysdata)
 			continue;
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 07/22] PCI: Kill pci_find_next_bus in pci_sysfs
  2013-01-27 19:23                   ` Yinghai Lu
                                     ` (7 preceding siblings ...)
  (?)
@ 2013-01-27 19:23                   ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu

Replace that with hotplug-safe version for iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/pci-sysfs.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 9c6e9bb..6f41daf 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -289,15 +289,15 @@ static ssize_t bus_rescan_store(struct bus_type *bus, const char *buf,
 				size_t count)
 {
 	unsigned long val;
-	struct pci_bus *b = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	if (strict_strtoul(buf, 0, &val) < 0)
 		return -EINVAL;
 
 	if (val) {
 		mutex_lock(&pci_remove_rescan_mutex);
-		while ((b = pci_find_next_bus(b)) != NULL)
-			pci_rescan_bus(b);
+		for_each_pci_host_bridge(host_bridge)
+			pci_rescan_bus(host_bridge->bus);
 		mutex_unlock(&pci_remove_rescan_mutex);
 	}
 	return count;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 08/22] PCI, edac: Kill pci_find_next_bus in edac
  2013-01-27 19:23                   ` Yinghai Lu
                                     ` (8 preceding siblings ...)
  (?)
@ 2013-01-27 19:23                   ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu, Mauro Carvalho Chehab,
	Doug Thompson, linux-edac

Replace that with hotplug-safe version for iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac@vger.kernel.org
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/edac/i7core_edac.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 10c8c00..be6ef4f 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -1294,10 +1294,10 @@ static void __init i7core_xeon_pci_fixup(const struct pci_id_table *table)
 static unsigned i7core_pci_lastbus(void)
 {
 	int last_bus = 0, bus;
-	struct pci_bus *b = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
 
-	while ((b = pci_find_next_bus(b)) != NULL) {
-		bus = b->number;
+	for_each_pci_host_bridge(host_bridge) {
+		bus = host_bridge->bus->number;
 		edac_dbg(0, "Found bus %d\n", bus);
 		if (bus > last_bus)
 			last_bus = bus;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 09/22] PCI, x86: Kill pci_find_next_bus in pcibios_scan_root
  2013-01-27 19:23                   ` Yinghai Lu
                                     ` (9 preceding siblings ...)
  (?)
@ 2013-01-27 19:23                   ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu, x86

Replace that with hotplug-safe version for iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: x86@kernel.org
---
 arch/x86/pci/common.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 505731b..b4b4032 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -447,11 +447,14 @@ void __init dmi_check_pciprobe(void)
 
 struct pci_bus * __devinit pcibios_scan_root(int busnum)
 {
-	struct pci_bus *bus = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
+	struct pci_bus *bus;
 
-	while ((bus = pci_find_next_bus(bus)) != NULL) {
-		if (bus->number == busnum) {
+	for_each_pci_host_bridge(host_bridge) {
+		if (host_bridge->bus->number == busnum) {
 			/* Already scanned */
+			bus = host_bridge->bus;
+			put_device(&host_bridge->dev);
 			return bus;
 		}
 	}
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 10/22] PCI, x86: Kill pci_root_buses in resources reservations
  2013-01-27 19:23                   ` Yinghai Lu
                                     ` (10 preceding siblings ...)
  (?)
@ 2013-01-27 19:23                   ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu, x86

Replace that with hotplug-safe version for iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: x86@kernel.org
---
 arch/x86/pci/i386.c |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 94919e3..b13e0af 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -340,11 +340,11 @@ static void pcibios_allocate_rom_resources(struct pci_bus *bus)
 
 static int __init pcibios_assign_resources(void)
 {
-	struct pci_bus *bus;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	if (!(pci_probe & PCI_ASSIGN_ROMS))
-		list_for_each_entry(bus, &pci_root_buses, node)
-			pcibios_allocate_rom_resources(bus);
+		for_each_pci_host_bridge(host_bridge)
+			pcibios_allocate_rom_resources(host_bridge->bus);
 
 	pci_assign_unassigned_resources();
 	pcibios_fw_addr_list_del();
@@ -367,17 +367,17 @@ void pcibios_resource_survey_bus(struct pci_bus *bus)
 
 void __init pcibios_resource_survey(void)
 {
-	struct pci_bus *bus;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	DBG("PCI: Allocating resources\n");
 
-	list_for_each_entry(bus, &pci_root_buses, node)
-		pcibios_allocate_bus_resources(bus);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_bus_resources(host_bridge->bus);
 
-	list_for_each_entry(bus, &pci_root_buses, node)
-		pcibios_allocate_resources(bus, 0);
-	list_for_each_entry(bus, &pci_root_buses, node)
-		pcibios_allocate_resources(bus, 1);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_resources(host_bridge->bus, 0);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_resources(host_bridge->bus, 1);
 
 	e820_reserve_resources_late();
 	/*
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 11/22] PCI, drm: Kill pci_root_buses in alpha hose setting
  2013-01-27 19:23                   ` Yinghai Lu
                                     ` (11 preceding siblings ...)
  (?)
@ 2013-01-27 19:23                   ` Yinghai Lu
  2013-01-28  3:21                       ` Yijing Wang
  -1 siblings, 1 reply; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu, David Airlie, dri-devel

Replace that with hotplug-safe version.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
---
 drivers/gpu/drm/drm_fops.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 133b413..b92a9cc 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -356,9 +356,13 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
 			pci_dev_put(pci_dev);
 		}
 		if (!dev->hose) {
-			struct pci_bus *b = pci_bus_b(pci_root_buses.next);
-			if (b)
-				dev->hose = b->sysdata;
+			struct pci_host_bridge *host_bridge;
+
+			host_bridge = pci_next_host_bridge(NULL);
+			if (host_bridge) {
+				dev->hose = host_bridge->bus->sysdata;
+				put_device(&host_bridge->dev);
+			}
 		}
 	}
 #endif
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 12/22] PCI: Kill pci_root_buses in setup-bus
  2013-01-27 19:23                   ` Yinghai Lu
                                     ` (12 preceding siblings ...)
  (?)
@ 2013-01-27 19:23                   ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu

Replace that with hotplug-safe version iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
 drivers/pci/setup-bus.c |   24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 7e8739e..8c0870b 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -1318,12 +1318,12 @@ static int __init pci_bus_get_depth(struct pci_bus *bus)
 static int __init pci_get_max_depth(void)
 {
 	int depth = 0;
-	struct pci_bus *bus;
+	struct pci_host_bridge *host_bridge = NULL;
 
-	list_for_each_entry(bus, &pci_root_buses, node) {
+	for_each_pci_host_bridge(host_bridge) {
 		int ret;
 
-		ret = pci_bus_get_depth(bus);
+		ret = pci_bus_get_depth(host_bridge->bus);
 		if (ret > depth)
 			depth = ret;
 	}
@@ -1393,6 +1393,7 @@ void __init
 pci_assign_unassigned_resources(void)
 {
 	struct pci_bus *bus;
+	struct pci_host_bridge *host_bridge = NULL;
 	LIST_HEAD(realloc_head); /* list of resources that
 					want additional resources */
 	struct list_head *add_list = NULL;
@@ -1423,12 +1424,13 @@ again:
 		add_list = &realloc_head;
 	/* Depth first, calculate sizes and alignments of all
 	   subordinate buses. */
-	list_for_each_entry(bus, &pci_root_buses, node)
-		__pci_bus_size_bridges(bus, add_list);
+	for_each_pci_host_bridge(host_bridge)
+		__pci_bus_size_bridges(host_bridge->bus, add_list);
 
 	/* Depth last, allocate resources and update the hardware. */
-	list_for_each_entry(bus, &pci_root_buses, node)
-		__pci_bus_assign_resources(bus, add_list, &fail_head);
+	for_each_pci_host_bridge(host_bridge)
+		__pci_bus_assign_resources(host_bridge->bus, add_list,
+						 &fail_head);
 	if (add_list)
 		BUG_ON(!list_empty(add_list));
 	tried_times++;
@@ -1480,12 +1482,12 @@ again:
 
 enable_and_dump:
 	/* Depth last, update the hardware. */
-	list_for_each_entry(bus, &pci_root_buses, node)
-		pci_enable_bridges(bus);
+	for_each_pci_host_bridge(host_bridge)
+		pci_enable_bridges(host_bridge->bus);
 
 	/* dump the resource on buses */
-	list_for_each_entry(bus, &pci_root_buses, node)
-		pci_bus_dump_resources(bus);
+	for_each_pci_host_bridge(host_bridge)
+		pci_bus_dump_resources(host_bridge->bus);
 }
 
 void pci_assign_unassigned_bridge_resources(struct pci_dev *bridge)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 13/22] PCI, sparc: Kill pci_find_next_bus
  2013-01-27 19:23                   ` Yinghai Lu
@ 2013-01-27 19:23                     ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu, David S. Miller, sparclinux

Replace that with hotplug-safe version iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Acked-by: David S. Miller <davem@davemloft.net>
---
 arch/sparc/kernel/pci.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 75b31bc..403f6e0 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -997,11 +997,13 @@ static void __devinit pci_bus_slot_names(struct device_node *node,
 
 static int __init of_pci_slot_init(void)
 {
-	struct pci_bus *pbus = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
+	struct pci_bus *pbus;
 
-	while ((pbus = pci_find_next_bus(pbus)) != NULL) {
+	for_each_pci_host_bridge(host_bridge) {
 		struct device_node *node;
 
+		pbus = host_bridge->bus;
 		if (pbus->self) {
 			/* PCI->PCI bridge */
 			node = pbus->self->dev.of_node;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 13/22] PCI, sparc: Kill pci_find_next_bus
@ 2013-01-27 19:23                     ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu, David S. Miller, sparclinux

Replace that with hotplug-safe version iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Acked-by: David S. Miller <davem@davemloft.net>
---
 arch/sparc/kernel/pci.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index 75b31bc..403f6e0 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -997,11 +997,13 @@ static void __devinit pci_bus_slot_names(struct device_node *node,
 
 static int __init of_pci_slot_init(void)
 {
-	struct pci_bus *pbus = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
+	struct pci_bus *pbus;
 
-	while ((pbus = pci_find_next_bus(pbus)) != NULL) {
+	for_each_pci_host_bridge(host_bridge) {
 		struct device_node *node;
 
+		pbus = host_bridge->bus;
 		if (pbus->self) {
 			/* PCI->PCI bridge */
 			node = pbus->self->dev.of_node;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 14/22] PCI, ia64: Kill pci_find_next_bus
  2013-01-27 19:23                   ` Yinghai Lu
@ 2013-01-27 19:23                     ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu, Tony Luck, Fenghua Yu,
	linux-ia64, linux-altix

Replace that with hotplug-safe version iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-altix@sgi.com
---
 arch/ia64/hp/common/sba_iommu.c |    7 ++++---
 arch/ia64/sn/kernel/io_common.c |    5 +++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index bcda5b2..0f27a37 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -2155,9 +2155,10 @@ sba_init(void)
 
 #ifdef CONFIG_PCI
 	{
-		struct pci_bus *b = NULL;
-		while ((b = pci_find_next_bus(b)) != NULL)
-			sba_connect_bus(b);
+		struct pci_host_bridge *host_bridge = NULL;
+
+		for_each_pci_host_bridge(host_bridge)
+			sba_connect_bus(host_bridge->bus);
 	}
 #endif
 
diff --git a/arch/ia64/sn/kernel/io_common.c b/arch/ia64/sn/kernel/io_common.c
index 8630875..131938b 100644
--- a/arch/ia64/sn/kernel/io_common.c
+++ b/arch/ia64/sn/kernel/io_common.c
@@ -516,6 +516,7 @@ arch_initcall(sn_io_early_init);
 int __init
 sn_io_late_init(void)
 {
+	struct pci_host_bridge *host_bridge = NULL;
 	struct pci_bus *bus;
 	struct pcibus_bussoft *bussoft;
 	cnodeid_t cnode;
@@ -530,8 +531,8 @@ sn_io_late_init(void)
 	 * PIC, TIOCP, TIOCE (TIOCA does it during bus fixup using
 	 * info from the PROM).
 	 */
-	bus = NULL;
-	while ((bus = pci_find_next_bus(bus)) != NULL) {
+	for_each_pci_host_bridge(host_bridge) {
+		bus = host_bridge->bus;
 		bussoft = SN_PCIBUS_BUSSOFT(bus);
 		nasid = NASID_GET(bussoft->bs_base);
 		cnode = nasid_to_cnodeid(nasid);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 14/22] PCI, ia64: Kill pci_find_next_bus
@ 2013-01-27 19:23                     ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu, Tony Luck, Fenghua Yu,
	linux-ia64, linux-altix

Replace that with hotplug-safe version iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-altix@sgi.com
---
 arch/ia64/hp/common/sba_iommu.c |    7 ++++---
 arch/ia64/sn/kernel/io_common.c |    5 +++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index bcda5b2..0f27a37 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -2155,9 +2155,10 @@ sba_init(void)
 
 #ifdef CONFIG_PCI
 	{
-		struct pci_bus *b = NULL;
-		while ((b = pci_find_next_bus(b)) != NULL)
-			sba_connect_bus(b);
+		struct pci_host_bridge *host_bridge = NULL;
+
+		for_each_pci_host_bridge(host_bridge)
+			sba_connect_bus(host_bridge->bus);
 	}
 #endif
 
diff --git a/arch/ia64/sn/kernel/io_common.c b/arch/ia64/sn/kernel/io_common.c
index 8630875..131938b 100644
--- a/arch/ia64/sn/kernel/io_common.c
+++ b/arch/ia64/sn/kernel/io_common.c
@@ -516,6 +516,7 @@ arch_initcall(sn_io_early_init);
 int __init
 sn_io_late_init(void)
 {
+	struct pci_host_bridge *host_bridge = NULL;
 	struct pci_bus *bus;
 	struct pcibus_bussoft *bussoft;
 	cnodeid_t cnode;
@@ -530,8 +531,8 @@ sn_io_late_init(void)
 	 * PIC, TIOCP, TIOCE (TIOCA does it during bus fixup using
 	 * info from the PROM).
 	 */
-	bus = NULL;
-	while ((bus = pci_find_next_bus(bus)) != NULL) {
+	for_each_pci_host_bridge(host_bridge) {
+		bus = host_bridge->bus;
 		bussoft = SN_PCIBUS_BUSSOFT(bus);
 		nasid = NASID_GET(bussoft->bs_base);
 		cnode = nasid_to_cnodeid(nasid);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 15/22] PCI, alpha: Kill pci_root_buses
  2013-01-27 19:23                   ` Yinghai Lu
                                     ` (15 preceding siblings ...)
  (?)
@ 2013-01-27 19:23                   ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu, Richard Henderson,
	Ivan Kokshaysky, Matt Turner, linux-alpha

Replace that with hotplug-safe version iteration.

-v2: Fix typo that is found by Fengguang

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha@vger.kernel.org
---
 arch/alpha/kernel/pci.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index ef75714..6c55e16 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -305,10 +305,10 @@ pcibios_claim_one_bus(struct pci_bus *b)
 static void __init
 pcibios_claim_console_setup(void)
 {
-	struct pci_bus *b;
+	struct pci_host_bridge *host_bridge = NULL;
 
-	list_for_each_entry(b, &pci_root_buses, node)
-		pcibios_claim_one_bus(b);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_claim_one_bus(host_bridge->bus);
 }
 
 void __init
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 16/22] PCI, arm: Kill pci_root_buses
  2013-01-27 19:23                   ` Yinghai Lu
@ 2013-01-27 19:23                     ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu, Russell King,
	linux-arm-kernel

Replace that with hotplug-safe version iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
---
 arch/arm/kernel/bios32.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index 9b72261..d0befe4 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -57,13 +57,10 @@ static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, in
 
 void pcibios_report_status(u_int status_mask, int warn)
 {
-	struct list_head *l;
+	struct pci_host_bridge *host_bridge = NULL;
 
-	list_for_each(l, &pci_root_buses) {
-		struct pci_bus *bus = pci_bus_b(l);
-
-		pcibios_bus_report_status(bus, status_mask, warn);
-	}
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_bus_report_status(host_bridge->bus, status_mask, warn);
 }
 
 /*
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 16/22] PCI, arm: Kill pci_root_buses
@ 2013-01-27 19:23                     ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: linux-arm-kernel

Replace that with hotplug-safe version iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
---
 arch/arm/kernel/bios32.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index 9b72261..d0befe4 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -57,13 +57,10 @@ static void pcibios_bus_report_status(struct pci_bus *bus, u_int status_mask, in
 
 void pcibios_report_status(u_int status_mask, int warn)
 {
-	struct list_head *l;
+	struct pci_host_bridge *host_bridge = NULL;
 
-	list_for_each(l, &pci_root_buses) {
-		struct pci_bus *bus = pci_bus_b(l);
-
-		pcibios_bus_report_status(bus, status_mask, warn);
-	}
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_bus_report_status(host_bridge->bus, status_mask, warn);
 }
 
 /*
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 17/22] PCI, frv: Kill pci_root_buses in resources reservations
  2013-01-27 19:23                   ` Yinghai Lu
                                     ` (17 preceding siblings ...)
  (?)
@ 2013-01-27 19:23                   ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu, David Howells

Replace that with hotplug-safe version iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: David Howells <dhowells@redhat.com>
---
 arch/frv/mb93090-mb00/pci-frv.c |   37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/arch/frv/mb93090-mb00/pci-frv.c b/arch/frv/mb93090-mb00/pci-frv.c
index c281217..2a127f9 100644
--- a/arch/frv/mb93090-mb00/pci-frv.c
+++ b/arch/frv/mb93090-mb00/pci-frv.c
@@ -78,27 +78,26 @@ pcibios_align_resource(void *data, const struct resource *res,
  *	    as well.
  */
 
-static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
+static void __init pcibios_allocate_bridge_resources(struct pci_dev *dev)
 {
-	struct list_head *ln;
-	struct pci_bus *bus;
-	struct pci_dev *dev;
 	int idx;
 	struct resource *r;
+	for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
+		r = &dev->resource[idx];
+		if (!r->start)
+			continue;
+		pci_claim_resource(dev, idx);
+	}
+}
+static void __init pcibios_allocate_bus_resources(struct pci_bus *bus)
+{
+	struct pci_bus *child;
 
 	/* Depth-First Search on bus tree */
-	for (ln=bus_list->next; ln != bus_list; ln=ln->next) {
-		bus = pci_bus_b(ln);
-		if ((dev = bus->self)) {
-			for (idx = PCI_BRIDGE_RESOURCES; idx < PCI_NUM_RESOURCES; idx++) {
-				r = &dev->resource[idx];
-				if (!r->start)
-					continue;
-				pci_claim_resource(dev, idx);
-			}
-		}
-		pcibios_allocate_bus_resources(&bus->children);
-	}
+	if (bus->self)
+		pcibios_allocate_bridge_resources(bus->self);
+	list_for_each_entry(child, &bus->children, node)
+		pcibios_allocate_bus_resources(child);
 }
 
 static void __init pcibios_allocate_resources(int pass)
@@ -188,8 +187,12 @@ static void __init pcibios_assign_resources(void)
 
 void __init pcibios_resource_survey(void)
 {
+	struct pci_host_bridge *host_bridge = NULL;
+
 	DBG("PCI: Allocating resources\n");
-	pcibios_allocate_bus_resources(&pci_root_buses);
+
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_bus_resources(host_bridge->bus);
 	pcibios_allocate_resources(0);
 	pcibios_allocate_resources(1);
 	pcibios_assign_resources();
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 18/22] PCI, microblaze: Kill pci_root_buses in resources reservations
  2013-01-27 19:23                   ` Yinghai Lu
                                     ` (18 preceding siblings ...)
  (?)
@ 2013-01-27 19:23                   ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu, Michal Simek,
	microblaze-uclinux

Replace that with hotplug-safe version iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux@itee.uq.edu.au
---
 arch/microblaze/pci/pci-common.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index a1c5b99..51f6651 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -1323,13 +1323,13 @@ static void __init pcibios_reserve_legacy_regions(struct pci_bus *bus)
 
 void __init pcibios_resource_survey(void)
 {
-	struct pci_bus *b;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	/* Allocate and assign resources. If we re-assign everything, then
 	 * we skip the allocate phase
 	 */
-	list_for_each_entry(b, &pci_root_buses, node)
-		pcibios_allocate_bus_resources(b);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_bus_resources(host_bridge->bus);
 
 	pcibios_allocate_resources(0);
 	pcibios_allocate_resources(1);
@@ -1338,8 +1338,8 @@ void __init pcibios_resource_survey(void)
 	 * the low IO area and the VGA memory area if they intersect the
 	 * bus available resources to avoid allocating things on top of them
 	 */
-	list_for_each_entry(b, &pci_root_buses, node)
-		pcibios_reserve_legacy_regions(b);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_reserve_legacy_regions(host_bridge->bus);
 
 	/* Now proceed to assigning things that were left unassigned */
 	pr_debug("PCI: Assigning unassigned resources...\n");
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 19/22] PCI, mn10300: Kill pci_root_buses in resources reservations
  2013-01-27 19:23                   ` Yinghai Lu
                                     ` (19 preceding siblings ...)
  (?)
@ 2013-01-27 19:23                   ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu, David Howells,
	Koichi Yasutake, linux-am33-list

Replace that with hotplug-safe version iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list@redhat.com
---
 arch/mn10300/unit-asb2305/pci-asb2305.c |   62 ++++++++++++++++---------------
 1 file changed, 33 insertions(+), 29 deletions(-)

diff --git a/arch/mn10300/unit-asb2305/pci-asb2305.c b/arch/mn10300/unit-asb2305/pci-asb2305.c
index c4e2e79..87c945d 100644
--- a/arch/mn10300/unit-asb2305/pci-asb2305.c
+++ b/arch/mn10300/unit-asb2305/pci-asb2305.c
@@ -88,42 +88,42 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,
  *	    requested by the user, configure expansion ROM address
  *	    as well.
  */
-static void __init pcibios_allocate_bus_resources(struct list_head *bus_list)
+static void __init pcibios_allocate_bridge_resources(struct pci_dev *dev)
 {
-	struct pci_bus *bus;
-	struct pci_dev *dev;
 	int idx;
 	struct resource *r;
 
-	/* Depth-First Search on bus tree */
-	list_for_each_entry(bus, bus_list, node) {
-		dev = bus->self;
-		if (dev) {
-			for (idx = PCI_BRIDGE_RESOURCES;
-			     idx < PCI_NUM_RESOURCES;
-			     idx++) {
-				r = &dev->resource[idx];
-				if (!r->flags)
-					continue;
-				if (!r->start ||
-				    pci_claim_resource(dev, idx) < 0) {
-					printk(KERN_ERR "PCI:"
-					       " Cannot allocate resource"
-					       " region %d of bridge %s\n",
-					       idx, pci_name(dev));
-					/* Something is wrong with the region.
-					 * Invalidate the resource to prevent
-					 * child resource allocations in this
-					 * range. */
-					r->start = r->end = 0;
-					r->flags = 0;
-				}
-			}
+	for (idx = PCI_BRIDGE_RESOURCES;
+	     idx < PCI_NUM_RESOURCES;
+	     idx++) {
+		r = &dev->resource[idx];
+		if (!r->flags)
+			continue;
+		if (!r->start ||
+		    pci_claim_resource(dev, idx) < 0) {
+			pr_err("PCI: Cannot allocate resource region %d of bridge %s\n",
+			       idx, pci_name(dev));
+			/* Something is wrong with the region.
+			 * Invalidate the resource to prevent
+			 * child resource allocations in this
+			 * range. */
+			r->start = r->end = 0;
+			r->flags = 0;
 		}
-		pcibios_allocate_bus_resources(&bus->children);
 	}
 }
 
+static void pcibios_allocate_bus_resources(struct pci_bus *bus)
+{
+	struct pci_bus *child;
+
+	/* Depth-First Search on bus tree */
+	if (bus->self)
+		pcibios_allocate_bridge_resources(bus->self);
+	list_for_each_entry(child, &bus->children, node)
+		pcibios_allocate_bus_resources(child);
+}
+
 static void __init pcibios_allocate_resources(int pass)
 {
 	struct pci_dev *dev = NULL;
@@ -207,8 +207,12 @@ fs_initcall(pcibios_assign_resources);
 
 void __init pcibios_resource_survey(void)
 {
+	struct pci_host_bridge *host_bridge = NULL;
+
 	DBG("PCI: Allocating resources\n");
-	pcibios_allocate_bus_resources(&pci_root_buses);
+
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_bus_resources(host_bridge->bus);
 	pcibios_allocate_resources(0);
 	pcibios_allocate_resources(1);
 }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 20/22] PCI, powerpc: Kill pci_root_buses in resources reservations
  2013-01-27 19:23                   ` Yinghai Lu
@ 2013-01-27 19:23                     ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, Yinghai Lu,
	Benjamin Herrenschmidt, Paul Mackerras, linuxppc-dev

Replace that with hotplug-safe version iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 arch/powerpc/kernel/pci-common.c |   13 ++++++-------
 arch/powerpc/kernel/pci_64.c     |    8 ++++----
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index abc0d08..9ccecbe 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1398,11 +1398,11 @@ static void __init pcibios_reserve_legacy_regions(struct pci_bus *bus)
 
 void __init pcibios_resource_survey(void)
 {
-	struct pci_bus *b;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	/* Allocate and assign resources */
-	list_for_each_entry(b, &pci_root_buses, node)
-		pcibios_allocate_bus_resources(b);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_bus_resources(host_bridge->bus);
 	pcibios_allocate_resources(0);
 	pcibios_allocate_resources(1);
 
@@ -1410,10 +1410,9 @@ void __init pcibios_resource_survey(void)
 	 * the low IO area and the VGA memory area if they intersect the
 	 * bus available resources to avoid allocating things on top of them
 	 */
-	if (!pci_has_flag(PCI_PROBE_ONLY)) {
-		list_for_each_entry(b, &pci_root_buses, node)
-			pcibios_reserve_legacy_regions(b);
-	}
+	if (!pci_has_flag(PCI_PROBE_ONLY))
+		for_each_pci_host_bridge(host_bridge)
+			pcibios_reserve_legacy_regions(host_bridge->bus);
 
 	/* Now, if the platform didn't decide to blindly trust the firmware,
 	 * we proceed to assigning things that were left unassigned
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 2cbe676..f848325 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -208,9 +208,9 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
 			  unsigned long in_devfn)
 {
 	struct pci_controller* hose;
-	struct list_head *ln;
-	struct pci_bus *bus = NULL;
+	struct pci_bus *bus;
 	struct device_node *hose_node;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	/* Argh ! Please forgive me for that hack, but that's the
 	 * simplest way to get existing XFree to not lockup on some
@@ -230,8 +230,8 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
 	 * used on pre-domains setup. We return the first match
 	 */
 
-	for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
-		bus = pci_bus_b(ln);
+	for_each_pci_host_bridge(host_bridge) {
+		bus = host_bridge->bus;
 		if (in_bus >= bus->number && in_bus <= bus->busn_res.end)
 			break;
 		bus = NULL;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 20/22] PCI, powerpc: Kill pci_root_buses in resources reservations
@ 2013-01-27 19:23                     ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, linux-pci, linuxppc-dev, Paul Mackerras, Yinghai Lu

Replace that with hotplug-safe version iteration.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 arch/powerpc/kernel/pci-common.c |   13 ++++++-------
 arch/powerpc/kernel/pci_64.c     |    8 ++++----
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index abc0d08..9ccecbe 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1398,11 +1398,11 @@ static void __init pcibios_reserve_legacy_regions(struct pci_bus *bus)
 
 void __init pcibios_resource_survey(void)
 {
-	struct pci_bus *b;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	/* Allocate and assign resources */
-	list_for_each_entry(b, &pci_root_buses, node)
-		pcibios_allocate_bus_resources(b);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_bus_resources(host_bridge->bus);
 	pcibios_allocate_resources(0);
 	pcibios_allocate_resources(1);
 
@@ -1410,10 +1410,9 @@ void __init pcibios_resource_survey(void)
 	 * the low IO area and the VGA memory area if they intersect the
 	 * bus available resources to avoid allocating things on top of them
 	 */
-	if (!pci_has_flag(PCI_PROBE_ONLY)) {
-		list_for_each_entry(b, &pci_root_buses, node)
-			pcibios_reserve_legacy_regions(b);
-	}
+	if (!pci_has_flag(PCI_PROBE_ONLY))
+		for_each_pci_host_bridge(host_bridge)
+			pcibios_reserve_legacy_regions(host_bridge->bus);
 
 	/* Now, if the platform didn't decide to blindly trust the firmware,
 	 * we proceed to assigning things that were left unassigned
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 2cbe676..f848325 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -208,9 +208,9 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
 			  unsigned long in_devfn)
 {
 	struct pci_controller* hose;
-	struct list_head *ln;
-	struct pci_bus *bus = NULL;
+	struct pci_bus *bus;
 	struct device_node *hose_node;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	/* Argh ! Please forgive me for that hack, but that's the
 	 * simplest way to get existing XFree to not lockup on some
@@ -230,8 +230,8 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
 	 * used on pre-domains setup. We return the first match
 	 */
 
-	for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
-		bus = pci_bus_b(ln);
+	for_each_pci_host_bridge(host_bridge) {
+		bus = host_bridge->bus;
 		if (in_bus >= bus->number && in_bus <= bus->busn_res.end)
 			break;
 		bus = NULL;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 21/22] PCI: Kill pci_find_next_bus
  2013-01-27 19:23                   ` Yinghai Lu
  (?)
@ 2013-01-27 19:23                     ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: linux-ia64, Mauro Carvalho Chehab, David Airlie, linux-pci,
	dri-devel, David Howells, Paul Mackerras, sparclinux,
	linux-am33-list, Russell King, x86, linux-altix, Doug Thompson,
	Matt Turner, linux-edac, Fenghua Yu, microblaze-uclinux,
	Ivan Kokshaysky, Yinghai Lu, linux-arm-kernel, Richard Henderson,
	Michal Simek, Tony Luck, Greg Kroah-Hartman, linux-alpha,
	Koichi Yasutake, linuxppc-dev, David S. Miller

No user now, remove it.

That name is misleading as it only for root buses.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac@vger.kernel.org
Cc: x86@kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-altix@sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha@vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux@itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list@redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 drivers/pci/search.c |   37 +++++++------------------------------
 include/linux/pci.h  |    4 ----
 2 files changed, 7 insertions(+), 34 deletions(-)

diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index db0c3a9..329c533 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -79,44 +79,22 @@ static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr)
  */
 struct pci_bus * pci_find_bus(int domain, int busnr)
 {
-	struct pci_bus *bus = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
 	struct pci_bus *tmp_bus;
 
-	while ((bus = pci_find_next_bus(bus)) != NULL)  {
-		if (pci_domain_nr(bus) != domain)
+	for_each_pci_host_bridge(host_bridge) {
+		if (pci_domain_nr(host_bridge->bus) != domain)
 			continue;
-		tmp_bus = pci_do_find_bus(bus, busnr);
-		if (tmp_bus)
+		tmp_bus = pci_do_find_bus(host_bridge->bus, busnr);
+		if (tmp_bus) {
+			put_device(&host_bridge->dev);
 			return tmp_bus;
+		}
 	}
 	return NULL;
 }
 
 /**
- * pci_find_next_bus - begin or continue searching for a PCI bus
- * @from: Previous PCI bus found, or %NULL for new search.
- *
- * Iterates through the list of known PCI busses.  A new search is
- * initiated by passing %NULL as the @from argument.  Otherwise if
- * @from is not %NULL, searches continue from next device on the
- * global list.
- */
-struct pci_bus * 
-pci_find_next_bus(const struct pci_bus *from)
-{
-	struct list_head *n;
-	struct pci_bus *b = NULL;
-
-	WARN_ON(in_interrupt());
-	down_read(&pci_bus_sem);
-	n = from ? from->node.next : pci_root_buses.next;
-	if (n != &pci_root_buses)
-		b = pci_bus_b(n);
-	up_read(&pci_bus_sem);
-	return b;
-}
-
-/**
  * pci_get_slot - locate PCI device for a given PCI slot
  * @bus: PCI bus on which desired PCI device resides
  * @devfn: encodes number of PCI slot in which the desired PCI 
@@ -356,7 +334,6 @@ EXPORT_SYMBOL(pci_dev_present);
 
 /* For boot time work */
 EXPORT_SYMBOL(pci_find_bus);
-EXPORT_SYMBOL(pci_find_next_bus);
 /* For everyone */
 EXPORT_SYMBOL(pci_get_device);
 EXPORT_SYMBOL(pci_get_subsys);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 67879cb..bb07db2 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -763,7 +763,6 @@ int pci_find_ext_capability(struct pci_dev *dev, int cap);
 int pci_find_next_ext_capability(struct pci_dev *dev, int pos, int cap);
 int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
 int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
-struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
 
 struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from);
 struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
@@ -1404,9 +1403,6 @@ static inline int pci_block_cfg_access_in_atomic(struct pci_dev *dev)
 static inline void pci_unblock_cfg_access(struct pci_dev *dev)
 { }
 
-static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
-{ return NULL; }
-
 static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
 						unsigned int devfn)
 { return NULL; }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 21/22] PCI: Kill pci_find_next_bus
@ 2013-01-27 19:23                     ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: linux-arm-kernel

No user now, remove it.

That name is misleading as it only for root buses.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac at vger.kernel.org
Cc: x86 at kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel at lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux at vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64 at vger.kernel.org
Cc: linux-altix at sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha at vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list at redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev at lists.ozlabs.org
---
 drivers/pci/search.c |   37 +++++++------------------------------
 include/linux/pci.h  |    4 ----
 2 files changed, 7 insertions(+), 34 deletions(-)

diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index db0c3a9..329c533 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -79,44 +79,22 @@ static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr)
  */
 struct pci_bus * pci_find_bus(int domain, int busnr)
 {
-	struct pci_bus *bus = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
 	struct pci_bus *tmp_bus;
 
-	while ((bus = pci_find_next_bus(bus)) != NULL)  {
-		if (pci_domain_nr(bus) != domain)
+	for_each_pci_host_bridge(host_bridge) {
+		if (pci_domain_nr(host_bridge->bus) != domain)
 			continue;
-		tmp_bus = pci_do_find_bus(bus, busnr);
-		if (tmp_bus)
+		tmp_bus = pci_do_find_bus(host_bridge->bus, busnr);
+		if (tmp_bus) {
+			put_device(&host_bridge->dev);
 			return tmp_bus;
+		}
 	}
 	return NULL;
 }
 
 /**
- * pci_find_next_bus - begin or continue searching for a PCI bus
- * @from: Previous PCI bus found, or %NULL for new search.
- *
- * Iterates through the list of known PCI busses.  A new search is
- * initiated by passing %NULL as the @from argument.  Otherwise if
- * @from is not %NULL, searches continue from next device on the
- * global list.
- */
-struct pci_bus * 
-pci_find_next_bus(const struct pci_bus *from)
-{
-	struct list_head *n;
-	struct pci_bus *b = NULL;
-
-	WARN_ON(in_interrupt());
-	down_read(&pci_bus_sem);
-	n = from ? from->node.next : pci_root_buses.next;
-	if (n != &pci_root_buses)
-		b = pci_bus_b(n);
-	up_read(&pci_bus_sem);
-	return b;
-}
-
-/**
  * pci_get_slot - locate PCI device for a given PCI slot
  * @bus: PCI bus on which desired PCI device resides
  * @devfn: encodes number of PCI slot in which the desired PCI 
@@ -356,7 +334,6 @@ EXPORT_SYMBOL(pci_dev_present);
 
 /* For boot time work */
 EXPORT_SYMBOL(pci_find_bus);
-EXPORT_SYMBOL(pci_find_next_bus);
 /* For everyone */
 EXPORT_SYMBOL(pci_get_device);
 EXPORT_SYMBOL(pci_get_subsys);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 67879cb..bb07db2 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -763,7 +763,6 @@ int pci_find_ext_capability(struct pci_dev *dev, int cap);
 int pci_find_next_ext_capability(struct pci_dev *dev, int pos, int cap);
 int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
 int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
-struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
 
 struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from);
 struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
@@ -1404,9 +1403,6 @@ static inline int pci_block_cfg_access_in_atomic(struct pci_dev *dev)
 static inline void pci_unblock_cfg_access(struct pci_dev *dev)
 { }
 
-static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
-{ return NULL; }
-
 static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
 						unsigned int devfn)
 { return NULL; }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 21/22] PCI: Kill pci_find_next_bus
@ 2013-01-27 19:23                     ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: linux-ia64, Mauro Carvalho Chehab, David Airlie, linux-pci,
	dri-devel, David Howells, Paul Mackerras, sparclinux,
	linux-am33-list, Russell King, x86, linux-altix, Doug Thompson,
	Matt Turner, linux-edac, Fenghua Yu, microblaze-uclinux,
	Ivan Kokshaysky, Yinghai Lu, linux-arm-kernel, Richard Henderson,
	Michal Simek, Tony Luck, Greg Kroah-Hartman,
	Benjamin Herrenschmidt, linux-alpha

No user now, remove it.

That name is misleading as it only for root buses.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac@vger.kernel.org
Cc: x86@kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-altix@sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha@vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux@itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list@redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 drivers/pci/search.c |   37 +++++++------------------------------
 include/linux/pci.h  |    4 ----
 2 files changed, 7 insertions(+), 34 deletions(-)

diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index db0c3a9..329c533 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -79,44 +79,22 @@ static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr)
  */
 struct pci_bus * pci_find_bus(int domain, int busnr)
 {
-	struct pci_bus *bus = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
 	struct pci_bus *tmp_bus;
 
-	while ((bus = pci_find_next_bus(bus)) != NULL)  {
-		if (pci_domain_nr(bus) != domain)
+	for_each_pci_host_bridge(host_bridge) {
+		if (pci_domain_nr(host_bridge->bus) != domain)
 			continue;
-		tmp_bus = pci_do_find_bus(bus, busnr);
-		if (tmp_bus)
+		tmp_bus = pci_do_find_bus(host_bridge->bus, busnr);
+		if (tmp_bus) {
+			put_device(&host_bridge->dev);
 			return tmp_bus;
+		}
 	}
 	return NULL;
 }
 
 /**
- * pci_find_next_bus - begin or continue searching for a PCI bus
- * @from: Previous PCI bus found, or %NULL for new search.
- *
- * Iterates through the list of known PCI busses.  A new search is
- * initiated by passing %NULL as the @from argument.  Otherwise if
- * @from is not %NULL, searches continue from next device on the
- * global list.
- */
-struct pci_bus * 
-pci_find_next_bus(const struct pci_bus *from)
-{
-	struct list_head *n;
-	struct pci_bus *b = NULL;
-
-	WARN_ON(in_interrupt());
-	down_read(&pci_bus_sem);
-	n = from ? from->node.next : pci_root_buses.next;
-	if (n != &pci_root_buses)
-		b = pci_bus_b(n);
-	up_read(&pci_bus_sem);
-	return b;
-}
-
-/**
  * pci_get_slot - locate PCI device for a given PCI slot
  * @bus: PCI bus on which desired PCI device resides
  * @devfn: encodes number of PCI slot in which the desired PCI 
@@ -356,7 +334,6 @@ EXPORT_SYMBOL(pci_dev_present);
 
 /* For boot time work */
 EXPORT_SYMBOL(pci_find_bus);
-EXPORT_SYMBOL(pci_find_next_bus);
 /* For everyone */
 EXPORT_SYMBOL(pci_get_device);
 EXPORT_SYMBOL(pci_get_subsys);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 67879cb..bb07db2 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -763,7 +763,6 @@ int pci_find_ext_capability(struct pci_dev *dev, int cap);
 int pci_find_next_ext_capability(struct pci_dev *dev, int pos, int cap);
 int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
 int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
-struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
 
 struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from);
 struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
@@ -1404,9 +1403,6 @@ static inline int pci_block_cfg_access_in_atomic(struct pci_dev *dev)
 static inline void pci_unblock_cfg_access(struct pci_dev *dev)
 { }
 
-static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
-{ return NULL; }
-
 static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
 						unsigned int devfn)
 { return NULL; }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 22/22] PCI: Kill pci_root_buses
  2013-01-27 19:23                   ` Yinghai Lu
  (?)
@ 2013-01-27 19:23                     ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: linux-ia64, Mauro Carvalho Chehab, David Airlie, linux-pci,
	dri-devel, David Howells, Paul Mackerras, sparclinux,
	linux-am33-list, Russell King, x86, linux-altix, Doug Thompson,
	Matt Turner, linux-edac, Fenghua Yu, microblaze-uclinux,
	Ivan Kokshaysky, Yinghai Lu, linux-arm-kernel, Richard Henderson,
	Michal Simek, Tony Luck, Greg Kroah-Hartman, linux-alpha,
	Koichi Yasutake, linuxppc-dev, David S. Miller

No user now, remove it.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac@vger.kernel.org
Cc: x86@kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-altix@sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha@vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux@itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list@redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 drivers/pci/probe.c |    8 --------
 include/linux/pci.h |    3 ---
 2 files changed, 11 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 04ecf0d..8420b9d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -23,10 +23,6 @@ struct resource busn_resource = {
 	.flags	= IORESOURCE_BUS,
 };
 
-/* Ugh.  Need to stop exporting this to modules. */
-LIST_HEAD(pci_root_buses);
-EXPORT_SYMBOL(pci_root_buses);
-
 static LIST_HEAD(pci_domain_busn_res_list);
 
 struct pci_domain_busn_res {
@@ -1746,10 +1742,6 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 		dev_info(&b->dev, "root bus resource %pR%s\n", res, bus_addr);
 	}
 
-	down_write(&pci_bus_sem);
-	list_add_tail(&b->node, &pci_root_buses);
-	up_write(&pci_bus_sem);
-
 	return b;
 
 class_dev_reg_err:
diff --git a/include/linux/pci.h b/include/linux/pci.h
index bb07db2..b42721b 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -674,9 +674,6 @@ extern enum pcie_bus_config_types pcie_bus_config;
 extern struct bus_type pci_host_bridge_bus_type;
 extern struct bus_type pci_bus_type;
 
-/* Do NOT directly access these two variables, unless you are arch specific pci
- * code, or pci core code. */
-extern struct list_head pci_root_buses;	/* list of all known PCI buses */
 /* Some device drivers need know if pci is initiated */
 extern int no_pci_devices(void);
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 22/22] PCI: Kill pci_root_buses
@ 2013-01-27 19:23                     ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: linux-arm-kernel

No user now, remove it.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac at vger.kernel.org
Cc: x86 at kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel at lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux at vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64 at vger.kernel.org
Cc: linux-altix at sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha at vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux at itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list at redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev at lists.ozlabs.org
---
 drivers/pci/probe.c |    8 --------
 include/linux/pci.h |    3 ---
 2 files changed, 11 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 04ecf0d..8420b9d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -23,10 +23,6 @@ struct resource busn_resource = {
 	.flags	= IORESOURCE_BUS,
 };
 
-/* Ugh.  Need to stop exporting this to modules. */
-LIST_HEAD(pci_root_buses);
-EXPORT_SYMBOL(pci_root_buses);
-
 static LIST_HEAD(pci_domain_busn_res_list);
 
 struct pci_domain_busn_res {
@@ -1746,10 +1742,6 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 		dev_info(&b->dev, "root bus resource %pR%s\n", res, bus_addr);
 	}
 
-	down_write(&pci_bus_sem);
-	list_add_tail(&b->node, &pci_root_buses);
-	up_write(&pci_bus_sem);
-
 	return b;
 
 class_dev_reg_err:
diff --git a/include/linux/pci.h b/include/linux/pci.h
index bb07db2..b42721b 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -674,9 +674,6 @@ extern enum pcie_bus_config_types pcie_bus_config;
 extern struct bus_type pci_host_bridge_bus_type;
 extern struct bus_type pci_bus_type;
 
-/* Do NOT directly access these two variables, unless you are arch specific pci
- * code, or pci core code. */
-extern struct list_head pci_root_buses;	/* list of all known PCI buses */
 /* Some device drivers need know if pci is initiated */
 extern int no_pci_devices(void);
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 22/22] PCI: Kill pci_root_buses
@ 2013-01-27 19:23                     ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-27 19:23 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: linux-ia64, Mauro Carvalho Chehab, David Airlie, linux-pci,
	dri-devel, David Howells, Paul Mackerras, sparclinux,
	linux-am33-list, Russell King, x86, linux-altix, Doug Thompson,
	Matt Turner, linux-edac, Fenghua Yu, microblaze-uclinux,
	Ivan Kokshaysky, Yinghai Lu, linux-arm-kernel, Richard Henderson,
	Michal Simek, Tony Luck, Greg Kroah-Hartman,
	Benjamin Herrenschmidt, linux-alpha

No user now, remove it.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: Doug Thompson <dougthompson@xmission.com>
Cc: linux-edac@vger.kernel.org
Cc: x86@kernel.org
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
Cc: linux-altix@sgi.com
Cc: Richard Henderson <rth@twiddle.net>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Matt Turner <mattst88@gmail.com>
Cc: linux-alpha@vger.kernel.org
Cc: Russell King <linux@arm.linux.org.uk>
Cc: linux-arm-kernel@lists.infradead.org
Cc: David Howells <dhowells@redhat.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux@itee.uq.edu.au
Cc: Koichi Yasutake <yasutake.koichi@jp.panasonic.com>
Cc: linux-am33-list@redhat.com
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
 drivers/pci/probe.c |    8 --------
 include/linux/pci.h |    3 ---
 2 files changed, 11 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 04ecf0d..8420b9d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -23,10 +23,6 @@ struct resource busn_resource = {
 	.flags	= IORESOURCE_BUS,
 };
 
-/* Ugh.  Need to stop exporting this to modules. */
-LIST_HEAD(pci_root_buses);
-EXPORT_SYMBOL(pci_root_buses);
-
 static LIST_HEAD(pci_domain_busn_res_list);
 
 struct pci_domain_busn_res {
@@ -1746,10 +1742,6 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 		dev_info(&b->dev, "root bus resource %pR%s\n", res, bus_addr);
 	}
 
-	down_write(&pci_bus_sem);
-	list_add_tail(&b->node, &pci_root_buses);
-	up_write(&pci_bus_sem);
-
 	return b;
 
 class_dev_reg_err:
diff --git a/include/linux/pci.h b/include/linux/pci.h
index bb07db2..b42721b 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -674,9 +674,6 @@ extern enum pcie_bus_config_types pcie_bus_config;
 extern struct bus_type pci_host_bridge_bus_type;
 extern struct bus_type pci_bus_type;
 
-/* Do NOT directly access these two variables, unless you are arch specific pci
- * code, or pci core code. */
-extern struct list_head pci_root_buses;	/* list of all known PCI buses */
 /* Some device drivers need know if pci is initiated */
 extern int no_pci_devices(void);
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 122+ messages in thread

* Re: [PATCH v2 01/22] PCI: Rename pci_release_bus_bridge_dev to pci_release_host_bridge_dev
  2013-01-27  5:36           ` [PATCH v2 01/22] PCI: Rename pci_release_bus_bridge_dev to pci_release_host_bridge_dev Yinghai Lu
@ 2013-01-27 22:26             ` Rafael J. Wysocki
  0 siblings, 0 replies; 122+ messages in thread
From: Rafael J. Wysocki @ 2013-01-27 22:26 UTC (permalink / raw)
  To: Yinghai Lu; +Cc: Bjorn Helgaas, Jiang Liu, Taku Izumi, linux-pci

On Saturday, January 26, 2013 09:36:22 PM Yinghai Lu wrote:
> It is with host bridge, so change the name to reflect the fact.
> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  drivers/pci/probe.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index b494066..ef50154 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -1187,7 +1187,7 @@ int pci_cfg_space_size(struct pci_dev *dev)
>  	return PCI_CFG_SPACE_SIZE;
>  }
>  
> -static void pci_release_bus_bridge_dev(struct device *dev)
> +static void pci_release_host_bridge_dev(struct device *dev)
>  {
>  	struct pci_host_bridge *bridge = to_pci_host_bridge(dev);
>  
> @@ -1692,7 +1692,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
>  		goto err_out;
>  
>  	bridge->dev.parent = parent;
> -	bridge->dev.release = pci_release_bus_bridge_dev;
> +	bridge->dev.release = pci_release_host_bridge_dev;
>  	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
>  	error = pcibios_root_bridge_prepare(bridge);
>  	if (error)
> 
-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 04/22] PCI, ACPI: Update comments for find_bridge in acpi_bus_type
  2013-01-27 19:23                   ` [PATCH v3 04/22] PCI, ACPI: Update comments for " Yinghai Lu
@ 2013-01-27 22:32                     ` Rafael J. Wysocki
  2013-01-28  1:00                       ` Yinghai Lu
  0 siblings, 1 reply; 122+ messages in thread
From: Rafael J. Wysocki @ 2013-01-27 22:32 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Bjorn Helgaas, Jiang Liu, Taku Izumi, Toshi Kani,
	Greg Kroah-Hartman, linux-pci, Len Brown, linux-acpi,
	Jeff Garzik, Tejun Heo

On Sunday, January 27, 2013 11:23:31 AM Yinghai Lu wrote:
> only device that does not have bus_type, will go to that path...

While I agree that the comment doesn't make sense any more, I also think that
changing the comment alone is not sufficient, because what USB does with
.find_bridge() is really disgusting to me and USB is the only real user of it
(SATA just pretends to be one).

So, instead of this change, I'd prefer to apply the appended patch some time
in the second part of the 3.9 merge window, after integrating all of the
ACPI and PCI changes already queued up.

Thanks,
Rafael


---
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Subject: ACPI / glue: Drop .find_bridge() callback from struct acpi_bus_type

After PCI has stopped using the .find_bridge() callback in
struct acpi_bus_type, the only remaining users of it are SATA and
USB.  However, SATA only pretends to be a user, because it points
that callback to a stub always returning -ENODEV, and USB uses it
incorrectly, because as a result of the way it is used by USB every
device in the system that doesn't have a bus type or parent is
passed to usb_acpi_find_device() for inspection.

What USB actually needs, though, is to call usb_acpi_find_device()
for USB ports that don't have a bus type defined, but have
usb_port_device_type as their device type.

To fix that add a device type field to struct acpi_bus_type and
make acpi_get_bus_type() compare it with the device type fields of
the device objects it inspects in addition to checking their bus
types.  Next, make USB set the new type field in usb_acpi_bus to
point to usb_port_device_type and stop abusing the .find_bridge()
callback.

In addition to that drop the SATA's dummy .find_bridge() callback,
and remove .find_bridge(), which is not used any more, from struct
acpi_bus_type entirely.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/glue.c         |   39 ++++++---------------------------------
 drivers/ata/libata-acpi.c   |    6 ------
 drivers/usb/core/usb-acpi.c |    2 +-
 include/acpi/acpi_bus.h     |    4 +---
 4 files changed, 8 insertions(+), 43 deletions(-)

Index: linux-pm/drivers/acpi/glue.c
===================================================================
--- linux-pm.orig/drivers/acpi/glue.c
+++ linux-pm/drivers/acpi/glue.c
@@ -64,16 +64,17 @@ int unregister_acpi_bus_type(struct acpi
 }
 EXPORT_SYMBOL_GPL(unregister_acpi_bus_type);
 
-static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type)
+static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
 {
 	struct acpi_bus_type *tmp, *ret = NULL;
 
-	if (!type)
+	if (!dev->bus && !dev->type)
 		return NULL;
 
 	down_read(&bus_type_sem);
 	list_for_each_entry(tmp, &bus_type_list, list) {
-		if (tmp->bus == type) {
+		if ((tmp->bus && tmp->bus == dev->bus)
+		    || (tmp->type && tmp->type == dev->type)) {
 			ret = tmp;
 			break;
 		}
@@ -82,22 +83,6 @@ static struct acpi_bus_type *acpi_get_bu
 	return ret;
 }
 
-static int acpi_find_bridge_device(struct device *dev, acpi_handle * handle)
-{
-	struct acpi_bus_type *tmp;
-	int ret = -ENODEV;
-
-	down_read(&bus_type_sem);
-	list_for_each_entry(tmp, &bus_type_list, list) {
-		if (tmp->find_bridge && !tmp->find_bridge(dev, handle)) {
-			ret = 0;
-			break;
-		}
-	}
-	up_read(&bus_type_sem);
-	return ret;
-}
-
 static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used,
 				      void *addr_p, void **ret_p)
 {
@@ -261,22 +246,11 @@ err:
 
 static int acpi_platform_notify(struct device *dev)
 {
-	struct acpi_bus_type *type;
+	struct acpi_bus_type *type = acpi_get_bus_type(dev);
 	acpi_handle handle;
 	int ret;
 
 	ret = acpi_bind_one(dev, NULL);
-	if (ret && (!dev->bus || !dev->parent)) {
-		/* bridge devices genernally haven't bus or parent */
-		ret = acpi_find_bridge_device(dev, &handle);
-		if (!ret) {
-			ret = acpi_bind_one(dev, handle);
-			if (ret)
-				goto out;
-		}
-	}
-
-	type = acpi_get_bus_type(dev->bus);
 	if (ret) {
 		if (!type || !type->find_device) {
 			DBG("No ACPI bus support for %s\n", dev_name(dev));
@@ -293,7 +267,6 @@ static int acpi_platform_notify(struct d
 		if (ret)
 			goto out;
 	}
-
 	if (type && type->setup)
 		type->setup(dev);
 
@@ -316,7 +289,7 @@ static int acpi_platform_notify_remove(s
 {
 	struct acpi_bus_type *type;
 
-	type = acpi_get_bus_type(dev->bus);
+	type = acpi_get_bus_type(dev);
 	if (type && type->cleanup)
 		type->cleanup(dev);
 
Index: linux-pm/include/acpi/acpi_bus.h
===================================================================
--- linux-pm.orig/include/acpi/acpi_bus.h
+++ linux-pm/include/acpi/acpi_bus.h
@@ -412,10 +412,8 @@ void acpi_remove_dir(struct acpi_device
 struct acpi_bus_type {
 	struct list_head list;
 	struct bus_type *bus;
-	/* For general devices under the bus */
+	struct device_type *type;
 	int (*find_device) (struct device *, acpi_handle *);
-	/* For bridges, such as PCI root bridge, IDE controller */
-	int (*find_bridge) (struct device *, acpi_handle *);
 	void (*setup)(struct device *);
 	void (*cleanup)(struct device *);
 };
Index: linux-pm/drivers/ata/libata-acpi.c
===================================================================
--- linux-pm.orig/drivers/ata/libata-acpi.c
+++ linux-pm/drivers/ata/libata-acpi.c
@@ -1167,13 +1167,7 @@ static int ata_acpi_find_device(struct d
 		return -ENODEV;
 }
 
-static int ata_acpi_find_dummy(struct device *dev, acpi_handle *handle)
-{
-	return -ENODEV;
-}
-
 static struct acpi_bus_type ata_acpi_bus = {
-	.find_bridge = ata_acpi_find_dummy,
 	.find_device = ata_acpi_find_device,
 };
 
Index: linux-pm/drivers/usb/core/usb-acpi.c
===================================================================
--- linux-pm.orig/drivers/usb/core/usb-acpi.c
+++ linux-pm/drivers/usb/core/usb-acpi.c
@@ -212,7 +212,7 @@ static int usb_acpi_find_device(struct d
 
 static struct acpi_bus_type usb_acpi_bus = {
 	.bus = &usb_bus_type,
-	.find_bridge = usb_acpi_find_device,
+	.type = &usb_port_device_type,
 	.find_device = usb_acpi_find_device,
 };
 


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 04/22] PCI, ACPI: Update comments for find_bridge in acpi_bus_type
  2013-01-27 22:32                     ` Rafael J. Wysocki
@ 2013-01-28  1:00                       ` Yinghai Lu
  2013-01-28 12:37                         ` Rafael J. Wysocki
  0 siblings, 1 reply; 122+ messages in thread
From: Yinghai Lu @ 2013-01-28  1:00 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Bjorn Helgaas, Jiang Liu, Taku Izumi, Toshi Kani,
	Greg Kroah-Hartman, linux-pci, Len Brown, linux-acpi,
	Jeff Garzik, Tejun Heo

On Sun, Jan 27, 2013 at 2:32 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> On Sunday, January 27, 2013 11:23:31 AM Yinghai Lu wrote:
>> only device that does not have bus_type, will go to that path...
>
> While I agree that the comment doesn't make sense any more, I also think that
> changing the comment alone is not sufficient, because what USB does with
> .find_bridge() is really disgusting to me and USB is the only real user of it
> (SATA just pretends to be one).

agree. that is really like hack for usb.

>
> So, instead of this change, I'd prefer to apply the appended patch some time
> in the second part of the 3.9 merge window, after integrating all of the
> ACPI and PCI changes already queued up.

Good, I will drop patch 4 but will keep patch3 about libata part with
ack from  Jeff Garzik.

>
> Thanks,
> Rafael
>
>
> ---
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Subject: ACPI / glue: Drop .find_bridge() callback from struct acpi_bus_type
>
> After PCI has stopped using the .find_bridge() callback in
> struct acpi_bus_type, the only remaining users of it are SATA and
> USB.  However, SATA only pretends to be a user, because it points
> that callback to a stub always returning -ENODEV, and USB uses it
> incorrectly, because as a result of the way it is used by USB every
> device in the system that doesn't have a bus type or parent is
> passed to usb_acpi_find_device() for inspection.
>
> What USB actually needs, though, is to call usb_acpi_find_device()
> for USB ports that don't have a bus type defined, but have
> usb_port_device_type as their device type.
>
> To fix that add a device type field to struct acpi_bus_type and
> make acpi_get_bus_type() compare it with the device type fields of
> the device objects it inspects in addition to checking their bus
> types.  Next, make USB set the new type field in usb_acpi_bus to
> point to usb_port_device_type and stop abusing the .find_bridge()
> callback.
>
> In addition to that drop the SATA's dummy .find_bridge() callback,
> and remove .find_bridge(), which is not used any more, from struct
> acpi_bus_type entirely.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/acpi/glue.c         |   39 ++++++---------------------------------
>  drivers/ata/libata-acpi.c   |    6 ------
>  drivers/usb/core/usb-acpi.c |    2 +-
>  include/acpi/acpi_bus.h     |    4 +---
>  4 files changed, 8 insertions(+), 43 deletions(-)
>
> Index: linux-pm/drivers/acpi/glue.c
> ===================================================================
> --- linux-pm.orig/drivers/acpi/glue.c
> +++ linux-pm/drivers/acpi/glue.c
> @@ -64,16 +64,17 @@ int unregister_acpi_bus_type(struct acpi
>  }
>  EXPORT_SYMBOL_GPL(unregister_acpi_bus_type);
>
> -static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type)
> +static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
>  {
>         struct acpi_bus_type *tmp, *ret = NULL;
>
> -       if (!type)
> +       if (!dev->bus && !dev->type)
>                 return NULL;
>
>         down_read(&bus_type_sem);
>         list_for_each_entry(tmp, &bus_type_list, list) {
> -               if (tmp->bus == type) {
> +               if ((tmp->bus && tmp->bus == dev->bus)
> +                   || (tmp->type && tmp->type == dev->type)) {
>                         ret = tmp;
>                         break;
>                 }
> @@ -82,22 +83,6 @@ static struct acpi_bus_type *acpi_get_bu
>         return ret;
>  }
>
> -static int acpi_find_bridge_device(struct device *dev, acpi_handle * handle)
> -{
> -       struct acpi_bus_type *tmp;
> -       int ret = -ENODEV;
> -
> -       down_read(&bus_type_sem);
> -       list_for_each_entry(tmp, &bus_type_list, list) {
> -               if (tmp->find_bridge && !tmp->find_bridge(dev, handle)) {
> -                       ret = 0;
> -                       break;
> -               }
> -       }
> -       up_read(&bus_type_sem);
> -       return ret;
> -}
> -
>  static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used,
>                                       void *addr_p, void **ret_p)
>  {
> @@ -261,22 +246,11 @@ err:
>
>  static int acpi_platform_notify(struct device *dev)
>  {
> -       struct acpi_bus_type *type;
> +       struct acpi_bus_type *type = acpi_get_bus_type(dev);
>         acpi_handle handle;
>         int ret;
>
>         ret = acpi_bind_one(dev, NULL);
> -       if (ret && (!dev->bus || !dev->parent)) {
> -               /* bridge devices genernally haven't bus or parent */
> -               ret = acpi_find_bridge_device(dev, &handle);
> -               if (!ret) {
> -                       ret = acpi_bind_one(dev, handle);
> -                       if (ret)
> -                               goto out;
> -               }
> -       }
> -
> -       type = acpi_get_bus_type(dev->bus);
>         if (ret) {
>                 if (!type || !type->find_device) {
>                         DBG("No ACPI bus support for %s\n", dev_name(dev));
> @@ -293,7 +267,6 @@ static int acpi_platform_notify(struct d
>                 if (ret)
>                         goto out;
>         }
> -
>         if (type && type->setup)
>                 type->setup(dev);
>
> @@ -316,7 +289,7 @@ static int acpi_platform_notify_remove(s
>  {
>         struct acpi_bus_type *type;
>
> -       type = acpi_get_bus_type(dev->bus);
> +       type = acpi_get_bus_type(dev);
>         if (type && type->cleanup)
>                 type->cleanup(dev);
>
> Index: linux-pm/include/acpi/acpi_bus.h
> ===================================================================
> --- linux-pm.orig/include/acpi/acpi_bus.h
> +++ linux-pm/include/acpi/acpi_bus.h
> @@ -412,10 +412,8 @@ void acpi_remove_dir(struct acpi_device
>  struct acpi_bus_type {
>         struct list_head list;
>         struct bus_type *bus;
> -       /* For general devices under the bus */
> +       struct device_type *type;
>         int (*find_device) (struct device *, acpi_handle *);
> -       /* For bridges, such as PCI root bridge, IDE controller */
> -       int (*find_bridge) (struct device *, acpi_handle *);
>         void (*setup)(struct device *);
>         void (*cleanup)(struct device *);
>  };
> Index: linux-pm/drivers/ata/libata-acpi.c
> ===================================================================
> --- linux-pm.orig/drivers/ata/libata-acpi.c
> +++ linux-pm/drivers/ata/libata-acpi.c
> @@ -1167,13 +1167,7 @@ static int ata_acpi_find_device(struct d
>                 return -ENODEV;
>  }
>
> -static int ata_acpi_find_dummy(struct device *dev, acpi_handle *handle)
> -{
> -       return -ENODEV;
> -}
> -
>  static struct acpi_bus_type ata_acpi_bus = {
> -       .find_bridge = ata_acpi_find_dummy,
>         .find_device = ata_acpi_find_device,
>  };
>
> Index: linux-pm/drivers/usb/core/usb-acpi.c
> ===================================================================
> --- linux-pm.orig/drivers/usb/core/usb-acpi.c
> +++ linux-pm/drivers/usb/core/usb-acpi.c
> @@ -212,7 +212,7 @@ static int usb_acpi_find_device(struct d
>
>  static struct acpi_bus_type usb_acpi_bus = {
>         .bus = &usb_bus_type,
> -       .find_bridge = usb_acpi_find_device,
> +       .type = &usb_port_device_type,
>         .find_device = usb_acpi_find_device,
>  };

Can we add one acpi_bus_type for port directly?

Thanks

Yinghai

^ permalink raw reply	[flat|nested] 122+ messages in thread

* [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-01-27 18:22                 ` Yinghai Lu
  (?)
  (?)
@ 2013-01-28  1:54                 ` Yinghai Lu
  2013-01-28  1:54                   ` [PATCH v3 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
                                     ` (3 more replies)
  -1 siblings, 4 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-28  1:54 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, Russell King, linux-pci, Yinghai Lu

Now we have pci_root_buses list, and there is lots of iteration with
list_of_each of it, that is not safe after we add pci root bus hotplug
support after booting stage.

Add pci_get_next_host_bridge and use bus_find_device in driver core to
iterate host bridge and the same time get root bus.

We replace searching root bus with searching host_bridge,
as host_bridge->bus is the root bus.
After those replacing, we even could kill pci_root_buses list.

based on pci/next

could get from
        git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-for-each-host-bridge

-v2: updated after pci_root_bus_hotplug get into pci/next
-v3: update changelog and add cc for pci core change for arch guys.

Yinghai Lu (22):
  PCI: Rename pci_release_bus_bridge_dev to pci_release_host_bridge_dev
  PCI: Add dummy bus_type for pci_host_bridge
  PCI, libata: remove find_bridge in acpi_bus_type
  PCI, ACPI: Update comments for find_bridge in acpi_bus_type
  PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge
  PCI, hotplug: Kill pci_find_next_bus in sgi_hotplug
  PCI: Kill pci_find_next_bus in pci_sysfs
  PCI, edac: Kill pci_find_next_bus in edac
  PCI, x86: Kill pci_find_next_bus in pcibios_scan_root
  PCI, x86: Kill pci_root_buses in resources reservations
  PCI, drm: Kill pci_root_buses in alpha hose setting
  PCI: Kill pci_root_buses in setup-bus
  PCI, sparc: Kill pci_find_next_bus
  PCI, ia64: Kill pci_find_next_bus
  PCI, alpha: Kill pci_root_buses
  PCI, arm: Kill pci_root_buses
  PCI, frv: Kill pci_root_buses in resources reservations
  PCI, microblaze: Kill pci_root_buses in resources reservations
  PCI, mn10300: Kill pci_root_buses in resources reservations
  PCI, powerpc: Kill pci_root_buses in resources reservations
  PCI: Kill pci_find_next_bus
  PCI: Kill pci_root_buses

 arch/alpha/kernel/pci.c                 |    6 +--
 arch/arm/kernel/bios32.c                |    9 ++---
 arch/frv/mb93090-mb00/pci-frv.c         |   37 +++++++++---------
 arch/ia64/hp/common/sba_iommu.c         |    7 ++--
 arch/ia64/sn/kernel/io_common.c         |    5 ++-
 arch/microblaze/pci/pci-common.c        |   10 ++---
 arch/mn10300/unit-asb2305/pci-asb2305.c |   62 ++++++++++++++++---------------
 arch/powerpc/kernel/pci-common.c        |   13 +++----
 arch/powerpc/kernel/pci_64.c            |    8 ++--
 arch/sparc/kernel/pci.c                 |    6 ++-
 arch/x86/pci/common.c                   |    9 +++--
 arch/x86/pci/i386.c                     |   20 +++++-----
 drivers/ata/libata-acpi.c               |    6 ---
 drivers/edac/i7core_edac.c              |    6 +--
 drivers/gpu/drm/drm_fops.c              |   10 +++--
 drivers/pci/hotplug/sgi_hotplug.c       |    6 ++-
 drivers/pci/pci-driver.c                |   11 +++++-
 drivers/pci/pci-sysfs.c                 |    6 +--
 drivers/pci/probe.c                     |   13 ++-----
 drivers/pci/search.c                    |   61 +++++++++++++++---------------
 drivers/pci/setup-bus.c                 |   24 ++++++------
 include/acpi/acpi_bus.h                 |    2 +-
 include/linux/pci.h                     |   18 +++++----
 23 files changed, 187 insertions(+), 168 deletions(-)

-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 122+ messages in thread

* [PATCH v3 02/22] PCI: Add dummy bus_type for pci_host_bridge
  2013-01-28  1:54                 ` Yinghai Lu
@ 2013-01-28  1:54                   ` Yinghai Lu
  2013-01-28  1:54                   ` [PATCH v3 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge Yinghai Lu
                                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-28  1:54 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, Russell King, linux-pci, Yinghai Lu

Need to use it for looping registered host_bridge, and kill
pci_root_buses list.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/pci/pci-driver.c |   11 ++++++++++-
 drivers/pci/probe.c      |    1 +
 include/linux/pci.h      |    2 ++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index acdcc3c..9fb004b 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -1278,11 +1278,20 @@ struct bus_type pci_bus_type = {
 	.pm		= PCI_PM_OPS_PTR,
 };
 
+struct bus_type pci_host_bridge_bus_type = {
+	.name           = "pci_host_bridge",
+};
+
+static int __init pci_host_bridge_driver_init(void)
+{
+	return bus_register(&pci_host_bridge_bus_type);
+}
+postcore_initcall(pci_host_bridge_driver_init);
+
 static int __init pci_driver_init(void)
 {
 	return bus_register(&pci_bus_type);
 }
-
 postcore_initcall(pci_driver_init);
 
 EXPORT_SYMBOL_GPL(pci_add_dynid);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index ef50154..04ecf0d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1692,6 +1692,7 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 		goto err_out;
 
 	bridge->dev.parent = parent;
+	bridge->dev.bus = &pci_host_bridge_bus_type;
 	bridge->dev.release = pci_release_host_bridge_dev;
 	dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(b), bus);
 	error = pcibios_root_bridge_prepare(bridge);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 056d3d6..9da06ec 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -669,6 +669,7 @@ enum pcie_bus_config_types {
 
 extern enum pcie_bus_config_types pcie_bus_config;
 
+extern struct bus_type pci_host_bridge_bus_type;
 extern struct bus_type pci_bus_type;
 
 /* Do NOT directly access these two variables, unless you are arch specific pci
@@ -740,6 +741,7 @@ void pci_stop_root_bus(struct pci_bus *bus);
 void pci_remove_root_bus(struct pci_bus *bus);
 void pci_setup_cardbus(struct pci_bus *bus);
 extern void pci_sort_breadthfirst(void);
+#define dev_is_pci_host_bridge(d) ((d)->bus == &pci_host_bridge_bus_type)
 #define dev_is_pci(d) ((d)->bus == &pci_bus_type)
 #define dev_is_pf(d) ((dev_is_pci(d) ? to_pci_dev(d)->is_physfn : false))
 #define dev_num_vf(d) ((dev_is_pci(d) ? pci_num_vf(to_pci_dev(d)) : 0))
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge
  2013-01-28  1:54                 ` Yinghai Lu
  2013-01-28  1:54                   ` [PATCH v3 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
@ 2013-01-28  1:54                   ` Yinghai Lu
  2013-01-28  1:54                   ` [PATCH v3 21/22] PCI: Kill pci_find_next_bus Yinghai Lu
  2013-01-28  1:54                   ` [PATCH v3 22/22] PCI: Kill pci_root_buses Yinghai Lu
  3 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-28  1:54 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, Russell King, linux-pci, Yinghai Lu

Now we have pci_root_buses list, and there is lots of iteration with
list_of_each of it, that is not safe after we add pci root bus hotplug
support after booting stage.

Also pci_find_next_bus is pretty misleading name, and it is only finding
next root bus instead of regular pci bus.

Add pci_get_next_host_bridge and use bus_find_device in driver core to
iterate host bridge and the same time get root bus.

In folllowing patches will replace searching root bus with searching host_bridge.
after using with that host-bridge, will need to call put device to release
reference if break early from the loop.

After those replacing, we even could kill pci_root_buses list.

-v2: fixes compiling error when CONFIG_PCI is not defined that Fengguang Wu found.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/pci/search.c |   24 ++++++++++++++++++++++++
 include/linux/pci.h  |    9 +++++++++
 2 files changed, 33 insertions(+)

diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index d0627fa..db0c3a9 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -178,6 +178,30 @@ struct pci_dev *pci_get_domain_bus_and_slot(int domain, unsigned int bus,
 }
 EXPORT_SYMBOL(pci_get_domain_bus_and_slot);
 
+static int match_pci_host_bridge(struct device *dev, void *data)
+{
+	return 1;
+}
+
+struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from)
+{
+	struct device *dev;
+	struct device *dev_start = NULL;
+	struct pci_host_bridge *bridge = NULL;
+
+	WARN_ON(in_interrupt());
+	if (from)
+		dev_start = &from->dev;
+	dev = bus_find_device(&pci_host_bridge_bus_type, dev_start, NULL,
+			      match_pci_host_bridge);
+	if (dev)
+		bridge = to_pci_host_bridge(dev);
+	if (from)
+		put_device(&from->dev);
+	return bridge;
+}
+EXPORT_SYMBOL_GPL(pci_get_next_host_bridge);
+
 static int match_pci_dev_by_id(struct device *dev, void *data)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9da06ec..67879cb 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -375,6 +375,8 @@ struct pci_host_bridge {
 };
 
 #define	to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev)
+#define for_each_pci_host_bridge(d) while ((d = pci_get_next_host_bridge(d)) != NULL)
+
 void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
 		     void (*release_fn)(struct pci_host_bridge *),
 		     void *release_data);
@@ -763,6 +765,7 @@ int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
 int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
 struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
 
+struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from);
 struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
 				struct pci_dev *from);
 struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
@@ -1418,6 +1421,12 @@ static inline int pci_domain_nr(struct pci_bus *bus)
 static inline struct pci_dev *pci_dev_get(struct pci_dev *dev)
 { return NULL; }
 
+static inline struct pci_host_bridge *pci_get_next_host_bridge(
+			struct pci_host_bridge *host_bridge)
+{
+	return NULL;
+}
+
 #define dev_is_pci(d) (false)
 #define dev_is_pf(d) (false)
 #define dev_num_vf(d) (0)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 21/22] PCI: Kill pci_find_next_bus
  2013-01-28  1:54                 ` Yinghai Lu
  2013-01-28  1:54                   ` [PATCH v3 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
  2013-01-28  1:54                   ` [PATCH v3 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge Yinghai Lu
@ 2013-01-28  1:54                   ` Yinghai Lu
  2013-01-28  1:54                   ` [PATCH v3 22/22] PCI: Kill pci_root_buses Yinghai Lu
  3 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-28  1:54 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, Russell King, linux-pci, Yinghai Lu

No user now, remove it.

That name is misleading as it only for root buses.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/pci/search.c |   37 +++++++------------------------------
 include/linux/pci.h  |    4 ----
 2 files changed, 7 insertions(+), 34 deletions(-)

diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index db0c3a9..329c533 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -79,44 +79,22 @@ static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr)
  */
 struct pci_bus * pci_find_bus(int domain, int busnr)
 {
-	struct pci_bus *bus = NULL;
+	struct pci_host_bridge *host_bridge = NULL;
 	struct pci_bus *tmp_bus;
 
-	while ((bus = pci_find_next_bus(bus)) != NULL)  {
-		if (pci_domain_nr(bus) != domain)
+	for_each_pci_host_bridge(host_bridge) {
+		if (pci_domain_nr(host_bridge->bus) != domain)
 			continue;
-		tmp_bus = pci_do_find_bus(bus, busnr);
-		if (tmp_bus)
+		tmp_bus = pci_do_find_bus(host_bridge->bus, busnr);
+		if (tmp_bus) {
+			put_device(&host_bridge->dev);
 			return tmp_bus;
+		}
 	}
 	return NULL;
 }
 
 /**
- * pci_find_next_bus - begin or continue searching for a PCI bus
- * @from: Previous PCI bus found, or %NULL for new search.
- *
- * Iterates through the list of known PCI busses.  A new search is
- * initiated by passing %NULL as the @from argument.  Otherwise if
- * @from is not %NULL, searches continue from next device on the
- * global list.
- */
-struct pci_bus * 
-pci_find_next_bus(const struct pci_bus *from)
-{
-	struct list_head *n;
-	struct pci_bus *b = NULL;
-
-	WARN_ON(in_interrupt());
-	down_read(&pci_bus_sem);
-	n = from ? from->node.next : pci_root_buses.next;
-	if (n != &pci_root_buses)
-		b = pci_bus_b(n);
-	up_read(&pci_bus_sem);
-	return b;
-}
-
-/**
  * pci_get_slot - locate PCI device for a given PCI slot
  * @bus: PCI bus on which desired PCI device resides
  * @devfn: encodes number of PCI slot in which the desired PCI 
@@ -356,7 +334,6 @@ EXPORT_SYMBOL(pci_dev_present);
 
 /* For boot time work */
 EXPORT_SYMBOL(pci_find_bus);
-EXPORT_SYMBOL(pci_find_next_bus);
 /* For everyone */
 EXPORT_SYMBOL(pci_get_device);
 EXPORT_SYMBOL(pci_get_subsys);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 67879cb..bb07db2 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -763,7 +763,6 @@ int pci_find_ext_capability(struct pci_dev *dev, int cap);
 int pci_find_next_ext_capability(struct pci_dev *dev, int pos, int cap);
 int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
 int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
-struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
 
 struct pci_host_bridge *pci_get_next_host_bridge(struct pci_host_bridge *from);
 struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
@@ -1404,9 +1403,6 @@ static inline int pci_block_cfg_access_in_atomic(struct pci_dev *dev)
 static inline void pci_unblock_cfg_access(struct pci_dev *dev)
 { }
 
-static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
-{ return NULL; }
-
 static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
 						unsigned int devfn)
 { return NULL; }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* [PATCH v3 22/22] PCI: Kill pci_root_buses
  2013-01-28  1:54                 ` Yinghai Lu
                                     ` (2 preceding siblings ...)
  2013-01-28  1:54                   ` [PATCH v3 21/22] PCI: Kill pci_find_next_bus Yinghai Lu
@ 2013-01-28  1:54                   ` Yinghai Lu
  3 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-28  1:54 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani
  Cc: Greg Kroah-Hartman, Russell King, linux-pci, Yinghai Lu

No user now, remove it.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
 drivers/pci/probe.c |    8 --------
 include/linux/pci.h |    3 ---
 2 files changed, 11 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 04ecf0d..8420b9d 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -23,10 +23,6 @@ struct resource busn_resource = {
 	.flags	= IORESOURCE_BUS,
 };
 
-/* Ugh.  Need to stop exporting this to modules. */
-LIST_HEAD(pci_root_buses);
-EXPORT_SYMBOL(pci_root_buses);
-
 static LIST_HEAD(pci_domain_busn_res_list);
 
 struct pci_domain_busn_res {
@@ -1746,10 +1742,6 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
 		dev_info(&b->dev, "root bus resource %pR%s\n", res, bus_addr);
 	}
 
-	down_write(&pci_bus_sem);
-	list_add_tail(&b->node, &pci_root_buses);
-	up_write(&pci_bus_sem);
-
 	return b;
 
 class_dev_reg_err:
diff --git a/include/linux/pci.h b/include/linux/pci.h
index bb07db2..b42721b 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -674,9 +674,6 @@ extern enum pcie_bus_config_types pcie_bus_config;
 extern struct bus_type pci_host_bridge_bus_type;
 extern struct bus_type pci_bus_type;
 
-/* Do NOT directly access these two variables, unless you are arch specific pci
- * code, or pci core code. */
-extern struct list_head pci_root_buses;	/* list of all known PCI buses */
 /* Some device drivers need know if pci is initiated */
 extern int no_pci_devices(void);
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 11/22] PCI, drm: Kill pci_root_buses in alpha hose setting
  2013-01-27 19:23                   ` [PATCH v3 11/22] PCI, drm: Kill pci_root_buses in alpha hose setting Yinghai Lu
@ 2013-01-28  3:21                       ` Yijing Wang
  0 siblings, 0 replies; 122+ messages in thread
From: Yijing Wang @ 2013-01-28  3:21 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi,
	Toshi Kani, Greg Kroah-Hartman, linux-pci, David Airlie,
	dri-devel

On 2013/1/28 3:23, Yinghai Lu wrote:
> Replace that with hotplug-safe version.
> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: David Airlie <airlied@linux.ie>
> Cc: dri-devel@lists.freedesktop.org
> ---
>  drivers/gpu/drm/drm_fops.c |   10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index 133b413..b92a9cc 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -356,9 +356,13 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
>  			pci_dev_put(pci_dev);
>  		}
>  		if (!dev->hose) {
> -			struct pci_bus *b = pci_bus_b(pci_root_buses.next);
> -			if (b)
> -				dev->hose = b->sysdata;
> +			struct pci_host_bridge *host_bridge;
> +
> +			host_bridge = pci_next_host_bridge(NULL);

pci_get_next_host_bridge() ?

> +			if (host_bridge) {
> +				dev->hose = host_bridge->bus->sysdata;
> +				put_device(&host_bridge->dev);
> +			}
>  		}
>  	}
>  #endif
> 


-- 
Thanks!
Yijing


^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 11/22] PCI, drm: Kill pci_root_buses in alpha hose setting
@ 2013-01-28  3:21                       ` Yijing Wang
  0 siblings, 0 replies; 122+ messages in thread
From: Yijing Wang @ 2013-01-28  3:21 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi,
	Toshi Kani, Greg Kroah-Hartman, linux-pci, David Airlie,
	dri-devel

On 2013/1/28 3:23, Yinghai Lu wrote:
> Replace that with hotplug-safe version.
> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: David Airlie <airlied@linux.ie>
> Cc: dri-devel@lists.freedesktop.org
> ---
>  drivers/gpu/drm/drm_fops.c |   10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
> index 133b413..b92a9cc 100644
> --- a/drivers/gpu/drm/drm_fops.c
> +++ b/drivers/gpu/drm/drm_fops.c
> @@ -356,9 +356,13 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
>  			pci_dev_put(pci_dev);
>  		}
>  		if (!dev->hose) {
> -			struct pci_bus *b = pci_bus_b(pci_root_buses.next);
> -			if (b)
> -				dev->hose = b->sysdata;
> +			struct pci_host_bridge *host_bridge;
> +
> +			host_bridge = pci_next_host_bridge(NULL);

pci_get_next_host_bridge() ?

> +			if (host_bridge) {
> +				dev->hose = host_bridge->bus->sysdata;
> +				put_device(&host_bridge->dev);
> +			}
>  		}
>  	}
>  #endif
> 


-- 
Thanks!
Yijing

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 11/22] PCI, drm: Kill pci_root_buses in alpha hose setting
  2013-01-28  3:21                       ` Yijing Wang
  (?)
@ 2013-01-28  3:35                       ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-28  3:35 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi,
	Toshi Kani, Greg Kroah-Hartman, linux-pci, David Airlie,
	dri-devel

On Sun, Jan 27, 2013 at 7:21 PM, Yijing Wang <wangyijing@huawei.com> wrote:
> On 2013/1/28 3:23, Yinghai Lu wrote:
>> Replace that with hotplug-safe version.
>>
>> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
>> Cc: David Airlie <airlied@linux.ie>
>> Cc: dri-devel@lists.freedesktop.org
>> ---
>>  drivers/gpu/drm/drm_fops.c |   10 +++++++---
>>  1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
>> index 133b413..b92a9cc 100644
>> --- a/drivers/gpu/drm/drm_fops.c
>> +++ b/drivers/gpu/drm/drm_fops.c
>> @@ -356,9 +356,13 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
>>                       pci_dev_put(pci_dev);
>>               }
>>               if (!dev->hose) {
>> -                     struct pci_bus *b = pci_bus_b(pci_root_buses.next);
>> -                     if (b)
>> -                             dev->hose = b->sysdata;
>> +                     struct pci_host_bridge *host_bridge;
>> +
>> +                     host_bridge = pci_next_host_bridge(NULL);
>
> pci_get_next_host_bridge() ?
>

Fixed.

Thanks.

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 20/22] PCI, powerpc: Kill pci_root_buses in resources reservations
  2013-01-27 19:23                     ` Yinghai Lu
@ 2013-01-28  3:48                       ` Yijing Wang
  -1 siblings, 0 replies; 122+ messages in thread
From: Yijing Wang @ 2013-01-28  3:48 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi,
	Toshi Kani, Greg Kroah-Hartman, linux-pci,
	Benjamin Herrenschmidt, Paul Mackerras, linuxppc-dev

On 2013/1/28 3:23, Yinghai Lu wrote:
> Replace that with hotplug-safe version iteration.
> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
>  arch/powerpc/kernel/pci-common.c |   13 ++++++-------
>  arch/powerpc/kernel/pci_64.c     |    8 ++++----
>  2 files changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index abc0d08..9ccecbe 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1398,11 +1398,11 @@ static void __init pcibios_reserve_legacy_regions(struct pci_bus *bus)
>  
>  void __init pcibios_resource_survey(void)
>  {
> -	struct pci_bus *b;
> +	struct pci_host_bridge *host_bridge = NULL;
>  
>  	/* Allocate and assign resources */
> -	list_for_each_entry(b, &pci_root_buses, node)
> -		pcibios_allocate_bus_resources(b);
> +	for_each_pci_host_bridge(host_bridge)
> +		pcibios_allocate_bus_resources(host_bridge->bus);
>  	pcibios_allocate_resources(0);
>  	pcibios_allocate_resources(1);
>  
> @@ -1410,10 +1410,9 @@ void __init pcibios_resource_survey(void)
>  	 * the low IO area and the VGA memory area if they intersect the
>  	 * bus available resources to avoid allocating things on top of them
>  	 */
> -	if (!pci_has_flag(PCI_PROBE_ONLY)) {
> -		list_for_each_entry(b, &pci_root_buses, node)
> -			pcibios_reserve_legacy_regions(b);
> -	}
> +	if (!pci_has_flag(PCI_PROBE_ONLY))
> +		for_each_pci_host_bridge(host_bridge)
> +			pcibios_reserve_legacy_regions(host_bridge->bus);
>  
>  	/* Now, if the platform didn't decide to blindly trust the firmware,
>  	 * we proceed to assigning things that were left unassigned
> diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
> index 2cbe676..f848325 100644
> --- a/arch/powerpc/kernel/pci_64.c
> +++ b/arch/powerpc/kernel/pci_64.c
> @@ -208,9 +208,9 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
>  			  unsigned long in_devfn)
>  {
>  	struct pci_controller* hose;
> -	struct list_head *ln;
> -	struct pci_bus *bus = NULL;
> +	struct pci_bus *bus;
>  	struct device_node *hose_node;
> +	struct pci_host_bridge *host_bridge = NULL;
>  
>  	/* Argh ! Please forgive me for that hack, but that's the
>  	 * simplest way to get existing XFree to not lockup on some
> @@ -230,8 +230,8 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
>  	 * used on pre-domains setup. We return the first match
>  	 */
>  
> -	for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
> -		bus = pci_bus_b(ln);
> +	for_each_pci_host_bridge(host_bridge) {
> +		bus = host_bridge->bus;
>  		if (in_bus >= bus->number && in_bus <= bus->busn_res.end)

Need put_device(&host_bridge->dev).

>  			break;
>  		bus = NULL;
> 


-- 
Thanks!
Yijing


^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 20/22] PCI, powerpc: Kill pci_root_buses in resources reservations
@ 2013-01-28  3:48                       ` Yijing Wang
  0 siblings, 0 replies; 122+ messages in thread
From: Yijing Wang @ 2013-01-28  3:48 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Toshi Kani, Jiang Liu, Greg Kroah-Hartman, Rafael J. Wysocki,
	linux-pci, Bjorn Helgaas, Taku Izumi, linuxppc-dev,
	Paul Mackerras

On 2013/1/28 3:23, Yinghai Lu wrote:
> Replace that with hotplug-safe version iteration.
> 
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: linuxppc-dev@lists.ozlabs.org
> ---
>  arch/powerpc/kernel/pci-common.c |   13 ++++++-------
>  arch/powerpc/kernel/pci_64.c     |    8 ++++----
>  2 files changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
> index abc0d08..9ccecbe 100644
> --- a/arch/powerpc/kernel/pci-common.c
> +++ b/arch/powerpc/kernel/pci-common.c
> @@ -1398,11 +1398,11 @@ static void __init pcibios_reserve_legacy_regions(struct pci_bus *bus)
>  
>  void __init pcibios_resource_survey(void)
>  {
> -	struct pci_bus *b;
> +	struct pci_host_bridge *host_bridge = NULL;
>  
>  	/* Allocate and assign resources */
> -	list_for_each_entry(b, &pci_root_buses, node)
> -		pcibios_allocate_bus_resources(b);
> +	for_each_pci_host_bridge(host_bridge)
> +		pcibios_allocate_bus_resources(host_bridge->bus);
>  	pcibios_allocate_resources(0);
>  	pcibios_allocate_resources(1);
>  
> @@ -1410,10 +1410,9 @@ void __init pcibios_resource_survey(void)
>  	 * the low IO area and the VGA memory area if they intersect the
>  	 * bus available resources to avoid allocating things on top of them
>  	 */
> -	if (!pci_has_flag(PCI_PROBE_ONLY)) {
> -		list_for_each_entry(b, &pci_root_buses, node)
> -			pcibios_reserve_legacy_regions(b);
> -	}
> +	if (!pci_has_flag(PCI_PROBE_ONLY))
> +		for_each_pci_host_bridge(host_bridge)
> +			pcibios_reserve_legacy_regions(host_bridge->bus);
>  
>  	/* Now, if the platform didn't decide to blindly trust the firmware,
>  	 * we proceed to assigning things that were left unassigned
> diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
> index 2cbe676..f848325 100644
> --- a/arch/powerpc/kernel/pci_64.c
> +++ b/arch/powerpc/kernel/pci_64.c
> @@ -208,9 +208,9 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
>  			  unsigned long in_devfn)
>  {
>  	struct pci_controller* hose;
> -	struct list_head *ln;
> -	struct pci_bus *bus = NULL;
> +	struct pci_bus *bus;
>  	struct device_node *hose_node;
> +	struct pci_host_bridge *host_bridge = NULL;
>  
>  	/* Argh ! Please forgive me for that hack, but that's the
>  	 * simplest way to get existing XFree to not lockup on some
> @@ -230,8 +230,8 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
>  	 * used on pre-domains setup. We return the first match
>  	 */
>  
> -	for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
> -		bus = pci_bus_b(ln);
> +	for_each_pci_host_bridge(host_bridge) {
> +		bus = host_bridge->bus;
>  		if (in_bus >= bus->number && in_bus <= bus->busn_res.end)

Need put_device(&host_bridge->dev).

>  			break;
>  		bus = NULL;
> 


-- 
Thanks!
Yijing

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 20/22] PCI, powerpc: Kill pci_root_buses in resources reservations
  2013-01-28  3:48                       ` Yijing Wang
@ 2013-01-28  5:23                         ` Yinghai Lu
  -1 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-28  5:23 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Bjorn Helgaas, Jiang Liu, Rafael J. Wysocki, Taku Izumi,
	Toshi Kani, Greg Kroah-Hartman, linux-pci,
	Benjamin Herrenschmidt, Paul Mackerras, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 1334 bytes --]

On Sun, Jan 27, 2013 at 7:48 PM, Yijing Wang <wangyijing@huawei.com> wrote:
> On 2013/1/28 3:23, Yinghai Lu wrote:
>> diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
>> index 2cbe676..f848325 100644
>> --- a/arch/powerpc/kernel/pci_64.c
>> +++ b/arch/powerpc/kernel/pci_64.c
>> @@ -208,9 +208,9 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
>>                         unsigned long in_devfn)
>>  {
>>       struct pci_controller* hose;
>> -     struct list_head *ln;
>> -     struct pci_bus *bus = NULL;
>> +     struct pci_bus *bus;
>>       struct device_node *hose_node;
>> +     struct pci_host_bridge *host_bridge = NULL;
>>
>>       /* Argh ! Please forgive me for that hack, but that's the
>>        * simplest way to get existing XFree to not lockup on some
>> @@ -230,8 +230,8 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
>>        * used on pre-domains setup. We return the first match
>>        */
>>
>> -     for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
>> -             bus = pci_bus_b(ln);
>> +     for_each_pci_host_bridge(host_bridge) {
>> +             bus = host_bridge->bus;
>>               if (in_bus >= bus->number && in_bus <= bus->busn_res.end)
>
> Need put_device(&host_bridge->dev).
>

fixed in attached.

Thanks

Yinghai

[-- Attachment #2: kill_pci_root_buses_powerpc.patch --]
[-- Type: application/octet-stream, Size: 4361 bytes --]

Subject: [PATCH] PCI, powerpc: Kill pci_root_buses in resources reservations

Replace that with hotplug-safe version iteration.

-v2: add missing put_device found by Yijing Wang <wangyijing@huawei.com>
     also move the handling into the for_each_pci_host_bridge {} to
     make it really hotplug safe, also make the function more readable.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org

---
 arch/powerpc/kernel/pci-common.c |   13 +++----
 arch/powerpc/kernel/pci_64.c     |   67 +++++++++++++++++++++++----------------
 2 files changed, 46 insertions(+), 34 deletions(-)

Index: linux-2.6/arch/powerpc/kernel/pci-common.c
===================================================================
--- linux-2.6.orig/arch/powerpc/kernel/pci-common.c
+++ linux-2.6/arch/powerpc/kernel/pci-common.c
@@ -1397,11 +1397,11 @@ static void __init pcibios_reserve_legac
 
 void __init pcibios_resource_survey(void)
 {
-	struct pci_bus *b;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	/* Allocate and assign resources */
-	list_for_each_entry(b, &pci_root_buses, node)
-		pcibios_allocate_bus_resources(b);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_bus_resources(host_bridge->bus);
 	pcibios_allocate_resources(0);
 	pcibios_allocate_resources(1);
 
@@ -1409,10 +1409,9 @@ void __init pcibios_resource_survey(void
 	 * the low IO area and the VGA memory area if they intersect the
 	 * bus available resources to avoid allocating things on top of them
 	 */
-	if (!pci_has_flag(PCI_PROBE_ONLY)) {
-		list_for_each_entry(b, &pci_root_buses, node)
-			pcibios_reserve_legacy_regions(b);
-	}
+	if (!pci_has_flag(PCI_PROBE_ONLY))
+		for_each_pci_host_bridge(host_bridge)
+			pcibios_reserve_legacy_regions(host_bridge->bus);
 
 	/* Now, if the platform didn't decide to blindly trust the firmware,
 	 * we proceed to assigning things that were left unassigned
Index: linux-2.6/arch/powerpc/kernel/pci_64.c
===================================================================
--- linux-2.6.orig/arch/powerpc/kernel/pci_64.c
+++ linux-2.6/arch/powerpc/kernel/pci_64.c
@@ -207,10 +207,7 @@ void pcibios_setup_phb_io_space(struct p
 long sys_pciconfig_iobase(long which, unsigned long in_bus,
 			  unsigned long in_devfn)
 {
-	struct pci_controller* hose;
-	struct list_head *ln;
-	struct pci_bus *bus = NULL;
-	struct device_node *hose_node;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	/* Argh ! Please forgive me for that hack, but that's the
 	 * simplest way to get existing XFree to not lockup on some
@@ -229,33 +226,49 @@ long sys_pciconfig_iobase(long which, un
 	/* That syscall isn't quite compatible with PCI domains, but it's
 	 * used on pre-domains setup. We return the first match
 	 */
-
-	for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
-		bus = pci_bus_b(ln);
-		if (in_bus >= bus->number && in_bus <= bus->busn_res.end)
+	for_each_pci_host_bridge(host_bridge) {
+		struct device_node *hose_node;
+		struct pci_controller* hose;
+		struct pci_bus *bus;
+		long ret;
+
+		bus = host_bridge->bus;
+		if (in_bus < bus->number || in_bus > bus->busn_res.end)
+			continue;
+
+		if (!bus->dev.of_node) {
+			put_device(&host_bridge->dev);
+			return -ENODEV;
+		}
+
+		hose_node = bus->dev.of_node;
+		hose = PCI_DN(hose_node)->phb;
+
+		switch (which) {
+		case IOBASE_BRIDGE_NUMBER:
+			ret = (long)hose->first_busno;
 			break;
-		bus = NULL;
-	}
-	if (bus == NULL || bus->dev.of_node == NULL)
-		return -ENODEV;
-
-	hose_node = bus->dev.of_node;
-	hose = PCI_DN(hose_node)->phb;
+		case IOBASE_MEMORY:
+			ret = (long)hose->pci_mem_offset;
+			break;
+		case IOBASE_IO:
+			ret = (long)hose->io_base_phys;
+			break;
+		case IOBASE_ISA_IO:
+			ret = (long)isa_io_base;
+			break;
+		case IOBASE_ISA_MEM:
+			ret = -EINVAL;
+			break;
+		default:
+			ret = -EOPNOTSUPP;
+		}
 
-	switch (which) {
-	case IOBASE_BRIDGE_NUMBER:
-		return (long)hose->first_busno;
-	case IOBASE_MEMORY:
-		return (long)hose->pci_mem_offset;
-	case IOBASE_IO:
-		return (long)hose->io_base_phys;
-	case IOBASE_ISA_IO:
-		return (long)isa_io_base;
-	case IOBASE_ISA_MEM:
-		return -EINVAL;
+		put_device(&host_bridge->dev);
+		return ret;
 	}
 
-	return -EOPNOTSUPP;
+	return -ENODEV;
 }
 
 #ifdef CONFIG_NUMA

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 20/22] PCI, powerpc: Kill pci_root_buses in resources reservations
@ 2013-01-28  5:23                         ` Yinghai Lu
  0 siblings, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-01-28  5:23 UTC (permalink / raw)
  To: Yijing Wang
  Cc: Toshi Kani, Jiang Liu, Greg Kroah-Hartman, Rafael J. Wysocki,
	linux-pci, Bjorn Helgaas, Taku Izumi, linuxppc-dev,
	Paul Mackerras

[-- Attachment #1: Type: text/plain, Size: 1334 bytes --]

On Sun, Jan 27, 2013 at 7:48 PM, Yijing Wang <wangyijing@huawei.com> wrote:
> On 2013/1/28 3:23, Yinghai Lu wrote:
>> diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
>> index 2cbe676..f848325 100644
>> --- a/arch/powerpc/kernel/pci_64.c
>> +++ b/arch/powerpc/kernel/pci_64.c
>> @@ -208,9 +208,9 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
>>                         unsigned long in_devfn)
>>  {
>>       struct pci_controller* hose;
>> -     struct list_head *ln;
>> -     struct pci_bus *bus = NULL;
>> +     struct pci_bus *bus;
>>       struct device_node *hose_node;
>> +     struct pci_host_bridge *host_bridge = NULL;
>>
>>       /* Argh ! Please forgive me for that hack, but that's the
>>        * simplest way to get existing XFree to not lockup on some
>> @@ -230,8 +230,8 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
>>        * used on pre-domains setup. We return the first match
>>        */
>>
>> -     for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
>> -             bus = pci_bus_b(ln);
>> +     for_each_pci_host_bridge(host_bridge) {
>> +             bus = host_bridge->bus;
>>               if (in_bus >= bus->number && in_bus <= bus->busn_res.end)
>
> Need put_device(&host_bridge->dev).
>

fixed in attached.

Thanks

Yinghai

[-- Attachment #2: kill_pci_root_buses_powerpc.patch --]
[-- Type: application/octet-stream, Size: 4361 bytes --]

Subject: [PATCH] PCI, powerpc: Kill pci_root_buses in resources reservations

Replace that with hotplug-safe version iteration.

-v2: add missing put_device found by Yijing Wang <wangyijing@huawei.com>
     also move the handling into the for_each_pci_host_bridge {} to
     make it really hotplug safe, also make the function more readable.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@lists.ozlabs.org

---
 arch/powerpc/kernel/pci-common.c |   13 +++----
 arch/powerpc/kernel/pci_64.c     |   67 +++++++++++++++++++++++----------------
 2 files changed, 46 insertions(+), 34 deletions(-)

Index: linux-2.6/arch/powerpc/kernel/pci-common.c
===================================================================
--- linux-2.6.orig/arch/powerpc/kernel/pci-common.c
+++ linux-2.6/arch/powerpc/kernel/pci-common.c
@@ -1397,11 +1397,11 @@ static void __init pcibios_reserve_legac
 
 void __init pcibios_resource_survey(void)
 {
-	struct pci_bus *b;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	/* Allocate and assign resources */
-	list_for_each_entry(b, &pci_root_buses, node)
-		pcibios_allocate_bus_resources(b);
+	for_each_pci_host_bridge(host_bridge)
+		pcibios_allocate_bus_resources(host_bridge->bus);
 	pcibios_allocate_resources(0);
 	pcibios_allocate_resources(1);
 
@@ -1409,10 +1409,9 @@ void __init pcibios_resource_survey(void
 	 * the low IO area and the VGA memory area if they intersect the
 	 * bus available resources to avoid allocating things on top of them
 	 */
-	if (!pci_has_flag(PCI_PROBE_ONLY)) {
-		list_for_each_entry(b, &pci_root_buses, node)
-			pcibios_reserve_legacy_regions(b);
-	}
+	if (!pci_has_flag(PCI_PROBE_ONLY))
+		for_each_pci_host_bridge(host_bridge)
+			pcibios_reserve_legacy_regions(host_bridge->bus);
 
 	/* Now, if the platform didn't decide to blindly trust the firmware,
 	 * we proceed to assigning things that were left unassigned
Index: linux-2.6/arch/powerpc/kernel/pci_64.c
===================================================================
--- linux-2.6.orig/arch/powerpc/kernel/pci_64.c
+++ linux-2.6/arch/powerpc/kernel/pci_64.c
@@ -207,10 +207,7 @@ void pcibios_setup_phb_io_space(struct p
 long sys_pciconfig_iobase(long which, unsigned long in_bus,
 			  unsigned long in_devfn)
 {
-	struct pci_controller* hose;
-	struct list_head *ln;
-	struct pci_bus *bus = NULL;
-	struct device_node *hose_node;
+	struct pci_host_bridge *host_bridge = NULL;
 
 	/* Argh ! Please forgive me for that hack, but that's the
 	 * simplest way to get existing XFree to not lockup on some
@@ -229,33 +226,49 @@ long sys_pciconfig_iobase(long which, un
 	/* That syscall isn't quite compatible with PCI domains, but it's
 	 * used on pre-domains setup. We return the first match
 	 */
-
-	for (ln = pci_root_buses.next; ln != &pci_root_buses; ln = ln->next) {
-		bus = pci_bus_b(ln);
-		if (in_bus >= bus->number && in_bus <= bus->busn_res.end)
+	for_each_pci_host_bridge(host_bridge) {
+		struct device_node *hose_node;
+		struct pci_controller* hose;
+		struct pci_bus *bus;
+		long ret;
+
+		bus = host_bridge->bus;
+		if (in_bus < bus->number || in_bus > bus->busn_res.end)
+			continue;
+
+		if (!bus->dev.of_node) {
+			put_device(&host_bridge->dev);
+			return -ENODEV;
+		}
+
+		hose_node = bus->dev.of_node;
+		hose = PCI_DN(hose_node)->phb;
+
+		switch (which) {
+		case IOBASE_BRIDGE_NUMBER:
+			ret = (long)hose->first_busno;
 			break;
-		bus = NULL;
-	}
-	if (bus == NULL || bus->dev.of_node == NULL)
-		return -ENODEV;
-
-	hose_node = bus->dev.of_node;
-	hose = PCI_DN(hose_node)->phb;
+		case IOBASE_MEMORY:
+			ret = (long)hose->pci_mem_offset;
+			break;
+		case IOBASE_IO:
+			ret = (long)hose->io_base_phys;
+			break;
+		case IOBASE_ISA_IO:
+			ret = (long)isa_io_base;
+			break;
+		case IOBASE_ISA_MEM:
+			ret = -EINVAL;
+			break;
+		default:
+			ret = -EOPNOTSUPP;
+		}
 
-	switch (which) {
-	case IOBASE_BRIDGE_NUMBER:
-		return (long)hose->first_busno;
-	case IOBASE_MEMORY:
-		return (long)hose->pci_mem_offset;
-	case IOBASE_IO:
-		return (long)hose->io_base_phys;
-	case IOBASE_ISA_IO:
-		return (long)isa_io_base;
-	case IOBASE_ISA_MEM:
-		return -EINVAL;
+		put_device(&host_bridge->dev);
+		return ret;
 	}
 
-	return -EOPNOTSUPP;
+	return -ENODEV;
 }
 
 #ifdef CONFIG_NUMA

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 04/22] PCI, ACPI: Update comments for find_bridge in acpi_bus_type
  2013-01-28  1:00                       ` Yinghai Lu
@ 2013-01-28 12:37                         ` Rafael J. Wysocki
  0 siblings, 0 replies; 122+ messages in thread
From: Rafael J. Wysocki @ 2013-01-28 12:37 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Bjorn Helgaas, Jiang Liu, Taku Izumi, Toshi Kani,
	Greg Kroah-Hartman, linux-pci, Len Brown, linux-acpi,
	Jeff Garzik, Tejun Heo

On Sunday, January 27, 2013 05:00:38 PM Yinghai Lu wrote:
> On Sun, Jan 27, 2013 at 2:32 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > On Sunday, January 27, 2013 11:23:31 AM Yinghai Lu wrote:
> >> only device that does not have bus_type, will go to that path...
> >
> > While I agree that the comment doesn't make sense any more, I also think that
> > changing the comment alone is not sufficient, because what USB does with
> > .find_bridge() is really disgusting to me and USB is the only real user of it
> > (SATA just pretends to be one).
> 
> agree. that is really like hack for usb.
> 
> >
> > So, instead of this change, I'd prefer to apply the appended patch some time
> > in the second part of the 3.9 merge window, after integrating all of the
> > ACPI and PCI changes already queued up.
> 
> Good, I will drop patch 4 but will keep patch3 about libata part with
> ack from  Jeff Garzik.

OK

> > ---
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > Subject: ACPI / glue: Drop .find_bridge() callback from struct acpi_bus_type
> >
> > After PCI has stopped using the .find_bridge() callback in
> > struct acpi_bus_type, the only remaining users of it are SATA and
> > USB.  However, SATA only pretends to be a user, because it points
> > that callback to a stub always returning -ENODEV, and USB uses it
> > incorrectly, because as a result of the way it is used by USB every
> > device in the system that doesn't have a bus type or parent is
> > passed to usb_acpi_find_device() for inspection.
> >
> > What USB actually needs, though, is to call usb_acpi_find_device()
> > for USB ports that don't have a bus type defined, but have
> > usb_port_device_type as their device type.
> >
> > To fix that add a device type field to struct acpi_bus_type and
> > make acpi_get_bus_type() compare it with the device type fields of
> > the device objects it inspects in addition to checking their bus
> > types.  Next, make USB set the new type field in usb_acpi_bus to
> > point to usb_port_device_type and stop abusing the .find_bridge()
> > callback.
> >
> > In addition to that drop the SATA's dummy .find_bridge() callback,
> > and remove .find_bridge(), which is not used any more, from struct
> > acpi_bus_type entirely.
> >
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > ---
> >  drivers/acpi/glue.c         |   39 ++++++---------------------------------
> >  drivers/ata/libata-acpi.c   |    6 ------
> >  drivers/usb/core/usb-acpi.c |    2 +-
> >  include/acpi/acpi_bus.h     |    4 +---
> >  4 files changed, 8 insertions(+), 43 deletions(-)
> >
> > Index: linux-pm/drivers/acpi/glue.c
> > ===================================================================
> > --- linux-pm.orig/drivers/acpi/glue.c
> > +++ linux-pm/drivers/acpi/glue.c
> > @@ -64,16 +64,17 @@ int unregister_acpi_bus_type(struct acpi
> >  }
> >  EXPORT_SYMBOL_GPL(unregister_acpi_bus_type);
> >
> > -static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type)
> > +static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
> >  {
> >         struct acpi_bus_type *tmp, *ret = NULL;
> >
> > -       if (!type)
> > +       if (!dev->bus && !dev->type)
> >                 return NULL;
> >
> >         down_read(&bus_type_sem);
> >         list_for_each_entry(tmp, &bus_type_list, list) {
> > -               if (tmp->bus == type) {
> > +               if ((tmp->bus && tmp->bus == dev->bus)
> > +                   || (tmp->type && tmp->type == dev->type)) {
> >                         ret = tmp;
> >                         break;
> >                 }
> > @@ -82,22 +83,6 @@ static struct acpi_bus_type *acpi_get_bu
> >         return ret;
> >  }
> >
> > -static int acpi_find_bridge_device(struct device *dev, acpi_handle * handle)
> > -{
> > -       struct acpi_bus_type *tmp;
> > -       int ret = -ENODEV;
> > -
> > -       down_read(&bus_type_sem);
> > -       list_for_each_entry(tmp, &bus_type_list, list) {
> > -               if (tmp->find_bridge && !tmp->find_bridge(dev, handle)) {
> > -                       ret = 0;
> > -                       break;
> > -               }
> > -       }
> > -       up_read(&bus_type_sem);
> > -       return ret;
> > -}
> > -
> >  static acpi_status do_acpi_find_child(acpi_handle handle, u32 lvl_not_used,
> >                                       void *addr_p, void **ret_p)
> >  {
> > @@ -261,22 +246,11 @@ err:
> >
> >  static int acpi_platform_notify(struct device *dev)
> >  {
> > -       struct acpi_bus_type *type;
> > +       struct acpi_bus_type *type = acpi_get_bus_type(dev);
> >         acpi_handle handle;
> >         int ret;
> >
> >         ret = acpi_bind_one(dev, NULL);
> > -       if (ret && (!dev->bus || !dev->parent)) {
> > -               /* bridge devices genernally haven't bus or parent */
> > -               ret = acpi_find_bridge_device(dev, &handle);
> > -               if (!ret) {
> > -                       ret = acpi_bind_one(dev, handle);
> > -                       if (ret)
> > -                               goto out;
> > -               }
> > -       }
> > -
> > -       type = acpi_get_bus_type(dev->bus);
> >         if (ret) {
> >                 if (!type || !type->find_device) {
> >                         DBG("No ACPI bus support for %s\n", dev_name(dev));
> > @@ -293,7 +267,6 @@ static int acpi_platform_notify(struct d
> >                 if (ret)
> >                         goto out;
> >         }
> > -
> >         if (type && type->setup)
> >                 type->setup(dev);
> >
> > @@ -316,7 +289,7 @@ static int acpi_platform_notify_remove(s
> >  {
> >         struct acpi_bus_type *type;
> >
> > -       type = acpi_get_bus_type(dev->bus);
> > +       type = acpi_get_bus_type(dev);
> >         if (type && type->cleanup)
> >                 type->cleanup(dev);
> >
> > Index: linux-pm/include/acpi/acpi_bus.h
> > ===================================================================
> > --- linux-pm.orig/include/acpi/acpi_bus.h
> > +++ linux-pm/include/acpi/acpi_bus.h
> > @@ -412,10 +412,8 @@ void acpi_remove_dir(struct acpi_device
> >  struct acpi_bus_type {
> >         struct list_head list;
> >         struct bus_type *bus;
> > -       /* For general devices under the bus */
> > +       struct device_type *type;
> >         int (*find_device) (struct device *, acpi_handle *);
> > -       /* For bridges, such as PCI root bridge, IDE controller */
> > -       int (*find_bridge) (struct device *, acpi_handle *);
> >         void (*setup)(struct device *);
> >         void (*cleanup)(struct device *);
> >  };
> > Index: linux-pm/drivers/ata/libata-acpi.c
> > ===================================================================
> > --- linux-pm.orig/drivers/ata/libata-acpi.c
> > +++ linux-pm/drivers/ata/libata-acpi.c
> > @@ -1167,13 +1167,7 @@ static int ata_acpi_find_device(struct d
> >                 return -ENODEV;
> >  }
> >
> > -static int ata_acpi_find_dummy(struct device *dev, acpi_handle *handle)
> > -{
> > -       return -ENODEV;
> > -}
> > -
> >  static struct acpi_bus_type ata_acpi_bus = {
> > -       .find_bridge = ata_acpi_find_dummy,
> >         .find_device = ata_acpi_find_device,
> >  };
> >
> > Index: linux-pm/drivers/usb/core/usb-acpi.c
> > ===================================================================
> > --- linux-pm.orig/drivers/usb/core/usb-acpi.c
> > +++ linux-pm/drivers/usb/core/usb-acpi.c
> > @@ -212,7 +212,7 @@ static int usb_acpi_find_device(struct d
> >
> >  static struct acpi_bus_type usb_acpi_bus = {
> >         .bus = &usb_bus_type,
> > -       .find_bridge = usb_acpi_find_device,
> > +       .type = &usb_port_device_type,
> >         .find_device = usb_acpi_find_device,
> >  };
> 
> Can we add one acpi_bus_type for port directly?

We could, but then we'd trade one extra check in usb_acpi_find_device() for
one extra item in bus_type_list that would be checked for every invocation of
acpi_platform_notify() and acpi_platform_notify().  I'm not sure if that's a
good deal. :-)

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-01-27 19:23                   ` Yinghai Lu
  (?)
@ 2013-02-02 21:50                     ` Bjorn Helgaas
  -1 siblings, 0 replies; 122+ messages in thread
From: Bjorn Helgaas @ 2013-02-02 21:50 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: linux-ia64, Mauro Carvalho Chehab, David Airlie, linux-pci,
	dri-devel, David Howells, Paul Mackerras, sparclinux,
	linux-am33-list, Russell King, x86, linux-altix, Doug Thompson,
	Matt Turner, linux-edac, Fenghua Yu, Jiang Liu,
	microblaze-uclinux, Rafael J. Wysocki, Ivan Kokshaysky,
	Taku Izumi, linux-arm-kernel, Richard Henderson, Michal Simek,
	Tony Luck, Toshi Kani, Greg Kroah-Hartman, linux-alpha,
	Koichi Yasutake, linuxppc-dev, David S. Miller

On Sun, Jan 27, 2013 at 12:23 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> Now we have pci_root_buses list, and there is lots of iteration with
> list_of_each of it, that is not safe after we add pci root bus hotplug
> support after booting stage.
>
> Add pci_get_next_host_bridge and use bus_find_device in driver core to
> iterate host bridge and the same time get root bus.
>
> We replace searching root bus with searching host_bridge,
> as host_bridge->bus is the root bus.
> After those replacing, we even could kill pci_root_buses list.

These are the problems I think you're fixing:

1) pci_find_next_bus() is not safe because even though it holds
pci_bus_sem while walking the pci_root_buses list, it doesn't hold a
reference on the bus it returns.  The bus could be removed while the
caller is using it.

2) "list_for_each_entry(bus, &pci_root_buses, node)" is not safe
because hotplug might modify the pci_root_buses list.  Replacing that
with for_each_pci_host_bridge() solves that problem by using
bus_find_device(), which is built on klists, which are designed for
that problem.

3) pci_find_next_bus() claims to iterate through all known PCI buses,
but in fact only iterates through root buses.

So far, so good.  Those are problems we need to fix.

Your solution is to introduce for_each_pci_host_bridge() as an
iterator through the known host bridges.  There are two scenarios
where we use something like this:

1) We want to perform an operation on every known host bridge.

2) We want to initialize something for every host bridge.

In my opinion, the only instance of scenario 1) is bus_rescan_store(),
where we want to rescan all PCI host bridges.

In every other case, we're doing some kind of initialization of all
the host bridges.  For these cases, for_each_pci_host_bridge() is the
wrong solution because it doesn't work for hot-added bridges.  I think
these cases should be changed to use pcibios_root_bridge_prepare() or
something something else called in the host bridge add path.

Bjorn

^ permalink raw reply	[flat|nested] 122+ messages in thread

* [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
@ 2013-02-02 21:50                     ` Bjorn Helgaas
  0 siblings, 0 replies; 122+ messages in thread
From: Bjorn Helgaas @ 2013-02-02 21:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Jan 27, 2013 at 12:23 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> Now we have pci_root_buses list, and there is lots of iteration with
> list_of_each of it, that is not safe after we add pci root bus hotplug
> support after booting stage.
>
> Add pci_get_next_host_bridge and use bus_find_device in driver core to
> iterate host bridge and the same time get root bus.
>
> We replace searching root bus with searching host_bridge,
> as host_bridge->bus is the root bus.
> After those replacing, we even could kill pci_root_buses list.

These are the problems I think you're fixing:

1) pci_find_next_bus() is not safe because even though it holds
pci_bus_sem while walking the pci_root_buses list, it doesn't hold a
reference on the bus it returns.  The bus could be removed while the
caller is using it.

2) "list_for_each_entry(bus, &pci_root_buses, node)" is not safe
because hotplug might modify the pci_root_buses list.  Replacing that
with for_each_pci_host_bridge() solves that problem by using
bus_find_device(), which is built on klists, which are designed for
that problem.

3) pci_find_next_bus() claims to iterate through all known PCI buses,
but in fact only iterates through root buses.

So far, so good.  Those are problems we need to fix.

Your solution is to introduce for_each_pci_host_bridge() as an
iterator through the known host bridges.  There are two scenarios
where we use something like this:

1) We want to perform an operation on every known host bridge.

2) We want to initialize something for every host bridge.

In my opinion, the only instance of scenario 1) is bus_rescan_store(),
where we want to rescan all PCI host bridges.

In every other case, we're doing some kind of initialization of all
the host bridges.  For these cases, for_each_pci_host_bridge() is the
wrong solution because it doesn't work for hot-added bridges.  I think
these cases should be changed to use pcibios_root_bridge_prepare() or
something something else called in the host bridge add path.

Bjorn

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
@ 2013-02-02 21:50                     ` Bjorn Helgaas
  0 siblings, 0 replies; 122+ messages in thread
From: Bjorn Helgaas @ 2013-02-02 21:50 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: linux-ia64, Mauro Carvalho Chehab, David Airlie, linux-pci,
	dri-devel, David Howells, Paul Mackerras, sparclinux,
	linux-am33-list, Russell King, x86, linux-altix, Doug Thompson,
	Matt Turner, linux-edac, Fenghua Yu, Jiang Liu,
	microblaze-uclinux, Rafael J. Wysocki, Ivan Kokshaysky,
	Taku Izumi, linux-arm-kernel, Richard Henderson, Michal Simek,
	Tony Luck, Toshi Kani, Greg

On Sun, Jan 27, 2013 at 12:23 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> Now we have pci_root_buses list, and there is lots of iteration with
> list_of_each of it, that is not safe after we add pci root bus hotplug
> support after booting stage.
>
> Add pci_get_next_host_bridge and use bus_find_device in driver core to
> iterate host bridge and the same time get root bus.
>
> We replace searching root bus with searching host_bridge,
> as host_bridge->bus is the root bus.
> After those replacing, we even could kill pci_root_buses list.

These are the problems I think you're fixing:

1) pci_find_next_bus() is not safe because even though it holds
pci_bus_sem while walking the pci_root_buses list, it doesn't hold a
reference on the bus it returns.  The bus could be removed while the
caller is using it.

2) "list_for_each_entry(bus, &pci_root_buses, node)" is not safe
because hotplug might modify the pci_root_buses list.  Replacing that
with for_each_pci_host_bridge() solves that problem by using
bus_find_device(), which is built on klists, which are designed for
that problem.

3) pci_find_next_bus() claims to iterate through all known PCI buses,
but in fact only iterates through root buses.

So far, so good.  Those are problems we need to fix.

Your solution is to introduce for_each_pci_host_bridge() as an
iterator through the known host bridges.  There are two scenarios
where we use something like this:

1) We want to perform an operation on every known host bridge.

2) We want to initialize something for every host bridge.

In my opinion, the only instance of scenario 1) is bus_rescan_store(),
where we want to rescan all PCI host bridges.

In every other case, we're doing some kind of initialization of all
the host bridges.  For these cases, for_each_pci_host_bridge() is the
wrong solution because it doesn't work for hot-added bridges.  I think
these cases should be changed to use pcibios_root_bridge_prepare() or
something something else called in the host bridge add path.

Bjorn

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-02 21:50                     ` Bjorn Helgaas
  (?)
  (?)
@ 2013-02-03  5:05                     ` Yinghai Lu
  2013-02-05 23:55                       ` Yinghai Lu
  -1 siblings, 1 reply; 122+ messages in thread
From: Yinghai Lu @ 2013-02-03  5:05 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani,
	Greg Kroah-Hartman, linux-pci, Russell King,
	Linux Kernel Mailing List

[Trim down CC list, otherwise lkml will drop it, Thanks for David
Miller to bring attention to me ]

On Sat, Feb 2, 2013 at 1:50 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Sun, Jan 27, 2013 at 12:23 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>> Now we have pci_root_buses list, and there is lots of iteration with
>> list_of_each of it, that is not safe after we add pci root bus hotplug
>> support after booting stage.
>>
>> Add pci_get_next_host_bridge and use bus_find_device in driver core to
>> iterate host bridge and the same time get root bus.
>>
>> We replace searching root bus with searching host_bridge,
>> as host_bridge->bus is the root bus.
>> After those replacing, we even could kill pci_root_buses list.
>
> These are the problems I think you're fixing:
>
> 1) pci_find_next_bus() is not safe because even though it holds
> pci_bus_sem while walking the pci_root_buses list, it doesn't hold a
> reference on the bus it returns.  The bus could be removed while the
> caller is using it.
>
> 2) "list_for_each_entry(bus, &pci_root_buses, node)" is not safe
> because hotplug might modify the pci_root_buses list.  Replacing that
> with for_each_pci_host_bridge() solves that problem by using
> bus_find_device(), which is built on klists, which are designed for
> that problem.
>
> 3) pci_find_next_bus() claims to iterate through all known PCI buses,
> but in fact only iterates through root buses.
>
> So far, so good.  Those are problems we need to fix.
>
> Your solution is to introduce for_each_pci_host_bridge() as an
> iterator through the known host bridges.  There are two scenarios
> where we use something like this:
>
> 1) We want to perform an operation on every known host bridge.
>
> 2) We want to initialize something for every host bridge.
>
> In my opinion, the only instance of scenario 1) is bus_rescan_store(),
> where we want to rescan all PCI host bridges.
>
> In every other case, we're doing some kind of initialization of all
> the host bridges.  For these cases, for_each_pci_host_bridge() is the
> wrong solution because it doesn't work for hot-added bridges.  I think
> these cases should be changed to use pcibios_root_bridge_prepare() or
> something something else called in the host bridge add path.

Yes, will check if those for_pci_host_bridge could be converted to
adding calling in pcibios_root_bridge_prepare one by one.

Thanks

Yinghai

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-03  5:05                     ` Yinghai Lu
@ 2013-02-05 23:55                       ` Yinghai Lu
  2013-02-06  0:19                         ` Bjorn Helgaas
  0 siblings, 1 reply; 122+ messages in thread
From: Yinghai Lu @ 2013-02-05 23:55 UTC (permalink / raw)
  To: Bjorn Helgaas, Mauro Carvalho Chehab, Tony Luck
  Cc: Jiang Liu, Rafael J. Wysocki, Taku Izumi, Toshi Kani,
	Greg Kroah-Hartman, linux-pci, Russell King,
	Linux Kernel Mailing List

On Sat, Feb 2, 2013 at 9:05 PM, Yinghai Lu <yinghai@kernel.org> wrote:

>> Your solution is to introduce for_each_pci_host_bridge() as an
>> iterator through the known host bridges.  There are two scenarios
>> where we use something like this:
>>
>> 1) We want to perform an operation on every known host bridge.
>>
>> 2) We want to initialize something for every host bridge.
>>
>> In my opinion, the only instance of scenario 1) is bus_rescan_store(),
>> where we want to rescan all PCI host bridges.
>>
>> In every other case, we're doing some kind of initialization of all
>> the host bridges.  For these cases, for_each_pci_host_bridge() is the
>> wrong solution because it doesn't work for hot-added bridges.  I think
>> these cases should be changed to use pcibios_root_bridge_prepare() or
>> something something else called in the host bridge add path.
>
> Yes, will check if those for_pci_host_bridge could be converted to
> adding calling in pcibios_root_bridge_prepare one by one.

I went through those patches again, here are findings:
1. run-time iteration includes at least 3 occurrence are addressed.
a. in pci-sysfs::bus_rescan_store
b. powerpc pci_64.c::sys_pciconfig_iobase system call
c. probe.c::pci_create_root_bus/pci_find_bus

2. edac: i7core_edac.c::i7core_pci_lastbus()
this one is not support host bridge hotplug, and in i7core_probe it will
bail-out if probed before overall.
To make edac with i7 to support host-bridge hotadd, will change the structure of
that i7core_probe.
But I'm not worried about that yet, because Nehalem-EX does not support EDAC,
and assume we will NOT have use case with new -EX intel cpu with
hotplug support to use EDAC.

3. pcibios_resource_survey/pcibios_assign_unassigned_resource in __init path.
it is with x86/frv/microblaze/mn10300.
for x86/acpi, we have per root bus calling in pci_root.c::acpi_pci_root_add().
other three does not support pci_root_bridge hotplug yet.

4. looks like all other changes are __init path, and those arch does not support
pci_root_bridge hotplug yet.

So looks like this patch set is ok now.

Also i updated
	git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git
for-pci-for-each-host-bridge

with new ordering of patches.

BTW, I would address unifying pcibios_reserource_survey between
x86/frv/microblaze/mn10300 later.

Thanks

Yinghai

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-05 23:55                       ` Yinghai Lu
@ 2013-02-06  0:19                         ` Bjorn Helgaas
  2013-02-06  0:47                           ` Yinghai Lu
  0 siblings, 1 reply; 122+ messages in thread
From: Bjorn Helgaas @ 2013-02-06  0:19 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Mauro Carvalho Chehab, Tony Luck, Jiang Liu, Rafael J. Wysocki,
	Taku Izumi, Toshi Kani, Greg Kroah-Hartman, linux-pci,
	Russell King, Linux Kernel Mailing List

On Tue, Feb 5, 2013 at 4:55 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Sat, Feb 2, 2013 at 9:05 PM, Yinghai Lu <yinghai@kernel.org> wrote:
>
>>> Your solution is to introduce for_each_pci_host_bridge() as an
>>> iterator through the known host bridges.  There are two scenarios
>>> where we use something like this:
>>>
>>> 1) We want to perform an operation on every known host bridge.
>>>
>>> 2) We want to initialize something for every host bridge.
>>>
>>> In my opinion, the only instance of scenario 1) is bus_rescan_store(),
>>> where we want to rescan all PCI host bridges.
>>>
>>> In every other case, we're doing some kind of initialization of all
>>> the host bridges.  For these cases, for_each_pci_host_bridge() is the
>>> wrong solution because it doesn't work for hot-added bridges.  I think
>>> these cases should be changed to use pcibios_root_bridge_prepare() or
>>> something something else called in the host bridge add path.
>>
>> Yes, will check if those for_pci_host_bridge could be converted to
>> adding calling in pcibios_root_bridge_prepare one by one.
>
> I went through those patches again, here are findings:
> 1. run-time iteration includes at least 3 occurrence are addressed.
> a. in pci-sysfs::bus_rescan_store
> b. powerpc pci_64.c::sys_pciconfig_iobase system call
> c. probe.c::pci_create_root_bus/pci_find_bus
>
> 2. edac: i7core_edac.c::i7core_pci_lastbus()
> this one is not support host bridge hotplug, and in i7core_probe it will
> bail-out if probed before overall.
> To make edac with i7 to support host-bridge hotadd, will change the structure of
> that i7core_probe.
> But I'm not worried about that yet, because Nehalem-EX does not support EDAC,
> and assume we will NOT have use case with new -EX intel cpu with
> hotplug support to use EDAC.
>
> 3. pcibios_resource_survey/pcibios_assign_unassigned_resource in __init path.
> it is with x86/frv/microblaze/mn10300.
> for x86/acpi, we have per root bus calling in pci_root.c::acpi_pci_root_add().
> other three does not support pci_root_bridge hotplug yet.
>
> 4. looks like all other changes are __init path, and those arch does not support
> pci_root_bridge hotplug yet.
>
> So looks like this patch set is ok now.

Maybe.  I'd rather not introduce for_each_pci_host_bridge() at all, if
we can avoid it.  Every place it's used is a place we have to audit to
make sure it's safe.  I think your audit above is correct and
complete, but it relies on way too much architecture knowledge.  It's
better if we can deduce correctness without knowing which arches
support hotplug and which CPUs support EDAC.

As soon as for_each_pci_host_bridge() is in the tree, those uses can
be copied to even more places.  It's a macro, so it's usable by any
module, even out-of-tree ones that we'll never see and can't fix.  So
we won't really have a good way to deprecate and remove it.

Bjorn

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-06  0:19                         ` Bjorn Helgaas
@ 2013-02-06  0:47                           ` Yinghai Lu
  2013-02-06  8:53                             ` Mauro Carvalho Chehab
  2013-02-06 17:54                             ` Bjorn Helgaas
  0 siblings, 2 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-02-06  0:47 UTC (permalink / raw)
  To: Bjorn Helgaas, Jiang Liu, Mauro Carvalho Chehab
  Cc: Tony Luck, Rafael J. Wysocki, Taku Izumi, Toshi Kani,
	Greg Kroah-Hartman, linux-pci, Russell King,
	Linux Kernel Mailing List

On Tue, Feb 5, 2013 at 4:19 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>
> Maybe.  I'd rather not introduce for_each_pci_host_bridge() at all, if
> we can avoid it.  Every place it's used is a place we have to audit to
> make sure it's safe.  I think your audit above is correct and
> complete, but it relies on way too much architecture knowledge.  It's
> better if we can deduce correctness without knowing which arches
> support hotplug and which CPUs support EDAC.
>
> As soon as for_each_pci_host_bridge() is in the tree, those uses can
> be copied to even more places.  It's a macro, so it's usable by any
> module, even out-of-tree ones that we'll never see and can't fix.  So
> we won't really have a good way to deprecate and remove it.

Now we only have two references in modules.

drivers/edac/i7core_edac.c:     for_each_pci_host_bridge(host_bridge) {
drivers/pci/hotplug/sgi_hotplug.c:      for_each_pci_host_bridge(host_bridge) {

for the sgi_hotplug.c, it should be same problem that have for acpiphp
and pciehp.
need to make it support pci host bridge hotplug anyway.

for edac, we need to check Mauro about their plan.

After those two are addressed, we can drop that EXPORT_SYMBOL_GPL for
pci_get_next_host_bridge.

We do have pci_get_domain_bus_and_slot() as export symbol.
So we export pci_get_next_host_bridge should be ok now.
and it would be better than export root buses list.

Thanks

Yinghai

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-06  0:47                           ` Yinghai Lu
@ 2013-02-06  8:53                             ` Mauro Carvalho Chehab
  2013-02-06 17:45                               ` Bjorn Helgaas
  2013-02-06 17:54                             ` Bjorn Helgaas
  1 sibling, 1 reply; 122+ messages in thread
From: Mauro Carvalho Chehab @ 2013-02-06  8:53 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Bjorn Helgaas, Jiang Liu, Tony Luck, Rafael J. Wysocki,
	Taku Izumi, Toshi Kani, Greg Kroah-Hartman, linux-pci,
	Russell King, Linux Kernel Mailing List

Em Tue, 5 Feb 2013 16:47:10 -0800
Yinghai Lu <yinghai@kernel.org> escreveu:

> On Tue, Feb 5, 2013 at 4:19 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> >
> > Maybe.  I'd rather not introduce for_each_pci_host_bridge() at all, if
> > we can avoid it.  Every place it's used is a place we have to audit to
> > make sure it's safe.  I think your audit above is correct and
> > complete, but it relies on way too much architecture knowledge.  It's
> > better if we can deduce correctness without knowing which arches
> > support hotplug and which CPUs support EDAC.
> >
> > As soon as for_each_pci_host_bridge() is in the tree, those uses can
> > be copied to even more places.  It's a macro, so it's usable by any
> > module, even out-of-tree ones that we'll never see and can't fix.  So
> > we won't really have a good way to deprecate and remove it.
> 
> Now we only have two references in modules.
> 
> drivers/edac/i7core_edac.c:     for_each_pci_host_bridge(host_bridge) {
> drivers/pci/hotplug/sgi_hotplug.c:      for_each_pci_host_bridge(host_bridge) {
> 
> for the sgi_hotplug.c, it should be same problem that have for acpiphp
> and pciehp.
> need to make it support pci host bridge hotplug anyway.
> 
> for edac, we need to check Mauro about their plan.

The i7core_pci_lastbus() code at i7core_edac is there to make it work
with some Nehalem/Nehalem-EP machines that hide the memory controller's
PCI ID by using an artificially low last bus. There's no plan to
support Nehalem-EX, as the information I got is that there's no way
to access the memory controller registers on it without interfering with
BIOS.

It should be noticed, however, that I got a report of a Sandy Bridge
server that is also hiding the memory controller's PCI address.
So, maybe we'll need to add later some logic at sb_edac to unhide the
memory controller, just like the one in i7core_edac.

> 
> After those two are addressed, we can drop that EXPORT_SYMBOL_GPL for
> pci_get_next_host_bridge.
> 
> We do have pci_get_domain_bus_and_slot() as export symbol.
> So we export pci_get_next_host_bridge should be ok now.
> and it would be better than export root buses list.
> 
> Thanks
> 
> Yinghai


-- 

Cheers,
Mauro

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-06  8:53                             ` Mauro Carvalho Chehab
@ 2013-02-06 17:45                               ` Bjorn Helgaas
  2013-02-07 10:24                                 ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 122+ messages in thread
From: Bjorn Helgaas @ 2013-02-06 17:45 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Yinghai Lu, Jiang Liu, Tony Luck, Rafael J. Wysocki, Taku Izumi,
	Toshi Kani, Greg Kroah-Hartman, linux-pci, Russell King,
	Linux Kernel Mailing List

On Wed, Feb 6, 2013 at 1:53 AM, Mauro Carvalho Chehab
<mchehab@redhat.com> wrote:
> Em Tue, 5 Feb 2013 16:47:10 -0800
> Yinghai Lu <yinghai@kernel.org> escreveu:
>
>> On Tue, Feb 5, 2013 at 4:19 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> >
>> > Maybe.  I'd rather not introduce for_each_pci_host_bridge() at all, if
>> > we can avoid it.  Every place it's used is a place we have to audit to
>> > make sure it's safe.  I think your audit above is correct and
>> > complete, but it relies on way too much architecture knowledge.  It's
>> > better if we can deduce correctness without knowing which arches
>> > support hotplug and which CPUs support EDAC.
>> >
>> > As soon as for_each_pci_host_bridge() is in the tree, those uses can
>> > be copied to even more places.  It's a macro, so it's usable by any
>> > module, even out-of-tree ones that we'll never see and can't fix.  So
>> > we won't really have a good way to deprecate and remove it.
>>
>> Now we only have two references in modules.
>>
>> drivers/edac/i7core_edac.c:     for_each_pci_host_bridge(host_bridge) {
>> drivers/pci/hotplug/sgi_hotplug.c:      for_each_pci_host_bridge(host_bridge) {
>>
>> for the sgi_hotplug.c, it should be same problem that have for acpiphp
>> and pciehp.
>> need to make it support pci host bridge hotplug anyway.
>>
>> for edac, we need to check Mauro about their plan.
>
> The i7core_pci_lastbus() code at i7core_edac is there to make it work
> with some Nehalem/Nehalem-EP machines that hide the memory controller's
> PCI ID by using an artificially low last bus.

I don't really understand how this helps.  An example would probably
make it clearer.

i7core_edac.c has some very creative use of PCI infrastructure.
Normally a driver has a pci_device_id table that identifies the
vendor/device IDs of the devices it cares about, and the driver's
.probe() method is called for every matching device.

But i7core_edac only has two entries in its id_table.  When we find a
device that matches one of those two entries, we call i7core_probe(),
which then gropes around for all the *other* devices related to that
original one.  This is a bit messy.

I'd like it a lot better if the device IDs in
pci_dev_descr_i7core_nehalem[], pci_dev_descr_lynnfield[], etc., were
just in the pci_device_id table directly.  Then i7core_probe() would
be called directly for every device you care about, and you could sort
them out there.  That should work without any need for
pci_get_device(), i7core_pci_lastbus(), etc.

Bjorn

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-06  0:47                           ` Yinghai Lu
  2013-02-06  8:53                             ` Mauro Carvalho Chehab
@ 2013-02-06 17:54                             ` Bjorn Helgaas
  2013-02-06 18:59                               ` Yinghai Lu
  1 sibling, 1 reply; 122+ messages in thread
From: Bjorn Helgaas @ 2013-02-06 17:54 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Jiang Liu, Mauro Carvalho Chehab, Tony Luck, Rafael J. Wysocki,
	Taku Izumi, Toshi Kani, Greg Kroah-Hartman, linux-pci,
	Russell King, Linux Kernel Mailing List

On Tue, Feb 5, 2013 at 5:47 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Tue, Feb 5, 2013 at 4:19 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>>
>> Maybe.  I'd rather not introduce for_each_pci_host_bridge() at all, if
>> we can avoid it.  Every place it's used is a place we have to audit to
>> make sure it's safe.  I think your audit above is correct and
>> complete, but it relies on way too much architecture knowledge.  It's
>> better if we can deduce correctness without knowing which arches
>> support hotplug and which CPUs support EDAC.
>>
>> As soon as for_each_pci_host_bridge() is in the tree, those uses can
>> be copied to even more places.  It's a macro, so it's usable by any
>> module, even out-of-tree ones that we'll never see and can't fix.  So
>> we won't really have a good way to deprecate and remove it.
>
> Now we only have two references in modules.
>
> drivers/edac/i7core_edac.c:     for_each_pci_host_bridge(host_bridge) {
> drivers/pci/hotplug/sgi_hotplug.c:      for_each_pci_host_bridge(host_bridge) {
>
> for the sgi_hotplug.c, it should be same problem that have for acpiphp
> and pciehp.
> need to make it support pci host bridge hotplug anyway.
>
> for edac, we need to check Mauro about their plan.
>
> After those two are addressed, we can drop that EXPORT_SYMBOL_GPL for
> pci_get_next_host_bridge.
>
> We do have pci_get_domain_bus_and_slot() as export symbol.
> So we export pci_get_next_host_bridge should be ok now.
> and it would be better than export root buses list.

I think you're missing the point.

Search the tree for uses of "for_each_pci_dev()."  Almost every
occurrence is a bug because that code doesn't work correctly for
hot-added devices.  That code gets run for devices that are present at
boot, but not for devices hot-added later.

You're proposing to add "for_each_pci_host_bridge()."  That will have
the exact same problem as for_each_pci_dev() already does.  Code that
uses it will work for host bridges present at boot, but not for
bridges hot-added later.

Why would we want to add an interface when every use of that interface
will be a design bug?  I think we should fix the existing users of
pci_root_buses by changing their designs so they will work correctly
with host bridge hotplug.

Bjorn

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-06 17:54                             ` Bjorn Helgaas
@ 2013-02-06 18:59                               ` Yinghai Lu
  2013-02-06 20:50                                 ` Bjorn Helgaas
  0 siblings, 1 reply; 122+ messages in thread
From: Yinghai Lu @ 2013-02-06 18:59 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, Mauro Carvalho Chehab, Tony Luck, Rafael J. Wysocki,
	Taku Izumi, Toshi Kani, Greg Kroah-Hartman, linux-pci,
	Russell King, Linux Kernel Mailing List

On Wed, Feb 6, 2013 at 9:54 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> I think you're missing the point.
>
> Search the tree for uses of "for_each_pci_dev()."  Almost every
> occurrence is a bug because that code doesn't work correctly for
> hot-added devices.  That code gets run for devices that are present at
> boot, but not for devices hot-added later.
>
> You're proposing to add "for_each_pci_host_bridge()."  That will have
> the exact same problem as for_each_pci_dev() already does.  Code that
> uses it will work for host bridges present at boot, but not for
> bridges hot-added later.
>
> Why would we want to add an interface when every use of that interface
> will be a design bug?  I think we should fix the existing users of
> pci_root_buses by changing their designs so they will work correctly
> with host bridge hotplug.

I'm a little confused about what you want.

In boot stage using for_each_pci_host_bridge or pci_root_buses is fine.

For those cases that it should support host-bridge by nature.
there are two solutions:
1. use for_each_pci_host_bridge, and it is hotplug-safe.
and make sgi_hotplug to use acpi_pci_driver interface.
and acpi_pci_root_add() will call .add in the acpi_pci_driver.

2. make them all to be built-in, and  those acpi_pci_driver should be registered
much early before acpi_pci_root_add is called.
then we don't need to call for_each_host_bridge for it.

So difference between them:
1. still keep the module support, and register acpi_pci_driver later.
2. built-in support only, and need to register acpi_pci_driver early.

Please let me which one you like.

Thanks

Yinghai

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-06 18:59                               ` Yinghai Lu
@ 2013-02-06 20:50                                 ` Bjorn Helgaas
  2013-02-06 21:28                                   ` Yinghai Lu
  0 siblings, 1 reply; 122+ messages in thread
From: Bjorn Helgaas @ 2013-02-06 20:50 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Jiang Liu, Mauro Carvalho Chehab, Tony Luck, Rafael J. Wysocki,
	Taku Izumi, Toshi Kani, Greg Kroah-Hartman, linux-pci,
	Russell King, Linux Kernel Mailing List

On Wed, Feb 6, 2013 at 11:59 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Wed, Feb 6, 2013 at 9:54 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>> I think you're missing the point.
>>
>> Search the tree for uses of "for_each_pci_dev()."  Almost every
>> occurrence is a bug because that code doesn't work correctly for
>> hot-added devices.  That code gets run for devices that are present at
>> boot, but not for devices hot-added later.
>>
>> You're proposing to add "for_each_pci_host_bridge()."  That will have
>> the exact same problem as for_each_pci_dev() already does.  Code that
>> uses it will work for host bridges present at boot, but not for
>> bridges hot-added later.
>>
>> Why would we want to add an interface when every use of that interface
>> will be a design bug?  I think we should fix the existing users of
>> pci_root_buses by changing their designs so they will work correctly
>> with host bridge hotplug.
>
> I'm a little confused about what you want.
>
> In boot stage using for_each_pci_host_bridge or pci_root_buses is fine.

No, it's not.  Boot-time should work exactly the same way as hot-add
time, unless there's a reason it can't.  There might be corner cases
where we can't do that yet, e.g., the pcibios_resource_survey stuff,
but in general I don't think there's anything that *forces* us to
iterate through host bridges at boot-time.

> For those cases that it should support host-bridge by nature.
> there are two solutions:
> 1. use for_each_pci_host_bridge, and it is hotplug-safe.

I'm trying to tell you that for_each_pci_host_bridge() is NOT
hotplug-safe.  Your series makes it safer than it was, in the sense
that it probably fixes stray pointer references when a host bridge
hotplug happens while somebody's traversing pci_root_buses.  But the
whole point of for_each_pci_host_bridge() is to run some code for
every bridge we know about *right now*.  If a host bridge is added
right after the for_each_pci_host_bridge() loop exits, that code
doesn't get run.  In most cases, that's a bug.  The only exception I
know about is the /sys/.../rescan interface.

> and make sgi_hotplug to use acpi_pci_driver interface.
> and acpi_pci_root_add() will call .add in the acpi_pci_driver.
>
> 2. make them all to be built-in, and  those acpi_pci_driver should be registered
> much early before acpi_pci_root_add is called.
> then we don't need to call for_each_host_bridge for it.
>
> So difference between them:
> 1. still keep the module support, and register acpi_pci_driver later.
> 2. built-in support only, and need to register acpi_pci_driver early.

acpi_pci_driver is going away, so I don't want to add any more uses of
it.  Obviously it's only relevant to x86 and ia64 anyway.

What I'd like is a change where for_each_pci_host_bridge() is used
only inside the PCI core and defined somewhere like drivers/pci/pci.h
so it's not even available outside.

The other uses should be changed so they use
pcibios_root_bridge_prepare() or something similar.  That way, it will
be obvious that the code supports hot-added bridges, and when it gets
copied to other places, we'll be copying a working design instead of a
broken one.

I don't want to have to audit these places and figure out "this is
safe because this arch doesn't support host bridge hotplug" or "this
is safe because this CPU doesn't support XYZ."  That's not a
maintainable solution.  The safety should be apparent from the code
itself, without requiring extra platform-specific knowledge.

Bjorn

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-06 20:50                                 ` Bjorn Helgaas
@ 2013-02-06 21:28                                   ` Yinghai Lu
  2013-02-06 21:43                                     ` Rafael J. Wysocki
  0 siblings, 1 reply; 122+ messages in thread
From: Yinghai Lu @ 2013-02-06 21:28 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Jiang Liu, Mauro Carvalho Chehab, Tony Luck, Rafael J. Wysocki,
	Taku Izumi, Toshi Kani, Greg Kroah-Hartman, linux-pci,
	Russell King, Linux Kernel Mailing List

On Wed, Feb 6, 2013 at 12:50 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Wed, Feb 6, 2013 at 11:59 AM, Yinghai Lu <yinghai@kernel.org> wrote:
>> On Wed, Feb 6, 2013 at 9:54 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
>>> I think you're missing the point.
>>>
>>> Search the tree for uses of "for_each_pci_dev()."  Almost every
>>> occurrence is a bug because that code doesn't work correctly for
>>> hot-added devices.  That code gets run for devices that are present at
>>> boot, but not for devices hot-added later.
>>>
>>> You're proposing to add "for_each_pci_host_bridge()."  That will have
>>> the exact same problem as for_each_pci_dev() already does.  Code that
>>> uses it will work for host bridges present at boot, but not for
>>> bridges hot-added later.
>>>
>>> Why would we want to add an interface when every use of that interface
>>> will be a design bug?  I think we should fix the existing users of
>>> pci_root_buses by changing their designs so they will work correctly
>>> with host bridge hotplug.
>>
>> I'm a little confused about what you want.
>>
>> In boot stage using for_each_pci_host_bridge or pci_root_buses is fine.
>
> No, it's not.  Boot-time should work exactly the same way as hot-add
> time, unless there's a reason it can't.  There might be corner cases
> where we can't do that yet, e.g., the pcibios_resource_survey stuff,
> but in general I don't think there's anything that *forces* us to
> iterate through host bridges at boot-time.
>
>> For those cases that it should support host-bridge by nature.
>> there are two solutions:
>> 1. use for_each_pci_host_bridge, and it is hotplug-safe.
>
> I'm trying to tell you that for_each_pci_host_bridge() is NOT
> hotplug-safe.  Your series makes it safer than it was, in the sense
> that it probably fixes stray pointer references when a host bridge
> hotplug happens while somebody's traversing pci_root_buses.  But the
> whole point of for_each_pci_host_bridge() is to run some code for
> every bridge we know about *right now*.  If a host bridge is added
> right after the for_each_pci_host_bridge() loop exits, that code
> doesn't get run.  In most cases, that's a bug.  The only exception I
> know about is the /sys/.../rescan interface.
>
>> and make sgi_hotplug to use acpi_pci_driver interface.
>> and acpi_pci_root_add() will call .add in the acpi_pci_driver.
>>
>> 2. make them all to be built-in, and  those acpi_pci_driver should be registered
>> much early before acpi_pci_root_add is called.
>> then we don't need to call for_each_host_bridge for it.
>>
>> So difference between them:
>> 1. still keep the module support, and register acpi_pci_driver later.
>> 2. built-in support only, and need to register acpi_pci_driver early.
>
> acpi_pci_driver is going away, so I don't want to add any more uses of
> it.  Obviously it's only relevant to x86 and ia64 anyway.

when?

I have ioapic and iommu hotplug patch set that need to use them.

>
> What I'd like is a change where for_each_pci_host_bridge() is used
> only inside the PCI core and defined somewhere like drivers/pci/pci.h
> so it's not even available outside.
>
> The other uses should be changed so they use
> pcibios_root_bridge_prepare() or something similar.  That way, it will
> be obvious that the code supports hot-added bridges, and when it gets
> copied to other places, we'll be copying a working design instead of a
> broken one.
>
> I don't want to have to audit these places and figure out "this is
> safe because this arch doesn't support host bridge hotplug" or "this
> is safe because this CPU doesn't support XYZ."  That's not a
> maintainable solution.  The safety should be apparent from the code
> itself, without requiring extra platform-specific knowledge.

so you still did not answer you want 1 or 2 yet:

for sgi_hotplug,

1. still keep the module support, and register acpi_pci_driver later.
2. built-in support only, and need to register acpi_pci_driver early.

Thanks

Yinghai

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-06 21:28                                   ` Yinghai Lu
@ 2013-02-06 21:43                                     ` Rafael J. Wysocki
  2013-02-06 21:53                                       ` Yinghai Lu
  0 siblings, 1 reply; 122+ messages in thread
From: Rafael J. Wysocki @ 2013-02-06 21:43 UTC (permalink / raw)
  To: Yinghai Lu
  Cc: Bjorn Helgaas, Jiang Liu, Mauro Carvalho Chehab, Tony Luck,
	Taku Izumi, Toshi Kani, Greg Kroah-Hartman, linux-pci,
	Russell King, Linux Kernel Mailing List

On Wednesday, February 06, 2013 01:28:27 PM Yinghai Lu wrote:
> On Wed, Feb 6, 2013 at 12:50 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> > On Wed, Feb 6, 2013 at 11:59 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> >> On Wed, Feb 6, 2013 at 9:54 AM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> >>> I think you're missing the point.
> >>>
> >>> Search the tree for uses of "for_each_pci_dev()."  Almost every
> >>> occurrence is a bug because that code doesn't work correctly for
> >>> hot-added devices.  That code gets run for devices that are present at
> >>> boot, but not for devices hot-added later.
> >>>
> >>> You're proposing to add "for_each_pci_host_bridge()."  That will have
> >>> the exact same problem as for_each_pci_dev() already does.  Code that
> >>> uses it will work for host bridges present at boot, but not for
> >>> bridges hot-added later.
> >>>
> >>> Why would we want to add an interface when every use of that interface
> >>> will be a design bug?  I think we should fix the existing users of
> >>> pci_root_buses by changing their designs so they will work correctly
> >>> with host bridge hotplug.
> >>
> >> I'm a little confused about what you want.
> >>
> >> In boot stage using for_each_pci_host_bridge or pci_root_buses is fine.
> >
> > No, it's not.  Boot-time should work exactly the same way as hot-add
> > time, unless there's a reason it can't.  There might be corner cases
> > where we can't do that yet, e.g., the pcibios_resource_survey stuff,
> > but in general I don't think there's anything that *forces* us to
> > iterate through host bridges at boot-time.
> >
> >> For those cases that it should support host-bridge by nature.
> >> there are two solutions:
> >> 1. use for_each_pci_host_bridge, and it is hotplug-safe.
> >
> > I'm trying to tell you that for_each_pci_host_bridge() is NOT
> > hotplug-safe.  Your series makes it safer than it was, in the sense
> > that it probably fixes stray pointer references when a host bridge
> > hotplug happens while somebody's traversing pci_root_buses.  But the
> > whole point of for_each_pci_host_bridge() is to run some code for
> > every bridge we know about *right now*.  If a host bridge is added
> > right after the for_each_pci_host_bridge() loop exits, that code
> > doesn't get run.  In most cases, that's a bug.  The only exception I
> > know about is the /sys/.../rescan interface.
> >
> >> and make sgi_hotplug to use acpi_pci_driver interface.
> >> and acpi_pci_root_add() will call .add in the acpi_pci_driver.
> >>
> >> 2. make them all to be built-in, and  those acpi_pci_driver should be registered
> >> much early before acpi_pci_root_add is called.
> >> then we don't need to call for_each_host_bridge for it.
> >>
> >> So difference between them:
> >> 1. still keep the module support, and register acpi_pci_driver later.
> >> 2. built-in support only, and need to register acpi_pci_driver early.
> >
> > acpi_pci_driver is going away, so I don't want to add any more uses of
> > it.  Obviously it's only relevant to x86 and ia64 anyway.
> 
> when?
> 
> I have ioapic and iommu hotplug patch set that need to use them.

I suppose it would be a bit simpler if you tried to fix things up before
adding more stuff on top of them, which only makes it more difficult
to clean them up when this additional stuff is applied.

A patchset to remove acpi_pci_driver has been posted already and it is going
to be submitted again after 3.9-rc1.  So this is the time frame.

> > What I'd like is a change where for_each_pci_host_bridge() is used
> > only inside the PCI core and defined somewhere like drivers/pci/pci.h
> > so it's not even available outside.
> >
> > The other uses should be changed so they use
> > pcibios_root_bridge_prepare() or something similar.  That way, it will
> > be obvious that the code supports hot-added bridges, and when it gets
> > copied to other places, we'll be copying a working design instead of a
> > broken one.
> >
> > I don't want to have to audit these places and figure out "this is
> > safe because this arch doesn't support host bridge hotplug" or "this
> > is safe because this CPU doesn't support XYZ."  That's not a
> > maintainable solution.  The safety should be apparent from the code
> > itself, without requiring extra platform-specific knowledge.
> 
> so you still did not answer you want 1 or 2 yet:
> 
> for sgi_hotplug,
> 
> 1. still keep the module support, and register acpi_pci_driver later.
> 2. built-in support only, and need to register acpi_pci_driver early.

Please work with the assumption that acpi_pci_driver is not going to be there
any more.

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-06 21:43                                     ` Rafael J. Wysocki
@ 2013-02-06 21:53                                       ` Yinghai Lu
  2013-02-06 22:05                                         ` Rafael J. Wysocki
  0 siblings, 1 reply; 122+ messages in thread
From: Yinghai Lu @ 2013-02-06 21:53 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Bjorn Helgaas, Jiang Liu, Mauro Carvalho Chehab, Tony Luck,
	Taku Izumi, Toshi Kani, Greg Kroah-Hartman, linux-pci,
	Russell King, Linux Kernel Mailing List

On Wed, Feb 6, 2013 at 1:43 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> On Wednesday, February 06, 2013 01:28:27 PM Yinghai Lu wrote:
>> so you still did not answer you want 1 or 2 yet:
>>
>> for sgi_hotplug,
>>
>> 1. still keep the module support, and register acpi_pci_driver later.
>> 2. built-in support only, and need to register acpi_pci_driver early.
>
> Please work with the assumption that acpi_pci_driver is not going to be there
> any more.
>

I think I could change ioapic and iommu hotplug to weak add/remove because they
should be built-in by nature.

but how about others like sgi_hotplug etc?

Thanks

Yinghai

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-06 21:53                                       ` Yinghai Lu
@ 2013-02-06 22:05                                         ` Rafael J. Wysocki
  2013-02-06 23:02                                           ` Bjorn Helgaas
  0 siblings, 1 reply; 122+ messages in thread
From: Rafael J. Wysocki @ 2013-02-06 22:05 UTC (permalink / raw)
  To: Yinghai Lu, Myron Stowe
  Cc: Bjorn Helgaas, Jiang Liu, Mauro Carvalho Chehab, Tony Luck,
	Taku Izumi, Toshi Kani, Greg Kroah-Hartman, linux-pci,
	Russell King, Linux Kernel Mailing List

On Wednesday, February 06, 2013 01:53:50 PM Yinghai Lu wrote:
> On Wed, Feb 6, 2013 at 1:43 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > On Wednesday, February 06, 2013 01:28:27 PM Yinghai Lu wrote:
> >> so you still did not answer you want 1 or 2 yet:
> >>
> >> for sgi_hotplug,
> >>
> >> 1. still keep the module support, and register acpi_pci_driver later.
> >> 2. built-in support only, and need to register acpi_pci_driver early.
> >
> > Please work with the assumption that acpi_pci_driver is not going to be there
> > any more.
> >
> 
> I think I could change ioapic and iommu hotplug to weak add/remove because they
> should be built-in by nature.
> 
> but how about others like sgi_hotplug etc?

I'd really prefer to wait for the patchset removing acpi_pci_driver (from
Myron) before proceeding with more changes in that area.

Myron, do you have a prototype based on the current linux-next?

Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-06 22:05                                         ` Rafael J. Wysocki
@ 2013-02-06 23:02                                           ` Bjorn Helgaas
  2013-02-06 23:31                                             ` Yinghai Lu
  2013-02-07  0:27                                             ` Jiang Liu
  0 siblings, 2 replies; 122+ messages in thread
From: Bjorn Helgaas @ 2013-02-06 23:02 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Yinghai Lu, Myron Stowe, Jiang Liu, Mauro Carvalho Chehab,
	Tony Luck, Taku Izumi, Toshi Kani, Greg Kroah-Hartman, linux-pci,
	Russell King, Linux Kernel Mailing List

On Wed, Feb 6, 2013 at 3:05 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> On Wednesday, February 06, 2013 01:53:50 PM Yinghai Lu wrote:
>> On Wed, Feb 6, 2013 at 1:43 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
>> > On Wednesday, February 06, 2013 01:28:27 PM Yinghai Lu wrote:
>> >> so you still did not answer you want 1 or 2 yet:
>> >>
>> >> for sgi_hotplug,
>> >>
>> >> 1. still keep the module support, and register acpi_pci_driver later.
>> >> 2. built-in support only, and need to register acpi_pci_driver early.
>> >
>> > Please work with the assumption that acpi_pci_driver is not going to be there
>> > any more.
>> >
>>
>> I think I could change ioapic and iommu hotplug to weak add/remove because they
>> should be built-in by nature.
>>
>> but how about others like sgi_hotplug etc?

I think that could be handled with pcibios_root_bridge_prepare() or
something similar -- something that happens in the "add host bridge"
path.  I'm not saying we necessarily have all the right hooks in place
yet.  It's just that I'd rather figure out what the right hooks *are*
and add them if necessary, than just convert pci_root_buses to
for_each_pci_host_bridge().

> I'd really prefer to wait for the patchset removing acpi_pci_driver (from
> Myron) before proceeding with more changes in that area.
>
> Myron, do you have a prototype based on the current linux-next?

I think it's really the acpiphp/pciehp issue that's holding up the
removal of acpi_pci_driver.  I'm not sure if anybody's working on
that.

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-06 23:02                                           ` Bjorn Helgaas
@ 2013-02-06 23:31                                             ` Yinghai Lu
  2013-02-07  0:27                                             ` Jiang Liu
  1 sibling, 0 replies; 122+ messages in thread
From: Yinghai Lu @ 2013-02-06 23:31 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Rafael J. Wysocki, Myron Stowe, Jiang Liu, Mauro Carvalho Chehab,
	Tony Luck, Taku Izumi, Toshi Kani, Greg Kroah-Hartman, linux-pci,
	Russell King, Linux Kernel Mailing List

On Wed, Feb 6, 2013 at 3:02 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> On Wed, Feb 6, 2013 at 3:05 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
>> On Wednesday, February 06, 2013 01:53:50 PM Yinghai Lu wrote:
>>> On Wed, Feb 6, 2013 at 1:43 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
>>> > On Wednesday, February 06, 2013 01:28:27 PM Yinghai Lu wrote:
>>> >> so you still did not answer you want 1 or 2 yet:
>>> >>
>>> >> for sgi_hotplug,
>>> >>
>>> >> 1. still keep the module support, and register acpi_pci_driver later.
>>> >> 2. built-in support only, and need to register acpi_pci_driver early.
>>> >
>>> > Please work with the assumption that acpi_pci_driver is not going to be there
>>> > any more.
>>> >
>>>
>>> I think I could change ioapic and iommu hotplug to weak add/remove because they
>>> should be built-in by nature.
>>>
>>> but how about others like sgi_hotplug etc?
>
> I think that could be handled with pcibios_root_bridge_prepare() or
> something similar -- something that happens in the "add host bridge"
> path.  I'm not saying we necessarily have all the right hooks in place
> yet.  It's just that I'd rather figure out what the right hooks *are*
> and add them if necessary, than just convert pci_root_buses to
> for_each_pci_host_bridge().

so we will have all built-in for apci_pci_driver and call add/remove directly?

BTW, looks like sgi_hotplug may need some time to convert ...
Also not sure who can test it.

>
>> I'd really prefer to wait for the patchset removing acpi_pci_driver (from
>> Myron) before proceeding with more changes in that area.
>>
>> Myron, do you have a prototype based on the current linux-next?
>
> I think it's really the acpiphp/pciehp issue that's holding up the
> removal of acpi_pci_driver.  I'm not sure if anybody's working on
> that.

Myron's last Dec's version would split all acpi_pci_driver's
add/remove into acpi_pci_root_add/remove.

other way is use host-bridge nodifier, looks like that is not favorable.

BTW, looks like I could put add/remove calling directly in
acpi_pci_root_add/remove
for ioapic and iommu.

Thanks

Yinghai

^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-06 23:02                                           ` Bjorn Helgaas
  2013-02-06 23:31                                             ` Yinghai Lu
@ 2013-02-07  0:27                                             ` Jiang Liu
  1 sibling, 0 replies; 122+ messages in thread
From: Jiang Liu @ 2013-02-07  0:27 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Rafael J. Wysocki, Yinghai Lu, Myron Stowe,
	Mauro Carvalho Chehab, Tony Luck, Taku Izumi, Toshi Kani,
	Greg Kroah-Hartman, linux-pci, Russell King,
	Linux Kernel Mailing List

On 2013-2-7 7:02, Bjorn Helgaas wrote:
> On Wed, Feb 6, 2013 at 3:05 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
>> On Wednesday, February 06, 2013 01:53:50 PM Yinghai Lu wrote:
>>> On Wed, Feb 6, 2013 at 1:43 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
>>>> On Wednesday, February 06, 2013 01:28:27 PM Yinghai Lu wrote:
>>>>> so you still did not answer you want 1 or 2 yet:
>>>>>
>>>>> for sgi_hotplug,
>>>>>
>>>>> 1. still keep the module support, and register acpi_pci_driver later.
>>>>> 2. built-in support only, and need to register acpi_pci_driver early.
>>>>
>>>> Please work with the assumption that acpi_pci_driver is not going to be there
>>>> any more.
>>>>
>>>
>>> I think I could change ioapic and iommu hotplug to weak add/remove because they
>>> should be built-in by nature.
>>>
>>> but how about others like sgi_hotplug etc?
> 
> I think that could be handled with pcibios_root_bridge_prepare() or
> something similar -- something that happens in the "add host bridge"
> path.  I'm not saying we necessarily have all the right hooks in place
> yet.  It's just that I'd rather figure out what the right hooks *are*
> and add them if necessary, than just convert pci_root_buses to
> for_each_pci_host_bridge().
> 
>> I'd really prefer to wait for the patchset removing acpi_pci_driver (from
>> Myron) before proceeding with more changes in that area.
>>
>> Myron, do you have a prototype based on the current linux-next?
> 
> I think it's really the acpiphp/pciehp issue that's holding up the
> removal of acpi_pci_driver.  I'm not sure if anybody's working on
> that.
Hi Bjorn,
	I'm working on this topic, but a little busy with other stuff
in last few days. I guess I could should out a version in coming days.
	Thanks!

> 
> .
> 



^ permalink raw reply	[flat|nested] 122+ messages in thread

* Re: [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus
  2013-02-06 17:45                               ` Bjorn Helgaas
@ 2013-02-07 10:24                                 ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 122+ messages in thread
From: Mauro Carvalho Chehab @ 2013-02-07 10:24 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Yinghai Lu, Jiang Liu, Tony Luck, Rafael J. Wysocki, Taku Izumi,
	Toshi Kani, Greg Kroah-Hartman, linux-pci, Russell King,
	Linux Kernel Mailing List

Em Wed, 6 Feb 2013 10:45:16 -0700
Bjorn Helgaas <bhelgaas@google.com> escreveu:

> On Wed, Feb 6, 2013 at 1:53 AM, Mauro Carvalho Chehab
> <mchehab@redhat.com> wrote:
> > Em Tue, 5 Feb 2013 16:47:10 -0800
> > Yinghai Lu <yinghai@kernel.org> escreveu:
> >
> >> On Tue, Feb 5, 2013 at 4:19 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:
> >> >
> >> > Maybe.  I'd rather not introduce for_each_pci_host_bridge() at all, if
> >> > we can avoid it.  Every place it's used is a place we have to audit to
> >> > make sure it's safe.  I think your audit above is correct and
> >> > complete, but it relies on way too much architecture knowledge.  It's
> >> > better if we can deduce correctness without knowing which arches
> >> > support hotplug and which CPUs support EDAC.
> >> >
> >> > As soon as for_each_pci_host_bridge() is in the tree, those uses can
> >> > be copied to even more places.  It's a macro, so it's usable by any
> >> > module, even out-of-tree ones that we'll never see and can't fix.  So
> >> > we won't really have a good way to deprecate and remove it.
> >>
> >> Now we only have two references in modules.
> >>
> >> drivers/edac/i7core_edac.c:     for_each_pci_host_bridge(host_bridge) {
> >> drivers/pci/hotplug/sgi_hotplug.c:      for_each_pci_host_bridge(host_bridge) {
> >>
> >> for the sgi_hotplug.c, it should be same problem that have for acpiphp
> >> and pciehp.
> >> need to make it support pci host bridge hotplug anyway.
> >>
> >> for edac, we need to check Mauro about their plan.
> >
> > The i7core_pci_lastbus() code at i7core_edac is there to make it work
> > with some Nehalem/Nehalem-EP machines that hide the memory controller's
> > PCI ID by using an artificially low last bus.
> 
> I don't really understand how this helps.  An example would probably
> make it clearer.
> 
> i7core_edac.c has some very creative use of PCI infrastructure.
> Normally a driver has a pci_device_id table that identifies the
> vendor/device IDs of the devices it cares about, and the driver's
> .probe() method is called for every matching device.
> 
> But i7core_edac only has two entries in its id_table.  When we find a
> device that matches one of those two entries, we call i7core_probe(),
> which then gropes around for all the *other* devices related to that
> original one.  This is a bit messy.
> 
> I'd like it a lot better if the device IDs in
> pci_dev_descr_i7core_nehalem[], pci_dev_descr_lynnfield[], etc., were
> just in the pci_device_id table directly.  Then i7core_probe() would
> be called directly for every device you care about, and you could sort
> them out there.  That should work without any need for
> pci_get_device(), i7core_pci_lastbus(), etc.


Bjorn,

On almost all Intel memory controllers since 2002, the memory controller
handling function were split into several different PCI devices and
PCI functions. So, for example, even if you look on old driver like 
i5000_edac.c, you'll see 5 different PCI IDs that are required to
control a single device:

#ifndef PCI_DEVICE_ID_INTEL_FBD_0
#define PCI_DEVICE_ID_INTEL_FBD_0	0x25F5
#endif
#ifndef PCI_DEVICE_ID_INTEL_FBD_1
#define PCI_DEVICE_ID_INTEL_FBD_1	0x25F6
#endif

/* Device 16,
 * Function 0: System Address
 * Function 1: Memory Branch Map, Control, Errors Register
 * Function 2: FSB Error Registers
 *
 * All 3 functions of Device 16 (0,1,2) share the SAME DID
 */
#define	PCI_DEVICE_ID_INTEL_I5000_DEV16	0x25F0

/* OFFSETS for Function 1 */

(a long list of registers there)

/*
 * Device 21,
 * Function 0: Memory Map Branch 0
 *
 * Device 22,
 * Function 0: Memory Map Branch 1
 */
#define PCI_DEVICE_ID_I5000_BRANCH_0	0x25F5
#define PCI_DEVICE_ID_I5000_BRANCH_1	0x25F6

(another long list or registers there)

I've no idea why the hardware engineers there decided on that way, 
but the number of different PCI devices required for the functionality 
to work has been increased on their newer chipsets. At the Sandy
Bridge driver (sb_edac.c), all those PCI devices need to be opened
at the same time, in order to allow controlling a single memory
controller (and one system have one memory controller per socket):

#define PCI_DEVICE_ID_INTEL_SBRIDGE_SAD0	0x3cf4	/* 12.6 */
#define PCI_DEVICE_ID_INTEL_SBRIDGE_SAD1	0x3cf6	/* 12.7 */
#define PCI_DEVICE_ID_INTEL_SBRIDGE_BR		0x3cf5	/* 13.6 */
#define PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_HA0	0x3ca0	/* 14.0 */
#define PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TA	0x3ca8	/* 15.0 */
#define PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_RAS	0x3c71	/* 15.1 */
#define PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD0	0x3caa	/* 15.2 */
#define PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD1	0x3cab	/* 15.3 */
#define PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD2	0x3cac	/* 15.4 */
#define PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD3	0x3cad	/* 15.5 */
#define PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_DDRIO	0x3cb8	/* 17.0 */

The first thing that any EDAC driver needs to do is to get the memory
configuration (number of DIMMs, channels filled, DIMM size, etc).
In the case of sb_edac, the logic is at get_dimm_config(). It needs
to read data on _several_ of the above PCI IDs:

static int get_dimm_config(struct mem_ctl_info *mci)
{
...
	pci_read_config_dword(pvt->pci_br, SAD_TARGET, &reg);		// reads from PCI_DEVICE_ID_INTEL_SBRIDGE_BR
...
	pci_read_config_dword(pvt->pci_br, SAD_CONTROL, &reg);		// reads from PCI_DEVICE_ID_INTEL_SBRIDGE_BR
...
	pci_read_config_dword(pvt->pci_ras, RASENABLES, &reg);		// reads from PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_RAS
...
	pci_read_config_dword(pvt->pci_ta, MCMTR, &pvt->info.mcmtr);	// reads from PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TA
...
	pci_read_config_dword(pvt->pci_ddrio, RANK_CFG_A, &reg);	// reads from PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_DDRIO
...
	for (i = 0; i < NUM_CHANNELS; i++) {
...
		for (j = 0; j < ARRAY_SIZE(mtr_regs); j++) {
...
			pci_read_config_dword(pvt->pci_tad[i],
					      mtr_regs[j], &mtr);	// PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD0 to PCI_DEVICE_ID_INTEL_SBRIDGE_IMC_TAD3

So, while the usual design of having one PCI ID entry for each device
works for the vast majority of drivers, as each different PCI ID/function
are typically independent and pci_driver.probe() can be called for every
entry inside the PCI ID table, that's not the case of EDAC.

On EDAC drivers, the probing routine can be called only after calling
pci_get_device() for the entire set of PCI devices that belongs to the
memory controller. 

To make things worse, the PCI IDs for the memory controllers are sometimes
after PCI lastbus.

So, the logic used on almost all drivers there is to use one PCI ID "detect"
device at the table, used to discover if the system has a supported memory
controller chipset. If it matches, the pci_driver.probe() will seek for the
actual PCI devices that are required for it to work, with may or may not be
the same as the "detect" device.

Also, the highest bus corresponds to the first memory controller. So,
bus=255 matches the memory controller for the CPU socket 0,
bus=254 matches the one for CPU socket 1 and so on. That forced the driver
to probe all devices at the same time, on all CPU sockets, in order to reverse
the order when initializing the memory controller EDAC structures.

There are some other odd details there... In the case of i7core_edac, it 
supports 3 different versions of memory controllers; each version has its 
own set of PCI ID's. So, its "real" PCI ID table set has 3 entries:

static const struct pci_id_table pci_dev_table[] = {
	PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_nehalem),
	PCI_ID_TABLE_ENTRY(pci_dev_descr_lynnfield),
	PCI_ID_TABLE_ENTRY(pci_dev_descr_i7core_westmere),
	{0,}			/* 0 terminated list. */
};

while its PCI ID "detect" table has only two, as the PCI device 8086:342e
(PCI_DEVICE_ID_INTEL_X58_HUB_MGMT) is found on both Nehalem and Westmere:

static DEFINE_PCI_DEVICE_TABLE(i7core_pci_tbl) = {
	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_X58_HUB_MGMT)},
	{PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LYNNFIELD_QPI_LINK0)},
	{0,}			/* 0 terminated list. */

-- 

Cheers,
Mauro

^ permalink raw reply	[flat|nested] 122+ messages in thread

end of thread, other threads:[~2013-02-07 10:25 UTC | newest]

Thread overview: 122+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-21 21:20 [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Yinghai Lu
2013-01-21 21:20 ` [PATCH v10 01/11] PCI, acpiphp: Add is_hotplug_bridge detection Yinghai Lu
2013-01-21 21:20 ` [PATCH v10 02/11] PCI: Add root bus children dev's res to fail list Yinghai Lu
2013-01-21 21:20 ` [PATCH v10 03/11] PCI: Set dev_node early for pci_dev Yinghai Lu
2013-01-21 21:20 ` [PATCH v10 04/11] PCI: Fix a device reference count leakage issue in pci_dev_present() Yinghai Lu
2013-01-21 21:20 ` [PATCH v10 05/11] PCI: make PCI device create/destroy logic symmetric Yinghai Lu
2013-01-21 21:20 ` [PATCH v10 06/11] PCI, ACPI, acpiphp: Rename alloc_acpiphp_hp_work() to alloc_acpi_hp_work Yinghai Lu
2013-01-21 21:20 ` [PATCH v10 07/11] PCI, acpiphp: Move and enhance hotplug support of pci host bridge Yinghai Lu
2013-01-21 21:20 ` [PATCH v10 08/11] PCI, ACPI: debug print for installation of acpi root bridge's notifier Yinghai Lu
2013-01-21 21:20 ` [PATCH v10 09/11] PCI, acpiphp: Don't bailout even no slots found yet Yinghai Lu
2013-01-21 21:20 ` [PATCH v10 10/11] PCI: Skip attaching driver in device_add() Yinghai Lu
2013-01-21 21:20 ` [PATCH v10 11/11] PCI: Put pci dev to device tree as early as possible Yinghai Lu
2013-01-22 22:09 ` [PATCH v10 00/11] PCI, ACPI: pci root bus hotplug support / pci match_driver Rafael J. Wysocki
2013-01-22 22:19   ` Yinghai Lu
2013-01-26  0:04     ` Bjorn Helgaas
2013-01-26  1:24       ` Jiang Liu
2013-01-26  1:24         ` Jiang Liu
2013-01-26 23:34       ` Yinghai Lu
2013-01-27  5:36         ` [PATCH v2 00/22] PCI: use pci host bridge to loop pci root bus Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 01/22] PCI: Rename pci_release_bus_bridge_dev to pci_release_host_bridge_dev Yinghai Lu
2013-01-27 22:26             ` Rafael J. Wysocki
2013-01-27  5:36           ` [PATCH v2 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 03/22] PCI, libata: remove find_bridge in acpi_bus_type Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 04/22] PCI, ACPI: Update comments for " Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 06/22] PCI, hotplug: Kill pci_find_next_bus in sgi_hotplug Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 07/22] PCI: Kill pci_find_next_bus in pci_sysfs Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 08/22] PCI, edac: Kill pci_find_next_bus in edac Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 09/22] PCI, x86: Kill pci_find_next_bus in pcibios_scan_root Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 10/22] PCI, x86: Kill pci_root_buses in resources reservations Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 11/22] PCI, drm: Kill pci_root_buses in alpha hose setting Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 12/22] PCI: Kill pci_root_buses in setup-bus Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 13/22] PCI, sparc: Kill pci_find_next_bus Yinghai Lu
2013-01-27  5:36             ` Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 14/22] PCI, ia64: " Yinghai Lu
2013-01-27  5:36             ` Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 15/22] PCI, alpha: Kill pci_root_buses Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 16/22] PCI, arm: " Yinghai Lu
2013-01-27  5:36             ` Yinghai Lu
2013-01-27 17:38             ` Russell King - ARM Linux
2013-01-27 17:38               ` Russell King - ARM Linux
2013-01-27 18:22               ` Yinghai Lu
2013-01-27 18:22                 ` Yinghai Lu
2013-01-27 19:23                 ` [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus Yinghai Lu
2013-01-27 19:23                   ` Yinghai Lu
2013-01-27 19:23                   ` Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 01/22] PCI: Rename pci_release_bus_bridge_dev to pci_release_host_bridge_dev Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
2013-01-27 19:23                     ` Yinghai Lu
2013-01-27 19:23                     ` Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 03/22] PCI, libata: remove find_bridge in acpi_bus_type Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 04/22] PCI, ACPI: Update comments for " Yinghai Lu
2013-01-27 22:32                     ` Rafael J. Wysocki
2013-01-28  1:00                       ` Yinghai Lu
2013-01-28 12:37                         ` Rafael J. Wysocki
2013-01-27 19:23                   ` [PATCH v3 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge Yinghai Lu
2013-01-27 19:23                     ` Yinghai Lu
2013-01-27 19:23                     ` Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 06/22] PCI, hotplug: Kill pci_find_next_bus in sgi_hotplug Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 07/22] PCI: Kill pci_find_next_bus in pci_sysfs Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 08/22] PCI, edac: Kill pci_find_next_bus in edac Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 09/22] PCI, x86: Kill pci_find_next_bus in pcibios_scan_root Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 10/22] PCI, x86: Kill pci_root_buses in resources reservations Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 11/22] PCI, drm: Kill pci_root_buses in alpha hose setting Yinghai Lu
2013-01-28  3:21                     ` Yijing Wang
2013-01-28  3:21                       ` Yijing Wang
2013-01-28  3:35                       ` Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 12/22] PCI: Kill pci_root_buses in setup-bus Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 13/22] PCI, sparc: Kill pci_find_next_bus Yinghai Lu
2013-01-27 19:23                     ` Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 14/22] PCI, ia64: " Yinghai Lu
2013-01-27 19:23                     ` Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 15/22] PCI, alpha: Kill pci_root_buses Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 16/22] PCI, arm: " Yinghai Lu
2013-01-27 19:23                     ` Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 17/22] PCI, frv: Kill pci_root_buses in resources reservations Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 18/22] PCI, microblaze: " Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 19/22] PCI, mn10300: " Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 20/22] PCI, powerpc: " Yinghai Lu
2013-01-27 19:23                     ` Yinghai Lu
2013-01-28  3:48                     ` Yijing Wang
2013-01-28  3:48                       ` Yijing Wang
2013-01-28  5:23                       ` Yinghai Lu
2013-01-28  5:23                         ` Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 21/22] PCI: Kill pci_find_next_bus Yinghai Lu
2013-01-27 19:23                     ` Yinghai Lu
2013-01-27 19:23                     ` Yinghai Lu
2013-01-27 19:23                   ` [PATCH v3 22/22] PCI: Kill pci_root_buses Yinghai Lu
2013-01-27 19:23                     ` Yinghai Lu
2013-01-27 19:23                     ` Yinghai Lu
2013-02-02 21:50                   ` [PATCH v3 00/22] PCI: Iterate pci host bridge instead of pci root bus Bjorn Helgaas
2013-02-02 21:50                     ` Bjorn Helgaas
2013-02-02 21:50                     ` Bjorn Helgaas
2013-02-03  5:05                     ` Yinghai Lu
2013-02-05 23:55                       ` Yinghai Lu
2013-02-06  0:19                         ` Bjorn Helgaas
2013-02-06  0:47                           ` Yinghai Lu
2013-02-06  8:53                             ` Mauro Carvalho Chehab
2013-02-06 17:45                               ` Bjorn Helgaas
2013-02-07 10:24                                 ` Mauro Carvalho Chehab
2013-02-06 17:54                             ` Bjorn Helgaas
2013-02-06 18:59                               ` Yinghai Lu
2013-02-06 20:50                                 ` Bjorn Helgaas
2013-02-06 21:28                                   ` Yinghai Lu
2013-02-06 21:43                                     ` Rafael J. Wysocki
2013-02-06 21:53                                       ` Yinghai Lu
2013-02-06 22:05                                         ` Rafael J. Wysocki
2013-02-06 23:02                                           ` Bjorn Helgaas
2013-02-06 23:31                                             ` Yinghai Lu
2013-02-07  0:27                                             ` Jiang Liu
2013-01-28  1:54                 ` Yinghai Lu
2013-01-28  1:54                   ` [PATCH v3 02/22] PCI: Add dummy bus_type for pci_host_bridge Yinghai Lu
2013-01-28  1:54                   ` [PATCH v3 05/22] PCI: Add for_each_pci_host_bridge() and pci_get_next_host_bridge Yinghai Lu
2013-01-28  1:54                   ` [PATCH v3 21/22] PCI: Kill pci_find_next_bus Yinghai Lu
2013-01-28  1:54                   ` [PATCH v3 22/22] PCI: Kill pci_root_buses Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 17/22] PCI, frv: Kill pci_root_buses in resources reservations Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 18/22] PCI, microblaze: " Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 19/22] PCI, mn10300: " Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 20/22] PCI, powerpc: " Yinghai Lu
2013-01-27  5:36             ` Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 21/22] PCI: Kill pci_find_next_bus Yinghai Lu
2013-01-27  5:36           ` [PATCH v2 22/22] PCI: Kill pci_root_buses Yinghai Lu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.