public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC/Patch 0/12] ACPI based root bridge hot-add
@ 2005-03-18 21:38 Rajesh Shah
  2005-03-18 21:48 ` [Patch 1/12] " Rajesh Shah
                   ` (13 more replies)
  0 siblings, 14 replies; 22+ messages in thread
From: Rajesh Shah @ 2005-03-18 21:38 UTC (permalink / raw)
  To: gregkh; +Cc: linux-pci, linux-kernel, pcihpd-discuss

Here is a series of patches to support ACPI hot-add of a root
bridge hierarchy. The added hierarchy may contain other p2p 
bridges and end/leaf I/O devices too. The root bridge itself is
assumed to have been assigned resource ranges, but the p2p
bridges and end devices are not required to be initialized by
firmware. Most of the code changes are to make the existing code
flows suitable for such a hierarchy of bridges & devices.

This code supports hot-add on ia64 only for now.It does not yet
support I/O APIC hot-add, which is needed to make this fully
functional.  The patches are against 2.6.11-mm4 (plus the patch 
needed for ia64 to boot). I've tested to make sure this does not 
break end/leaf device hotplug on the hotplug capable ia64 box I have.

Thanks,
Rajesh

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

* [Patch 1/12] ACPI based root bridge hot-add
  2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
@ 2005-03-18 21:48 ` Rajesh Shah
  2005-03-18 21:59 ` [Patch 2/12] Fix pci_enable_device() for p2p bridges Rajesh Shah
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Rajesh Shah @ 2005-03-18 21:48 UTC (permalink / raw)
  To: gregkh, tony.luck, matthew, len.brown
  Cc: linux-pci, linux-kernel, pcihpd-discuss, linux-ia64, parisc-linux

When you hot-plug a (root) bridge hierarchy, it may have p2p
bridges and devices attached to it that have not been configured
by firmware. In this case, we need to configure the devices 
before starting them. This patch separates device start from
device scan so that we can introduce the configuration step in
the middle. 

I kept the existing semantics for pci_scan_bus() since there
are a huge number of callers to that function.

Also, I have no way of testing the changes I made to the parisc
files, so this needs review by those folks. Sorry for the massive
cross-post, this touches files in many different places.

Signed-off-by: Rajesh Shah <rajesh.shah@intel.com>
---

 linux-2.6.11-mm4-iohp-rshah1/arch/i386/pci/common.c   |    2 -
 linux-2.6.11-mm4-iohp-rshah1/arch/i386/pci/legacy.c   |    2 +
 linux-2.6.11-mm4-iohp-rshah1/arch/i386/pci/numa.c     |    2 +
 linux-2.6.11-mm4-iohp-rshah1/arch/ia64/pci/pci.c      |    2 -
 linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/pci_bind.c  |   16 +++++++++++-
 linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/pci_root.c  |   24 +++++++++++++++++-
 linux-2.6.11-mm4-iohp-rshah1/drivers/parisc/dino.c    |    1 
 linux-2.6.11-mm4-iohp-rshah1/drivers/parisc/lba_pci.c |    2 +
 linux-2.6.11-mm4-iohp-rshah1/drivers/pci/probe.c      |    2 -
 linux-2.6.11-mm4-iohp-rshah1/include/linux/pci.h      |    8 ++++--
 10 files changed, 53 insertions(+), 8 deletions(-)

diff -puN arch/i386/pci/common.c~pci_serparate_device_add arch/i386/pci/common.c
--- linux-2.6.11-mm4-iohp/arch/i386/pci/common.c~pci_serparate_device_add	2005-03-16 13:06:53.259117000 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/arch/i386/pci/common.c	2005-03-16 13:06:53.419273248 -0800
@@ -133,7 +133,7 @@ struct pci_bus * __devinit pcibios_scan_
 
 	printk("PCI: Probing PCI hardware (bus %02x)\n", busnum);
 
-	return pci_scan_bus(busnum, &pci_root_ops, NULL);
+	return pci_scan_bus_parented(NULL, busnum, &pci_root_ops, NULL);
 }
 
 extern u8 pci_cache_line_size;
diff -puN arch/i386/pci/legacy.c~pci_serparate_device_add arch/i386/pci/legacy.c
--- linux-2.6.11-mm4-iohp/arch/i386/pci/legacy.c~pci_serparate_device_add	2005-03-16 13:06:53.263999812 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/arch/i386/pci/legacy.c	2005-03-16 13:06:53.420249810 -0800
@@ -45,6 +45,8 @@ static int __init pci_legacy_init(void)
 
 	printk("PCI: Probing PCI hardware\n");
 	pci_root_bus = pcibios_scan_root(0);
+	if (pci_root_bus)
+		pci_bus_add_devices(pci_root_bus);
 
 	pcibios_fixup_peer_bridges();
 
diff -puN arch/i386/pci/numa.c~pci_serparate_device_add arch/i386/pci/numa.c
--- linux-2.6.11-mm4-iohp/arch/i386/pci/numa.c~pci_serparate_device_add	2005-03-16 13:06:53.267906062 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/arch/i386/pci/numa.c	2005-03-16 13:06:53.421226373 -0800
@@ -115,6 +115,8 @@ static int __init pci_numa_init(void)
 		return 0;
 
 	pci_root_bus = pcibios_scan_root(0);
+	if (pci_root_bus)
+		pci_bus_add_devices(pci_root_bus);
 	if (num_online_nodes() > 1)
 		for_each_online_node(quad) {
 			if (quad == 0)
diff -puN arch/ia64/pci/pci.c~pci_serparate_device_add arch/ia64/pci/pci.c
--- linux-2.6.11-mm4-iohp/arch/ia64/pci/pci.c~pci_serparate_device_add	2005-03-16 13:06:53.272788874 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/arch/ia64/pci/pci.c	2005-03-16 13:06:53.430991997 -0800
@@ -330,7 +330,7 @@ pci_acpi_scan_root(struct acpi_device *d
 	acpi_walk_resources(device->handle, METHOD_NAME__CRS, add_window,
 			&info);
 
-	pbus = pci_scan_bus(bus, &pci_root_ops, controller);
+	pbus = pci_scan_bus_parented(NULL, bus, &pci_root_ops, controller);
 	if (pbus)
 		pcibios_setup_root_windows(pbus, controller);
 
diff -puN drivers/acpi/pci_bind.c~pci_serparate_device_add drivers/acpi/pci_bind.c
--- linux-2.6.11-mm4-iohp/drivers/acpi/pci_bind.c~pci_serparate_device_add	2005-03-16 13:06:53.276695124 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/pci_bind.c	2005-03-16 13:06:53.431968560 -0800
@@ -129,6 +129,8 @@ acpi_pci_bind (
 	char			*pathname = NULL;
 	struct acpi_buffer	buffer = {0, NULL};
 	acpi_handle		handle = NULL;
+	struct pci_dev		*dev;
+	struct pci_bus 		*bus;
 
 	ACPI_FUNCTION_TRACE("acpi_pci_bind");
 
@@ -193,8 +195,20 @@ acpi_pci_bind (
 	 * Locate matching device in PCI namespace.  If it doesn't exist
 	 * this typically means that the device isn't currently inserted
 	 * (e.g. docking station, port replicator, etc.).
+	 * We cannot simply search the global pci device list, since
+	 * PCI devices are added to the global pci list when the root
+	 * bridge start ops are run, which may not have happened yet.
 	 */
-	data->dev = pci_find_slot(data->id.bus, PCI_DEVFN(data->id.device, data->id.function));
+	bus = pci_find_bus(data->id.segment, data->id.bus);
+	if (bus) {
+		list_for_each_entry(dev, &bus->devices, bus_list) {
+			if (dev->devfn == PCI_DEVFN(data->id.device,
+						data->id.function)) {
+				data->dev = dev;
+				break;
+			}
+		}
+	}
 	if (!data->dev) {
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO, 
 			"Device %02x:%02x:%02x.%02x not present in PCI namespace\n",
diff -puN drivers/acpi/pci_root.c~pci_serparate_device_add drivers/acpi/pci_root.c
--- linux-2.6.11-mm4-iohp/drivers/acpi/pci_root.c~pci_serparate_device_add	2005-03-16 13:06:53.281577937 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/pci_root.c	2005-03-16 13:06:53.432945122 -0800
@@ -46,6 +46,7 @@ ACPI_MODULE_NAME		("pci_root")
 
 static int acpi_pci_root_add (struct acpi_device *device);
 static int acpi_pci_root_remove (struct acpi_device *device, int type);
+static int acpi_pci_root_start (struct acpi_device *device);
 
 static struct acpi_driver acpi_pci_root_driver = {
 	.name =		ACPI_PCI_ROOT_DRIVER_NAME,
@@ -54,6 +55,7 @@ static struct acpi_driver acpi_pci_root_
 	.ops =		{
 				.add =    acpi_pci_root_add,
 				.remove = acpi_pci_root_remove,
+				.start =  acpi_pci_root_start,
 			},
 };
 
@@ -169,6 +171,7 @@ acpi_pci_root_add (
 	if (!root)
 		return_VALUE(-ENOMEM);
 	memset(root, 0, sizeof(struct acpi_pci_root));
+	INIT_LIST_HEAD(&root->node);
 
 	root->handle = device->handle;
 	strcpy(acpi_device_name(device), ACPI_PCI_ROOT_DEVICE_NAME);
@@ -298,12 +301,31 @@ acpi_pci_root_add (
 			root->id.bus);
 
 end:
-	if (result)
+	if (result) {
+		if (!list_empty(&root->node))
+			list_del(&root->node);
 		kfree(root);
+	}
 
 	return_VALUE(result);
 }
 
+static int
+acpi_pci_root_start (
+	struct acpi_device	*device)
+{
+	struct acpi_pci_root	*root;
+
+	ACPI_FUNCTION_TRACE("acpi_pci_root_start");
+
+	list_for_each_entry(root, &acpi_pci_roots, node) {
+		if (root->handle == device->handle) {
+			pci_bus_add_devices(root->bus);
+			return_VALUE(0);
+		}
+	}
+	return_VALUE(-ENODEV);
+}
 
 static int
 acpi_pci_root_remove (
diff -puN drivers/parisc/dino.c~pci_serparate_device_add drivers/parisc/dino.c
--- linux-2.6.11-mm4-iohp/drivers/parisc/dino.c~pci_serparate_device_add	2005-03-16 13:06:53.285484187 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/parisc/dino.c	2005-03-16 13:06:53.433921685 -0800
@@ -993,6 +993,7 @@ dino_driver_callback(struct parisc_devic
 	bus = pci_scan_bus_parented(&dev->dev, dino_current_bus,
 				    &dino_cfg_ops, NULL);
 	if(bus) {
+		pci_bus_add_devices(bus);
 		/* This code *depends* on scanning being single threaded
 		 * if it isn't, this global bus number count will fail
 		 */
diff -puN drivers/parisc/lba_pci.c~pci_serparate_device_add drivers/parisc/lba_pci.c
--- linux-2.6.11-mm4-iohp/drivers/parisc/lba_pci.c~pci_serparate_device_add	2005-03-16 13:06:53.290366999 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/parisc/lba_pci.c	2005-03-16 13:06:53.435874810 -0800
@@ -1570,6 +1570,8 @@ lba_driver_probe(struct parisc_device *d
 	lba_bus = lba_dev->hba.hba_bus =
 		pci_scan_bus_parented(&dev->dev, lba_dev->hba.bus_num.start,
 				cfg_ops, NULL);
+	if (lba_bus)
+		pci_bus_add_devices(lba_bus);
 
 	/* This is in lieu of calling pci_assign_unassigned_resources() */
 	if (is_pdc_pat()) {
diff -puN drivers/pci/probe.c~pci_serparate_device_add drivers/pci/probe.c
--- linux-2.6.11-mm4-iohp/drivers/pci/probe.c~pci_serparate_device_add	2005-03-16 13:06:53.294273249 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/pci/probe.c	2005-03-16 13:06:53.436851372 -0800
@@ -916,8 +916,6 @@ struct pci_bus * __devinit pci_scan_bus_
 
 	b->subordinate = pci_scan_child_bus(b);
 
-	pci_bus_add_devices(b);
-
 	return b;
 
 sys_create_link_err:
diff -puN include/linux/pci.h~pci_serparate_device_add include/linux/pci.h
--- linux-2.6.11-mm4-iohp/include/linux/pci.h~pci_serparate_device_add	2005-03-16 13:06:53.299156062 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/include/linux/pci.h	2005-03-16 13:06:53.449546685 -0800
@@ -732,16 +732,20 @@ void pcibios_update_irq(struct pci_dev *
 /* Generic PCI functions used internally */
 
 extern struct pci_bus *pci_find_bus(int domain, int busnr);
+void pci_bus_add_devices(struct pci_bus *bus);
 struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata);
 static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata)
 {
-	return pci_scan_bus_parented(NULL, bus, ops, sysdata);
+	struct pci_bus *root_bus;
+	root_bus = pci_scan_bus_parented(NULL, bus, ops, sysdata);
+	if (root_bus)
+		pci_bus_add_devices(root_bus);
+	return root_bus;
 }
 int pci_scan_slot(struct pci_bus *bus, int devfn);
 struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn);
 unsigned int pci_scan_child_bus(struct pci_bus *bus);
 void pci_bus_add_device(struct pci_dev *dev);
-void pci_bus_add_devices(struct pci_bus *bus);
 void pci_name_device(struct pci_dev *dev);
 char *pci_class_name(u32 class);
 void pci_read_bridge_bases(struct pci_bus *child);
_

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

* [Patch 2/12] Fix pci_enable_device() for p2p bridges
  2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
  2005-03-18 21:48 ` [Patch 1/12] " Rajesh Shah
@ 2005-03-18 21:59 ` Rajesh Shah
  2005-03-18 22:02 ` [patch 03/12] Make pcibios_fixup_bus() hot-plug safe Rajesh Shah
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Rajesh Shah @ 2005-03-18 21:59 UTC (permalink / raw)
  To: gregkh, tony.luck, len.brown
  Cc: linux-pci, linux-kernel, pcihpd-discuss, linux-ia64, acpi-devel

When checking if a PCI to PCI bridge should be enabled to decode
memory and/or IO resources, we need to look at all device 
resources not just the first 6. This is needed to allow PCI
bridges to pass down memory and IO accesses to child devices
even when the bridge itself does not consume resources in its
PCI BARs.

Signed-off-by: Rajesh Shah <rajesh.shah@intel.com>
---

 linux-2.6.11-mm4-iohp-rshah1/arch/ia64/pci/pci.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff -puN arch/ia64/pci/pci.c~fix-ia64-pcibios_enable_resources arch/ia64/pci/pci.c
--- linux-2.6.11-mm4-iohp/arch/ia64/pci/pci.c~fix-ia64-pcibios_enable_resources	2005-03-16 13:07:02.055015329 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/arch/ia64/pci/pci.c	2005-03-16 13:07:02.164390328 -0800
@@ -436,18 +436,24 @@ pcibios_enable_resources (struct pci_dev
 	u16 cmd, old_cmd;
 	int idx;
 	struct resource *r;
+	unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM;
 
 	if (!dev)
 		return -EINVAL;
 
 	pci_read_config_word(dev, PCI_COMMAND, &cmd);
 	old_cmd = cmd;
-	for (idx=0; idx<6; idx++) {
+	for (idx=0; idx<PCI_NUM_RESOURCES; idx++) {
 		/* Only set up the desired resources.  */
 		if (!(mask & (1 << idx)))
 			continue;
 
 		r = &dev->resource[idx];
+		if (!(r->flags & type_mask))
+			continue;
+		if ((idx == PCI_ROM_RESOURCE) &&
+				(!(r->flags & IORESOURCE_ROM_ENABLE)))
+			continue;
 		if (!r->start && r->end) {
 			printk(KERN_ERR
 			       "PCI: Device %s not available because of resource collisions\n",
@@ -459,8 +465,6 @@ pcibios_enable_resources (struct pci_dev
 		if (r->flags & IORESOURCE_MEM)
 			cmd |= PCI_COMMAND_MEMORY;
 	}
-	if (dev->resource[PCI_ROM_RESOURCE].start)
-		cmd |= PCI_COMMAND_MEMORY;
 	if (cmd != old_cmd) {
 		printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd);
 		pci_write_config_word(dev, PCI_COMMAND, cmd);
_

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

* [patch 03/12] Make pcibios_fixup_bus() hot-plug safe
  2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
  2005-03-18 21:48 ` [Patch 1/12] " Rajesh Shah
  2005-03-18 21:59 ` [Patch 2/12] Fix pci_enable_device() for p2p bridges Rajesh Shah
@ 2005-03-18 22:02 ` Rajesh Shah
  2005-03-18 22:04 ` [patch 04/12] Prevent duplicate bus numbers when scanning PCI bridge Rajesh Shah
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Rajesh Shah @ 2005-03-18 22:02 UTC (permalink / raw)
  To: gregkh, tony.luck, len.brown
  Cc: linux-pci, linux-kernel, pcihpd-discuss, linux-ia64, acpi-devel

PCI scan code calls the arch specific pcibios_fixup_bus() each
time it scans a new bridge. For root bridge hot-plug, the bridge
and it's attached devices may not have been configured properly
yet, so it's not safe to claim those resources at this time.

This code goes away when we clean up the way pci resources are
claimed (in pci_enable_device()), so this is only a stopgap fix.

Signed-off-by: Rajesh Shah <rajesh.shah@intel.com>
---

 linux-2.6.11-mm4-iohp-rshah1/arch/ia64/pci/pci.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletion(-)

diff -puN arch/ia64/pci/pci.c~ia64-pcibios_fixup_bus-hotplug-safe arch/ia64/pci/pci.c
--- linux-2.6.11-mm4-iohp/arch/ia64/pci/pci.c~ia64-pcibios_fixup_bus-hotplug-safe	2005-03-16 13:07:06.343101214 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/arch/ia64/pci/pci.c	2005-03-16 13:07:06.450523088 -0800
@@ -391,6 +391,25 @@ void pcibios_bus_to_resource(struct pci_
 	res->end = region->end + offset;
 }
 
+static int __devinit is_valid_resource(struct pci_dev *dev, int idx)
+{
+	unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM;
+	struct resource *devr = &dev->resource[idx];
+
+	if (!dev->bus)
+		return 0;
+	for (i=0; i<PCI_BUS_NUM_RESOURCES; i++) {
+		struct resource *busr = dev->bus->resource[i];
+
+		if (!busr || ((busr->flags ^ devr->flags) & type_mask))
+			continue;
+		if ((devr->start) && (devr->start >= busr->start) &&
+				(devr->end <= busr->end))
+			return 1;
+	}
+	return 0;
+}
+
 static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev)
 {
 	struct pci_bus_region region;
@@ -404,7 +423,8 @@ static void __devinit pcibios_fixup_devi
 		region.start = dev->resource[i].start;
 		region.end = dev->resource[i].end;
 		pcibios_bus_to_resource(dev, &dev->resource[i], &region);
-		pci_claim_resource(dev, i);
+		if ((is_valid_resource(dev, i)))
+			pci_claim_resource(dev, i);
 	}
 }
 
_

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

* [patch 04/12] Prevent duplicate bus numbers when scanning PCI bridge
  2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
                   ` (2 preceding siblings ...)
  2005-03-18 22:02 ` [patch 03/12] Make pcibios_fixup_bus() hot-plug safe Rajesh Shah
@ 2005-03-18 22:04 ` Rajesh Shah
  2005-03-18 22:07 ` [patch 05/12] Take the PCI lock when modifying pci bus or device lists Rajesh Shah
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Rajesh Shah @ 2005-03-18 22:04 UTC (permalink / raw)
  To: gregkh, tony.luck, len.brown
  Cc: linux-pci, linux-kernel, pcihpd-discuss, linux-ia64, acpi-devel

When hot-plugging a root bridge, as we try to assign bus numbers
we may find that the hotplugged hieratchy has more PCI to PCI
bridges (i.e. bus requirements) than available.  Make sure we
don't step over an existing bus when that happens. 

Signed-off-by: Rajesh Shah <rajesh.shah@intel.com>
---

 linux-2.6.11-mm4-iohp-rshah1/drivers/pci/probe.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff -puN drivers/pci/probe.c~prevent_duplicate_busnr drivers/pci/probe.c
--- linux-2.6.11-mm4-iohp/drivers/pci/probe.c~prevent_duplicate_busnr	2005-03-16 13:07:10.376304290 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/pci/probe.c	2005-03-16 13:07:10.496421476 -0800
@@ -417,7 +417,7 @@ int __devinit pci_scan_bridge(struct pci
 {
 	struct pci_bus *child;
 	int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS);
-	u32 buses;
+	u32 buses, i;
 	u16 bctl;
 
 	pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses);
@@ -476,6 +476,10 @@ int __devinit pci_scan_bridge(struct pci
 		/* Clear errors */
 		pci_write_config_word(dev, PCI_STATUS, 0xffff);
 
+		/* Prevent assigning a bus number that already exists.
+		 * This can happen when a bridge is hot-plugged */
+		if (pci_find_bus(pci_domain_nr(bus), max+1))
+			return max;
 		child = pci_alloc_child_bus(bus, dev, ++max);
 		buses = (buses & 0xff000000)
 		      | ((unsigned int)(child->primary)     <<  0)
@@ -507,7 +511,11 @@ int __devinit pci_scan_bridge(struct pci
 			 * as cards with a PCI-to-PCI bridge can be
 			 * inserted later.
 			 */
-			max += CARDBUS_RESERVE_BUSNR;
+			for (i=0; i<CARDBUS_RESERVE_BUSNR; i++)
+				if (pci_find_bus(pci_domain_nr(bus),
+							max+i+1))
+					break;
+			max += i;
 		}
 		/*
 		 * Set the subordinate bus number to its real value.
_

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

* [patch 05/12] Take the PCI lock when modifying pci bus or device lists
  2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
                   ` (3 preceding siblings ...)
  2005-03-18 22:04 ` [patch 04/12] Prevent duplicate bus numbers when scanning PCI bridge Rajesh Shah
@ 2005-03-18 22:07 ` Rajesh Shah
  2005-03-18 22:09 ` [patch 06/12] Link newly created pci child bus to its parent on creation Rajesh Shah
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Rajesh Shah @ 2005-03-18 22:07 UTC (permalink / raw)
  To: gregkh, tony.luck, len.brown
  Cc: linux-pci, linux-kernel, pcihpd-discuss, linux-ia64, acpi-devel

With root bridge and pci bridge hot-plug, new buses and devices
can be added or removed at run time. Protect the pci bus and
device lists with the pci lock when doing so.

Signed-off-by: Rajesh Shah <rajesh.shah@intel.com>
---

 linux-2.6.11-mm4-iohp-rshah1/drivers/pci/probe.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletion(-)

diff -puN drivers/pci/probe.c~lock-pci-root-bus-add drivers/pci/probe.c
--- linux-2.6.11-mm4-iohp/drivers/pci/probe.c~lock-pci-root-bus-add	2005-03-16 13:07:14.694663612 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/pci/probe.c	2005-03-16 13:07:14.802085486 -0800
@@ -8,6 +8,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/cpumask.h>
+#include "pci.h"
 
 #undef DEBUG
 
@@ -380,8 +381,11 @@ struct pci_bus * __devinit pci_add_new_b
 	struct pci_bus *child;
 
 	child = pci_alloc_child_bus(parent, dev, busnr);
-	if (child)
+	if (child) {
+		spin_lock(&pci_bus_lock);
 		list_add_tail(&child->node, &parent->children);
+		spin_unlock(&pci_bus_lock);
+	}
 	return child;
 }
 
@@ -771,7 +775,9 @@ pci_scan_single_device(struct pci_bus *b
 	 * and the bus list for fixup functions, etc.
 	 */
 	INIT_LIST_HEAD(&dev->global_list);
+	spin_lock(&pci_bus_lock);
 	list_add_tail(&dev->bus_list, &bus->devices);
+	spin_unlock(&pci_bus_lock);
 
 	return dev;
 }
@@ -891,7 +897,9 @@ struct pci_bus * __devinit pci_scan_bus_
 		DBG("PCI: Bus %04x:%02x already known\n", pci_domain_nr(b), bus);
 		goto err_out;
 	}
+	spin_lock(&pci_bus_lock);
 	list_add_tail(&b->node, &pci_root_buses);
+	spin_unlock(&pci_bus_lock);
 
 	memset(dev, 0, sizeof(*dev));
 	dev->parent = parent;
@@ -933,7 +941,9 @@ class_dev_create_file_err:
 class_dev_reg_err:
 	device_unregister(dev);
 dev_reg_err:
+	spin_lock(&pci_bus_lock);
 	list_del(&b->node);
+	spin_unlock(&pci_bus_lock);
 err_out:
 	kfree(dev);
 	kfree(b);
_

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

* [patch 06/12] Link newly created pci child bus to its parent on creation
  2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
                   ` (4 preceding siblings ...)
  2005-03-18 22:07 ` [patch 05/12] Take the PCI lock when modifying pci bus or device lists Rajesh Shah
@ 2005-03-18 22:09 ` Rajesh Shah
  2005-03-18 22:11 ` [patch 07/12] Make the PCI remove routines safe for failed hot-plug Rajesh Shah
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Rajesh Shah @ 2005-03-18 22:09 UTC (permalink / raw)
  To: gregkh, tony.luck, len.brown
  Cc: linux-pci, linux-kernel, pcihpd-discuss, linux-ia64, acpi-devel

When a pci child bus is created, add it to the parent's children
list immediately rather than waiting till pci_bus_add_devices().
For hot-plug bridges/devices, pci_bus_add_devices() may be called
much later, after they have been properly configured. In the 
meantime, this allows us to use the normal pci bus search functions
for the hot-plug bridges/buses.

Signed-off-by: Rajesh Shah <rajesh.shah@intel.com>
---

 linux-2.6.11-mm4-iohp-rshah1/drivers/pci/bus.c   |   11 +++++++----
 linux-2.6.11-mm4-iohp-rshah1/drivers/pci/probe.c |    4 ++--
 2 files changed, 9 insertions(+), 6 deletions(-)

diff -puN drivers/pci/probe.c~pci_link_child_bus drivers/pci/probe.c
--- linux-2.6.11-mm4-iohp/drivers/pci/probe.c~pci_link_child_bus	2005-03-16 13:07:18.745444812 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/pci/probe.c	2005-03-16 13:07:18.857749498 -0800
@@ -457,7 +457,7 @@ int __devinit pci_scan_bridge(struct pci
 			return max;
 		}
 
-		child = pci_alloc_child_bus(bus, dev, busnr);
+		child = pci_add_new_bus(bus, dev, busnr);
 		if (!child)
 			return max;
 		child->primary = buses & 0xFF;
@@ -484,7 +484,7 @@ int __devinit pci_scan_bridge(struct pci
 		 * This can happen when a bridge is hot-plugged */
 		if (pci_find_bus(pci_domain_nr(bus), max+1))
 			return max;
-		child = pci_alloc_child_bus(bus, dev, ++max);
+		child = pci_add_new_bus(bus, dev, ++max);
 		buses = (buses & 0xff000000)
 		      | ((unsigned int)(child->primary)     <<  0)
 		      | ((unsigned int)(child->secondary)   <<  8)
diff -puN drivers/pci/bus.c~pci_link_child_bus drivers/pci/bus.c
--- linux-2.6.11-mm4-iohp/drivers/pci/bus.c~pci_link_child_bus	2005-03-16 13:07:18.749351062 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/pci/bus.c	2005-03-16 13:07:18.858726061 -0800
@@ -121,10 +121,13 @@ void __devinit pci_bus_add_devices(struc
 		 * If there is an unattached subordinate bus, attach
 		 * it and then scan for unattached PCI devices.
 		 */
-		if (dev->subordinate && list_empty(&dev->subordinate->node)) {
-			spin_lock(&pci_bus_lock);
-			list_add_tail(&dev->subordinate->node, &dev->bus->children);
-			spin_unlock(&pci_bus_lock);
+		if (dev->subordinate) {
+		       if (list_empty(&dev->subordinate->node)) {
+			       spin_lock(&pci_bus_lock);
+			       list_add_tail(&dev->subordinate->node,
+					       &dev->bus->children);
+			       spin_unlock(&pci_bus_lock);
+		       }
 			pci_bus_add_devices(dev->subordinate);
 
 			sysfs_create_link(&dev->subordinate->class_dev.kobj, &dev->dev.kobj, "bridge");
_

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

* [patch 07/12] Make the PCI remove routines safe for failed hot-plug
  2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
                   ` (5 preceding siblings ...)
  2005-03-18 22:09 ` [patch 06/12] Link newly created pci child bus to its parent on creation Rajesh Shah
@ 2005-03-18 22:11 ` Rajesh Shah
  2005-03-19  5:14   ` Greg KH
  2005-03-18 22:14 ` [patch 08/12] Remove hot-plugged devices that could not be allocated resources Rajesh Shah
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 22+ messages in thread
From: Rajesh Shah @ 2005-03-18 22:11 UTC (permalink / raw)
  To: gregkh, tony.luck, len.brown
  Cc: linux-pci, linux-kernel, pcihpd-discuss, linux-ia64, acpi-devel

When a root bridge hierarchy is hot-plugged, resource requirements
for the new devices may be greater than what the root bridge is
decoding. In this case, we want to remove devices that did not
get needed resources. These devices have been scanned into bus
specific lists but not yet added to the global device list.
Make sure the pci remove functions can handle this case.

Signed-off-by: Rajesh Shah <rajesh.shah@intel.com>
---

 linux-2.6.11-mm4-iohp-rshah1/drivers/pci/remove.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff -puN drivers/pci/remove.c~pci-remove-device-hotplug-safe drivers/pci/remove.c
--- linux-2.6.11-mm4-iohp/drivers/pci/remove.c~pci-remove-device-hotplug-safe	2005-03-16 13:07:22.667319764 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/pci/remove.c	2005-03-16 13:07:22.775718200 -0800
@@ -26,17 +26,21 @@ static void pci_free_resources(struct pc
 
 static void pci_destroy_dev(struct pci_dev *dev)
 {
-	pci_proc_detach_device(dev);
-	pci_remove_sysfs_dev_files(dev);
-	device_unregister(&dev->dev);
+	if (!list_empty(&dev->global_list)) {
+		pci_proc_detach_device(dev);
+		pci_remove_sysfs_dev_files(dev);
+		device_unregister(&dev->dev);
+		spin_lock(&pci_bus_lock);
+		list_del(&dev->global_list);
+		dev->global_list.next = dev->global_list.prev = NULL;
+		spin_unlock(&pci_bus_lock);
+	}
 
 	/* Remove the device from the device lists, and prevent any further
 	 * list accesses from this device */
 	spin_lock(&pci_bus_lock);
 	list_del(&dev->bus_list);
-	list_del(&dev->global_list);
 	dev->bus_list.next = dev->bus_list.prev = NULL;
-	dev->global_list.next = dev->global_list.prev = NULL;
 	spin_unlock(&pci_bus_lock);
 
 	pci_free_resources(dev);
_

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

* [patch 08/12] Remove hot-plugged devices that could not be allocated resources
  2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
                   ` (6 preceding siblings ...)
  2005-03-18 22:11 ` [patch 07/12] Make the PCI remove routines safe for failed hot-plug Rajesh Shah
@ 2005-03-18 22:14 ` Rajesh Shah
  2005-03-18 22:16 ` [patch 09/12] Read bridge resources when fixing up the bus Rajesh Shah
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Rajesh Shah @ 2005-03-18 22:14 UTC (permalink / raw)
  To: gregkh, tony.luck, len.brown
  Cc: linux-pci, linux-kernel, pcihpd-discuss, linux-ia64, acpi-devel

When hot-plugging an I/O hierarchy that contains many bridges
and leaf devices, it's possible that there are not enough 
resources to start all the device present. If we fail to assign
a resource, clear the corresponding value in the pci_dev structure,
so other code can take corrective action.

Signed-off-by: Rajesh Shah <rajesh.shah@intel.com>
---

 linux-2.6.11-mm4-iohp-rshah1/drivers/pci/setup-bus.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletion(-)

diff -puN drivers/pci/setup-bus.c~discard_no_resource_devs drivers/pci/setup-bus.c
--- linux-2.6.11-mm4-iohp/drivers/pci/setup-bus.c~discard_no_resource_devs	2005-03-16 13:07:26.557944717 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/pci/setup-bus.c	2005-03-16 13:07:26.666343153 -0800
@@ -72,7 +72,10 @@ pbus_assign_resources_sorted(struct pci_
 	for (list = head.next; list;) {
 		res = list->res;
 		idx = res - &list->dev->resource[0];
-		pci_assign_resource(list->dev, idx);
+		if (pci_assign_resource(list->dev, idx)) {
+			res->start = 0;
+			res->flags = 0;
+		}
 		tmp = list;
 		list = list->next;
 		kfree(tmp);
_

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

* [patch 09/12] Read bridge resources when fixing up the bus
  2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
                   ` (7 preceding siblings ...)
  2005-03-18 22:14 ` [patch 08/12] Remove hot-plugged devices that could not be allocated resources Rajesh Shah
@ 2005-03-18 22:16 ` Rajesh Shah
  2005-03-18 22:18 ` [patch 10/12] Allow ACPI .add and .start operations to be done independently Rajesh Shah
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Rajesh Shah @ 2005-03-18 22:16 UTC (permalink / raw)
  To: gregkh, tony.luck, len.brown
  Cc: linux-pci, linux-kernel, pcihpd-discuss, linux-ia64, acpi-devel

Read bridge io/mem/pfmem ranges when fixing up the bus so that 
bus resources are tracked. This is required to properly support
pci end device and bridge hotplug.

Signed-off-by: Rajesh Shah <rajesh.shah@intel.com>
---

 linux-2.6.11-mm4-iohp-rshah1/arch/ia64/pci/pci.c |    4 ++++
 1 files changed, 4 insertions(+)

diff -puN arch/ia64/pci/pci.c~ia64-read_bridge_bases arch/ia64/pci/pci.c
--- linux-2.6.11-mm4-iohp/arch/ia64/pci/pci.c~ia64-read_bridge_bases	2005-03-16 13:07:30.503257168 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/arch/ia64/pci/pci.c	2005-03-16 13:07:30.612632167 -0800
@@ -436,6 +436,10 @@ pcibios_fixup_bus (struct pci_bus *b)
 {
 	struct pci_dev *dev;
 
+	if (b->self) {
+		pci_read_bridge_bases(b);
+		pcibios_fixup_device_resources(b->self);
+	}
 	list_for_each_entry(dev, &b->devices, bus_list)
 		pcibios_fixup_device_resources(dev);
 
_

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

* [patch 10/12] Allow ACPI .add and .start operations to be done independently
  2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
                   ` (8 preceding siblings ...)
  2005-03-18 22:16 ` [patch 09/12] Read bridge resources when fixing up the bus Rajesh Shah
@ 2005-03-18 22:18 ` Rajesh Shah
  2005-03-18 22:20 ` [patch 11/12] Export the interface to get PCI id for an ACPI handle Rajesh Shah
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Rajesh Shah @ 2005-03-18 22:18 UTC (permalink / raw)
  To: gregkh, tony.luck, len.brown
  Cc: linux-pci, linux-kernel, pcihpd-discuss, linux-ia64, acpi-devel

Create new interfaces to recursively add an acpi namespace object
to the acpi device list, and recursively start the namespace 
object. This is needed for ACPI based hotplug of a root bridge
hierarchy where the add operation must be performed first and 
the start operation must be performed separately after the 
hot-plugged devices have been properly configured.

Signed-off-by: Rajesh Shah <rajesh.shah@intel.com>
---

 linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/container.c      |    2 
 linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/processor_core.c |    2 
 linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/scan.c           |  126 ++++++++++---
 linux-2.6.11-mm4-iohp-rshah1/include/acpi/acpi_bus.h       |   17 +
 4 files changed, 119 insertions(+), 28 deletions(-)

diff -puN drivers/acpi/scan.c~acpi_separate_device_start drivers/acpi/scan.c
--- linux-2.6.11-mm4-iohp/drivers/acpi/scan.c~acpi_separate_device_start	2005-03-16 13:07:34.326499309 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/scan.c	2005-03-16 13:07:34.452475870 -0800
@@ -553,20 +553,29 @@ acpi_bus_driver_init (
 	 * upon possible configuration and currently allocated resources.
 	 */
 
+	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Driver successfully bound to device\n"));
+	return_VALUE(0);
+}
+
+int
+acpi_start_single_object (
+		struct acpi_device *device)
+{
+	int result = 0;
+	struct acpi_driver *driver;
+
+	ACPI_FUNCTION_TRACE("acpi_start_single_object");
+
+	if (!(driver = device->driver))
+		return_VALUE(0);
+
 	if (driver->ops.start) {
 		result = driver->ops.start(device);
 		if (result && driver->ops.remove)
 			driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
-		return_VALUE(result);
-	}
-
-	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Driver successfully bound to device\n"));
-
-	if (driver->ops.scan) {
-		driver->ops.scan(device);
 	}
 
-	return_VALUE(0);
+	return_VALUE(result);
 }
 
 static int acpi_driver_attach(struct acpi_driver * drv)
@@ -586,6 +595,7 @@ static int acpi_driver_attach(struct acp
 
 		if (!acpi_bus_match(dev, drv)) {
 			if (!acpi_bus_driver_init(dev, drv)) {
+				acpi_start_single_object(dev);
 				atomic_inc(&drv->references);
 				count++;
 				ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n",
@@ -1009,8 +1019,8 @@ acpi_bus_remove (
 }
 
 
-int
-acpi_bus_add (
+static int
+acpi_add_single_object (
 	struct acpi_device	**child,
 	struct acpi_device	*parent,
 	acpi_handle		handle,
@@ -1019,7 +1029,7 @@ acpi_bus_add (
 	int			result = 0;
 	struct acpi_device	*device = NULL;
 
-	ACPI_FUNCTION_TRACE("acpi_bus_add");
+	ACPI_FUNCTION_TRACE("acpi_add_single_object");
 
 	if (!child)
 		return_VALUE(-EINVAL);
@@ -1140,7 +1150,7 @@ acpi_bus_add (
 	 *
 	 * TBD: Assumes LDM provides driver hot-plug capability.
 	 */
-	acpi_bus_find_driver(device);
+	result = acpi_bus_find_driver(device);
 
 end:
 	if (!result)
@@ -1153,10 +1163,10 @@ end:
 
 	return_VALUE(result);
 }
-EXPORT_SYMBOL(acpi_bus_add);
 
 
-int acpi_bus_scan (struct acpi_device	*start)
+static int acpi_bus_scan (struct acpi_device	*start,
+		struct acpi_bus_ops *ops)
 {
 	acpi_status		status = AE_OK;
 	struct acpi_device	*parent = NULL;
@@ -1229,9 +1239,20 @@ int acpi_bus_scan (struct acpi_device	*s
 			continue;
 		}
 
-		status = acpi_bus_add(&child, parent, chandle, type);
-		if (ACPI_FAILURE(status))
-			continue;
+		if (ops->acpi_op_add)
+			status = acpi_add_single_object(&child, parent,
+					chandle, type);
+		 else
+			status = acpi_bus_get_device(chandle, &child);
+
+		 if (ACPI_FAILURE(status))
+			 continue;
+
+		if (ops->acpi_op_start) {
+			status = acpi_start_single_object(child);
+			if (ACPI_FAILURE(status))
+				continue;
+		}
 
 		/*
 		 * If the device is present, enabled, and functioning then
@@ -1257,8 +1278,50 @@ int acpi_bus_scan (struct acpi_device	*s
 
 	return_VALUE(0);
 }
-EXPORT_SYMBOL(acpi_bus_scan);
 
+int
+acpi_bus_add (
+	struct acpi_device	**child,
+	struct acpi_device	*parent,
+	acpi_handle		handle,
+	int			type)
+{
+	int result;
+	struct acpi_bus_ops ops;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_add");
+
+	result = acpi_add_single_object(child, parent, handle, type);
+	if (!result) {
+		memset(&ops, 0, sizeof(ops));
+		ops.acpi_op_add = 1;
+		result = acpi_bus_scan(*child, &ops);
+	}
+	return_VALUE(result);
+}
+EXPORT_SYMBOL(acpi_bus_add);
+
+int
+acpi_bus_start (
+	struct acpi_device *device)
+{
+	int result;
+	struct acpi_bus_ops ops;
+
+	ACPI_FUNCTION_TRACE("acpi_bus_start");
+
+	if (!device)
+		return_VALUE(-EINVAL);
+
+	result = acpi_start_single_object(device);
+	if (!result) {
+		memset(&ops, 0, sizeof(ops));
+		ops.acpi_op_start = 1;
+		result = acpi_bus_scan(device, &ops);
+	}
+	return_VALUE(result);
+}
+EXPORT_SYMBOL(acpi_bus_start);
 
 static int
 acpi_bus_trim(struct acpi_device	*start,
@@ -1331,13 +1394,19 @@ acpi_bus_scan_fixed (
 	/*
 	 * Enumerate all fixed-feature devices.
 	 */
-	if (acpi_fadt.pwr_button == 0)
-		result = acpi_bus_add(&device, acpi_root, 
+	if (acpi_fadt.pwr_button == 0) {
+		result = acpi_add_single_object(&device, acpi_root,
 			NULL, ACPI_BUS_TYPE_POWER_BUTTON);
+		if (!result)
+			result = acpi_start_single_object(device);
+	}
 
-	if (acpi_fadt.sleep_button == 0)
-		result = acpi_bus_add(&device, acpi_root, 
+	if (acpi_fadt.sleep_button == 0) {
+		result = acpi_add_single_object(&device, acpi_root,
 			NULL, ACPI_BUS_TYPE_SLEEP_BUTTON);
+		if (!result)
+			result = acpi_start_single_object(device);
+	}
 
 	return_VALUE(result);
 }
@@ -1346,6 +1415,7 @@ acpi_bus_scan_fixed (
 static int __init acpi_scan_init(void)
 {
 	int result;
+	struct acpi_bus_ops ops;
 
 	ACPI_FUNCTION_TRACE("acpi_scan_init");
 
@@ -1357,17 +1427,23 @@ static int __init acpi_scan_init(void)
 	/*
 	 * Create the root device in the bus's device tree
 	 */
-	result = acpi_bus_add(&acpi_root, NULL, ACPI_ROOT_OBJECT, 
+	result = acpi_add_single_object(&acpi_root, NULL, ACPI_ROOT_OBJECT,
 		ACPI_BUS_TYPE_SYSTEM);
 	if (result)
 		goto Done;
 
+	result = acpi_start_single_object(acpi_root);
+
 	/*
 	 * Enumerate devices in the ACPI namespace.
 	 */
 	result = acpi_bus_scan_fixed(acpi_root);
-	if (!result) 
-		result = acpi_bus_scan(acpi_root);
+	if (!result) {
+		memset(&ops, 0, sizeof(ops));
+		ops.acpi_op_add = 1;
+		ops.acpi_op_start = 1;
+		result = acpi_bus_scan(acpi_root, &ops);
+	}
 
 	if (result)
 		acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
diff -puN include/acpi/acpi_bus.h~acpi_separate_device_start include/acpi/acpi_bus.h
--- linux-2.6.11-mm4-iohp/include/acpi/acpi_bus.h~acpi_separate_device_start	2005-03-16 13:07:34.330405559 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/include/acpi/acpi_bus.h	2005-03-16 13:07:34.453452432 -0800
@@ -108,6 +108,21 @@ typedef int (*acpi_op_unbind)	(struct ac
 typedef int (*acpi_op_match)	(struct acpi_device *device,
 				 struct acpi_driver *driver);
 
+struct acpi_bus_ops {
+	u32 			acpi_op_add:1;
+	u32			acpi_op_remove:1;
+	u32			acpi_op_lock:1;
+	u32			acpi_op_start:1;
+	u32			acpi_op_stop:1;
+	u32			acpi_op_suspend:1;
+	u32			acpi_op_resume:1;
+	u32			acpi_op_scan:1;
+	u32			acpi_op_bind:1;
+	u32			acpi_op_unbind:1;
+	u32			acpi_op_match:1;
+	u32			reserved:21;
+};
+
 struct acpi_device_ops {
 	acpi_op_add		add;
 	acpi_op_remove		remove;
@@ -327,9 +342,9 @@ int acpi_bus_generate_event (struct acpi
 int acpi_bus_receive_event (struct acpi_bus_event *event);
 int acpi_bus_register_driver (struct acpi_driver *driver);
 int acpi_bus_unregister_driver (struct acpi_driver *driver);
-int acpi_bus_scan (struct acpi_device *start);
 int acpi_bus_add (struct acpi_device **child, struct acpi_device *parent,
 		acpi_handle handle, int type);
+int acpi_bus_start (struct acpi_device *device);
 
 
 int acpi_match_ids (struct acpi_device	*device, char	*ids);
diff -puN drivers/acpi/container.c~acpi_separate_device_start drivers/acpi/container.c
--- linux-2.6.11-mm4-iohp/drivers/acpi/container.c~acpi_separate_device_start	2005-03-16 13:07:34.335288371 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/container.c	2005-03-16 13:07:34.454428995 -0800
@@ -153,7 +153,7 @@ container_device_add(struct acpi_device 
 		return_VALUE(-ENODEV);
 	}
 
-	result = acpi_bus_scan(*device);
+	result = acpi_bus_start(*device);
 
 	return_VALUE(result);
 }
diff -puN drivers/acpi/processor_core.c~acpi_separate_device_start drivers/acpi/processor_core.c
--- linux-2.6.11-mm4-iohp/drivers/acpi/processor_core.c~acpi_separate_device_start	2005-03-16 13:07:34.339194621 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/processor_core.c	2005-03-16 13:07:34.455405557 -0800
@@ -723,7 +723,7 @@ int acpi_processor_device_add(
 		return_VALUE(-ENODEV);
 	}
 
-	acpi_bus_scan(*device);
+	acpi_bus_start(*device);
 
 	pr = acpi_driver_data(*device);
 	if (!pr)
_

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

* [patch 11/12] Export the interface to get PCI id for an ACPI handle
  2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
                   ` (9 preceding siblings ...)
  2005-03-18 22:18 ` [patch 10/12] Allow ACPI .add and .start operations to be done independently Rajesh Shah
@ 2005-03-18 22:20 ` Rajesh Shah
  2005-03-18 22:22 ` [patch 12/12] ACPI based root bridge hot-add Rajesh Shah
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 22+ messages in thread
From: Rajesh Shah @ 2005-03-18 22:20 UTC (permalink / raw)
  To: gregkh, tony.luck, len.brown
  Cc: linux-pci, linux-kernel, pcihpd-discuss, linux-ia64, acpi-devel

Export an acpi interface to get PCI domain/bus/devfn information
from the corresponding namespace handle. Used by acpiphp code
to transpate the device handle of the hot-plugged root bridge to
the corresponding pci location information.

Signed-off-by: Rajesh Shah <rajesh.shah@intel.com>
---

 linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/pci_bind.c     |   11 +++++------
 linux-2.6.11-mm4-iohp-rshah1/include/acpi/acpi_drivers.h |    1 +
 2 files changed, 6 insertions(+), 6 deletions(-)

diff -puN drivers/acpi/pci_bind.c~acpi-get-pci-id drivers/acpi/pci_bind.c
--- linux-2.6.11-mm4-iohp/drivers/acpi/pci_bind.c~acpi-get-pci-id	2005-03-16 13:07:39.028647689 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/acpi/pci_bind.c	2005-03-16 13:07:39.141928937 -0800
@@ -61,15 +61,14 @@ acpi_pci_data_handler (
 
 
 /**
- * acpi_os_get_pci_id
+ * acpi_get_pci_id
  * ------------------
  * This function is used by the ACPI Interpreter (a.k.a. Core Subsystem)
  * to resolve PCI information for ACPI-PCI devices defined in the namespace.
  * This typically occurs when resolving PCI operation region information.
  */
-#ifdef ACPI_FUTURE_USAGE
 acpi_status
-acpi_os_get_pci_id (
+acpi_get_pci_id (
 	acpi_handle		handle,
 	struct acpi_pci_id	*id)
 {
@@ -78,7 +77,7 @@ acpi_os_get_pci_id (
 	struct acpi_device	*device = NULL;
 	struct acpi_pci_data	*data = NULL;
 
-	ACPI_FUNCTION_TRACE("acpi_os_get_pci_id");
+	ACPI_FUNCTION_TRACE("acpi_get_pci_id");
 
 	if (!id)
 		return_ACPI_STATUS(AE_BAD_PARAMETER);
@@ -92,7 +91,7 @@ acpi_os_get_pci_id (
 	}
 
 	status = acpi_get_data(handle, acpi_pci_data_handler, (void**) &data);
-	if (ACPI_FAILURE(status) || !data || !data->dev) {
+	if (ACPI_FAILURE(status) || !data) {
 		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 
 			"Invalid ACPI-PCI context for device %s\n",
 			acpi_device_bid(device)));
@@ -115,7 +114,7 @@ acpi_os_get_pci_id (
 
 	return_ACPI_STATUS(AE_OK);
 }
-#endif  /*  ACPI_FUTURE_USAGE  */
+EXPORT_SYMBOL(acpi_get_pci_id);
 
 	
 int
diff -puN include/acpi/acpi_drivers.h~acpi-get-pci-id include/acpi/acpi_drivers.h
--- linux-2.6.11-mm4-iohp/include/acpi/acpi_drivers.h~acpi-get-pci-id	2005-03-16 13:07:39.033530501 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/include/acpi/acpi_drivers.h	2005-03-16 13:07:39.142905500 -0800
@@ -68,6 +68,7 @@ void acpi_pci_irq_del_prt (int segment, 
 
 struct pci_bus;
 
+acpi_status acpi_get_pci_id (acpi_handle handle, struct acpi_pci_id *id);
 int acpi_pci_bind (struct acpi_device *device);
 int acpi_pci_unbind (struct acpi_device *device);
 int acpi_pci_bind_root (struct acpi_device *device, struct acpi_pci_id *id, struct pci_bus *bus);
_

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

* [patch 12/12] ACPI based root bridge hot-add
  2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
                   ` (10 preceding siblings ...)
  2005-03-18 22:20 ` [patch 11/12] Export the interface to get PCI id for an ACPI handle Rajesh Shah
@ 2005-03-18 22:22 ` Rajesh Shah
  2005-03-19  5:13 ` [RFC/Patch 0/12] " Greg KH
  2005-03-19 13:50 ` Paul Ionescu
  13 siblings, 0 replies; 22+ messages in thread
From: Rajesh Shah @ 2005-03-18 22:22 UTC (permalink / raw)
  To: gregkh, tony.luck, len.brown
  Cc: linux-pci, linux-kernel, pcihpd-discuss, linux-ia64, acpi-devel

acpiphp changes to support acpi based root bridge hot-add.
This patch applies on top of the acpiphp re-write patch by
Matthew Wilcox at:
http://marc.theaimsgroup.com/?l=linux-ia64&m=110616116714938&w=2

Signed-off-by: Rajesh Shah <rajesh.shah@intel.com>
---

 linux-2.6.11-mm4-iohp-rshah1/drivers/pci/hotplug/acpiphp_glue.c |  211 +++++++++-
 1 files changed, 202 insertions(+), 9 deletions(-)

diff -puN drivers/pci/hotplug/acpiphp_glue.c~acpiphp_h2p_add drivers/pci/hotplug/acpiphp_glue.c
--- linux-2.6.11-mm4-iohp/drivers/pci/hotplug/acpiphp_glue.c~acpiphp_h2p_add	2005-03-16 13:37:08.716126010 -0800
+++ linux-2.6.11-mm4-iohp-rshah1/drivers/pci/hotplug/acpiphp_glue.c	2005-03-16 13:37:08.825501009 -0800
@@ -6,6 +6,8 @@
  * Copyright (C) 2002,2003 NEC Corporation
  * Copyright (C) 2003-2005 Matthew Wilcox (matthew.wilcox@hp.com)
  * Copyright (C) 2003-2005 Hewlett Packard
+ * Copyright (C) 2005 Rajesh Shah (rajesh.shah@intel.com)
+ * Copyright (C) 2005 Intel Corporation
  *
  * All rights reserved.
  *
@@ -304,13 +306,15 @@ static void init_bridge_misc(struct acpi
 				     register_slot, bridge, NULL);
 
 	/* install notify handler */
-	status = acpi_install_notify_handler(bridge->handle,
+	if (bridge->type != BRIDGE_TYPE_HOST) {
+		status = acpi_install_notify_handler(bridge->handle,
 					     ACPI_SYSTEM_NOTIFY,
 					     handle_hotplug_event_bridge,
 					     bridge);
 
-	if (ACPI_FAILURE(status)) {
-		err("failed to register interrupt notify handler\n");
+		if (ACPI_FAILURE(status)) {
+			err("failed to register interrupt notify handler\n");
+		}
 	}
 
 	list_add(&bridge->list, &bridge_list);
@@ -802,6 +806,143 @@ static int acpiphp_check_bridge(struct a
 	return retval;
 }
 
+static void program_hpp(struct pci_dev *dev, struct acpiphp_bridge *bridge)
+{
+	u16 pci_cmd, pci_bctl;
+	struct pci_dev *cdev;
+
+	/* Program hpp values for this device */
+	if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL ||
+			(dev->hdr_type == PCI_HEADER_TYPE_BRIDGE &&
+			(dev->class >> 8) == PCI_CLASS_BRIDGE_PCI)))
+		return;
+	pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE,
+			bridge->hpp.cache_line_size);
+	pci_write_config_byte(dev, PCI_LATENCY_TIMER,
+			bridge->hpp.latency_timer);
+	pci_read_config_word(dev, PCI_COMMAND, &pci_cmd);
+	if (bridge->hpp.enable_SERR)
+		pci_cmd |= PCI_COMMAND_SERR;
+	else
+		pci_cmd &= ~PCI_COMMAND_SERR;
+	if (bridge->hpp.enable_PERR)
+		pci_cmd |= PCI_COMMAND_PARITY;
+	else
+		pci_cmd &= ~PCI_COMMAND_PARITY;
+	pci_write_config_word(dev, PCI_COMMAND, pci_cmd);
+
+	/* Program bridge control value and child devices */
+	if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
+		pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER,
+				bridge->hpp.latency_timer);
+		pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl);
+		if (bridge->hpp.enable_SERR)
+			pci_bctl |= PCI_BRIDGE_CTL_SERR;
+		else
+			pci_bctl &= ~PCI_BRIDGE_CTL_SERR;
+		if (bridge->hpp.enable_PERR)
+			pci_bctl |= PCI_BRIDGE_CTL_PARITY;
+		else
+			pci_bctl &= ~PCI_BRIDGE_CTL_PARITY;
+		pci_write_config_word(dev, PCI_BRIDGE_CONTROL, pci_bctl);
+		if (dev->subordinate) {
+			list_for_each_entry(cdev, &dev->subordinate->devices,
+					bus_list)
+				program_hpp(cdev, bridge);
+		}
+	}
+}
+
+static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus)
+{
+	struct acpiphp_bridge bridge;
+	struct pci_dev *dev;
+
+	memset(&bridge, 0, sizeof(bridge));
+	bridge.handle = handle;
+	decode_hpp(&bridge);
+	list_for_each_entry(dev, &bus->devices, bus_list)
+		program_hpp(dev, &bridge);
+
+}
+
+/*
+ * Remove devices for which we could not assign resources, call
+ * arch specific code to fix-up the bus
+ */
+static void acpiphp_sanitize_bus(struct pci_bus *bus)
+{
+	struct pci_dev *dev;
+	int i;
+	unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM;
+
+	list_for_each_entry(dev, &bus->devices, bus_list) {
+		for (i=0; i<PCI_BRIDGE_RESOURCES; i++) {
+			struct resource *res = &dev->resource[i];
+			if ((res->flags & type_mask) && !res->start &&
+					res->end) {
+				/* Could not assign a required resources
+				 * for this device, remove it */
+				pci_remove_bus_device(dev);
+				break;
+			}
+		}
+	}
+}
+
+/* Program resources in newly inserted bridge */
+static int acpiphp_configure_bridge (acpi_handle handle)
+{
+	struct acpi_pci_id pci_id;
+	struct pci_bus *bus;
+
+	if (ACPI_FAILURE(acpi_get_pci_id(handle, &pci_id))) {
+		err("cannot get PCI domain and bus number for bridge\n");
+		return -EINVAL;
+	}
+	bus = pci_find_bus(pci_id.segment, pci_id.bus);
+	if (!bus) {
+		err("cannot find bus %d:%d\n",
+				pci_id.segment, pci_id.bus);
+		return -EINVAL;
+	}
+
+	pci_bus_size_bridges(bus);
+	pci_bus_assign_resources(bus);
+	acpiphp_sanitize_bus(bus);
+	acpiphp_set_hpp_values(handle, bus);
+	pci_enable_bridges(bus);
+	return 0;
+}
+
+static void handle_bridge_insertion(acpi_handle handle, u32 type)
+{
+	struct acpi_device *device, *pdevice;
+	acpi_handle phandle;
+
+	if ((type != ACPI_NOTIFY_BUS_CHECK) &&
+			(type != ACPI_NOTIFY_DEVICE_CHECK)) {
+		err("unexpected notification type %d\n", type);
+		return;
+	}
+
+	acpi_get_parent(handle, &phandle);
+	if (acpi_bus_get_device(phandle, &pdevice)) {
+		dbg("no parent device, assuming NULL\n");
+		pdevice = NULL;
+	}
+	if (acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE)) {
+		err("cannot add bridge to acpi list\n");
+		return;
+	}
+	if (!acpiphp_configure_bridge(handle) &&
+		!acpi_bus_start(device))
+		add_bridge(handle);
+	else
+		err("cannot configure and start bridge\n");
+
+}
+
 /*
  * ACPI event handlers
  */
@@ -822,8 +963,19 @@ static void handle_hotplug_event_bridge(
 	char objname[64];
 	struct acpi_buffer buffer = { .length = sizeof(objname),
 				      .pointer = objname };
+	struct acpi_device *device;
 
-	bridge = (struct acpiphp_bridge *)context;
+	if (acpi_bus_get_device(handle, &device)) {
+		/* This bridge must have just been physically inserted */
+		handle_bridge_insertion(handle, type);
+		return;
+	}
+
+	bridge = acpiphp_handle_to_bridge(handle);
+	if (!bridge) {
+		err("cannot get bridge info\n");
+		return;
+	}
 
 	acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
 
@@ -923,6 +1075,47 @@ static void handle_hotplug_event_func(ac
 	}
 }
 
+static int is_root_bridge(acpi_handle handle)
+{
+	acpi_status status;
+	struct acpi_device_info *info;
+	struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+	int i;
+
+	status = acpi_get_object_info(handle, &buffer);
+	if (ACPI_SUCCESS(status)) {
+		info = buffer.pointer;
+		if ((info->valid & ACPI_VALID_HID) &&
+			!strcmp(PCI_ROOT_HID_STRING,
+					info->hardware_id.value)) {
+			acpi_os_free(buffer.pointer);
+			return 1;
+		}
+		if (info->valid & ACPI_VALID_CID) {
+			for (i=0; i < info->compatibility_id.count; i++) {
+				if (!strcmp(PCI_ROOT_HID_STRING,
+					info->compatibility_id.id[i].value)) {
+					acpi_os_free(buffer.pointer);
+					return 1;
+				}
+			}
+		}
+	}
+	return 0;
+}
+
+static acpi_status
+find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+	int *count = (int *)context;
+
+	if (is_root_bridge(handle)) {
+		acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
+				handle_hotplug_event_bridge, NULL);
+			(*count)++;
+	}
+	return AE_OK ;
+}
 
 static struct acpi_pci_driver acpi_pci_hp_driver = {
 	.add =		add_bridge,
@@ -935,15 +1128,15 @@ static struct acpi_pci_driver acpi_pci_h
  */
 int __init acpiphp_glue_init(void)
 {
-	int num;
-
-	if (list_empty(&pci_root_buses))
-		return -1;
+	int num = 0;
 
-	num = acpi_pci_register_driver(&acpi_pci_hp_driver);
+	acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+			ACPI_UINT32_MAX, find_root_bridges, &num, NULL);
 
 	if (num <= 0)
 		return -1;
+	else
+		acpi_pci_register_driver(&acpi_pci_hp_driver);
 
 	return 0;
 }
_

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

* Re: [RFC/Patch 0/12] ACPI based root bridge hot-add
  2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
                   ` (11 preceding siblings ...)
  2005-03-18 22:22 ` [patch 12/12] ACPI based root bridge hot-add Rajesh Shah
@ 2005-03-19  5:13 ` Greg KH
  2005-03-21 18:04   ` Rajesh Shah
  2005-03-19 13:50 ` Paul Ionescu
  13 siblings, 1 reply; 22+ messages in thread
From: Greg KH @ 2005-03-19  5:13 UTC (permalink / raw)
  To: Rajesh Shah; +Cc: linux-pci, linux-kernel, pcihpd-discuss

On Fri, Mar 18, 2005 at 01:38:57PM -0800, Rajesh Shah wrote:
> Here is a series of patches to support ACPI hot-add of a root
> bridge hierarchy. The added hierarchy may contain other p2p 
> bridges and end/leaf I/O devices too. The root bridge itself is
> assumed to have been assigned resource ranges, but the p2p
> bridges and end devices are not required to be initialized by
> firmware. Most of the code changes are to make the existing code
> flows suitable for such a hierarchy of bridges & devices.
> 
> This code supports hot-add on ia64 only for now.It does not yet
> support I/O APIC hot-add, which is needed to make this fully
> functional.  The patches are against 2.6.11-mm4 (plus the patch 
> needed for ia64 to boot). I've tested to make sure this does not 
> break end/leaf device hotplug on the hotplug capable ia64 box I have.

This all looks very good, nice job.  I only had one minor comment on the
patches, which I'll reply to directly.

But I did have a few questions:
	- This series relys on Mathew's rewrite of the acpiphp driver.
	  Is that acceptable?  Is that patch necessary for your work?
	  And if so, can you include it in the whole series?
	- Does this break the i386 acpiphp functionality?
	- Have you tested other pci hotplug systems with this patch
	  series?  Like pci express hotplug, standard pci hotplug,
	  cardbus, etc?
	- Are you wanting the acpi specific patches to go into the tree
	  through the acpi developers?  How about the ia64 specific
	  patches?
	- Have the acpi developers agreed with your acpi patches?

thanks,

greg k-h

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

* Re: [patch 07/12] Make the PCI remove routines safe for failed hot-plug
  2005-03-18 22:11 ` [patch 07/12] Make the PCI remove routines safe for failed hot-plug Rajesh Shah
@ 2005-03-19  5:14   ` Greg KH
  0 siblings, 0 replies; 22+ messages in thread
From: Greg KH @ 2005-03-19  5:14 UTC (permalink / raw)
  To: Rajesh Shah
  Cc: tony.luck, len.brown, linux-pci, linux-kernel, pcihpd-discuss,
	linux-ia64, acpi-devel

On Fri, Mar 18, 2005 at 02:11:44PM -0800, Rajesh Shah wrote:
> diff -puN drivers/pci/remove.c~pci-remove-device-hotplug-safe drivers/pci/remove.c
> --- linux-2.6.11-mm4-iohp/drivers/pci/remove.c~pci-remove-device-hotplug-safe	2005-03-16 13:07:22.667319764 -0800
> +++ linux-2.6.11-mm4-iohp-rshah1/drivers/pci/remove.c	2005-03-16 13:07:22.775718200 -0800
> @@ -26,17 +26,21 @@ static void pci_free_resources(struct pc
>  
>  static void pci_destroy_dev(struct pci_dev *dev)
>  {
> -	pci_proc_detach_device(dev);
> -	pci_remove_sysfs_dev_files(dev);
> -	device_unregister(&dev->dev);
> +	if (!list_empty(&dev->global_list)) {
> +		pci_proc_detach_device(dev);
> +		pci_remove_sysfs_dev_files(dev);
> +		device_unregister(&dev->dev);
> +		spin_lock(&pci_bus_lock);
> +		list_del(&dev->global_list);
> +		dev->global_list.next = dev->global_list.prev = NULL;
> +		spin_unlock(&pci_bus_lock);
> +	}
>  
>  	/* Remove the device from the device lists, and prevent any further
>  	 * list accesses from this device */
>  	spin_lock(&pci_bus_lock);
>  	list_del(&dev->bus_list);
> -	list_del(&dev->global_list);
>  	dev->bus_list.next = dev->bus_list.prev = NULL;
> -	dev->global_list.next = dev->global_list.prev = NULL;
>  	spin_unlock(&pci_bus_lock);
>  
>  	pci_free_resources(dev);

I did have a comment about this code at first glance, but in reviewing
it again, nevermind, it looks fine...

thanks,

greg k-h

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

* Re: [RFC/Patch 0/12] ACPI based root bridge hot-add
  2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
                   ` (12 preceding siblings ...)
  2005-03-19  5:13 ` [RFC/Patch 0/12] " Greg KH
@ 2005-03-19 13:50 ` Paul Ionescu
  2005-03-21 19:14   ` [ACPI] " Rajesh Shah
  13 siblings, 1 reply; 22+ messages in thread
From: Paul Ionescu @ 2005-03-19 13:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: acpi-devel

On Fri, 18 Mar 2005 13:38:57 -0800, Rajesh Shah wrote:

> Here is a series of patches to support ACPI hot-add of a root bridge
> hierarchy. The added hierarchy may contain other p2p bridges and end/leaf
> I/O devices too. The root bridge itself is assumed to have been assigned
> resource ranges, but the p2p bridges and end devices are not required to
> be initialized by firmware. Most of the code changes are to make the
> existing code flows suitable for such a hierarchy of bridges & devices.
> 
> This code supports hot-add on ia64 only for now.It does not yet support
> I/O APIC hot-add, which is needed to make this fully functional.  The
> patches are against 2.6.11-mm4 (plus the patch needed for ia64 to boot).
> I've tested to make sure this does not break end/leaf device hotplug on
> the hotplug capable ia64 box I have.
> 
> Thanks,
> Rajesh

Does this mean that when it will be ported for i386, I will be able to
really use my Docking Station ?
Does it rescan the DSDT to find new additions to ACPI devices ?

I have an IBM docking station with a PCI bus inside and some other
devices, and when I hot plug my IBM ThinkPad T41 in it, it does not
recognize those devices. Only if I boot in dock they are usable.
And the DSDT is different if I boot in dock or not.
So I wander if this patch would help me to hot plug my T41 in the dock and
all devices will be recognized. (when the patch will be for i386 too)


Thx,
Paul


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

* Re: [RFC/Patch 0/12] ACPI based root bridge hot-add
  2005-03-19  5:13 ` [RFC/Patch 0/12] " Greg KH
@ 2005-03-21 18:04   ` Rajesh Shah
  2005-03-21 18:27     ` Greg KH
  0 siblings, 1 reply; 22+ messages in thread
From: Rajesh Shah @ 2005-03-21 18:04 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-pci, linux-kernel, pcihpd-discuss, akpm, len.brown,
	tony.luck, dely.l.sy

On Fri, Mar 18, 2005 at 09:13:32PM -0800, Greg KH wrote:
> 
> This all looks very good, nice job.  I only had one minor comment on the
> patches, which I'll reply to directly.
> 
> But I did have a few questions:
> 	- This series relys on Mathew's rewrite of the acpiphp driver.
> 	  Is that acceptable?  Is that patch necessary for your work?
> 	  And if so, can you include it in the whole series?

The last patch (12) in the series is the only one that depends on
Matthew's acpiphp rewrite.  I do have a really old version of my
patch that worked with the original acpiphp code base but this
version is cleaner. I could probably resurrect my old patch if you
want, but I'd rather prefer to work on and fix any other objections
you or others may have with Matthew's re-write, since that's the 
better overall approach.

> 	- Does this break the i386 acpiphp functionality?

Dely Sy had tested hotplug with an earlier version of my patches
(with minor differences from the current series) on i386 and it
worked fine. She probably hasn't tested the latest one. Dely,
could you check that please? The i386 hotplug capable box I
have doesn't seem to have the right firmware, so I haven't 
been able to test hotplug on that (I'm working on fixing that).
Of course, I tested my patches on i386 (ACPI as well as non-ACPI)
and x86_64 machines to make sure I didn't break boot on those.


> 	- Have you tested other pci hotplug systems with this patch
> 	  series?  Like pci express hotplug, standard pci hotplug,
> 	  cardbus, etc?

No, because I the one system I have access to isn't doing any
hot-plug. I'm working on fixing that but was also hoping to hear
from others who surely have access to more machines than I do.

> 	- Are you wanting the acpi specific patches to go into the tree
> 	  through the acpi developers?  How about the ia64 specific
> 	  patches?

I honestly don't know what the best approach is here - what do you
recommend? I did receive an email from Andrew indicating he wants
to pick these up for the next mm. Perhaps the best thing is to
let Andrew include the whole series after I've addressed all
feedback and you, Tony, Len etc. all agree these are OK to go in.

> 	- Have the acpi developers agreed with your acpi patches?
> 
This is the first time I sent the patches to the acpi list, so I do
need to give them a few days to weigh in. 

Rajesh


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

* Re: [RFC/Patch 0/12] ACPI based root bridge hot-add
  2005-03-21 18:04   ` Rajesh Shah
@ 2005-03-21 18:27     ` Greg KH
  2005-03-31 19:06       ` Len Brown
  0 siblings, 1 reply; 22+ messages in thread
From: Greg KH @ 2005-03-21 18:27 UTC (permalink / raw)
  To: Rajesh Shah
  Cc: linux-pci, linux-kernel, pcihpd-discuss, akpm, len.brown,
	tony.luck, dely.l.sy

On Mon, Mar 21, 2005 at 10:04:57AM -0800, Rajesh Shah wrote:
> > 	- Are you wanting the acpi specific patches to go into the tree
> > 	  through the acpi developers?  How about the ia64 specific
> > 	  patches?
> 
> I honestly don't know what the best approach is here - what do you
> recommend? I did receive an email from Andrew indicating he wants
> to pick these up for the next mm. Perhaps the best thing is to
> let Andrew include the whole series after I've addressed all
> feedback and you, Tony, Len etc. all agree these are OK to go in.

That sounds like a fine plan to me.

thanks,

greg k-h

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

* Re: [ACPI] Re: [RFC/Patch 0/12] ACPI based root bridge hot-add
  2005-03-19 13:50 ` Paul Ionescu
@ 2005-03-21 19:14   ` Rajesh Shah
  0 siblings, 0 replies; 22+ messages in thread
From: Rajesh Shah @ 2005-03-21 19:14 UTC (permalink / raw)
  To: Paul Ionescu; +Cc: acpi-devel, linux-kernel

On Sat, Mar 19, 2005 at 03:50:16PM +0200, Paul Ionescu wrote:
> 
> Does this mean that when it will be ported for i386, I will be able to
> really use my Docking Station ?

No. The current patches only trigger when a _root_ bridge is
hot-added, not a PCI to PCI bridge (which is what the docking 
station is). The code to support p2p bridge hotplug will benefit
from these patches but more code is needed to support that.

> Does it rescan the DSDT to find new additions to ACPI devices ?
> 
It scans the ACPI namespace under the root bridge that was added.
Any pci devices underneath are scanned and added, but there isn't
any code to look for non-PCI devices there.

Rajesh

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

* RE: [RFC/Patch 0/12] ACPI based root bridge hot-add
@ 2005-03-22  1:06 Sy, Dely L
  0 siblings, 0 replies; 22+ messages in thread
From: Sy, Dely L @ 2005-03-22  1:06 UTC (permalink / raw)
  To: Shah, Rajesh, Greg KH
  Cc: linux-pci, linux-kernel, pcihpd-discuss, akpm, Brown, Len,
	Luck, Tony

On Monday, March 21, 2005 10:05 AM, Rajesh Shah wrote:
> On Fri, Mar 18, 2005 at 09:13:32PM -0800, Greg KH wrote:
> > 	- Does this break the i386 acpiphp functionality?

> Dely Sy had tested hotplug with an earlier version of my patches
> (with minor differences from the current series) on i386 and it
> worked fine. She probably hasn't tested the latest one. Dely,
> could you check that please? 

I tested an earlier version of this patch on my i386 system with
PCI Express hot-plug slots.  The i386 acpiphp functionality worked
fine - i.e. I was able to do hot-plug of single- & multi-function 
cards.  

I'll check this new patch on my system.

> > 	- Have you tested other pci hotplug systems with this patch
> > 	  series?  Like pci express hotplug, standard pci hotplug,
> > 	  cardbus, etc?

> No, because I the one system I have access to isn't doing any
> hot-plug. I'm working on fixing that but was also hoping to hear
> from others who surely have access to more machines than I do.

PCI Express hot-plug has been tried (see above).  The original 
acpiphp driver won't detect hot-pluggable slots that locate on the
p2p bridge (PCI Express to PCI/PCI-X bridge) behind another p2p 
bridge (root port).  Therefore, the acpiphp can't be used for
standard PCI hot-plug in my system.

Thanks,
Dely

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

* RE: [RFC/Patch 0/12] ACPI based root bridge hot-add
@ 2005-03-23  3:13 Dely Sy
  0 siblings, 0 replies; 22+ messages in thread
From: Dely Sy @ 2005-03-23  3:13 UTC (permalink / raw)
  To: gregkh, rajesh.shah
  Cc: akpm, dely.l.sy, len.brown, linux-kernel, linux-pci,
	pcihpd-discuss, tony.luck

On Monday, March 21, 2005 5:07 PM, Dely Sy wrote:
> On Monday, March 21, 2005 10:05 AM, Rajesh Shah wrote:
> > On Fri, Mar 18, 2005 at 09:13:32PM -0800, Greg KH wrote:
> > > 	- Does this break the i386 acpiphp functionality?

> > Dely Sy had tested hotplug with an earlier version of my patches
> > (with minor differences from the current series) on i386 and it
> > worked fine. She probably hasn't tested the latest one. Dely,
> > could you check that please? 

> I tested an earlier version of this patch on my i386 system with
> PCI Express hot-plug slots.  The i386 acpiphp functionality worked
> fine - i.e. I was able to do hot-plug of single- & multi-function 
> cards.  

> I'll check this new patch on my system.

Earlier I reported that Matthew's acpiphp rewrite had problem in 
powering down slot on my i386 system.  The following patch is 
needed to get the acpiphp rewrite properly powering down the slot.
A similar patch was sent out to Matthew for comment and Rajesh 
had tested the patch on Tiger4.

I just did a test of Rajesh's latest patch on 2.6.11.5 with
Wilcox's acpiphp rewrite and the following patch.  Hot-plug of 
PCI Express card worked fine on my i386 system
 
Thanks,
Dely

Signed-off-by: Dely Sy <dely.l.sy@intel.com>

diff -urpN linux-2.6.11.5rbha/drivers/pci/hotplug/acpiphp_glue.c linux-2.6.11.5rbhatst/drivers/pci/hotplug/acpiphp_glue.c
--- linux-2.6.11.5rbha/drivers/pci/hotplug/acpiphp_glue.c	2005-03-22 00:56:04.000000000 -0800
+++ linux-2.6.11.5rbhatst/drivers/pci/hotplug/acpiphp_glue.c	2005-03-22 23:21:23.000000000 -0800
@@ -586,7 +586,7 @@ static int power_off_slot(struct acpiphp
 	list_for_each (l, &slot->funcs) {
 		func = list_entry(l, struct acpiphp_func, sibling);
 
-		if (func->pci_dev && (func->flags & FUNC_HAS_PS3)) {
+		if (func->flags & FUNC_HAS_PS3) {
 			status = acpi_evaluate_object(func->handle, "_PS3", NULL, NULL);
 			if (ACPI_FAILURE(status)) {
 				warn("%s: _PS3 failed\n", __FUNCTION__);
@@ -601,7 +601,7 @@ static int power_off_slot(struct acpiphp
 		func = list_entry(l, struct acpiphp_func, sibling);
 
 		/* We don't want to call _EJ0 on non-existing functions. */
-		if (func->pci_dev && (func->flags & FUNC_HAS_EJ0)) {
+		if (func->flags & FUNC_HAS_EJ0) {
 			/* _EJ0 method take one argument */
 			arg_list.count = 1;
 			arg_list.pointer = &arg;

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

* Re: [RFC/Patch 0/12] ACPI based root bridge hot-add
  2005-03-21 18:27     ` Greg KH
@ 2005-03-31 19:06       ` Len Brown
  0 siblings, 0 replies; 22+ messages in thread
From: Len Brown @ 2005-03-31 19:06 UTC (permalink / raw)
  To: Greg KH
  Cc: Shah, Rajesh, linux-pci@atrey.karlin.mff.cuni.cz, linux-kernel,
	pcihpd-discuss, Andrew Morton, Tony Luck, Sy, Dely L

On Mon, 2005-03-21 at 13:27, Greg KH wrote:
> On Mon, Mar 21, 2005 at 10:04:57AM -0800, Rajesh Shah wrote:
> > >     - Are you wanting the acpi specific patches to go into the
> tree
> > >       through the acpi developers?  How about the ia64 specific
> > >       patches?
> >
> > I honestly don't know what the best approach is here - what do you
> > recommend? I did receive an email from Andrew indicating he wants
> > to pick these up for the next mm. Perhaps the best thing is to
> > let Andrew include the whole series after I've addressed all
> > feedback and you, Tony, Len etc. all agree these are OK to go in.
> 
> That sounds like a fine plan to me.

Me too.

And I don't see any issues with the ACPI specific changes.

cheers,
-Len



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

end of thread, other threads:[~2005-03-31 19:07 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-18 21:38 [RFC/Patch 0/12] ACPI based root bridge hot-add Rajesh Shah
2005-03-18 21:48 ` [Patch 1/12] " Rajesh Shah
2005-03-18 21:59 ` [Patch 2/12] Fix pci_enable_device() for p2p bridges Rajesh Shah
2005-03-18 22:02 ` [patch 03/12] Make pcibios_fixup_bus() hot-plug safe Rajesh Shah
2005-03-18 22:04 ` [patch 04/12] Prevent duplicate bus numbers when scanning PCI bridge Rajesh Shah
2005-03-18 22:07 ` [patch 05/12] Take the PCI lock when modifying pci bus or device lists Rajesh Shah
2005-03-18 22:09 ` [patch 06/12] Link newly created pci child bus to its parent on creation Rajesh Shah
2005-03-18 22:11 ` [patch 07/12] Make the PCI remove routines safe for failed hot-plug Rajesh Shah
2005-03-19  5:14   ` Greg KH
2005-03-18 22:14 ` [patch 08/12] Remove hot-plugged devices that could not be allocated resources Rajesh Shah
2005-03-18 22:16 ` [patch 09/12] Read bridge resources when fixing up the bus Rajesh Shah
2005-03-18 22:18 ` [patch 10/12] Allow ACPI .add and .start operations to be done independently Rajesh Shah
2005-03-18 22:20 ` [patch 11/12] Export the interface to get PCI id for an ACPI handle Rajesh Shah
2005-03-18 22:22 ` [patch 12/12] ACPI based root bridge hot-add Rajesh Shah
2005-03-19  5:13 ` [RFC/Patch 0/12] " Greg KH
2005-03-21 18:04   ` Rajesh Shah
2005-03-21 18:27     ` Greg KH
2005-03-31 19:06       ` Len Brown
2005-03-19 13:50 ` Paul Ionescu
2005-03-21 19:14   ` [ACPI] " Rajesh Shah
  -- strict thread matches above, loose matches on Subject: below --
2005-03-22  1:06 Sy, Dely L
2005-03-23  3:13 Dely Sy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox