Skip to contentSkip to conversation

Convert acpiphp to use generic resource code

PATCH Rajesh Shah 2 participants 4 messages Jan 20, 2005 – Feb 3, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Quoted 6 lines · Matthew Wilcox

This patch converts acpiphp to use the generic PCI resource assignment code. It's quite large, but most of it is deleting the acpiphp_pci and acpiphp_res files. It's tested on an hp Integrity rx8620 (which won't work without this patch). Testers with other hardware welcomed.

I've been playing around in this area too, working on root bridge hot-plug. I like these changes very much, and will move my patches on top of yours.

One nit - this patch does not program hpp values into hotplugged devices. This is easy to fix, since you already have the values as part of the bridge structure.

Rajesh

#1 lore raw
Quoted 6 lines

This patch converts acpiphp to use the generic PCI resource assignment code. It's quite large, but most of it is deleting the acpiphp_pci and acpiphp_res files. It's tested on an hp Integrity rx8620 (which won't work without this patch). Testers with other hardware welcomed.

If you're testing on ia64, you'll probably need two other patches as

well:

Quoted 4 lines

http://marc.theaimsgroup.com/?l=linux-ia64&m0614534704894&w=2

and this one (already sent to Greg):

Hi,
Should we make the count of pci_bus's resource dynamically? Root bridge's BAR isn't standard, I'm afraid ACPI will report more than 'PCI_BUS_NUM_RESOURCES' BARs.

Thanks,
Shaohua

#2 lore raw
In reply to Rajesh Shah
Quoted 4 lines · Matthew Wilcox

static void remove_bridge(acpi_handle handle)
{

(quoted diff) +0 -1
-	/* No-op for now .. */

Review

Quoted 10 lines
(quoted diff) +10 -0
+	struct list_head *list, *tmp;
+	struct acpiphp_bridge *bridge;
+	struct acpiphp_slot *slot;
+	acpi_status status;
+
+	bridge = acpiphp_handle_to_bridge(handle);
+	if (!bridge) {
+		err("Could not find bridge for handle %p\n", handle);
+		return;
+	}

A root bridge may not have directly attached hotpluggable slots under it. Instead, it may have p2p bridges with slots under it. In this case, we need to clean up the p2p bridges and slots properly too. Patch below applies on top of the original patch, and fixes this problem. Without this, acpiphp leaves behind notify handlers on module unload, and subsequent module load attempts don't work properly too. Patch was tested on an ia64 Tiger4 box.

---

 linux-2.6.11-rc1-mm2-t2-rshah1/drivers/pci/hotplug/acpiphp_glue.c |   34 +++++++---
 1 files changed, 26 insertions(+), 8 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c renamed from drivers/pci/hotplug/acpiphp_glue.c~unload_cleanup +26 -8
diff -puN drivers/pci/hotplug/acpiphp_glue.c~unload_cleanup drivers/pci/hotplug/acpiphp_glue.c
@@ -486,18 +486,12 @@ static struct acpiphp_bridge *acpiphp_ha
 	return NULL;
 }
 
-static void remove_bridge(acpi_handle handle)
+static void cleanup_bridge(struct acpiphp_bridge *bridge)
 {
 	struct list_head *list, *tmp;
-	struct acpiphp_bridge *bridge;
 	struct acpiphp_slot *slot;
 	acpi_status status;
-
-	bridge = acpiphp_handle_to_bridge(handle);
-	if (!bridge) {
-		err("Could not find bridge for handle %p\n", handle);
-		return;
-	}
+	acpi_handle handle = bridge->handle;
 
 	status = acpi_remove_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
 					    handle_hotplug_event_bridge);
@@ -528,6 +522,30 @@ static void remove_bridge(acpi_handle ha
 	kfree(bridge);
 }
 
+static acpi_status
+cleanup_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+	struct acpiphp_bridge *bridge;
+
+	if (!(bridge = acpiphp_handle_to_bridge(handle)))
+		return AE_OK;
+	cleanup_bridge(bridge);
+	return AE_OK;
+}
+
+static void remove_bridge(acpi_handle handle)
+{
+	struct acpiphp_bridge *bridge;
+
+	bridge = acpiphp_handle_to_bridge(handle);
+	if (bridge) {
+		cleanup_bridge(bridge);
+	} else {
+		/* clean-up p2p bridges under this host bridge */
+		acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
+				(u32)1, cleanup_p2p_bridge, NULL, NULL);
+	}
+}
 
 static int power_on_slot(struct acpiphp_slot *slot)
 {

_

#3 lore raw
In reply to Rajesh Shah
Quoted 6 lines · Matthew Wilcox

This patch converts acpiphp to use the generic PCI resource assignment code. It's quite large, but most of it is deleting the acpiphp_pci and acpiphp_res files. It's tested on an hp Integrity rx8620 (which won't work without this patch). Testers with other hardware welcomed.

I needed the additional patch below to make it work on Tiger4 ia64 systems. I noticed that a similar patch was submitted before
(http://marc.theaimsgroup.com/?l=linux-ia64&m7962911317596&w=2)
but don't know why it was not picked up.

---

 linux-2.6.11-rc1-mm2-t2-rshah1/arch/ia64/pci/pci.c |    1 +
 1 files changed, 1 insertion(+)
arch/ia64/pci/pci.c renamed from arch/ia64/pci/pci.c~track_bridge_resources +1 -0
diff -puN arch/ia64/pci/pci.c~track_bridge_resources arch/ia64/pci/pci.c
@@ -437,6 +437,7 @@ pcibios_fixup_bus (struct pci_bus *b)
 
 	list_for_each_entry(dev, &b->devices, bus_list)
 		pcibios_fixup_device_resources(dev);
+	pci_read_bridge_bases(b);
 
 	return;
 }

_