linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BK PATCH] Yet more PCI fixes for 2.5.73
@ 2003-06-27  0:50 Greg KH
  2003-06-27  0:51 ` [PATCH] " Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2003-06-27  0:50 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, pcihpd-discuss

Hi,

Here's some more PCI fixes that are against the latest 2.5.73 bk tree.
They fix up the kobject bug in the pci hotplug drivers (the core was
fixed in the patches sent yesterday), and change the pci_dev's slot_name
to be a pointer to the struct device's bus_id.  This provides us with
the unique name needed for pci domain support.  There's also a bugfix
for the pci direct code in i386.


Please pull from:
	bk://kernel.bkbits.net/gregkh/linux/pci-2.5

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/i386/pci/direct.c                  |  106 ++++++++++++++++++++------------
 drivers/pci/hotplug/acpiphp_core.c      |   30 ++++++---
 drivers/pci/hotplug/cpci_hotplug_core.c |   22 ++++--
 drivers/pci/hotplug/cpqphp_core.c       |   38 ++++++-----
 drivers/pci/hotplug/ibmphp.h            |    3 
 drivers/pci/hotplug/ibmphp_core.c       |   25 -------
 drivers/pci/hotplug/ibmphp_ebda.c       |   79 ++++++++++++++++++++---
 drivers/pci/hotplug/ibmphp_hpc.c        |   68 --------------------
 drivers/pci/hotplug/pcihp_skeleton.c    |   42 ++++++++----
 drivers/pci/probe.c                     |   16 ++--
 include/linux/pci.h                     |   10 ++-
 11 files changed, 245 insertions(+), 194 deletions(-)
-----

Greg Kroah-Hartman:
  o PCI Hotplug: ibmphp: add release() callback and other minor cleanups
  o PCI Hotplug: cpqphp: add release() callback and other minor cleanups
  o PCI Hotplug: cpci: fix delete bug and add release() callback
  o PCI Hotplug: acpiphp: add release() callback
  o PCI Hotplug: pcihp_skeleton: fix delete bug and add release() callback

Matthew Wilcox:
  o PCI: create pci_name()
  o PCI: i386/pci/direct.c fixes


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

* [PATCH] Yet more PCI fixes for 2.5.73
  2003-06-27  0:50 [BK PATCH] Yet more PCI fixes for 2.5.73 Greg KH
@ 2003-06-27  0:51 ` Greg KH
  2003-06-27  0:51   ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2003-06-27  0:51 UTC (permalink / raw)
  To: linux-kernel, pcihpd-discuss

ChangeSet 1.1498, 2003/06/26 16:04:05-07:00, greg@kroah.com

[PATCH] PCI Hotplug: pcihp_skeleton: fix delete bug and add release() callback


 drivers/pci/hotplug/pcihp_skeleton.c |   42 ++++++++++++++++++++++-------------
 1 files changed, 27 insertions(+), 15 deletions(-)


diff -Nru a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c
--- a/drivers/pci/hotplug/pcihp_skeleton.c	Thu Jun 26 17:39:24 2003
+++ b/drivers/pci/hotplug/pcihp_skeleton.c	Thu Jun 26 17:39:24 2003
@@ -1,8 +1,8 @@
 /*
- * PCI Hot Plug Controller Skeleton Driver - 0.1
+ * PCI Hot Plug Controller Skeleton Driver - 0.2
  *
- * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
- * Copyright (c) 2001 IBM Corp.
+ * Copyright (c) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
+ * Copyright (c) 2001,2003 IBM Corp.
  *
  * All rights reserved.
  *
@@ -69,7 +69,7 @@
 static int debug;
 static int num_slots;
 
-#define DRIVER_VERSION	"0.1"
+#define DRIVER_VERSION	"0.2"
 #define DRIVER_AUTHOR	"Greg Kroah-Hartman <greg@kroah.com>"
 #define DRIVER_DESC	"Hot Plug PCI Controller Skeleton Driver"
 
@@ -288,6 +288,21 @@
 	return retval;
 }
 
+static void release_slots(struct hotplug_slot *hotplug_slot)
+{
+	struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
+	int retval = 0;
+
+	if (slot == NULL)
+		return -ENODEV;
+
+	dbg(__FUNCTION__" - physical_slot = %s\n", hotplug_slot->name);
+	kfree(slot->hotplug_slot->info);
+	kfree(slot->hotplug_slot->name);
+	kfree(slot->hotplug_slot);
+	kfree(slot);
+}
+
 #define SLOT_NAME_SIZE	10
 static void make_slot_name (struct slot *slot)
 {
@@ -347,6 +362,7 @@
 		slot->number = i;
 
 		hotplug_slot->private = slot;
+		hotplug_slot->release = &release_slot;
 		make_slot_name (slot);
 		hotplug_slot->ops = &skel_hotplug_slot_ops;
 		
@@ -376,27 +392,23 @@
 
 	return retval;
 }
-		
-static void cleanup_slots (void)
+
+static void cleanup_slots(void)
 {
 	struct list_head *tmp;
+	struct list_head *next;
 	struct slot *slot;
 
 	/*
-	 * Unregister all of our slots with the pci_hotplug subsystem,
-	 * and free up all memory that we had allocated.
+	 * Unregister all of our slots with the pci_hotplug subsystem.
+	 * Memory will be freed in release_slot() callback after slot's
+	 * lifespan is finished.
 	 */
-	list_for_each (tmp, &slot_list) {
+	list_for_each_safe (tmp, next, &slot_list) {
 		slot = list_entry (tmp, struct slot, slot_list);
 		list_del (&slot->slot_list);
 		pci_hp_deregister (slot->hotplug_slot);
-		kfree (slot->hotplug_slot->info);
-		kfree (slot->hotplug_slot->name);
-		kfree (slot->hotplug_slot);
-		kfree (slot);
 	}
-
-	return;
 }
 		
 static int __init pcihp_skel_init(void)


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

* Re: [PATCH] Yet more PCI fixes for 2.5.73
  2003-06-27  0:51 ` [PATCH] " Greg KH
@ 2003-06-27  0:51   ` Greg KH
  2003-06-27  0:51     ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2003-06-27  0:51 UTC (permalink / raw)
  To: linux-kernel, pcihpd-discuss

ChangeSet 1.1499, 2003/06/26 16:04:19-07:00, greg@kroah.com

[PATCH] PCI Hotplug: acpiphp: add release() callback


 drivers/pci/hotplug/acpiphp_core.c |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)


diff -Nru a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
--- a/drivers/pci/hotplug/acpiphp_core.c	Thu Jun 26 17:39:18 2003
+++ b/drivers/pci/hotplug/acpiphp_core.c	Thu Jun 26 17:39:18 2003
@@ -380,6 +380,25 @@
 }
 
 /**
+ * release_slot - free up the memory used by a slot
+ * @hotplug_slot: slot to free
+ */
+static void release_slot(struct hotplug_slot *hotplug_slot)
+{
+	struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
+
+	if (slot == NULL)
+		return;
+
+	dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
+
+	kfree(slot->hotplug_slot->info);
+	kfree(slot->hotplug_slot->name);
+	kfree(slot->hotplug_slot);
+	kfree(slot);
+}
+
+/**
  * init_slots - initialize 'struct slot' structures for each slot
  *
  */
@@ -422,6 +441,7 @@
 		slot->number = i;
 
 		slot->hotplug_slot->private = slot;
+		slot->hotplug_slot->release = &release_slots;
 		slot->hotplug_slot->ops = &acpi_hotplug_slot_ops;
 
 		slot->acpi_slot = get_slot_from_id(i);
@@ -435,10 +455,7 @@
 		retval = pci_hp_register(slot->hotplug_slot);
 		if (retval) {
 			err("pci_hp_register failed with error %d\n", retval);
-			kfree(slot->hotplug_slot->info);
-			kfree(slot->hotplug_slot->name);
-			kfree(slot->hotplug_slot);
-			kfree(slot);
+			release_slot();
 			return retval;
 		}
 
@@ -457,13 +474,10 @@
 	struct slot *slot;
 
 	list_for_each_safe (tmp, n, &slot_list) {
+		/* memory will be freed in release_slot callback */
 		slot = list_entry(tmp, struct slot, slot_list);
 		list_del(&slot->slot_list);
 		pci_hp_deregister(slot->hotplug_slot);
-		kfree(slot->hotplug_slot->info);
-		kfree(slot->hotplug_slot->name);
-		kfree(slot->hotplug_slot);
-		kfree(slot);
 	}
 
 	return;


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

* Re: [PATCH] Yet more PCI fixes for 2.5.73
  2003-06-27  0:51     ` Greg KH
@ 2003-06-27  0:51       ` Greg KH
  2003-06-27  0:51         ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2003-06-27  0:51 UTC (permalink / raw)
  To: linux-kernel, pcihpd-discuss

ChangeSet 1.1501, 2003/06/26 16:05:11-07:00, greg@kroah.com

[PATCH] PCI Hotplug: cpqphp: add release() callback and other minor cleanups.


 drivers/pci/hotplug/cpqphp_core.c |   38 ++++++++++++++++++++++----------------
 1 files changed, 22 insertions(+), 16 deletions(-)


diff -Nru a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
--- a/drivers/pci/hotplug/cpqphp_core.c	Thu Jun 26 17:39:08 2003
+++ b/drivers/pci/hotplug/cpqphp_core.c	Thu Jun 26 17:39:08 2003
@@ -312,6 +312,20 @@
 	return previous;
 }
 
+static void release_slot(struct hotplug_slot *hotplug_slot)
+{
+	struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
+	
+	if (slot == NULL)
+		return;
+	
+	dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
+
+	kfree(slot->hotplug_slot->info);
+	kfree(slot->hotplug_slot->name);
+	kfree(slot->hotplug_slot);
+	kfree(slot);
+}
 
 static int ctrl_slot_setup (struct controller * ctrl, void *smbios_start, void *smbios_table)
 {
@@ -401,6 +415,7 @@
 		new_slot->capabilities |= ((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04;
 
 		/* register this slot with the hotplug pci core */
+		new_slot->hotplug_slot->release = &release_slot;
 		new_slot->hotplug_slot->private = new_slot;
 		make_slot_name (new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot);
 		new_slot->hotplug_slot->ops = &cpqphp_hotplug_slot_ops;
@@ -415,10 +430,7 @@
 		result = pci_hp_register (new_slot->hotplug_slot);
 		if (result) {
 			err ("pci_hp_register failed with error %d\n", result);
-			kfree (new_slot->hotplug_slot->info);
-			kfree (new_slot->hotplug_slot->name);
-			kfree (new_slot->hotplug_slot);
-			kfree (new_slot);
+			release_slot(new_slot->hotplug_slot);
 			return result;
 		}
 		
@@ -430,10 +442,9 @@
 		slot_number++;
 	}
 
-	return(0);
+	return 0;
 }
 
-
 static int ctrl_slot_cleanup (struct controller * ctrl)
 {
 	struct slot *old_slot, *next_slot;
@@ -442,12 +453,9 @@
 	ctrl->slot = NULL;
 
 	while (old_slot) {
+		/* memory will be freed by the release_slot callback */
 		next_slot = old_slot->next;
 		pci_hp_deregister (old_slot->hotplug_slot);
-		kfree(old_slot->hotplug_slot->info);
-		kfree(old_slot->hotplug_slot->name);
-		kfree(old_slot->hotplug_slot);
-		kfree(old_slot);
 		old_slot = next_slot;
 	}
 
@@ -498,7 +506,7 @@
 	       sizeof(struct irq_routing_table)) / sizeof(struct irq_info);
 	// Make sure I got at least one entry
 	if (len == 0) {
-		if (PCIIRQRoutingInfoLength != NULL) kfree(PCIIRQRoutingInfoLength );
+		kfree(PCIIRQRoutingInfoLength);
 		return -1;
 	}
 
@@ -509,9 +517,7 @@
 
 		if ((tbus == bus_num) && (tdevice == dev_num)) {
 			*slot = tslot;
-
-			if (PCIIRQRoutingInfoLength != NULL)
-				kfree(PCIIRQRoutingInfoLength);
+			kfree(PCIIRQRoutingInfoLength);
 			return 0;
 		} else {
 			// Didn't get a match on the target PCI device. Check if the
@@ -540,10 +546,10 @@
 	// slot number for the bridge.
 	if (bridgeSlot != 0xFF) {
 		*slot = bridgeSlot;
-		if (PCIIRQRoutingInfoLength != NULL) kfree(PCIIRQRoutingInfoLength );
+		kfree(PCIIRQRoutingInfoLength);
 		return 0;
 	}
-	if (PCIIRQRoutingInfoLength != NULL) kfree(PCIIRQRoutingInfoLength );
+	kfree(PCIIRQRoutingInfoLength);
 	// Couldn't find an entry in the routing table for this PCI device
 	return -1;
 }


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

* Re: [PATCH] Yet more PCI fixes for 2.5.73
  2003-06-27  0:51   ` Greg KH
@ 2003-06-27  0:51     ` Greg KH
  2003-06-27  0:51       ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2003-06-27  0:51 UTC (permalink / raw)
  To: linux-kernel, pcihpd-discuss

ChangeSet 1.1500, 2003/06/26 16:04:35-07:00, greg@kroah.com

[PATCH] PCI Hotplug: cpci: fix delete bug and add release() callback


 drivers/pci/hotplug/cpci_hotplug_core.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)


diff -Nru a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
--- a/drivers/pci/hotplug/cpci_hotplug_core.c	Thu Jun 26 17:39:13 2003
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c	Thu Jun 26 17:39:13 2003
@@ -278,6 +278,19 @@
 	return 0;
 }
 
+static void release_slot(struct hotplug_slot *hotplug_slot)
+{
+	struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
+
+	if(slot == NULL)
+		return;
+
+	kfree(slot->hotplug_slot->info);
+	kfree(slot->hotplug_slot->name);
+	kfree(slot->hotplug_slot);
+	kfree(slot);
+}
+
 #define SLOT_NAME_SIZE	6
 static void
 make_slot_name(struct slot *slot)
@@ -346,6 +359,7 @@
 		slot->devfn = PCI_DEVFN(i, 0);
 
 		hotplug_slot->private = slot;
+		hotplug_slot->release = &release_slot;
 		make_slot_name(slot);
 		hotplug_slot->ops = &cpci_hotplug_slot_ops;
 
@@ -382,6 +396,7 @@
 {
 	struct slot *slot;
 	struct list_head *tmp;
+	struct list_head *next;
 	int status;
 
 	if(!bus) {
@@ -393,7 +408,7 @@
 		spin_unlock(&list_lock);
 		return -1;
 	}
-	list_for_each(tmp, &slot_list) {
+	list_for_each_safe(tmp, next, &slot_list) {
 		slot = list_entry(tmp, struct slot, slot_list);
 		if(slot->bus == bus) {
 			dbg("deregistering slot %s", slot->hotplug_slot->name);
@@ -405,11 +420,6 @@
 			}
 
 			list_del(&slot->slot_list);
-			kfree(slot->hotplug_slot->info);
-			kfree(slot->hotplug_slot->name);
-			kfree(slot->hotplug_slot);
-			kfree(slot);
-
 			slots--;
 		}
 	}


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

* Re: [PATCH] Yet more PCI fixes for 2.5.73
  2003-06-27  0:51           ` Greg KH
@ 2003-06-27  0:51             ` Greg KH
  0 siblings, 0 replies; 8+ messages in thread
From: Greg KH @ 2003-06-27  0:51 UTC (permalink / raw)
  To: linux-kernel, pcihpd-discuss

ChangeSet 1.1504, 2003/06/26 17:27:43-07:00, willy@debian.org

[PATCH] PCI: create pci_name()

This patch introduces pci_name() and converts slot_name into a pointer to
dev.bus_id.


 drivers/pci/probe.c |   16 +++++++---------
 include/linux/pci.h |   10 +++++++++-
 2 files changed, 16 insertions(+), 10 deletions(-)


diff -Nru a/drivers/pci/probe.c b/drivers/pci/probe.c
--- a/drivers/pci/probe.c	Thu Jun 26 17:38:52 2003
+++ b/drivers/pci/probe.c	Thu Jun 26 17:38:52 2003
@@ -109,7 +109,7 @@
 						(((unsigned long) ~sz) << 32);
 #else
 			if (l) {
-				printk(KERN_ERR "PCI: Unable to handle 64-bit address for device %s\n", dev->slot_name);
+				printk(KERN_ERR "PCI: Unable to handle 64-bit address for device %s\n", pci_name(dev));
 				res->start = 0;
 				res->flags = 0;
 				continue;
@@ -304,7 +304,7 @@
 	pci_read_config_dword(dev, PCI_PRIMARY_BUS, &buses);
 
 	DBG("Scanning behind PCI bridge %s, config %06x, pass %d\n",
-	    dev->slot_name, buses & 0xffffff, pass);
+	    pci_name(dev), buses & 0xffffff, pass);
 
 	if ((buses & 0xffff00) && !pcibios_assign_all_busses() && !is_cardbus) {
 		unsigned int cmax;
@@ -403,8 +403,9 @@
 {
 	u32 class;
 
-	sprintf(dev->slot_name, "%02x:%02x.%d", dev->bus->number,
-		PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
+	dev->slot_name = dev->dev.bus_id;
+	sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(dev->bus),
+		dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
 	sprintf(dev->dev.name, "PCI device %04x:%04x",
 		dev->vendor, dev->device);
 
@@ -452,12 +453,12 @@
 
 	default:				    /* unknown header */
 		printk(KERN_ERR "PCI: device %s has unknown header type %02x, ignoring.\n",
-			dev->slot_name, dev->hdr_type);
+			pci_name(dev), dev->hdr_type);
 		return -1;
 
 	bad:
 		printk(KERN_ERR "PCI: %s: class %x doesn't match header type %02x. Ignoring class.\n",
-		       dev->slot_name, class, dev->hdr_type);
+		       pci_name(dev), class, dev->hdr_type);
 		dev->class = PCI_CLASS_NOT_DEFINED;
 	}
 
@@ -531,9 +532,6 @@
 
 	pci_name_device(dev);
 
-	/* now put in global tree */
-	sprintf(dev->dev.bus_id, "%04x:%s", pci_domain_nr(bus),
-			dev->slot_name);
 	dev->dev.dma_mask = &dev->dma_mask;
 
 	return dev;
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
--- a/include/linux/pci.h	Thu Jun 26 17:38:51 2003
+++ b/include/linux/pci.h	Thu Jun 26 17:38:51 2003
@@ -414,7 +414,7 @@
 	struct resource dma_resource[DEVICE_COUNT_DMA];
 	struct resource irq_resource[DEVICE_COUNT_IRQ];
 
-	char		slot_name[8];	/* slot name */
+	char *		slot_name;	/* pointer to dev.bus_id */
 
 	/* These fields are used by common fixups */
 	unsigned int	transparent:1;	/* Transparent PCI bridge */
@@ -802,6 +802,14 @@
 static inline void pci_set_drvdata (struct pci_dev *pdev, void *data)
 {
 	dev_set_drvdata(&pdev->dev, data);
+}
+
+/* If you want to know what to call your pci_dev, ask this function.
+ * Again, it's a wrapper around the generic device.
+ */
+static inline char *pci_name(struct pci_dev *pdev)
+{
+	return pdev->dev.bus_id;
 }
 
 /*


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

* Re: [PATCH] Yet more PCI fixes for 2.5.73
  2003-06-27  0:51       ` Greg KH
@ 2003-06-27  0:51         ` Greg KH
  2003-06-27  0:51           ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2003-06-27  0:51 UTC (permalink / raw)
  To: linux-kernel, pcihpd-discuss

ChangeSet 1.1502, 2003/06/26 16:05:27-07:00, greg@kroah.com

[PATCH] PCI Hotplug: ibmphp: add release() callback and other minor cleanups


 drivers/pci/hotplug/ibmphp.h      |    3 -
 drivers/pci/hotplug/ibmphp_core.c |   25 +-----------
 drivers/pci/hotplug/ibmphp_ebda.c |   79 +++++++++++++++++++++++++++++++++-----
 drivers/pci/hotplug/ibmphp_hpc.c  |   68 --------------------------------
 4 files changed, 74 insertions(+), 101 deletions(-)


diff -Nru a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h
--- a/drivers/pci/hotplug/ibmphp.h	Thu Jun 26 17:39:02 2003
+++ b/drivers/pci/hotplug/ibmphp.h	Thu Jun 26 17:39:02 2003
@@ -7,7 +7,7 @@
  * Written By: Jyoti Shah, Tong Yu, Irene Zubarev, IBM Corporation
  *
  * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
- * Copyright (c) 2001,2002 IBM Corp.
+ * Copyright (c) 2001-2003 IBM Corp.
  *
  * All rights reserved.
  *
@@ -398,7 +398,6 @@
 extern int ibmphp_hpc_writeslot (struct slot *, u8);
 extern void ibmphp_lock_operations (void);
 extern void ibmphp_unlock_operations (void);
-extern int ibmphp_hpc_fillhpslotinfo (struct hotplug_slot *);
 extern int ibmphp_hpc_start_poll_thread (void);
 extern void ibmphp_hpc_stop_poll_thread (void);
 
diff -Nru a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
--- a/drivers/pci/hotplug/ibmphp_core.c	Thu Jun 26 17:39:02 2003
+++ b/drivers/pci/hotplug/ibmphp_core.c	Thu Jun 26 17:39:02 2003
@@ -3,8 +3,8 @@
  *
  * Written By: Chuck Cole, Jyoti Shah, Tong Yu, Irene Zubarev, IBM Corporation
  *
- * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
- * Copyright (c) 2001,2002 IBM Corp.
+ * Copyright (c) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
+ * Copyright (c) 2001-2003 IBM Corp.
  *
  * All rights reserved.
  *
@@ -739,26 +739,8 @@
 	debug ("%s -- enter\n", __FUNCTION__);
 
 	list_for_each_safe (tmp, next, &ibmphp_slot_head) {
-	
 		slot_cur = list_entry (tmp, struct slot, ibm_slot_list);
-
 		pci_hp_deregister (slot_cur->hotplug_slot);
-
-		if (slot_cur->hotplug_slot) {
-			kfree (slot_cur->hotplug_slot);
-			slot_cur->hotplug_slot = NULL;
-		}
-
-		if (slot_cur->ctrl) 
-			slot_cur->ctrl = NULL;
-		
-		if (slot_cur->bus_on) 
-			slot_cur->bus_on = NULL;
-
-		ibmphp_unconfigure_card (&slot_cur, -1);  /* we don't want to actually remove the resources, since free_resources will do just that */
-
-		kfree (slot_cur);
-		slot_cur = NULL;
 	}
 	debug ("%s -- exit\n", __FUNCTION__);
 }
@@ -1221,7 +1203,6 @@
 {
 	int rc;
 	u8 flag;
-	int parm = 0;
 
 	debug ("DISABLING SLOT... \n"); 
 		
@@ -1270,7 +1251,7 @@
 		return 0;
 	}
 
-	rc = ibmphp_unconfigure_card (&slot_cur, parm);
+	rc = ibmphp_unconfigure_card (&slot_cur, 0);
 	slot_cur->func = NULL;
 	debug ("in disable_slot. after unconfigure_card\n");
 	if (rc) {
diff -Nru a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
--- a/drivers/pci/hotplug/ibmphp_ebda.c	Thu Jun 26 17:39:02 2003
+++ b/drivers/pci/hotplug/ibmphp_ebda.c	Thu Jun 26 17:39:02 2003
@@ -3,8 +3,8 @@
  *
  * Written By: Tong Yu, IBM Corporation
  *
- * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
- * Copyright (c) 2001,2002 IBM Corp.
+ * Copyright (c) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
+ * Copyright (c) 2001-2003 IBM Corp.
  *
  * All rights reserved.
  *
@@ -727,6 +727,64 @@
 	return str;
 }
 
+static int fillslotinfo(struct hotplug_slot *hotplug_slot)
+{
+	struct slot *slot;
+	int rc = 0;
+
+	if (!hotplug_slot || !hotplug_slot->private)
+		return -EINVAL;
+
+	slot = hotplug_slot->private;
+	rc = ibmphp_hpc_readslot(slot, READ_ALLSTAT, NULL);
+	if (rc)
+		return rc;
+
+	// power - enabled:1  not:0
+	hotplug_slot->info->power_status = SLOT_POWER(slot->status);
+
+	// attention - off:0, on:1, blinking:2
+	hotplug_slot->info->attention_status = SLOT_ATTN(slot->status, slot->ext_status);
+
+	// latch - open:1 closed:0
+	hotplug_slot->info->latch_status = SLOT_LATCH(slot->status);
+
+	// pci board - present:1 not:0
+	if (SLOT_PRESENT (slot->status))
+		hotplug_slot->info->adapter_status = 1;
+	else
+		hotplug_slot->info->adapter_status = 0;
+/*
+	if (slot->bus_on->supported_bus_mode
+		&& (slot->bus_on->supported_speed == BUS_SPEED_66))
+		hotplug_slot->info->max_bus_speed_status = BUS_SPEED_66PCIX;
+	else
+		hotplug_slot->info->max_bus_speed_status = slot->bus_on->supported_speed;
+*/
+
+	return rc;
+}
+
+static void release_slot(struct hotplug_slot *hotplug_slot)
+{
+	struct slot *slot;
+
+	if (!hotplug_slot || !hotplug_slot->private)
+		return;
+
+	slot = hotplug_slot->private;
+	kfree(slot->hotplug_slot->info);
+	kfree(slot->hotplug_slot->name);
+	kfree(slot->hotplug_slot);
+	slot->ctrl = NULL;
+	slot->bus_on = NULL;
+
+	/* we don't want to actually remove the resources, since free_resources will do just that */
+	ibmphp_unconfigure_card(&slot, -1);
+
+	kfree (slot);
+}
+
 static struct pci_driver ibmphp_driver;
 
 /*
@@ -900,32 +958,32 @@
 		// register slots with hpc core as well as create linked list of ibm slot
 		for (index = 0; index < hpc_ptr->slot_count; index++) {
 
-			hp_slot_ptr = (struct hotplug_slot *) kmalloc (sizeof (struct hotplug_slot), GFP_KERNEL);
+			hp_slot_ptr = kmalloc(sizeof(*hp_slot_ptr), GFP_KERNEL);
 			if (!hp_slot_ptr) {
 				rc = -ENOMEM;
 				goto error_no_hp_slot;
 			}
-			memset (hp_slot_ptr, 0, sizeof (struct hotplug_slot));
+			memset(hp_slot_ptr, 0, sizeof(*hp_slot_ptr));
 
-			hp_slot_ptr->info = (struct hotplug_slot_info *) kmalloc (sizeof (struct hotplug_slot_info), GFP_KERNEL);
+			hp_slot_ptr->info = kmalloc (sizeof(struct hotplug_slot_info), GFP_KERNEL);
 			if (!hp_slot_ptr->info) {
 				rc = -ENOMEM;
 				goto error_no_hp_info;
 			}
-			memset (hp_slot_ptr->info, 0, sizeof (struct hotplug_slot_info));
+			memset(hp_slot_ptr->info, 0, sizeof(struct hotplug_slot_info));
 
-			hp_slot_ptr->name = (char *) kmalloc (30, GFP_KERNEL);
+			hp_slot_ptr->name = kmalloc(30, GFP_KERNEL);
 			if (!hp_slot_ptr->name) {
 				rc = -ENOMEM;
 				goto error_no_hp_name;
 			}
 
-			tmp_slot = kmalloc (sizeof (struct slot), GFP_KERNEL);
+			tmp_slot = kmalloc(sizeof(*tmp_slot), GFP_KERNEL);
 			if (!tmp_slot) {
 				rc = -ENOMEM;
 				goto error_no_slot;
 			}
-			memset (tmp_slot, 0, sizeof (*tmp_slot));
+			memset(tmp_slot, 0, sizeof(*tmp_slot));
 
 			tmp_slot->flag = TRUE;
 
@@ -959,8 +1017,9 @@
 			tmp_slot->hotplug_slot = hp_slot_ptr;
 
 			hp_slot_ptr->private = tmp_slot;
+			hp_slot_ptr->release = release_slot;
 
-			rc = ibmphp_hpc_fillhpslotinfo (hp_slot_ptr);
+			rc = fillslotinfo(hp_slot_ptr);
 			if (rc)
 				goto error;
 
diff -Nru a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c
--- a/drivers/pci/hotplug/ibmphp_hpc.c	Thu Jun 26 17:39:02 2003
+++ b/drivers/pci/hotplug/ibmphp_hpc.c	Thu Jun 26 17:39:02 2003
@@ -3,7 +3,7 @@
  *
  * Written By: Jyoti Shah, IBM Corporation
  *
- * Copyright (c) 2001-2002 IBM Corp.
+ * Copyright (c) 2001-2003 IBM Corp.
  *
  * All rights reserved.
  *
@@ -114,7 +114,6 @@
 static void get_hpc_access (void);
 static void free_hpc_access (void);
 static void poll_hpc (void);
-static int update_slot (struct slot *, u8);
 static int process_changeinstatus (struct slot *, struct slot *);
 static int process_changeinlatch (u8, u8, struct controller *);
 static int hpc_poll_thread (void *);
@@ -916,71 +915,6 @@
 	debug ("%s - Exit\n", __FUNCTION__);
 }
 
-
-/* ----------------------------------------------------------------------
- *  Name:    ibmphp_hpc_fillhpslotinfo(hotplug_slot * phpslot)
- *
- *  Action:  fill out the hotplug_slot info
- *
- *  Input:   pointer to hotplug_slot
- *
- *  Return
- *  Value:   0 or error codes
- *-----------------------------------------------------------------------*/
-int ibmphp_hpc_fillhpslotinfo (struct hotplug_slot *phpslot)
-{
-	int rc = 0;
-	struct slot *pslot;
-
-	if (phpslot && phpslot->private) {
-		pslot = (struct slot *) phpslot->private;
-		rc = update_slot (pslot, (u8) TRUE);
-		if (!rc) {
-
-			// power - enabled:1  not:0
-			phpslot->info->power_status = SLOT_POWER (pslot->status);
-
-			// attention - off:0, on:1, blinking:2
-			phpslot->info->attention_status = SLOT_ATTN (pslot->status, pslot->ext_status);
-
-			// latch - open:1 closed:0
-			phpslot->info->latch_status = SLOT_LATCH (pslot->status);
-
-			// pci board - present:1 not:0
-			if (SLOT_PRESENT (pslot->status))
-				phpslot->info->adapter_status = 1;
-			else
-				phpslot->info->adapter_status = 0;
-/*
-			if (pslot->bus_on->supported_bus_mode
-				&& (pslot->bus_on->supported_speed == BUS_SPEED_66))
-				phpslot->info->max_bus_speed_status = BUS_SPEED_66PCIX;
-			else
-				phpslot->info->max_bus_speed_status = pslot->bus_on->supported_speed;
-*/		} else
-			rc = -EINVAL;
-	} else
-		rc = -EINVAL;
-
-	return rc;
-}
-
-/*----------------------------------------------------------------------
-* Name:    update_slot
-*
-* Action:  fill out slot status and extended status, controller status
-*
-* Input:   pointer to slot struct
-*---------------------------------------------------------------------*/
-static int update_slot (struct slot *pslot, u8 update)
-{
-	int rc = 0;
-
-	debug ("%s - Entry pslot[%p]\n", __FUNCTION__, pslot);
-	rc = ibmphp_hpc_readslot (pslot, READ_ALLSTAT, NULL);
-	debug ("%s - Exit rc[%d]\n", __FUNCTION__, rc);
-	return rc;
-}
 
 /*----------------------------------------------------------------------
 * Name:    process_changeinstatus


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

* Re: [PATCH] Yet more PCI fixes for 2.5.73
  2003-06-27  0:51         ` Greg KH
@ 2003-06-27  0:51           ` Greg KH
  2003-06-27  0:51             ` Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2003-06-27  0:51 UTC (permalink / raw)
  To: linux-kernel, pcihpd-discuss

ChangeSet 1.1503, 2003/06/26 17:27:29-07:00, willy@debian.org

[PATCH] PCI: i386/pci/direct.c fixes

 - Request resources before using them
 - Don't allocate GFP_KERNEL memory with interrupts disabled
 - Split pci_direct_init() into three functions to prevent it from
   getting too long.


 arch/i386/pci/direct.c |  106 +++++++++++++++++++++++++++++++------------------
 1 files changed, 68 insertions(+), 38 deletions(-)


diff -Nru a/arch/i386/pci/direct.c b/arch/i386/pci/direct.c
--- a/arch/i386/pci/direct.c	Thu Jun 26 17:38:57 2003
+++ b/arch/i386/pci/direct.c	Thu Jun 26 17:38:57 2003
@@ -201,54 +201,84 @@
 	return 0;
 }
 
-static int __init pci_direct_init(void)
+static int __init pci_check_type1(void)
 {
-	unsigned int tmp;
 	unsigned long flags;
+	unsigned int tmp;
+	int works = 0;
 
 	local_irq_save(flags);
 
-	/*
-	 * Check if configuration type 1 works.
-	 */
-	if (pci_probe & PCI_PROBE_CONF1) {
-		outb (0x01, 0xCFB);
-		tmp = inl (0xCF8);
-		outl (0x80000000, 0xCF8);
-		if (inl (0xCF8) == 0x80000000 &&
-		    pci_sanity_check(&pci_direct_conf1)) {
-			outl (tmp, 0xCF8);
-			local_irq_restore(flags);
-			printk(KERN_INFO "PCI: Using configuration type 1\n");
-			if (!request_region(0xCF8, 8, "PCI conf1"))
-				raw_pci_ops = NULL;
-			else
-				raw_pci_ops = &pci_direct_conf1;
-			return 0;
-		}
-		outl (tmp, 0xCF8);
+	outb(0x01, 0xCFB);
+	tmp = inl(0xCF8);
+	outl(0x80000000, 0xCF8);
+	if (inl(0xCF8) == 0x80000000 && pci_sanity_check(&pci_direct_conf1)) {
+		works = 1;
 	}
+	outl(tmp, 0xCF8);
+	local_irq_restore(flags);
+
+	return works;
+}
 
-	/*
-	 * Check if configuration type 2 works.
-	 */
-	if (pci_probe & PCI_PROBE_CONF2) {
-		outb (0x00, 0xCFB);
-		outb (0x00, 0xCF8);
-		outb (0x00, 0xCFA);
-		if (inb (0xCF8) == 0x00 && inb (0xCFA) == 0x00 &&
-		    pci_sanity_check(&pci_direct_conf2)) {
-			local_irq_restore(flags);
-			printk(KERN_INFO "PCI: Using configuration type 2\n");
-			if (!request_region(0xCF8, 4, "PCI conf2"))
-				raw_pci_ops = NULL;
-			else
-				raw_pci_ops = &pci_direct_conf2;
-			return 0;
-		}
+static int __init pci_check_type2(void)
+{
+	unsigned long flags;
+	int works = 0;
+
+	local_irq_save(flags);
+
+	outb(0x00, 0xCFB);
+	outb(0x00, 0xCF8);
+	outb(0x00, 0xCFA);
+	if (inb(0xCF8) == 0x00 && inb(0xCFA) == 0x00 &&
+	    pci_sanity_check(&pci_direct_conf2)) {
+		works = 1;
 	}
 
 	local_irq_restore(flags);
+
+	return works;
+}
+
+static int __init pci_direct_init(void)
+{
+	struct resource *region, *region2;
+
+	if ((pci_probe & PCI_PROBE_CONF1) == 0)
+		goto type2;
+	region = request_region(0xCF8, 8, "PCI conf1");
+	if (!region)
+		goto type2;
+
+	if (pci_check_type1()) {
+		printk(KERN_INFO "PCI: Using configuration type 1\n");
+		raw_pci_ops = &pci_direct_conf1;
+		return 0;
+	}
+	release_resource(region);
+
+ type2:
+	if ((!pci_probe & PCI_PROBE_CONF2) == 0)
+		goto out;
+	region = request_region(0xCF8, 4, "PCI conf2");
+	if (!region)
+		goto out;
+	region2 = request_region(0xC000, 0x1000, "PCI conf2");
+	if (!region2)
+		goto fail2;
+
+	if (pci_check_type2()) {
+		printk(KERN_INFO "PCI: Using configuration type 2\n");
+		raw_pci_ops = &pci_direct_conf2;
+		return 0;
+	}
+
+	release_resource(region2);
+ fail2:
+	release_resource(region);
+
+ out:
 	return 0;
 }
 


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

end of thread, other threads:[~2003-06-27  2:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-27  0:50 [BK PATCH] Yet more PCI fixes for 2.5.73 Greg KH
2003-06-27  0:51 ` [PATCH] " Greg KH
2003-06-27  0:51   ` Greg KH
2003-06-27  0:51     ` Greg KH
2003-06-27  0:51       ` Greg KH
2003-06-27  0:51         ` Greg KH
2003-06-27  0:51           ` Greg KH
2003-06-27  0:51             ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).