Skip to contentSkip to conversation

PCI and PCI Hotplug fixes for 2.6.5-rc1

PATCH New Greg KH 1 participant 8 messages Mar 19, 2004

Subsystems (5)
lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 PCI and PCI Hotplug fixes for 2.6.5-rc1

Hi,

Here are some PCI and PCI hotplug patches for 2.6.5-rc1. These are all bugfixes of one sort or another and the majority of them have been in the past few -mm releases.

Please pull from:

	bk://kernel.bkbits.net/gregkh/linux/pci-2.6

thanks,

greg k-h

p.s. I'll send these as patches in response to this email to lkml for those who want to see them.

 arch/ia64/pci/pci.c                 |   62 +
 drivers/pci/hotplug/Makefile        |    4 
 drivers/pci/hotplug/acpiphp.h       |    2 
 drivers/pci/hotplug/acpiphp_glue.c  |   27 
 drivers/pci/hotplug/acpiphp_pci.c   |   20 
 drivers/pci/hotplug/acpiphp_res.c   |    2 
 drivers/pci/hotplug/pciehp_pci.c    |    2 
 drivers/pci/hotplug/pciehprm_acpi.c |    3 
 drivers/pci/hotplug/rpadlpar_core.c |  186 ++-
 drivers/pci/hotplug/rpaphp.h        |   90 +
 drivers/pci/hotplug/rpaphp_core.c   | 1706 ++++++++----------------------------
 drivers/pci/hotplug/rpaphp_pci.c    |  357 +++++++
 drivers/pci/hotplug/rpaphp_slot.c   |  188 +++
 drivers/pci/hotplug/rpaphp_vio.c    |  121 ++
 drivers/pci/hotplug/shpchp_pci.c    |    2 
 drivers/pci/setup-res.c             |    9 
 kernel/resource.c                   |    1 
 17 files changed, 1319 insertions(+), 1463 deletions(-)

-----

<lxiep:ltcfwd.linux.ibm.com>:
o PCI Hotplug: rpaphp/rpadlpar latest (support for vio and multifunction devices )

Andreas Schwab:
o PCI Hotplug: Fix PCIE and SHPC hotplug drivers for ia64

Greg Kroah-Hartman:
o PCI Hotplug: fix compiler warning in acpiphp driver

Matthew Wilcox:
o PCI: claim PCI resources on ia64
o PCI: Use insert_resource in pci_claim_resource
o PCI: insert_resource can succeed and return an error

Takayoshi Kochi:
o PCI Hotlug: fix acpiphp unable to power off slots

author
#1 lore raw

PATCH 1/1 PCI and PCI Hotplug fixes for 2.6.5-rc1

ChangeSet 1.1608.97.1, 2004/03/10 14:22:31-08:00, [email protected]

[PATCH] PCI Hotplug: Fix PCIE and SHPC hotplug drivers for ia64

This patch fixes the PCIE and SHPC hotplug driver for ia64. The function pcibios_set_irq_routing only exists on x86, and acpi_bridges_head may be NULL, so don't crash.

Andreas.

 drivers/pci/hotplug/pciehp_pci.c    |    2 +-
 drivers/pci/hotplug/pciehprm_acpi.c |    3 ++-
 drivers/pci/hotplug/shpchp_pci.c    |    2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)
drivers/pci/hotplug/pciehp_pci.c +1 -1
diff -Nru a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
@@ -103,7 +103,7 @@
  */
 int pciehp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num)
 {
-#if !defined(CONFIG_X86_IO_APIC) && !defined(CONFIG_X86_64)
+#if defined(CONFIG_X86) && !defined(CONFIG_X86_IO_APIC) && !defined(CONFIG_X86_64)
 	int rc;
 	u16 temp_word;
 	struct pci_dev fakedev;
drivers/pci/hotplug/pciehprm_acpi.c +2 -1
diff -Nru a/drivers/pci/hotplug/pciehprm_acpi.c b/drivers/pci/hotplug/pciehprm_acpi.c
@@ -1268,7 +1268,8 @@
 int pciehprm_print_pirt(void)
 {
 	dbg("PCIEHPRM ACPI Slots\n");
-	print_acpi_resources (acpi_bridges_head);
+	if (acpi_bridges_head)
+		print_acpi_resources (acpi_bridges_head);
 
 	return 0;
 }
drivers/pci/hotplug/shpchp_pci.c +1 -1
diff -Nru a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c
@@ -101,7 +101,7 @@
  */
 int shpchp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num)
 {
-#if !defined(CONFIG_X86_IO_APIC) && !defined(CONFIG_X86_64)
+#if defined(CONFIG_X86) && !defined(CONFIG_X86_IO_APIC) && !defined(CONFIG_X86_64)
 	int rc;
 	u16 temp_word;
 	struct pci_dev fakedev;
author
#2 lore raw

ChangeSet 1.1608.97.2, 2004/03/10 14:22:59-08:00, [email protected]

[PATCH] PCI Hotlug: fix acpiphp unable to power off slots

Attached patch includes the I/O space fix and applies to 2.6.3. This should also solve the problem Maeda-san reported in January (sorry for replying so late!)

Here are changes in the patch:

- fix the acpiphp driver not powering down a PCI card (from Gary Hade)
- fix I/O space size calculation and ISA aliasing (from Gary Hade)
- fix some debug messages
- only execute ACPI methods on the first existing function

 drivers/pci/hotplug/acpiphp.h      |    2 +-
 drivers/pci/hotplug/acpiphp_glue.c |   27 +++++++++++----------------
 drivers/pci/hotplug/acpiphp_pci.c  |   19 ++++++++-----------
 drivers/pci/hotplug/acpiphp_res.c  |    2 +-
 4 files changed, 21 insertions(+), 29 deletions(-)
drivers/pci/hotplug/acpiphp.h +1 -1
diff -Nru a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
@@ -235,7 +235,7 @@
 extern struct pci_dev *acpiphp_allocate_pcidev (struct pci_bus *pbus, int dev, int fn);
 extern int acpiphp_configure_slot (struct acpiphp_slot *slot);
 extern int acpiphp_configure_function (struct acpiphp_func *func);
-extern int acpiphp_unconfigure_function (struct acpiphp_func *func);
+extern void acpiphp_unconfigure_function (struct acpiphp_func *func);
 extern int acpiphp_detect_pci_resource (struct acpiphp_bridge *bridge);
 extern int acpiphp_init_func_resource (struct acpiphp_func *func);
 
drivers/pci/hotplug/acpiphp_glue.c +11 -16
diff -Nru a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
@@ -694,14 +694,14 @@
 		func = list_entry(l, struct acpiphp_func, sibling);
 
 		if (func->flags & FUNC_HAS_PS0) {
-			dbg("%s: executing _PS0 on %s\n", __FUNCTION__,
-			    pci_name(func->pci_dev));
+			dbg("%s: executing _PS0\n", __FUNCTION__);
 			status = acpi_evaluate_object(func->handle, "_PS0", NULL, NULL);
 			if (ACPI_FAILURE(status)) {
 				warn("%s: _PS0 failed\n", __FUNCTION__);
 				retval = -1;
 				goto err_exit;
-			}
+			} else
+				break;
 		}
 	}
 
@@ -737,7 +737,8 @@
 				warn("%s: _PS3 failed\n", __FUNCTION__);
 				retval = -1;
 				goto err_exit;
-			}
+			} else
+				break;
 		}
 	}
 
@@ -757,7 +758,8 @@
 				warn("%s: _EJ0 failed\n", __FUNCTION__);
 				retval = -1;
 				goto err_exit;
-			}
+			} else
+				break;
 		}
 	}
 
@@ -865,15 +867,8 @@
 	list_for_each (l, &slot->funcs) {
 		func = list_entry(l, struct acpiphp_func, sibling);
 
-		if (func->pci_dev) {
-			if (acpiphp_unconfigure_function(func) == 0) {
-				func->pci_dev = NULL;
-			} else {
-				err("failed to unconfigure device\n");
-				retval = -1;
-				goto err_exit;
-			}
-		}
+		if (func->pci_dev)
+			acpiphp_unconfigure_function(func);
 	}
 
 	slot->flags &= (~SLOT_ENABLED);
@@ -1269,7 +1264,7 @@
 					up(&slot->crit_sect);
 					goto err_exit;
 				}
-				enabled++;
+				disabled++;
 			}
 		} else {
 			/* if disabled but present, enable */
@@ -1280,7 +1275,7 @@
 					up(&slot->crit_sect);
 					goto err_exit;
 				}
-				disabled++;
+				enabled++;
 			}
 		}
 	}
drivers/pci/hotplug/acpiphp_pci.c +8 -11
diff -Nru a/drivers/pci/hotplug/acpiphp_pci.c b/drivers/pci/hotplug/acpiphp_pci.c
@@ -83,8 +83,8 @@
 		if (bar & PCI_BASE_ADDRESS_SPACE_IO) {
 			/* This is IO */
 
-			len = bar & 0xFFFFFFFC;
-			len = ~len + 1;
+			len = bar & (PCI_BASE_ADDRESS_IO_MASK & 0xFFFF);
+			len = len & ~(len - 1);
 
 			dbg("len in IO %x, BAR %d\n", len, count);
 
@@ -226,8 +226,8 @@
 		if (len & PCI_BASE_ADDRESS_SPACE_IO) {
 			/* This is IO */
 			base = bar & 0xFFFFFFFC;
-			len &= 0xFFFFFFFC;
-			len = ~len + 1;
+			len = len & (PCI_BASE_ADDRESS_IO_MASK & 0xFFFF);
+			len = len & ~(len - 1);
 
 			dbg("BAR[%d] %08x - %08x (IO)\n", count, (u32)base, (u32)base + len - 1);
 
@@ -351,8 +351,8 @@
 		if (len & PCI_BASE_ADDRESS_SPACE_IO) {
 			/* This is IO */
 			base = bar & 0xFFFFFFFC;
-			len &= 0xFFFFFFFC;
-			len = ~len + 1;
+			len = len & (PCI_BASE_ADDRESS_IO_MASK & 0xFFFF);
+			len = len & ~(len - 1);
 
 			dbg("BAR[%d] %08x - %08x (IO)\n", count, (u32)base, (u32)base + len - 1);
 
@@ -485,14 +485,14 @@
  * @func: function to be unconfigured
  *
  */
-int acpiphp_unconfigure_function (struct acpiphp_func *func)
+void acpiphp_unconfigure_function (struct acpiphp_func *func)
 {
 	struct acpiphp_bridge *bridge;
 	int retval = 0;
 
 	/* if pci_dev is NULL, ignore it */
 	if (!func->pci_dev)
-		goto err_exit;
+		return;
 
 	pci_remove_bus_device(func->pci_dev);
 
@@ -505,7 +505,4 @@
 	acpiphp_move_resource(&func->p_mem_head, &bridge->p_mem_head);
 	acpiphp_move_resource(&func->bus_head, &bridge->bus_head);
 	spin_unlock(&bridge->res_lock);
-
- err_exit:
-	return retval;
 }
drivers/pci/hotplug/acpiphp_res.c +1 -1
diff -Nru a/drivers/pci/hotplug/acpiphp_res.c b/drivers/pci/hotplug/acpiphp_res.c
@@ -224,7 +224,7 @@
 		}  /* End of too big on top end */
 
 		/* For IO make sure it's not in the ISA aliasing space */
-		if (node->base & 0x300L)
+		if ((node->base & 0x300L) && !(node->base & 0xfffff000))
 			continue;
 
 		/* If we got here, then it is the right size
author
#3 lore raw

ChangeSet 1.1608.97.3, 2004/03/10 14:23:19-08:00, [email protected]

[PATCH] PCI Hotplug: rpaphp/rpadlpar latest (support for vio and multifunction devices )

 drivers/pci/hotplug/Makefile        |    4 
 drivers/pci/hotplug/rpadlpar_core.c |  186 +++++--
 drivers/pci/hotplug/rpaphp.h        |   90 ++-
 drivers/pci/hotplug/rpaphp_core.c   |  853 ++++++++----------------------------
 drivers/pci/hotplug/rpaphp_pci.c    |  357 ++++++++++++++-
 drivers/pci/hotplug/rpaphp_slot.c   |  188 +++++++
 drivers/pci/hotplug/rpaphp_vio.c    |  121 +++++
 7 files changed, 1038 insertions(+), 761 deletions(-)
drivers/pci/hotplug/Makefile +3 -1
diff -Nru a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile
@@ -40,7 +40,9 @@
 				acpiphp_res.o
 
 rpaphp-objs		:=	rpaphp_core.o	\
-				rpaphp_pci.o	
+				rpaphp_pci.o	\
+				rpaphp_slot.o	\
+				rpaphp_vio.o
 
 rpadlpar_io-objs	:=	rpadlpar_core.o \
 				rpadlpar_sysfs.o
drivers/pci/hotplug/rpadlpar_core.c +132 -54

291 lines not on this page · raw message

drivers/pci/hotplug/rpaphp.h +61 -29

124 lines not on this page · raw message

drivers/pci/hotplug/rpaphp_core.c +193 -660

1,070 lines not on this page · raw message

drivers/pci/hotplug/rpaphp_pci.c +340 -17

385 lines not on this page · raw message

drivers/pci/hotplug/rpaphp_slot.c new file +188 -0

188 lines not on this page · raw message

drivers/pci/hotplug/rpaphp_vio.c new file +121 -0

121 lines not on this page · raw message

author
#4 lore raw

ChangeSet 1.1608.97.4, 2004/03/10 14:23:37-08:00, [email protected]

[PATCH] PCI Hotplug: fix compiler warning in acpiphp driver

 drivers/pci/hotplug/acpiphp_pci.c |    1 -
 1 files changed, 1 deletion(-)
drivers/pci/hotplug/acpiphp_pci.c +0 -1
diff -Nru a/drivers/pci/hotplug/acpiphp_pci.c b/drivers/pci/hotplug/acpiphp_pci.c
@@ -488,7 +488,6 @@
 void acpiphp_unconfigure_function (struct acpiphp_func *func)
 {
 	struct acpiphp_bridge *bridge;
-	int retval = 0;
 
 	/* if pci_dev is NULL, ignore it */
 	if (!func->pci_dev)
author
#5 lore raw

ChangeSet 1.1608.97.5, 2004/03/19 14:07:09-08:00, [email protected]

[PATCH] PCI: insert_resource can succeed and return an error

If we start again, we can return an error even if we were successful. Reset the result to 0 before beginning again. Why don't we use a tailcall here?

 kernel/resource.c |    1 +
 1 files changed, 1 insertion(+)
kernel/resource.c +1 -0
diff -Nru a/kernel/resource.c b/kernel/resource.c
@@ -335,6 +335,7 @@
 	/* existing resource overlaps end of new resource */
 	if (next->end > new->end) {
 		parent = next;
+		result = 0;
 		goto begin;
 	}
 
author
#6 lore raw

ChangeSet 1.1608.97.6, 2004/03/19 14:08:16-08:00, [email protected]

[PATCH] PCI: Use insert_resource in pci_claim_resource

On ia64, the parent resources are not necessarily PCI resources and so won't get found by pci_find_parent_resource. Use the shiny new insert_resource() function instead, which I think we would have used here had it been available at the time.

 drivers/pci/setup-res.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
drivers/pci/setup-res.c +7 -2
diff -Nru a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
@@ -94,13 +94,18 @@
 pci_claim_resource(struct pci_dev *dev, int resource)
 {
 	struct resource *res = &dev->resource[resource];
-	struct resource *root = pci_find_parent_resource(dev, res);
+	struct resource *root = NULL;
 	char *dtype = resource < PCI_BRIDGE_RESOURCES ? "device" : "bridge";
 	int err;
 
+	if (res->flags & IORESOURCE_IO)
+		root = &ioport_resource;
+	if (res->flags & IORESOURCE_MEM)
+		root = &iomem_resource;
+
 	err = -EINVAL;
 	if (root != NULL)
-		err = request_resource(root, res);
+		err = insert_resource(root, res);
 
 	if (err) {
 		printk(KERN_ERR "PCI: %s region %d of %s %s [%lx:%lx]\n",
author
#7 lore raw

ChangeSet 1.1608.97.7, 2004/03/19 14:08:42-08:00, [email protected]

[PATCH] PCI: claim PCI resources on ia64

Call pci_claim_resources() so we can see what PCI resources are being used.

 arch/ia64/pci/pci.c |    1 +
 1 files changed, 1 insertion(+)
arch/ia64/pci/pci.c +1 -0
diff -Nru a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
@@ -320,6 +320,7 @@
 				dev->resource[i].end   += window->offset;
 			}
 		}
+		pci_claim_resource(dev, i);
 	}
 }