linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] PCI: let the core manage slot names
@ 2008-08-17  0:14 Alex Chiang
  2008-08-17  0:15 ` [PATCH 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface Alex Chiang
                   ` (12 more replies)
  0 siblings, 13 replies; 55+ messages in thread
From: Alex Chiang @ 2008-08-17  0:14 UTC (permalink / raw)
  To: jbarnes, kaneshige.kenji, matthew, kristen.c.accardi,
	linux-kernel, linux-pci

This series implements a series of changes that allows the
PCI core to manage slot names, rather than individual hotplug
drivers.

There are several benefits to this approach:

	1) The core can prevent duplicate slot names on systems
	   with broken firmware.

	2) Since the kobject core keeps a copy of the slot name,
	   there is no need for each driver to manage a separate
	   copy, especially since the core can rename slots from
	   underneath drivers. We save runtime memory by only
	   referencing the kobject name.

	2.a) The PCI hotplug core doesn't need its own reference
	     for slot name either.

	3) Individual hotplug drivers become just a little bit
	   simpler by pushing as many kzalloc() calls for 'name'
	   down into the PCI core as possible.

I've compile tested every driver, including sgi, rpaphp, and ibmphp. 

I've runtime tested acpiphp and pciehp, as I only have access to
platforms that support those two drivers.

I would love it if Kenji-san could test the duplicate slot name
logic for me, as I don't have access to platforms with that
behavior.

I think this *might* be 2.6.27 material, because the original
impetus for this change was a user (Pierre Ossman) complaining
that 2.6.27 required him to pass a parameter to pciehp in order
to successfully load the module.

Although the diffstat is large, don't be fooled. The significant
portion of the additions come from the duplicate slot logic in the
PCI core. And of those changes, they were 40% comments, so it looks
like more was added than is truly the case.
---

Alex Chiang (13):
      PCI: Hotplug core: remove 'name'
      PCI: shcphp: remove 'name' parameter
      PCI: SGI Hotplug: stop managing bss_hotplug_slot->name
      PCI: rpaphp: stop managing hotplug_slot->name
      PCI: pciehp: remove 'name' parameter
      PCI: ibmphp: stop managing hotplug_slot->name
      PCI: fakephp: remove 'name' parameter
      PCI: cpqphp: stop managing hotplug_slot->name
      PCI: cpci_hotplug: stop managing hotplug_slot->name
      PCI: acpiphp: remove 'name' parameter
      PCI, PCI Hotplug: introduce slot_name helpers
      PCI: prevent duplicate slot names
      PCI Hotplug core: add 'name' param pci_hp_register interface


 drivers/pci/hotplug/acpiphp.h           |    9 ++-
 drivers/pci/hotplug/acpiphp_core.c      |   37 +++++++-----
 drivers/pci/hotplug/cpci_hotplug.h      |    6 ++
 drivers/pci/hotplug/cpci_hotplug_core.c |   75 ++++++++++---------------
 drivers/pci/hotplug/cpci_hotplug_pci.c  |    4 +
 drivers/pci/hotplug/cpqphp.h            |   13 ++--
 drivers/pci/hotplug/cpqphp_core.c       |   41 +++++++-------
 drivers/pci/hotplug/fakephp.c           |   19 ++++--
 drivers/pci/hotplug/ibmphp.h            |    5 +-
 drivers/pci/hotplug/ibmphp_ebda.c       |   20 +++----
 drivers/pci/hotplug/pci_hotplug_core.c  |   29 ++++------
 drivers/pci/hotplug/pciehp.h            |   11 ++--
 drivers/pci/hotplug/pciehp_core.c       |   34 +++++------
 drivers/pci/hotplug/pciehp_ctrl.c       |   48 ++++++++--------
 drivers/pci/hotplug/pciehp_hpc.c        |   10 ---
 drivers/pci/hotplug/rpaphp.h            |   10 ++-
 drivers/pci/hotplug/rpaphp_core.c       |    6 +-
 drivers/pci/hotplug/rpaphp_pci.c        |    4 +
 drivers/pci/hotplug/rpaphp_slot.c       |   26 +++------
 drivers/pci/hotplug/sgi_hotplug.c       |   19 ++----
 drivers/pci/hotplug/shpchp.h            |    9 ++-
 drivers/pci/hotplug/shpchp_core.c       |   46 +++++----------
 drivers/pci/hotplug/shpchp_ctrl.c       |   48 ++++++++--------
 drivers/pci/slot.c                      |   93 +++++++++++++++++++++++++------
 include/linux/pci.h                     |    5 ++
 include/linux/pci_hotplug.h             |   13 +++-
 26 files changed, 328 insertions(+), 312 deletions(-)


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

* [PATCH 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface
  2008-08-17  0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
@ 2008-08-17  0:15 ` Alex Chiang
  2008-08-17  0:16 ` [PATCH 02/13] PCI: prevent duplicate slot names Alex Chiang
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-08-17  0:15 UTC (permalink / raw)
  To: linux-kernel, linux-pci
  Cc: jbarnes, kristen.c.accardi, matthew, kaneshige.kenji, Alex Chiang

Update pci_hp_register() to take a const char *name parameter.

The motivation for this is to clean up the individual hotplug
drivers so that each one does not have to manage its own name.
The PCI core should be the place where we manage the name.

We update the interface and all callsites first, in a
"no functional change" manner, and clean up the drivers later.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: matthew@wil.cx
Cc: kaneshige.kenji@jp.fujitsu.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/acpiphp_core.c      |    3 ++-
 drivers/pci/hotplug/cpci_hotplug_core.c |    3 ++-
 drivers/pci/hotplug/cpqphp_core.c       |    3 ++-
 drivers/pci/hotplug/fakephp.c           |    3 ++-
 drivers/pci/hotplug/ibmphp_ebda.c       |    3 ++-
 drivers/pci/hotplug/pci_hotplug_core.c  |   21 +++++++++++----------
 drivers/pci/hotplug/pciehp_core.c       |    3 ++-
 drivers/pci/hotplug/rpaphp_slot.c       |    2 +-
 drivers/pci/hotplug/sgi_hotplug.c       |    3 ++-
 drivers/pci/hotplug/shpchp_core.c       |    3 ++-
 include/linux/pci_hotplug.h             |    5 ++++-
 11 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index 0e496e8..e984176 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -340,7 +340,8 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
 
 	retval = pci_hp_register(slot->hotplug_slot,
 					acpiphp_slot->bridge->pci_bus,
-					acpiphp_slot->device);
+					acpiphp_slot->device,
+					slot->name);
 	if (retval == -EBUSY)
 		goto error_hpslot;
 	if (retval) {
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index 9359479..5e5dee8 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -285,7 +285,8 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
 		info->attention_status = cpci_get_attention_status(slot);
 
 		dbg("registering slot %s", slot->hotplug_slot->name);
-		status = pci_hp_register(slot->hotplug_slot, bus, i);
+		status = pci_hp_register(slot->hotplug_slot, bus, i,
+					 slot->hotplug_slot->name);
 		if (status) {
 			err("pci_hp_register failed with error %d", status);
 			goto error_name;
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index 54defec..a7fe458 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -436,7 +436,8 @@ static int ctrl_slot_setup(struct controller *ctrl,
 				slot_number);
 		result = pci_hp_register(hotplug_slot,
 					 ctrl->pci_dev->subordinate,
-					 slot->device);
+					 slot->device,
+					 hotplug_slot->name);
 		if (result) {
 			err("pci_hp_register failed with error %d\n", result);
 			goto error_name;
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index 40337a0..f1c1817 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -126,7 +126,8 @@ static int add_slot(struct pci_dev *dev)
 	slot->release = &dummy_release;
 	slot->private = dslot;
 
-	retval = pci_hp_register(slot, dev->bus, PCI_SLOT(dev->devfn));
+	retval = pci_hp_register(slot, dev->bus, PCI_SLOT(dev->devfn),
+				 slot->name);
 	if (retval) {
 		err("pci_hp_register failed with error %d\n", retval);
 		goto error_dslot;
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
index 8467d02..46deff3 100644
--- a/drivers/pci/hotplug/ibmphp_ebda.c
+++ b/drivers/pci/hotplug/ibmphp_ebda.c
@@ -1002,7 +1002,8 @@ static int __init ebda_rsrc_controller (void)
 
 		snprintf (tmp_slot->hotplug_slot->name, 30, "%s", create_file_name (tmp_slot));
 		pci_hp_register(tmp_slot->hotplug_slot,
-			pci_find_bus(0, tmp_slot->bus), tmp_slot->device);
+			pci_find_bus(0, tmp_slot->bus), tmp_slot->device,
+			tmp_slot->hotplug_slot->name);
 	}
 
 	print_ebda_hpc ();
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index 5f85b1b..96f274e 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -547,13 +547,15 @@ out:
  * @bus: bus this slot is on
  * @slot: pointer to the &struct hotplug_slot to register
  * @slot_nr: slot number
+ * @name: name registered with kobject core
  *
  * Registers a hotplug slot with the pci hotplug subsystem, which will allow
  * userspace interaction to the slot.
  *
  * Returns 0 if successful, anything else for an error.
- */
-int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
+ **/
+int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
+			const char *name)
 {
 	int result;
 	struct pci_slot *pci_slot;
@@ -569,7 +571,7 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
 	}
 
 	/* Check if we have already registered a slot with the same name. */
-	if (get_slot_from_name(slot->name))
+	if (get_slot_from_name(name))
 		return -EEXIST;
 
 	/*
@@ -577,7 +579,7 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
 	 * driver and call it here again. If we've already created the
 	 * pci_slot, the interface will simply bump the refcount.
 	 */
-	pci_slot = pci_create_slot(bus, slot_nr, slot->name);
+	pci_slot = pci_create_slot(bus, slot_nr, name);
 	if (IS_ERR(pci_slot))
 		return PTR_ERR(pci_slot);
 
@@ -593,8 +595,8 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
 	/*
 	 * Allow pcihp drivers to override the ACPI_PCI_SLOT name.
 	 */
-	if (strcmp(kobject_name(&pci_slot->kobj), slot->name)) {
-		result = kobject_rename(&pci_slot->kobj, slot->name);
+	if (strcmp(kobject_name(&pci_slot->kobj), name)) {
+		result = kobject_rename(&pci_slot->kobj, name);
 		if (result) {
 			pci_destroy_slot(pci_slot);
 			return result;
@@ -607,8 +609,7 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
 
 	result = fs_add_slot(pci_slot);
 	kobject_uevent(&pci_slot->kobj, KOBJ_ADD);
-	dbg("Added slot %s to the list\n", slot->name);
-
+	dbg("Added slot %s to the list\n", name);
 
 	return result;
 }
@@ -621,7 +622,7 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
  * previously with a call to pci_hp_register().
  *
  * Returns 0 if successful, anything else for an error.
- */
+ **/
 int pci_hp_deregister(struct hotplug_slot *hotplug)
 {
 	struct hotplug_slot *temp;
@@ -658,7 +659,7 @@ int pci_hp_deregister(struct hotplug_slot *hotplug)
  * hotplug subsystem previously with a call to pci_hp_register().
  *
  * Returns 0 if successful, anything else for an error.
- */
+ **/
 int __must_check pci_hp_change_slot_info(struct hotplug_slot *hotplug,
 					 struct hotplug_slot_info *info)
 {
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 3677495..5952315 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -222,7 +222,8 @@ static int init_slots(struct controller *ctrl)
 		    slot->hp_slot, slot->number, ctrl->slot_device_offset);
 		retval = pci_hp_register(hotplug_slot,
 					 ctrl->pci_dev->subordinate,
-					 slot->device);
+					 slot->device,
+					 slot->name);
 		if (retval) {
 			err("pci_hp_register failed with error %d\n", retval);
 			if (retval == -EEXIST)
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
index 9b714ea..30d430b 100644
--- a/drivers/pci/hotplug/rpaphp_slot.c
+++ b/drivers/pci/hotplug/rpaphp_slot.c
@@ -137,7 +137,7 @@ int rpaphp_register_slot(struct slot *slot)
 		slotno = PCI_SLOT(PCI_DN(slot->dn->child)->devfn);
 	else
 		slotno = -1;
-	retval = pci_hp_register(php_slot, slot->bus, slotno);
+	retval = pci_hp_register(php_slot, slot->bus, slotno, slot->name);
 	if (retval) {
 		err("pci_hp_register failed with error %d\n", retval);
 		return retval;
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index 410fe03..6d20bbd 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -653,7 +653,8 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus)
 		bss_hotplug_slot->ops = &sn_hotplug_slot_ops;
 		bss_hotplug_slot->release = &sn_release_slot;
 
-		rc = pci_hp_register(bss_hotplug_slot, pci_bus, device);
+		rc = pci_hp_register(bss_hotplug_slot, pci_bus, device,
+				     bss_hotplug_slot->name);
 		if (rc)
 			goto register_err;
 
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index a8cbd03..7bc06c0 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -158,7 +158,8 @@ static int init_slots(struct controller *ctrl)
 		    "slot_device_offset=%x\n", slot->bus, slot->device,
 		    slot->hp_slot, slot->number, ctrl->slot_device_offset);
 		retval = pci_hp_register(slot->hotplug_slot,
-				ctrl->pci_dev->subordinate, slot->device);
+				ctrl->pci_dev->subordinate, slot->device,
+				hotplug_slot->name);
 		if (retval) {
 			err("pci_hp_register failed with error %d\n", retval);
 			if (retval == -EEXIST)
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index a08cd06..303834b 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -165,7 +165,10 @@ struct hotplug_slot {
 };
 #define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj)
 
-extern int pci_hp_register(struct hotplug_slot *, struct pci_bus *, int nr);
+extern int pci_hp_register(struct hotplug_slot *,
+			   struct pci_bus *,
+			   int nr,
+			   const char *name);
 extern int pci_hp_deregister(struct hotplug_slot *slot);
 extern int __must_check pci_hp_change_slot_info	(struct hotplug_slot *slot,
 						 struct hotplug_slot_info *info);


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

* [PATCH 02/13] PCI: prevent duplicate slot names
  2008-08-17  0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
  2008-08-17  0:15 ` [PATCH 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface Alex Chiang
@ 2008-08-17  0:16 ` Alex Chiang
  2008-08-21 10:24   ` Kenji Kaneshige
  2008-08-17  0:16 ` [PATCH 03/13] PCI, PCI Hotplug: introduce slot_name helpers Alex Chiang
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 55+ messages in thread
From: Alex Chiang @ 2008-08-17  0:16 UTC (permalink / raw)
  To: linux-kernel, linux-pci
  Cc: jbarnes, kristen.c.accardi, matthew, kaneshige.kenji, Alex Chiang

Prevent callers of pci_create_slot() from registering slots with
duplicate names. This condition occurs most often when PCI hotplug
drivers are loaded on platforms with broken firmware that assigns
identical names to multiple slots.

We now rename these duplicate slots on behalf of the user.

If firmware assigns the name N to multiple slots, then:

	The first registered slot is assigned N
	The second registered slot is assigned N-1
	The third registered slot is assigned N-2
	The Mth registered slot becomes N-M

A side effect of this patch is that the error condition for when
multiple drivers attempt to claim the same slot becomes much more
prominent.

In other words, the previous error condition returned for
duplicate slot names (-EEXIST) masked the case when multiple
drivers attempted to claim the same slot. Now, the -EBUSY return
makes the true error more obvious.

Finally, since we now prevent duplicate slot names, we remove
the logic introduced by the following commits:

	pci hotplug core: add check of duplicate slot name
	a86161b3134465f072d965ca7508ec9c1e2e52c7

	pciehp: fix slot name
	3800345f723fd130d50434d4717b99d4a9f383c8

	pciehp: add message about pciehp_slot_with_bus option
	9e4f2e8d4ddb04ad16a3828cd9a369a5a5287009

	shpchp: fix slot name
	ef0ff95f136f0f2d035667af5d18b824609de320

	shpchp: add message about shpchp_slot_with_bus option
	b3bd307c628af2f0a581c42d5d7e4bcdbbf64b6a

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: matthew@wil.cx
Cc: kaneshige.kenji@jp.fujitsu.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/pci_hotplug_core.c |    4 -
 drivers/pci/hotplug/pciehp.h           |    1 
 drivers/pci/hotplug/pciehp_core.c      |    7 --
 drivers/pci/hotplug/pciehp_hpc.c       |    6 --
 drivers/pci/hotplug/shpchp_core.c      |   14 -----
 drivers/pci/slot.c                     |   93 +++++++++++++++++++++++++-------
 6 files changed, 76 insertions(+), 49 deletions(-)

diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index 96f274e..da5908f 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -570,10 +570,6 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
 		return -EINVAL;
 	}
 
-	/* Check if we have already registered a slot with the same name. */
-	if (get_slot_from_name(name))
-		return -EEXIST;
-
 	/*
 	 * No problems if we call this interface from both ACPI_PCI_SLOT
 	 * driver and call it here again. If we've already created the
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index e3a1e7e..9e6cec6 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -43,7 +43,6 @@ extern int pciehp_poll_mode;
 extern int pciehp_poll_time;
 extern int pciehp_debug;
 extern int pciehp_force;
-extern int pciehp_slot_with_bus;
 extern struct workqueue_struct *pciehp_wq;
 
 #define dbg(format, arg...)						\
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 5952315..bed77af 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -41,7 +41,6 @@ int pciehp_debug;
 int pciehp_poll_mode;
 int pciehp_poll_time;
 int pciehp_force;
-int pciehp_slot_with_bus;
 struct workqueue_struct *pciehp_wq;
 
 #define DRIVER_VERSION	"0.4"
@@ -56,12 +55,10 @@ module_param(pciehp_debug, bool, 0644);
 module_param(pciehp_poll_mode, bool, 0644);
 module_param(pciehp_poll_time, int, 0644);
 module_param(pciehp_force, bool, 0644);
-module_param(pciehp_slot_with_bus, bool, 0644);
 MODULE_PARM_DESC(pciehp_debug, "Debugging mode enabled or not");
 MODULE_PARM_DESC(pciehp_poll_mode, "Using polling mechanism for hot-plug events or not");
 MODULE_PARM_DESC(pciehp_poll_time, "Polling mechanism frequency, in seconds");
 MODULE_PARM_DESC(pciehp_force, "Force pciehp, even if _OSC and OSHP are missing");
-MODULE_PARM_DESC(pciehp_slot_with_bus, "Use bus number in the slot name");
 
 #define PCIE_MODULE_NAME "pciehp"
 
@@ -226,10 +223,6 @@ static int init_slots(struct controller *ctrl)
 					 slot->name);
 		if (retval) {
 			err("pci_hp_register failed with error %d\n", retval);
-			if (retval == -EEXIST)
-				err("Failed to register slot because of name "
-				    "collision. Try \'pciehp_slot_with_bus\' "
-				    "module option.\n");
 			goto error_info;
 		}
 		/* create additional sysfs entries */
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index ad27e9e..43ff979 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -1032,11 +1032,7 @@ static void pcie_shutdown_notification(struct controller *ctrl)
 
 static void make_slot_name(struct slot *slot)
 {
-	if (pciehp_slot_with_bus)
-		snprintf(slot->name, SLOT_NAME_SIZE, "%04d_%04d",
-			 slot->bus, slot->number);
-	else
-		snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number);
+	snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number);
 }
 
 static int pcie_init_slot(struct controller *ctrl)
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index 7bc06c0..136d9ea 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -39,7 +39,6 @@
 int shpchp_debug;
 int shpchp_poll_mode;
 int shpchp_poll_time;
-static int shpchp_slot_with_bus;
 struct workqueue_struct *shpchp_wq;
 
 #define DRIVER_VERSION	"0.4"
@@ -53,11 +52,9 @@ MODULE_LICENSE("GPL");
 module_param(shpchp_debug, bool, 0644);
 module_param(shpchp_poll_mode, bool, 0644);
 module_param(shpchp_poll_time, int, 0644);
-module_param(shpchp_slot_with_bus, bool, 0644);
 MODULE_PARM_DESC(shpchp_debug, "Debugging mode enabled or not");
 MODULE_PARM_DESC(shpchp_poll_mode, "Using polling mechanism for hot-plug events or not");
 MODULE_PARM_DESC(shpchp_poll_time, "Polling mechanism frequency, in seconds");
-MODULE_PARM_DESC(shpchp_slot_with_bus, "Use bus number in the slot name");
 
 #define SHPC_MODULE_NAME "shpchp"
 
@@ -101,12 +98,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 
 static void make_slot_name(struct slot *slot)
 {
-	if (shpchp_slot_with_bus)
-		snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%04d_%04d",
-			 slot->bus, slot->number);
-	else
-		snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%d",
-			 slot->number);
+	snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%d", slot->number);
 }
 
 static int init_slots(struct controller *ctrl)
@@ -162,10 +154,6 @@ static int init_slots(struct controller *ctrl)
 				hotplug_slot->name);
 		if (retval) {
 			err("pci_hp_register failed with error %d\n", retval);
-			if (retval == -EEXIST)
-				err("Failed to register slot because of name "
-                                    "collision. Try \'shpchp_slot_with_bus\' "
-				    "module option.\n");
 			goto error_info;
 		}
 
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
index 7e5b85c..42f0e12 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -73,6 +73,50 @@ static struct kobj_type pci_slot_ktype = {
 	.default_attrs = pci_slot_default_attrs,
 };
 
+static char *make_slot_name(const char *name)
+{
+	char *new_name;
+	int len, width, dup = 1;
+	struct kobject *dup_slot;
+
+	new_name = kstrdup(name, GFP_KERNEL);
+	if (!new_name)
+		goto out;
+
+	/*
+	 * Start off allocating enough room for "name-X"
+	 */
+	len = strlen(name) + 2;
+	width = 1;
+
+try_again:
+	dup_slot = kset_find_obj(pci_slots_kset, new_name);
+	if (!dup_slot)
+		goto out;
+
+	/*
+	 * We hit this the first time through, which gives us
+	 * space for terminating NULL, and then every power of 10
+	 * afterwards, which gives us space to add another digit
+	 * to "name-XX..."
+	 */
+	if (dup % width == 0) {
+		len++;
+		width *= 10;
+	}
+
+	new_name = krealloc(new_name, len, GFP_KERNEL);
+	if (!new_name)
+		goto out;
+
+	memset(new_name, 0, len);
+	snprintf(new_name, len, "%s-%d", name, dup++);
+	goto try_again;
+
+out:
+	return new_name;
+}
+
 /**
  * pci_create_slot - create or increment refcount for physical PCI slot
  * @parent: struct pci_bus of parent bridge
@@ -84,7 +128,19 @@ static struct kobj_type pci_slot_ktype = {
  * either return a new &struct pci_slot to the caller, or if the pci_slot
  * already exists, its refcount will be incremented.
  *
- * Slots are uniquely identified by a @pci_bus, @slot_nr, @name tuple.
+ * Slots are uniquely identified by a @pci_bus, @slot_nr tuple.
+ *
+ * The kobject API imposes a restriction on us, and does not allow sysfs
+ * entries with duplicate names. There are known platforms with broken
+ * firmware that assign the same name to multiple slots.
+ *
+ * We workaround these broken platforms by renaming the slots on behalf
+ * of the caller. If firmware assigns name N to multiple slots:
+ *
+ * The first slot is assigned N
+ * The second slot is assigned N-1
+ * The third slot is assigned N-2
+ * The Mth slot is assigned N-M
  *
  * Placeholder slots:
  * In most cases, @pci_bus, @slot_nr will be sufficient to uniquely identify
@@ -103,13 +159,13 @@ static struct kobj_type pci_slot_ktype = {
  * consist solely of a dddd:bb tuple, where dddd is the PCI domain of the
  * %struct pci_bus and bb is the bus number. In other words, the devfn of
  * the 'placeholder' slot will not be displayed.
- */
-
+ **/
 struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
 				 const char *name)
 {
 	struct pci_slot *slot;
-	int err;
+	int err = 0;
+	char *slot_name = NULL;
 
 	down_write(&pci_bus_sem);
 
@@ -138,12 +194,18 @@ placeholder:
 
 	slot->bus = parent;
 	slot->number = slot_nr;
-
 	slot->kobj.kset = pci_slots_kset;
+
+	slot_name = make_slot_name(name);
+	if (!slot_name) {
+		slot = ERR_PTR(-ENOMEM);
+		goto err;
+	}
+
 	err = kobject_init_and_add(&slot->kobj, &pci_slot_ktype, NULL,
-				   "%s", name);
+				   "%s", slot_name);
 	if (err) {
-		printk(KERN_ERR "Unable to register kobject %s\n", name);
+		printk(KERN_ERR "Unable to register kobject %s\n", slot_name);
 		goto err;
 	}
 
@@ -155,6 +217,8 @@ placeholder:
 		 __func__, pci_domain_nr(parent), parent->number, slot_nr);
 
  out:
+	if (slot_name)
+		kfree(slot_name);
 	up_write(&pci_bus_sem);
 	return slot;
  err:
@@ -172,23 +236,15 @@ EXPORT_SYMBOL_GPL(pci_create_slot);
  * The primary purpose of this interface is to allow callers who earlier
  * created a placeholder slot in pci_create_slot() by passing a -1 as
  * slot_nr, to update their %struct pci_slot with the correct @slot_nr.
- */
-
+ **/
 void pci_update_slot_number(struct pci_slot *slot, int slot_nr)
 {
-	int name_count = 0;
 	struct pci_slot *tmp;
 
 	down_write(&pci_bus_sem);
 
-	list_for_each_entry(tmp, &slot->bus->slots, list) {
+	list_for_each_entry(tmp, &slot->bus->slots, list)
 		WARN_ON(tmp->number == slot_nr);
-		if (!strcmp(kobject_name(&tmp->kobj), kobject_name(&slot->kobj)))
-			name_count++;
-	}
-
-	if (name_count > 1)
-		printk(KERN_WARNING "pci_update_slot_number found %d slots with the same name: %s\n", name_count, kobject_name(&slot->kobj));
 
 	slot->number = slot_nr;
 	up_write(&pci_bus_sem);
@@ -202,8 +258,7 @@ EXPORT_SYMBOL_GPL(pci_update_slot_number);
  * %struct pci_slot is refcounted, so destroying them is really easy; we
  * just call kobject_put on its kobj and let our release methods do the
  * rest.
- */
-
+ **/
 void pci_destroy_slot(struct pci_slot *slot)
 {
 	pr_debug("%s: dec refcount to %d on %04x:%02x:%02x\n", __func__,


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

* [PATCH 03/13] PCI, PCI Hotplug: introduce slot_name helpers
  2008-08-17  0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
  2008-08-17  0:15 ` [PATCH 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface Alex Chiang
  2008-08-17  0:16 ` [PATCH 02/13] PCI: prevent duplicate slot names Alex Chiang
@ 2008-08-17  0:16 ` Alex Chiang
  2008-08-17  0:16 ` [PATCH 04/13] PCI: acpiphp: remove 'name' parameter Alex Chiang
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-08-17  0:16 UTC (permalink / raw)
  To: linux-kernel, linux-pci
  Cc: jbarnes, kristen.c.accardi, matthew, kaneshige.kenji, Alex Chiang

In preparation for cleaning up the various hotplug drivers
such that they don't have to manage their own 'name' parameters
anymore, we provide the following convenience functions:

	pci_slot_name()
	hotplug_slot_name()

These helpers will be used by individual hotplug drivers.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: matthew@wil.cx
Cc: kaneshige.kenji@jp.fujitsu.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 include/linux/pci.h         |    5 +++++
 include/linux/pci_hotplug.h |    5 +++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/linux/pci.h b/include/linux/pci.h
index c0e1400..f33a5f6 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -64,6 +64,11 @@ struct pci_slot {
 	struct kobject kobj;
 };
 
+static inline const char *pci_slot_name(const struct pci_slot *slot)
+{
+	return kobject_name(&slot->kobj);
+}
+
 /* File state for mmap()s on /proc/bus/pci/X/Y */
 enum pci_mmap_state {
 	pci_mmap_io,
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index 303834b..7184bee 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -165,6 +165,11 @@ struct hotplug_slot {
 };
 #define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj)
 
+static inline const char *hotplug_slot_name(const struct hotplug_slot *slot)
+{
+	return pci_slot_name(slot->pci_slot);
+}
+
 extern int pci_hp_register(struct hotplug_slot *,
 			   struct pci_bus *,
 			   int nr,


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

* [PATCH 04/13] PCI: acpiphp: remove 'name' parameter
  2008-08-17  0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
                   ` (2 preceding siblings ...)
  2008-08-17  0:16 ` [PATCH 03/13] PCI, PCI Hotplug: introduce slot_name helpers Alex Chiang
@ 2008-08-17  0:16 ` Alex Chiang
  2008-08-17  8:59   ` Rolf Eike Beer
  2008-08-17  0:16 ` [PATCH 05/13] PCI: cpci_hotplug: stop managing hotplug_slot->name Alex Chiang
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 55+ messages in thread
From: Alex Chiang @ 2008-08-17  0:16 UTC (permalink / raw)
  To: linux-kernel, linux-pci
  Cc: jbarnes, kristen.c.accardi, kaneshige.kenji, Alex Chiang

We do not need to manage our own name parameter, especially since
the PCI core can change it on our behalf, in the case of duplicate
slot names.

Remove 'name' from acpiphp's version of struct slot.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: kaneshige.kenji@jp.fujitsu.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/acpiphp.h      |    9 +++++----
 drivers/pci/hotplug/acpiphp_core.c |   36 +++++++++++++++++++-----------------
 2 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index 5a58b07..f9e244d 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -50,9 +50,6 @@
 #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
 #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
 
-/* name size which is used for entries in pcihpfs */
-#define SLOT_NAME_SIZE	20		/* {_SUN} */
-
 struct acpiphp_bridge;
 struct acpiphp_slot;
 
@@ -63,9 +60,13 @@ struct slot {
 	struct hotplug_slot	*hotplug_slot;
 	struct acpiphp_slot	*acpi_slot;
 	struct hotplug_slot_info info;
-	char name[SLOT_NAME_SIZE];
 };
 
+static inline const char *slot_name(struct slot *slot)
+{
+	return hotplug_slot_name(slot->hotplug_slot);
+}
+
 /*
  * struct acpiphp_bridge - PCI bridge information
  *
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index e984176..687cac3 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -44,6 +44,9 @@
 
 #define MY_NAME	"acpiphp"
 
+/* name size which is used for entries in pcihpfs */
+#define SLOT_NAME_SIZE  20              /* {_SUN} */
+
 static int debug;
 int acpiphp_debug;
 
@@ -84,7 +87,6 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops = {
 	.get_adapter_status	= get_adapter_status,
 };
 
-
 /**
  * acpiphp_register_attention - set attention LED callback
  * @info: must be completely filled with LED callbacks
@@ -92,7 +94,7 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops = {
  * Description: This is used to register a hardware specific ACPI
  * driver that manipulates the attention LED.  All the fields in
  * info must be set.
- */
+ **/
 int acpiphp_register_attention(struct acpiphp_attention_info *info)
 {
 	int retval = -EINVAL;
@@ -113,7 +115,7 @@ int acpiphp_register_attention(struct acpiphp_attention_info *info)
  * Description: This is used to un-register a hardware specific acpi
  * driver that manipulates the attention LED.  The pointer to the 
  * info struct must be the same as the one used to set it.
- */
+ **/
 int acpiphp_unregister_attention(struct acpiphp_attention_info *info)
 {
 	int retval = -EINVAL;
@@ -136,7 +138,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	/* enable the specified slot */
 	return acpiphp_enable_slot(slot->acpi_slot);
@@ -154,7 +156,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
 	struct slot *slot = hotplug_slot->private;
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	/* disable the specified slot */
 	retval = acpiphp_disable_slot(slot->acpi_slot);
@@ -177,7 +179,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
  {
 	int retval = -ENODEV;
 
- 	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot_name(hotplug_slot));
  
 	if (attention_info && try_module_get(attention_info->owner)) {
 		retval = attention_info->set_attn(hotplug_slot, status);
@@ -200,7 +202,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = acpiphp_get_power_status(slot->acpi_slot);
 
@@ -222,7 +224,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
 	int retval = -EINVAL;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot_name(hotplug_slot));
 
 	if (attention_info && try_module_get(attention_info->owner)) {
 		retval = attention_info->get_attn(hotplug_slot, value);
@@ -245,7 +247,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = acpiphp_get_latch_status(slot->acpi_slot);
 
@@ -265,7 +267,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = acpiphp_get_adapter_status(slot->acpi_slot);
 
@@ -299,7 +301,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	kfree(slot->hotplug_slot);
 	kfree(slot);
@@ -310,6 +312,7 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
 {
 	struct slot *slot;
 	int retval = -ENOMEM;
+	char name[SLOT_NAME_SIZE];
 
 	slot = kzalloc(sizeof(*slot), GFP_KERNEL);
 	if (!slot)
@@ -321,8 +324,6 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
 
 	slot->hotplug_slot->info = &slot->info;
 
-	slot->hotplug_slot->name = slot->name;
-
 	slot->hotplug_slot->private = slot;
 	slot->hotplug_slot->release = &release_slot;
 	slot->hotplug_slot->ops = &acpi_hotplug_slot_ops;
@@ -336,12 +337,13 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
 	slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
 
 	acpiphp_slot->slot = slot;
-	snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun);
+	memset(name, 0, SLOT_NAME_SIZE);
+	snprintf(name, SLOT_NAME_SIZE, "%u", slot->acpi_slot->sun);
 
 	retval = pci_hp_register(slot->hotplug_slot,
 					acpiphp_slot->bridge->pci_bus,
 					acpiphp_slot->device,
-					slot->name);
+					name);
 	if (retval == -EBUSY)
 		goto error_hpslot;
 	if (retval) {
@@ -349,7 +351,7 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
 		goto error_hpslot;
  	}
 
-	info("Slot [%s] registered\n", slot->hotplug_slot->name);
+	info("Slot [%s] registered\n", slot_name(slot));
 
 	return 0;
 error_hpslot:
@@ -366,7 +368,7 @@ void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
 	struct slot *slot = acpiphp_slot->slot;
 	int retval = 0;
 
-	info ("Slot [%s] unregistered\n", slot->hotplug_slot->name);
+	info ("Slot [%s] unregistered\n", slot_name(slot));
 
 	retval = pci_hp_deregister(slot->hotplug_slot);
 	if (retval)


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

* [PATCH 05/13] PCI: cpci_hotplug: stop managing hotplug_slot->name
  2008-08-17  0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
                   ` (3 preceding siblings ...)
  2008-08-17  0:16 ` [PATCH 04/13] PCI: acpiphp: remove 'name' parameter Alex Chiang
@ 2008-08-17  0:16 ` Alex Chiang
  2008-08-17  0:16 ` [PATCH 06/13] PCI: cpqphp: " Alex Chiang
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-08-17  0:16 UTC (permalink / raw)
  To: linux-kernel, linux-pci; +Cc: jbarnes, kristen.c.accardi, scottm, Alex Chiang

We no longer need to manage our version of hotplug_slot->name
since the PCI and hotplug core manage it on our behalf.

Now, we simply advise the PCI core of the name that we would
like, and let the core take care of the rest.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: scottm@somanetworks.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/cpci_hotplug.h      |    6 ++
 drivers/pci/hotplug/cpci_hotplug_core.c |   76 ++++++++++++-------------------
 drivers/pci/hotplug/cpci_hotplug_pci.c  |    4 +-
 3 files changed, 37 insertions(+), 49 deletions(-)

diff --git a/drivers/pci/hotplug/cpci_hotplug.h b/drivers/pci/hotplug/cpci_hotplug.h
index d9769b3..9fff878 100644
--- a/drivers/pci/hotplug/cpci_hotplug.h
+++ b/drivers/pci/hotplug/cpci_hotplug.h
@@ -30,6 +30,7 @@
 
 #include <linux/types.h>
 #include <linux/pci.h>
+#include <linux/pci_hotplug.h>
 
 /* PICMG 2.1 R2.0 HS CSR bits: */
 #define HS_CSR_INS	0x0080
@@ -69,6 +70,11 @@ struct cpci_hp_controller {
 	struct cpci_hp_controller_ops *ops;
 };
 
+static inline const char *slot_name(struct slot *slot)
+{
+	return hotplug_slot_name(slot->hotplug_slot);
+}
+
 extern int cpci_hp_register_controller(struct cpci_hp_controller *controller);
 extern int cpci_hp_unregister_controller(struct cpci_hp_controller *controller);
 extern int cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last);
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index 5e5dee8..f4294bc 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -108,7 +108,7 @@ enable_slot(struct hotplug_slot *hotplug_slot)
 	struct slot *slot = hotplug_slot->private;
 	int retval = 0;
 
-	dbg("%s - physical_slot = %s", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s", __func__, slot_name(slot));
 
 	if (controller->ops->set_power)
 		retval = controller->ops->set_power(slot, 1);
@@ -121,25 +121,23 @@ disable_slot(struct hotplug_slot *hotplug_slot)
 	struct slot *slot = hotplug_slot->private;
 	int retval = 0;
 
-	dbg("%s - physical_slot = %s", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s", __func__, slot_name(slot));
 
 	down_write(&list_rwsem);
 
 	/* Unconfigure device */
-	dbg("%s - unconfiguring slot %s",
-	    __func__, slot->hotplug_slot->name);
+	dbg("%s - unconfiguring slot %s", __func__, slot_name(slot));
 	if ((retval = cpci_unconfigure_slot(slot))) {
 		err("%s - could not unconfigure slot %s",
-		    __func__, slot->hotplug_slot->name);
+		    __func__, slot_name(slot));
 		goto disable_error;
 	}
-	dbg("%s - finished unconfiguring slot %s",
-	    __func__, slot->hotplug_slot->name);
+	dbg("%s - finished unconfiguring slot %s", __func__, slot_name(slot));
 
 	/* Clear EXT (by setting it) */
 	if (cpci_clear_ext(slot)) {
 		err("%s - could not clear EXT for slot %s",
-		    __func__, slot->hotplug_slot->name);
+		    __func__, slot_name(slot));
 		retval = -ENODEV;
 		goto disable_error;
 	}
@@ -214,7 +212,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 	struct slot *slot = hotplug_slot->private;
 
 	kfree(slot->hotplug_slot->info);
-	kfree(slot->hotplug_slot->name);
 	kfree(slot->hotplug_slot);
 	if (slot->dev)
 		pci_dev_put(slot->dev);
@@ -222,12 +219,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 }
 
 #define SLOT_NAME_SIZE	6
-static void
-make_slot_name(struct slot *slot)
-{
-	snprintf(slot->hotplug_slot->name,
-		 SLOT_NAME_SIZE, "%02x:%02x", slot->bus->number, slot->number);
-}
 
 int
 cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
@@ -235,7 +226,7 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
 	struct slot *slot;
 	struct hotplug_slot *hotplug_slot;
 	struct hotplug_slot_info *info;
-	char *name;
+	char name[SLOT_NAME_SIZE];
 	int status = -ENOMEM;
 	int i;
 
@@ -262,34 +253,30 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
 			goto error_hpslot;
 		hotplug_slot->info = info;
 
-		name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
-		if (!name)
-			goto error_info;
-		hotplug_slot->name = name;
-
 		slot->bus = bus;
 		slot->number = i;
 		slot->devfn = PCI_DEVFN(i, 0);
 
+		memset(name, 0, SLOT_NAME_SIZE);
+		snprintf(name, SLOT_NAME_SIZE, "%02x:%02x", bus->number, i);
+
 		hotplug_slot->private = slot;
 		hotplug_slot->release = &release_slot;
-		make_slot_name(slot);
 		hotplug_slot->ops = &cpci_hotplug_slot_ops;
 
 		/*
 		 * Initialize the slot info structure with some known
 		 * good values.
 		 */
-		dbg("initializing slot %s", slot->hotplug_slot->name);
+		dbg("initializing slot %s", slot_name(slot));
 		info->power_status = cpci_get_power_status(slot);
 		info->attention_status = cpci_get_attention_status(slot);
 
-		dbg("registering slot %s", slot->hotplug_slot->name);
-		status = pci_hp_register(slot->hotplug_slot, bus, i,
-					 slot->hotplug_slot->name);
+		dbg("registering slot %s", slot_name(slot));
+		status = pci_hp_register(slot->hotplug_slot, bus, i, name);
 		if (status) {
 			err("pci_hp_register failed with error %d", status);
-			goto error_name;
+			goto error_info;
 		}
 
 		/* Add slot to our internal list */
@@ -299,8 +286,6 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
 		up_write(&list_rwsem);
 	}
 	return 0;
-error_name:
-	kfree(name);
 error_info:
 	kfree(info);
 error_hpslot:
@@ -328,7 +313,7 @@ cpci_hp_unregister_bus(struct pci_bus *bus)
 			list_del(&slot->slot_list);
 			slots--;
 
-			dbg("deregistering slot %s", slot->hotplug_slot->name);
+			dbg("deregistering slot %s", slot_name(slot));
 			status = pci_hp_deregister(slot->hotplug_slot);
 			if (status) {
 				err("pci_hp_deregister failed with error %d",
@@ -380,11 +365,10 @@ init_slots(int clear_ins)
 		return -1;
 	}
 	list_for_each_entry(slot, &slot_list, slot_list) {
-		dbg("%s - looking at slot %s",
-		    __func__, slot->hotplug_slot->name);
+		dbg("%s - looking at slot %s", __func__, slot_name(slot));
 		if (clear_ins && cpci_check_and_clear_ins(slot))
 			dbg("%s - cleared INS for slot %s",
-			    __func__, slot->hotplug_slot->name);
+			    __func__, slot_name(slot));
 		dev = pci_get_slot(slot->bus, PCI_DEVFN(slot->number, 0));
 		if (dev) {
 			if (update_adapter_status(slot->hotplug_slot, 1))
@@ -415,8 +399,7 @@ check_slots(void)
 	}
 	extracted = inserted = 0;
 	list_for_each_entry(slot, &slot_list, slot_list) {
-		dbg("%s - looking at slot %s",
-		    __func__, slot->hotplug_slot->name);
+		dbg("%s - looking at slot %s", __func__, slot_name(slot));
 		if (cpci_check_and_clear_ins(slot)) {
 			/*
 			 * Some broken hardware (e.g. PLX 9054AB) asserts
@@ -424,35 +407,34 @@ check_slots(void)
 			 */
 			if (slot->dev) {
 				warn("slot %s already inserted",
-				     slot->hotplug_slot->name);
+				     slot_name(slot));
 				inserted++;
 				continue;
 			}
 
 			/* Process insertion */
-			dbg("%s - slot %s inserted",
-			    __func__, slot->hotplug_slot->name);
+			dbg("%s - slot %s inserted", __func__, slot_name(slot));
 
 			/* GSM, debug */
 			hs_csr = cpci_get_hs_csr(slot);
 			dbg("%s - slot %s HS_CSR (1) = %04x",
-			    __func__, slot->hotplug_slot->name, hs_csr);
+			    __func__, slot_name(slot), hs_csr);
 
 			/* Configure device */
 			dbg("%s - configuring slot %s",
-			    __func__, slot->hotplug_slot->name);
+			    __func__, slot_name(slot));
 			if (cpci_configure_slot(slot)) {
 				err("%s - could not configure slot %s",
-				    __func__, slot->hotplug_slot->name);
+				    __func__, slot_name(slot));
 				continue;
 			}
 			dbg("%s - finished configuring slot %s",
-			    __func__, slot->hotplug_slot->name);
+			    __func__, slot_name(slot));
 
 			/* GSM, debug */
 			hs_csr = cpci_get_hs_csr(slot);
 			dbg("%s - slot %s HS_CSR (2) = %04x",
-			    __func__, slot->hotplug_slot->name, hs_csr);
+			    __func__, slot_name(slot), hs_csr);
 
 			if (update_latch_status(slot->hotplug_slot, 1))
 				warn("failure to update latch file");
@@ -465,18 +447,18 @@ check_slots(void)
 			/* GSM, debug */
 			hs_csr = cpci_get_hs_csr(slot);
 			dbg("%s - slot %s HS_CSR (3) = %04x",
-			    __func__, slot->hotplug_slot->name, hs_csr);
+			    __func__, slot_name(slot), hs_csr);
 
 			inserted++;
 		} else if (cpci_check_ext(slot)) {
 			/* Process extraction request */
 			dbg("%s - slot %s extracted",
-			    __func__, slot->hotplug_slot->name);
+			    __func__, slot_name(slot));
 
 			/* GSM, debug */
 			hs_csr = cpci_get_hs_csr(slot);
 			dbg("%s - slot %s HS_CSR = %04x",
-			    __func__, slot->hotplug_slot->name, hs_csr);
+			    __func__, slot_name(slot), hs_csr);
 
 			if (!slot->extracting) {
 				if (update_latch_status(slot->hotplug_slot, 0)) {
@@ -494,7 +476,7 @@ check_slots(void)
 				 * bother trying to tell the driver or not?
 				 */
 				err("card in slot %s was improperly removed",
-				    slot->hotplug_slot->name);
+				    slot_name(slot));
 				if (update_adapter_status(slot->hotplug_slot, 0))
 					warn("failure to update adapter file");
 				slot->extracting = 0;
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c
index df82b95..829c327 100644
--- a/drivers/pci/hotplug/cpci_hotplug_pci.c
+++ b/drivers/pci/hotplug/cpci_hotplug_pci.c
@@ -209,7 +209,7 @@ int cpci_led_on(struct slot* slot)
 					      hs_cap + 2,
 					      hs_csr)) {
 			err("Could not set LOO for slot %s",
-			    slot->hotplug_slot->name);
+			    hotplug_slot_name(slot->hotplug_slot));
 			return -ENODEV;
 		}
 	}
@@ -238,7 +238,7 @@ int cpci_led_off(struct slot* slot)
 					      hs_cap + 2,
 					      hs_csr)) {
 			err("Could not clear LOO for slot %s",
-			    slot->hotplug_slot->name);
+			    hotplug_slot_name(slot->hotplug_slot));
 			return -ENODEV;
 		}
 	}


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

* [PATCH 06/13] PCI: cpqphp: stop managing hotplug_slot->name
  2008-08-17  0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
                   ` (4 preceding siblings ...)
  2008-08-17  0:16 ` [PATCH 05/13] PCI: cpci_hotplug: stop managing hotplug_slot->name Alex Chiang
@ 2008-08-17  0:16 ` Alex Chiang
  2008-08-17  0:17 ` [PATCH 07/13] PCI: fakephp: remove 'name' parameter Alex Chiang
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-08-17  0:16 UTC (permalink / raw)
  To: linux-kernel, linux-pci; +Cc: jbarnes, kristen.c.accardi, Alex Chiang

We no longer need to manage our version of hotplug_slot->name
since the PCI and hotplug core manage it on our behalf.

Now, we simply advise the PCI core of the name that we would
like, and let the core take care of the rest.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/cpqphp.h      |   13 +++++-------
 drivers/pci/hotplug/cpqphp_core.c |   40 ++++++++++++++++++-------------------
 2 files changed, 24 insertions(+), 29 deletions(-)

diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h
index b1decfa..afaf8f6 100644
--- a/drivers/pci/hotplug/cpqphp.h
+++ b/drivers/pci/hotplug/cpqphp.h
@@ -449,6 +449,11 @@ extern u8 cpqhp_disk_irq;
 
 /* inline functions */
 
+static inline char *slot_name(struct slot *slot)
+{
+	return hotplug_slot_name(slot->hotplug_slot);
+}
+
 /*
  * return_resource
  *
@@ -696,14 +701,6 @@ static inline int get_presence_status(struct controller *ctrl, struct slot *slot
 	return presence_save;
 }
 
-#define SLOT_NAME_SIZE 10
-
-static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot)
-{
-	snprintf(buffer, buffer_size, "%d", slot->number);
-}
-
-
 static inline int wait_for_ctrl_irq(struct controller *ctrl)
 {
         DECLARE_WAITQUEUE(wait, current);
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index a7fe458..a08fa11 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -315,14 +315,15 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	kfree(slot->hotplug_slot->info);
-	kfree(slot->hotplug_slot->name);
 	kfree(slot->hotplug_slot);
 	kfree(slot);
 }
 
+#define SLOT_NAME_SIZE 10
+
 static int ctrl_slot_setup(struct controller *ctrl,
 			void __iomem *smbios_start,
 			void __iomem *smbios_table)
@@ -335,6 +336,7 @@ static int ctrl_slot_setup(struct controller *ctrl,
 	u8 slot_number;
 	u8 ctrl_slot;
 	u32 tempdword;
+	char name[SLOT_NAME_SIZE];
 	void __iomem *slot_entry= NULL;
 	int result = -ENOMEM;
 
@@ -363,10 +365,6 @@ static int ctrl_slot_setup(struct controller *ctrl,
 		if (!hotplug_slot->info)
 			goto error_hpslot;
 		hotplug_slot_info = hotplug_slot->info;
-		hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
-
-		if (!hotplug_slot->name)
-			goto error_info;
 
 		slot->ctrl = ctrl;
 		slot->bus = ctrl->bus;
@@ -418,8 +416,10 @@ static int ctrl_slot_setup(struct controller *ctrl,
 		/* register this slot with the hotplug pci core */
 		hotplug_slot->release = &release_slot;
 		hotplug_slot->private = slot;
-		make_slot_name(hotplug_slot->name, SLOT_NAME_SIZE, slot);
 		hotplug_slot->ops = &cpqphp_hotplug_slot_ops;
+
+		memset(name, 0, SLOT_NAME_SIZE);
+		snprintf(name, SLOT_NAME_SIZE, "%d", slot->number);
 		
 		hotplug_slot_info->power_status = get_slot_enabled(ctrl, slot);
 		hotplug_slot_info->attention_status =
@@ -437,10 +437,10 @@ static int ctrl_slot_setup(struct controller *ctrl,
 		result = pci_hp_register(hotplug_slot,
 					 ctrl->pci_dev->subordinate,
 					 slot->device,
-					 hotplug_slot->name);
+					 name);
 		if (result) {
 			err("pci_hp_register failed with error %d\n", result);
-			goto error_name;
+			goto error_info;
 		}
 		
 		slot->next = ctrl->slot;
@@ -452,8 +452,6 @@ static int ctrl_slot_setup(struct controller *ctrl,
 	}
 
 	return 0;
-error_name:
-	kfree(hotplug_slot->name);
 error_info:
 	kfree(hotplug_slot_info);
 error_hpslot:
@@ -639,7 +637,7 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status)
 	u8 device;
 	u8 function;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	if (cpqhp_get_bus_dev(ctrl, &bus, &devfn, slot->number) == -1)
 		return -ENODEV;
@@ -666,7 +664,7 @@ static int process_SI(struct hotplug_slot *hotplug_slot)
 	u8 device;
 	u8 function;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	if (cpqhp_get_bus_dev(ctrl, &bus, &devfn, slot->number) == -1)
 		return -ENODEV;
@@ -698,7 +696,7 @@ static int process_SS(struct hotplug_slot *hotplug_slot)
 	u8 device;
 	u8 function;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	if (cpqhp_get_bus_dev(ctrl, &bus, &devfn, slot->number) == -1)
 		return -ENODEV;
@@ -721,7 +719,7 @@ static int hardware_test(struct hotplug_slot *hotplug_slot, u32 value)
 	struct slot *slot = hotplug_slot->private;
 	struct controller *ctrl = slot->ctrl;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	return cpqhp_hardware_test(ctrl, value);	
 }
@@ -732,7 +730,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	struct controller *ctrl = slot->ctrl;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = get_slot_enabled(ctrl, slot);
 	return 0;
@@ -743,7 +741,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	struct controller *ctrl = slot->ctrl;
 	
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = cpq_get_attention_status(ctrl, slot);
 	return 0;
@@ -754,7 +752,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	struct controller *ctrl = slot->ctrl;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = cpq_get_latch_status(ctrl, slot);
 
@@ -766,7 +764,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	struct controller *ctrl = slot->ctrl;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = get_presence_status(ctrl, slot);
 
@@ -778,7 +776,7 @@ static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp
 	struct slot *slot = hotplug_slot->private;
 	struct controller *ctrl = slot->ctrl;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = ctrl->speed_capability;
 
@@ -790,7 +788,7 @@ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp
 	struct slot *slot = hotplug_slot->private;
 	struct controller *ctrl = slot->ctrl;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = ctrl->speed;
 


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

* [PATCH 07/13] PCI: fakephp: remove 'name' parameter
  2008-08-17  0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
                   ` (5 preceding siblings ...)
  2008-08-17  0:16 ` [PATCH 06/13] PCI: cpqphp: " Alex Chiang
@ 2008-08-17  0:17 ` Alex Chiang
  2008-08-17  0:17 ` [PATCH 08/13] PCI: ibmphp: stop managing hotplug_slot->name Alex Chiang
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-08-17  0:17 UTC (permalink / raw)
  To: linux-kernel, linux-pci; +Cc: jbarnes, kristen.c.accardi, Alex Chiang

Remove 'name' from fakephp's struct dummy_slot, as the PCI core
will now manage our slot name for us.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/fakephp.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index f1c1817..3a02016 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -66,7 +66,6 @@ struct dummy_slot {
 	struct pci_dev *dev;
 	struct work_struct remove_work;
 	unsigned long removed;
-	char name[8];
 };
 
 static int debug;
@@ -96,10 +95,13 @@ static void dummy_release(struct hotplug_slot *slot)
 	kfree(dslot);
 }
 
+#define SLOT_NAME_SIZE	8
+
 static int add_slot(struct pci_dev *dev)
 {
 	struct dummy_slot *dslot;
 	struct hotplug_slot *slot;
+	char name[SLOT_NAME_SIZE];
 	int retval = -ENOMEM;
 	static int count = 1;
 
@@ -119,15 +121,14 @@ static int add_slot(struct pci_dev *dev)
 	if (!dslot)
 		goto error_info;
 
-	slot->name = dslot->name;
-	snprintf(slot->name, sizeof(dslot->name), "fake%d", count++);
-	dbg("slot->name = %s\n", slot->name);
+	memset(name, 0, SLOT_NAME_SIZE);
+	snprintf(name, SLOT_NAME_SIZE, "fake%d", count++);
+	dbg("slot->name = %s\n", name);
 	slot->ops = &dummy_hotplug_slot_ops;
 	slot->release = &dummy_release;
 	slot->private = dslot;
 
-	retval = pci_hp_register(slot, dev->bus, PCI_SLOT(dev->devfn),
-				 slot->name);
+	retval = pci_hp_register(slot, dev->bus, PCI_SLOT(dev->devfn), name);
 	if (retval) {
 		err("pci_hp_register failed with error %d\n", retval);
 		goto error_dslot;
@@ -168,10 +169,11 @@ static void remove_slot(struct dummy_slot *dslot)
 {
 	int retval;
 
-	dbg("removing slot %s\n", dslot->slot->name);
+	dbg("removing slot %s\n", hotplug_slot_name(dslot->slot));
 	retval = pci_hp_deregister(dslot->slot);
 	if (retval)
-		err("Problem unregistering a slot %s\n", dslot->slot->name);
+		err("Problem unregistering a slot %s\n",
+			hotplug_slot_name(dslot->slot));
 }
 
 /* called from the single-threaded workqueue handler to remove a slot */
@@ -309,7 +311,7 @@ static int disable_slot(struct hotplug_slot *slot)
 		return -ENODEV;
 	dslot = slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot_name(slot));
 
 	for (func = 7; func >= 0; func--) {
 		dev = pci_get_slot(dslot->dev->bus, dslot->dev->devfn + func);


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

* [PATCH 08/13] PCI: ibmphp: stop managing hotplug_slot->name
  2008-08-17  0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
                   ` (6 preceding siblings ...)
  2008-08-17  0:17 ` [PATCH 07/13] PCI: fakephp: remove 'name' parameter Alex Chiang
@ 2008-08-17  0:17 ` Alex Chiang
  2008-08-17  0:17 ` [PATCH 09/13] PCI: pciehp: remove 'name' parameter Alex Chiang
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-08-17  0:17 UTC (permalink / raw)
  To: linux-kernel, linux-pci; +Cc: jbarnes, kristen.c.accardi, Alex Chiang

We no longer need to manage our version of hotplug_slot->name
since the PCI and hotplug core manage it on our behalf.

Now, we simply advise the PCI core of the name that we would
like, and let the core take care of the rest.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/ibmphp.h      |    5 ++---
 drivers/pci/hotplug/ibmphp_ebda.c |   21 ++++++++-------------
 2 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h
index 612d963..a8d391a 100644
--- a/drivers/pci/hotplug/ibmphp.h
+++ b/drivers/pci/hotplug/ibmphp.h
@@ -707,17 +707,16 @@ struct slot {
 	u8 device;
 	u8 number;
 	u8 real_physical_slot_num;
-	char name[100];
 	u32 capabilities;
 	u8 supported_speed;
 	u8 supported_bus_mode;
+	u8 flag;		/* this is for disable slot and polling */
+	u8 ctlr_index;
 	struct hotplug_slot *hotplug_slot;
 	struct controller *ctrl;
 	struct pci_func *func;
 	u8 irq[4];
-	u8 flag;		/* this is for disable slot and polling */
 	int bit_mode;		/* 0 = 32, 1 = 64 */
-	u8 ctlr_index;
 	struct bus_info *bus_on;
 	struct list_head ibm_slot_list;
 	u8 status;
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
index 46deff3..7114c8a 100644
--- a/drivers/pci/hotplug/ibmphp_ebda.c
+++ b/drivers/pci/hotplug/ibmphp_ebda.c
@@ -620,11 +620,14 @@ static u8 calculate_first_slot (u8 slot_num)
 	return first_slot + 1;
 
 }
+
+#define SLOT_NAME_SIZE 30
+
 static char *create_file_name (struct slot * slot_cur)
 {
 	struct opt_rio *opt_vg_ptr = NULL;
 	struct opt_rio_lo *opt_lo_ptr = NULL;
-	static char str[30];
+	static char str[SLOT_NAME_SIZE];
 	int which = 0; /* rxe = 1, chassis = 0 */
 	u8 number = 1; /* either chassis or rxe # */
 	u8 first_slot = 1;
@@ -736,7 +739,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 
 	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;
@@ -768,6 +770,7 @@ static int __init ebda_rsrc_controller (void)
 	int rc;
 	struct slot *tmp_slot;
 	struct list_head *list;
+	char name[SLOT_NAME_SIZE];
 
 	addr = hpc_list_ptr->phys_addr;
 	for (ctlr = 0; ctlr < hpc_list_ptr->num_ctlrs; ctlr++) {
@@ -931,12 +934,6 @@ static int __init ebda_rsrc_controller (void)
 				goto error_no_hp_info;
 			}
 
-			hp_slot_ptr->name = kmalloc(30, GFP_KERNEL);
-			if (!hp_slot_ptr->name) {
-				rc = -ENOMEM;
-				goto error_no_hp_name;
-			}
-
 			tmp_slot = kzalloc(sizeof(*tmp_slot), GFP_KERNEL);
 			if (!tmp_slot) {
 				rc = -ENOMEM;
@@ -1000,10 +997,10 @@ static int __init ebda_rsrc_controller (void)
 	list_for_each (list, &ibmphp_slot_head) {
 		tmp_slot = list_entry (list, struct slot, ibm_slot_list);
 
-		snprintf (tmp_slot->hotplug_slot->name, 30, "%s", create_file_name (tmp_slot));
+		memset(name, 0, SLOT_NAME_SIZE);
+		snprintf(name, SLOT_NAME_SIZE, "%s", create_file_name(tmp_slot));
 		pci_hp_register(tmp_slot->hotplug_slot,
-			pci_find_bus(0, tmp_slot->bus), tmp_slot->device,
-			tmp_slot->hotplug_slot->name);
+			pci_find_bus(0, tmp_slot->bus), tmp_slot->device, name);
 	}
 
 	print_ebda_hpc ();
@@ -1013,8 +1010,6 @@ static int __init ebda_rsrc_controller (void)
 error:
 	kfree (hp_slot_ptr->private);
 error_no_slot:
-	kfree (hp_slot_ptr->name);
-error_no_hp_name:
 	kfree (hp_slot_ptr->info);
 error_no_hp_info:
 	kfree (hp_slot_ptr);


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

* [PATCH 09/13] PCI: pciehp: remove 'name' parameter
  2008-08-17  0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
                   ` (7 preceding siblings ...)
  2008-08-17  0:17 ` [PATCH 08/13] PCI: ibmphp: stop managing hotplug_slot->name Alex Chiang
@ 2008-08-17  0:17 ` Alex Chiang
  2008-08-17  0:17 ` [PATCH 10/13] PCI: rpaphp: stop managing hotplug_slot->name Alex Chiang
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-08-17  0:17 UTC (permalink / raw)
  To: linux-kernel, linux-pci
  Cc: jbarnes, kristen.c.accardi, kaneshige.kenji, Alex Chiang

We do not need to manage our own name parameter, especially since
the PCI core can change it on our behalf, in the case of duplicate
slot names.

Remove 'name' from pciehp's version of struct slot.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: kaneshige.kenji@jp.fujitsu.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/pciehp.h      |   10 +++++---
 drivers/pci/hotplug/pciehp_core.c |   26 +++++++++++---------
 drivers/pci/hotplug/pciehp_ctrl.c |   48 +++++++++++++++++++------------------
 drivers/pci/hotplug/pciehp_hpc.c  |    6 -----
 4 files changed, 45 insertions(+), 45 deletions(-)

diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 9e6cec6..6bb0f16 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -61,15 +61,14 @@ extern struct workqueue_struct *pciehp_wq;
 struct slot {
 	u8 bus;
 	u8 device;
-	u32 number;
 	u8 state;
-	struct timer_list task_event;
 	u8 hp_slot;
+	u32 number;
+	struct timer_list task_event;
 	struct controller *ctrl;
 	struct hpc_ops *hpc_ops;
 	struct hotplug_slot *hotplug_slot;
 	struct list_head	slot_list;
-	char name[SLOT_NAME_SIZE];
 	unsigned long last_emi_toggle;
 	struct delayed_work work;	/* work for button event */
 	struct mutex lock;
@@ -161,6 +160,11 @@ int pciehp_enable_slot(struct slot *p_slot);
 int pciehp_disable_slot(struct slot *p_slot);
 int pcie_enable_notification(struct controller *ctrl);
 
+static inline const char *slot_name(struct slot *slot)
+{
+	return hotplug_slot_name(slot->hotplug_slot);
+}
+
 static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
 {
 	struct slot *slot;
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index bed77af..45715d3 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -180,7 +180,7 @@ static struct hotplug_slot_attribute hotplug_slot_attr_lock = {
  */
 static void release_slot(struct hotplug_slot *hotplug_slot)
 {
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot_name(hotplug_slot));
 
 	kfree(hotplug_slot->info);
 	kfree(hotplug_slot);
@@ -191,6 +191,7 @@ static int init_slots(struct controller *ctrl)
 	struct slot *slot;
 	struct hotplug_slot *hotplug_slot;
 	struct hotplug_slot_info *info;
+	char name[SLOT_NAME_SIZE];
 	int retval = -ENOMEM;
 
 	list_for_each_entry(slot, &ctrl->slot_list, slot_list) {
@@ -204,7 +205,6 @@ static int init_slots(struct controller *ctrl)
 
 		/* register this slot with the hotplug pci core */
 		hotplug_slot->info = info;
-		hotplug_slot->name = slot->name;
 		hotplug_slot->private = slot;
 		hotplug_slot->release = &release_slot;
 		hotplug_slot->ops = &pciehp_hotplug_slot_ops;
@@ -213,6 +213,8 @@ static int init_slots(struct controller *ctrl)
 		get_latch_status(hotplug_slot, &info->latch_status);
 		get_adapter_status(hotplug_slot, &info->adapter_status);
 		slot->hotplug_slot = hotplug_slot;
+		memset(name, 0, SLOT_NAME_SIZE);
+		snprintf(name, SLOT_NAME_SIZE, "%d", slot->number);
 
 		dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x "
 		    "slot_device_offset=%x\n", slot->bus, slot->device,
@@ -220,7 +222,7 @@ static int init_slots(struct controller *ctrl)
 		retval = pci_hp_register(hotplug_slot,
 					 ctrl->pci_dev->subordinate,
 					 slot->device,
-					 slot->name);
+					 name);
 		if (retval) {
 			err("pci_hp_register failed with error %d\n", retval);
 			goto error_info;
@@ -265,7 +267,7 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	hotplug_slot->info->attention_status = status;
 
@@ -280,7 +282,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	return pciehp_sysfs_enable_slot(slot);
 }
@@ -290,7 +292,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	return pciehp_sysfs_disable_slot(slot);
 }
@@ -300,7 +302,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_power_status(slot, value);
 	if (retval < 0)
@@ -314,7 +316,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_attention_status(slot, value);
 	if (retval < 0)
@@ -328,7 +330,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_latch_status(slot, value);
 	if (retval < 0)
@@ -342,7 +344,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_adapter_status(slot, value);
 	if (retval < 0)
@@ -357,7 +359,7 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot,
 	struct slot *slot = hotplug_slot->private;
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_max_bus_speed(slot, value);
 	if (retval < 0)
@@ -371,7 +373,7 @@ static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
 	struct slot *slot = hotplug_slot->private;
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_cur_bus_speed(slot, value);
 	if (retval < 0)
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 96a5d55..7266fbd 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -65,7 +65,7 @@ u8 pciehp_handle_attention_button(struct slot *p_slot)
 	/*
 	 *  Button pressed - See if need to TAKE ACTION!!!
 	 */
-	info("Button pressed on Slot(%s)\n", p_slot->name);
+	info("Button pressed on Slot(%s)\n", slot_name(p_slot));
 	event_type = INT_BUTTON_PRESS;
 
 	queue_interrupt_event(p_slot, event_type);
@@ -86,13 +86,13 @@ u8 pciehp_handle_switch_change(struct slot *p_slot)
 		/*
 		 * Switch opened
 		 */
-		info("Latch open on Slot(%s)\n", p_slot->name);
+		info("Latch open on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_SWITCH_OPEN;
 	} else {
 		/*
 		 *  Switch closed
 		 */
-		info("Latch close on Slot(%s)\n", p_slot->name);
+		info("Latch close on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_SWITCH_CLOSE;
 	}
 
@@ -117,13 +117,13 @@ u8 pciehp_handle_presence_change(struct slot *p_slot)
 		/*
 		 * Card Present
 		 */
-		info("Card present on Slot(%s)\n", p_slot->name);
+		info("Card present on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_PRESENCE_ON;
 	} else {
 		/*
 		 * Not Present
 		 */
-		info("Card not present on Slot(%s)\n", p_slot->name);
+		info("Card not present on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_PRESENCE_OFF;
 	}
 
@@ -143,13 +143,13 @@ u8 pciehp_handle_power_fault(struct slot *p_slot)
 		/*
 		 * power fault Cleared
 		 */
-		info("Power fault cleared on Slot(%s)\n", p_slot->name);
+		info("Power fault cleared on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_POWER_FAULT_CLEAR;
 	} else {
 		/*
 		 *   power fault
 		 */
-		info("Power fault on Slot(%s)\n", p_slot->name);
+		info("Power fault on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_POWER_FAULT;
 		info("power fault bit %x set\n", 0);
 	}
@@ -404,11 +404,11 @@ static void handle_button_press_event(struct slot *p_slot)
 		if (getstatus) {
 			p_slot->state = BLINKINGOFF_STATE;
 			info("PCI slot #%s - powering off due to button "
-			     "press.\n", p_slot->name);
+			     "press.\n", slot_name(p_slot));
 		} else {
 			p_slot->state = BLINKINGON_STATE;
 			info("PCI slot #%s - powering on due to button "
-			     "press.\n", p_slot->name);
+			     "press.\n", slot_name(p_slot));
 		}
 		/* blink green LED and turn off amber */
 		if (PWR_LED(ctrl))
@@ -425,7 +425,7 @@ static void handle_button_press_event(struct slot *p_slot)
 		 * press the attention again before the 5 sec. limit
 		 * expires to cancel hot-add or hot-remove
 		 */
-		info("Button cancel on Slot(%s)\n", p_slot->name);
+		info("Button cancel on Slot(%s)\n", slot_name(p_slot));
 		dbg("%s: button cancel\n", __func__);
 		cancel_delayed_work(&p_slot->work);
 		if (p_slot->state == BLINKINGOFF_STATE) {
@@ -438,7 +438,7 @@ static void handle_button_press_event(struct slot *p_slot)
 		if (ATTN_LED(ctrl))
 			p_slot->hpc_ops->set_attention_status(p_slot, 0);
 		info("PCI slot #%s - action canceled due to button press\n",
-		     p_slot->name);
+		     slot_name(p_slot));
 		p_slot->state = STATIC_STATE;
 		break;
 	case POWEROFF_STATE:
@@ -448,7 +448,7 @@ static void handle_button_press_event(struct slot *p_slot)
 		 * this means that the previous attention button action
 		 * to hot-add or hot-remove is undergoing
 		 */
-		info("Button ignore on Slot(%s)\n", p_slot->name);
+		info("Button ignore on Slot(%s)\n", slot_name(p_slot));
 		update_slot_info(p_slot);
 		break;
 	default:
@@ -529,7 +529,7 @@ int pciehp_enable_slot(struct slot *p_slot)
 	rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
 	if (rc || !getstatus) {
 		info("%s: no adapter on slot(%s)\n", __func__,
-		     p_slot->name);
+		     slot_name(p_slot));
 		mutex_unlock(&p_slot->ctrl->crit_sect);
 		return -ENODEV;
 	}
@@ -537,7 +537,7 @@ int pciehp_enable_slot(struct slot *p_slot)
 		rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
 		if (rc || getstatus) {
 			info("%s: latch open on slot(%s)\n", __func__,
-			     p_slot->name);
+			     slot_name(p_slot));
 			mutex_unlock(&p_slot->ctrl->crit_sect);
 			return -ENODEV;
 		}
@@ -547,7 +547,7 @@ int pciehp_enable_slot(struct slot *p_slot)
 		rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
 		if (rc || getstatus) {
 			info("%s: already enabled on slot(%s)\n", __func__,
-			     p_slot->name);
+			     slot_name(p_slot));
 			mutex_unlock(&p_slot->ctrl->crit_sect);
 			return -EINVAL;
 		}
@@ -582,7 +582,7 @@ int pciehp_disable_slot(struct slot *p_slot)
 		ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
 		if (ret || !getstatus) {
 			info("%s: no adapter on slot(%s)\n", __func__,
-			     p_slot->name);
+			     slot_name(p_slot));
 			mutex_unlock(&p_slot->ctrl->crit_sect);
 			return -ENODEV;
 		}
@@ -592,7 +592,7 @@ int pciehp_disable_slot(struct slot *p_slot)
 		ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
 		if (ret || getstatus) {
 			info("%s: latch open on slot(%s)\n", __func__,
-			     p_slot->name);
+			     slot_name(p_slot));
 			mutex_unlock(&p_slot->ctrl->crit_sect);
 			return -ENODEV;
 		}
@@ -602,7 +602,7 @@ int pciehp_disable_slot(struct slot *p_slot)
 		ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
 		if (ret || !getstatus) {
 			info("%s: already disabled slot(%s)\n", __func__,
-			     p_slot->name);
+			     slot_name(p_slot));
 			mutex_unlock(&p_slot->ctrl->crit_sect);
 			return -EINVAL;
 		}
@@ -632,14 +632,14 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot)
 		break;
 	case POWERON_STATE:
 		info("Slot %s is already in powering on state\n",
-		     p_slot->name);
+		     slot_name(p_slot));
 		break;
 	case BLINKINGOFF_STATE:
 	case POWEROFF_STATE:
-		info("Already enabled on slot %s\n", p_slot->name);
+		info("Already enabled on slot %s\n", slot_name(p_slot));
 		break;
 	default:
-		err("Not a valid state on slot %s\n", p_slot->name);
+		err("Not a valid state on slot %s\n", slot_name(p_slot));
 		break;
 	}
 	mutex_unlock(&p_slot->lock);
@@ -664,14 +664,14 @@ int pciehp_sysfs_disable_slot(struct slot *p_slot)
 		break;
 	case POWEROFF_STATE:
 		info("Slot %s is already in powering off state\n",
-		     p_slot->name);
+		     slot_name(p_slot));
 		break;
 	case BLINKINGON_STATE:
 	case POWERON_STATE:
-		info("Already disabled on slot %s\n", p_slot->name);
+		info("Already disabled on slot %s\n", slot_name(p_slot));
 		break;
 	default:
-		err("Not a valid state on slot %s\n", p_slot->name);
+		err("Not a valid state on slot %s\n", slot_name(p_slot));
 		break;
 	}
 	mutex_unlock(&p_slot->lock);
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 43ff979..31d5e7c 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -1030,11 +1030,6 @@ static void pcie_shutdown_notification(struct controller *ctrl)
 	pciehp_free_irq(ctrl);
 }
 
-static void make_slot_name(struct slot *slot)
-{
-	snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number);
-}
-
 static int pcie_init_slot(struct controller *ctrl)
 {
 	struct slot *slot;
@@ -1049,7 +1044,6 @@ static int pcie_init_slot(struct controller *ctrl)
 	slot->device = ctrl->slot_device_offset + slot->hp_slot;
 	slot->hpc_ops = ctrl->hpc_ops;
 	slot->number = ctrl->first_slot;
-	make_slot_name(slot);
 	mutex_init(&slot->lock);
 	INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work);
 	list_add(&slot->slot_list, &ctrl->slot_list);


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

* [PATCH 10/13] PCI: rpaphp: stop managing hotplug_slot->name
  2008-08-17  0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
                   ` (8 preceding siblings ...)
  2008-08-17  0:17 ` [PATCH 09/13] PCI: pciehp: remove 'name' parameter Alex Chiang
@ 2008-08-17  0:17 ` Alex Chiang
  2008-08-17  0:17 ` [PATCH 11/13] PCI: SGI Hotplug: stop managing bss_hotplug_slot->name Alex Chiang
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-08-17  0:17 UTC (permalink / raw)
  To: linux-kernel, linux-pci; +Cc: jbarnes, kristen.c.accardi, benh, Alex Chiang

We no longer need to manage our version of hotplug_slot->name
since the PCI and hotplug core manage it on our behalf.

This means that alloc_slot_struct() no longer needs to take
a 'name' param. On the other hand, we give rpaphp_register_slot()
a 'name' param now to simplify the hotplug registration process.
rpaphp_register_slot() can directly pass the drc_name to the
PCI hotplug core.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: benh@kernel.crashing.org
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/rpaphp.h      |   10 +++++++---
 drivers/pci/hotplug/rpaphp_core.c |    6 +++---
 drivers/pci/hotplug/rpaphp_pci.c  |    4 ++--
 drivers/pci/hotplug/rpaphp_slot.c |   26 +++++++++-----------------
 4 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
index 7d5921b..12f8aa7 100644
--- a/drivers/pci/hotplug/rpaphp.h
+++ b/drivers/pci/hotplug/rpaphp.h
@@ -73,13 +73,17 @@ struct slot {
 	u32 index;
 	u32 type;
 	u32 power_domain;
-	char *name;
 	struct device_node *dn;
 	struct pci_bus *bus;
 	struct list_head *pci_devs;
 	struct hotplug_slot *hotplug_slot;
 };
 
+static inline const char *slot_name(struct slot *slot)
+{
+	return hotplug_slot_name(slot->hotplug_slot);
+}
+
 extern struct hotplug_slot_ops rpaphp_hotplug_slot_ops;
 extern struct list_head rpaphp_slot_head;
 
@@ -96,8 +100,8 @@ extern int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
 
 /* rpaphp_slot.c */
 extern void dealloc_slot_struct(struct slot *slot);
-extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain);
-extern int rpaphp_register_slot(struct slot *slot);
+extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, int power_domain);
+extern int rpaphp_register_slot(struct slot *slot, const char *name);
 extern int rpaphp_deregister_slot(struct slot *slot);
 	
 #endif				/* _PPC64PHP_H */
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 1f84f40..c989005 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -324,7 +324,7 @@ int rpaphp_add_slot(struct device_node *dn)
 	type = (char *) &types[1];
 	for (i = 0; i < indexes[0]; i++) {
 
-		slot = alloc_slot_struct(dn, indexes[i + 1], name, power_domains[i + 1]);
+		slot = alloc_slot_struct(dn, indexes[i + 1], power_domains[i + 1]);
 		if (!slot)
 			return -ENOMEM;
 
@@ -335,7 +335,7 @@ int rpaphp_add_slot(struct device_node *dn)
 
 		retval = rpaphp_enable_slot(slot);
 		if (!retval)
-			retval = rpaphp_register_slot(slot);
+			retval = rpaphp_register_slot(slot, name);
 
 		if (retval)
 			dealloc_slot_struct(slot);
@@ -404,7 +404,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
 	} else if (state == EMPTY) {
 		slot->state = EMPTY;
 	} else {
-		err("%s: slot[%s] is in invalid state\n", __func__, slot->name);
+		err("%s: slot[%s] is in invalid state\n", __func__, slot_name(slot));
 		slot->state = NOT_VALID;
 		return -EINVAL;
 	}
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index 5acfd4f..46eed88 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -51,7 +51,7 @@ int rpaphp_get_sensor_state(struct slot *slot, int *state)
 						  &setlevel);
 			if (rc < 0) {
 				dbg("%s: power on slot[%s] failed rc=%d.\n",
-				    __func__, slot->name, rc);
+				    __func__, slot_name(slot), rc);
 			} else {
 				rc = rtas_get_sensor(DR_ENTITY_SENSE,
 						     slot->index, state);
@@ -111,7 +111,7 @@ int rpaphp_enable_slot(struct slot *slot)
 		/* non-empty slot has to have child */
 		if (!slot->dn->child) {
 			err("%s: slot[%s]'s device_node doesn't have child for adapter\n",
-			    __func__, slot->name);
+			    __func__, slot_name(slot));
 			return -EINVAL;
 		}
 
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
index 30d430b..eae149f 100644
--- a/drivers/pci/hotplug/rpaphp_slot.c
+++ b/drivers/pci/hotplug/rpaphp_slot.c
@@ -43,13 +43,12 @@ static void rpaphp_release_slot(struct hotplug_slot *hotplug_slot)
 void dealloc_slot_struct(struct slot *slot)
 {
 	kfree(slot->hotplug_slot->info);
-	kfree(slot->hotplug_slot->name);
 	kfree(slot->hotplug_slot);
 	kfree(slot);
 }
 
 struct slot *alloc_slot_struct(struct device_node *dn,
-                       int drc_index, char *drc_name, int power_domain)
+                       int drc_index, int power_domain)
 {
 	struct slot *slot;
 	
@@ -63,11 +62,6 @@ struct slot *alloc_slot_struct(struct device_node *dn,
 					   GFP_KERNEL);
 	if (!slot->hotplug_slot->info)
 		goto error_hpslot;
-	slot->hotplug_slot->name = kmalloc(strlen(drc_name) + 1, GFP_KERNEL);
-	if (!slot->hotplug_slot->name)
-		goto error_info;	
-	slot->name = slot->hotplug_slot->name;
-	strcpy(slot->name, drc_name);
 	slot->dn = dn;
 	slot->index = drc_index;
 	slot->power_domain = power_domain;
@@ -77,8 +71,6 @@ struct slot *alloc_slot_struct(struct device_node *dn,
 	
 	return (slot);
 
-error_info:
-	kfree(slot->hotplug_slot->info);
 error_hpslot:
 	kfree(slot->hotplug_slot);
 error_slot:
@@ -92,7 +84,7 @@ static int is_registered(struct slot *slot)
 	struct slot *tmp_slot;
 
 	list_for_each_entry(tmp_slot, &rpaphp_slot_head, rpaphp_slot_list) {
-		if (!strcmp(tmp_slot->name, slot->name))
+		if (!strcmp(slot_name(tmp_slot), slot_name(slot)))
 			return 1;
 	}	
 	return 0;
@@ -104,32 +96,32 @@ int rpaphp_deregister_slot(struct slot *slot)
 	struct hotplug_slot *php_slot = slot->hotplug_slot;
 
 	 dbg("%s - Entry: deregistering slot=%s\n",
-		__func__, slot->name);
+		__func__, slot_name(slot));
 
 	list_del(&slot->rpaphp_slot_list);
 	
 	retval = pci_hp_deregister(php_slot);
 	if (retval)
-		err("Problem unregistering a slot %s\n", slot->name);
+		err("Problem unregistering a slot %s\n", slot_name(slot));
 
 	dbg("%s - Exit: rc[%d]\n", __func__, retval);
 	return retval;
 }
 EXPORT_SYMBOL_GPL(rpaphp_deregister_slot);
 
-int rpaphp_register_slot(struct slot *slot)
+int rpaphp_register_slot(struct slot *slot, const char *name)
 {
 	struct hotplug_slot *php_slot = slot->hotplug_slot;
 	int retval;
 	int slotno;
 
 	dbg("%s registering slot:path[%s] index[%x], name[%s] pdomain[%x] type[%d]\n", 
-		__func__, slot->dn->full_name, slot->index, slot->name,
+		__func__, slot->dn->full_name, slot->index, slot_name(slot),
 		slot->power_domain, slot->type);
 
 	/* should not try to register the same slot twice */
 	if (is_registered(slot)) {
-		err("rpaphp_register_slot: slot[%s] is already registered\n", slot->name);
+		err("rpaphp_register_slot: slot[%s] is already registered\n", slot_name(slot));
 		return -EAGAIN;
 	}	
 
@@ -137,7 +129,7 @@ int rpaphp_register_slot(struct slot *slot)
 		slotno = PCI_SLOT(PCI_DN(slot->dn->child)->devfn);
 	else
 		slotno = -1;
-	retval = pci_hp_register(php_slot, slot->bus, slotno, slot->name);
+	retval = pci_hp_register(php_slot, slot->bus, slotno, name);
 	if (retval) {
 		err("pci_hp_register failed with error %d\n", retval);
 		return retval;
@@ -145,7 +137,7 @@ int rpaphp_register_slot(struct slot *slot)
 
 	/* add slot to our internal list */
 	list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head);
-	info("Slot [%s] registered\n", slot->name);
+	info("Slot [%s] registered\n", name);
 	return 0;
 
 sysfs_fail:


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

* [PATCH 11/13] PCI: SGI Hotplug: stop managing bss_hotplug_slot->name
  2008-08-17  0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
                   ` (9 preceding siblings ...)
  2008-08-17  0:17 ` [PATCH 10/13] PCI: rpaphp: stop managing hotplug_slot->name Alex Chiang
@ 2008-08-17  0:17 ` Alex Chiang
  2008-08-17  0:17 ` [PATCH 12/13] PCI: shcphp: remove 'name' parameter Alex Chiang
  2008-08-17  0:17 ` [PATCH 13/13] PCI: Hotplug core: remove 'name' Alex Chiang
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-08-17  0:17 UTC (permalink / raw)
  To: linux-kernel, linux-pci; +Cc: jbarnes, kristen.c.accardi, jpk, Alex Chiang

We no longer need to manage our version of hotplug_slot->name
since the PCI and hotplug core manage it on our behalf.

Update the sn_hp_slot_private_alloc() interface to fill in
the correct name for us, as that function already has all
the parameters needed to determine the name.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: jpk@sgi.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/sgi_hotplug.c |   20 +++++++-------------
 1 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index 6d20bbd..beee578 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -161,7 +161,8 @@ static int sn_pci_bus_valid(struct pci_bus *pci_bus)
 }
 
 static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot,
-				    struct pci_bus *pci_bus, int device)
+				    struct pci_bus *pci_bus, int device,
+				    char *name)
 {
 	struct pcibus_info *pcibus_info;
 	struct slot *slot;
@@ -173,15 +174,9 @@ static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot,
 		return -ENOMEM;
 	bss_hotplug_slot->private = slot;
 
-	bss_hotplug_slot->name = kmalloc(SN_SLOT_NAME_SIZE, GFP_KERNEL);
-	if (!bss_hotplug_slot->name) {
-		kfree(bss_hotplug_slot->private);
-		return -ENOMEM;
-	}
-
 	slot->device_num = device;
 	slot->pci_bus = pci_bus;
-	sprintf(bss_hotplug_slot->name, "%04x:%02x:%02x",
+	sprintf(name, "%04x:%02x:%02x",
 		pci_domain_nr(pci_bus),
 		((u16)pcibus_info->pbi_buscommon.bs_persist_busnum),
 		device + 1);
@@ -608,7 +603,6 @@ static inline int get_power_status(struct hotplug_slot *bss_hotplug_slot,
 static void sn_release_slot(struct hotplug_slot *bss_hotplug_slot)
 {
 	kfree(bss_hotplug_slot->info);
-	kfree(bss_hotplug_slot->name);
 	kfree(bss_hotplug_slot->private);
 	kfree(bss_hotplug_slot);
 }
@@ -618,6 +612,7 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus)
 	int device;
 	struct pci_slot *pci_slot;
 	struct hotplug_slot *bss_hotplug_slot;
+	char name[SN_SLOT_NAME_SIZE];
 	int rc = 0;
 
 	/*
@@ -644,17 +639,16 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus)
 			goto alloc_err;
 		}
 
+		memset(name, 0, SN_SLOT_NAME_SIZE);
 		if (sn_hp_slot_private_alloc(bss_hotplug_slot,
-					     pci_bus, device)) {
+					     pci_bus, device, name)) {
 			rc = -ENOMEM;
 			goto alloc_err;
 		}
-
 		bss_hotplug_slot->ops = &sn_hotplug_slot_ops;
 		bss_hotplug_slot->release = &sn_release_slot;
 
-		rc = pci_hp_register(bss_hotplug_slot, pci_bus, device,
-				     bss_hotplug_slot->name);
+		rc = pci_hp_register(bss_hotplug_slot, pci_bus, device, name);
 		if (rc)
 			goto register_err;
 


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

* [PATCH 12/13] PCI: shcphp: remove 'name' parameter
  2008-08-17  0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
                   ` (10 preceding siblings ...)
  2008-08-17  0:17 ` [PATCH 11/13] PCI: SGI Hotplug: stop managing bss_hotplug_slot->name Alex Chiang
@ 2008-08-17  0:17 ` Alex Chiang
  2008-08-17  0:17 ` [PATCH 13/13] PCI: Hotplug core: remove 'name' Alex Chiang
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-08-17  0:17 UTC (permalink / raw)
  To: linux-kernel, linux-pci
  Cc: jbarnes, kristen.c.accardi, kaneshige.kenji, Alex Chiang

We do not need to manage our own name parameter, especially since
the PCI core can change it on our behalf, in the case of duplicate
slot names.

Remove 'name' from shpchp's version of struct slot.

This change also removes the unused struct task_event from the
slot structure.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: kaneshige.kenji@jp.fujitsu.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/shpchp.h      |    9 +++++--
 drivers/pci/hotplug/shpchp_core.c |   35 ++++++++++++---------------
 drivers/pci/hotplug/shpchp_ctrl.c |   48 +++++++++++++++++++------------------
 3 files changed, 45 insertions(+), 47 deletions(-)

diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index 8a026f7..4d9fed0 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -69,15 +69,13 @@ struct slot {
 	u8 state;
 	u8 presence_save;
 	u8 pwr_save;
-	struct timer_list task_event;
-	u8 hp_slot;
 	struct controller *ctrl;
 	struct hpc_ops *hpc_ops;
 	struct hotplug_slot *hotplug_slot;
 	struct list_head	slot_list;
-	char name[SLOT_NAME_SIZE];
 	struct delayed_work work;	/* work for button event */
 	struct mutex lock;
+	u8 hp_slot;
 };
 
 struct event_info {
@@ -169,6 +167,11 @@ extern void cleanup_slots(struct controller *ctrl);
 extern void shpchp_queue_pushbutton_work(struct work_struct *work);
 extern int shpc_init( struct controller *ctrl, struct pci_dev *pdev);
 
+static inline const char *slot_name(struct slot *slot)
+{
+	return hotplug_slot_name(slot->hotplug_slot);
+}
+
 #ifdef CONFIG_ACPI
 #include <linux/pci-acpi.h>
 static inline int get_hp_params_from_firmware(struct pci_dev *dev,
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index 136d9ea..df1e2a0 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -89,23 +89,19 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	kfree(slot->hotplug_slot->info);
 	kfree(slot->hotplug_slot);
 	kfree(slot);
 }
 
-static void make_slot_name(struct slot *slot)
-{
-	snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%d", slot->number);
-}
-
 static int init_slots(struct controller *ctrl)
 {
 	struct slot *slot;
 	struct hotplug_slot *hotplug_slot;
 	struct hotplug_slot_info *info;
+	char name[SLOT_NAME_SIZE];
 	int retval = -ENOMEM;
 	int i;
 
@@ -124,8 +120,6 @@ static int init_slots(struct controller *ctrl)
 			goto error_hpslot;
 		hotplug_slot->info = info;
 
-		hotplug_slot->name = slot->name;
-
 		slot->hp_slot = i;
 		slot->ctrl = ctrl;
 		slot->bus = ctrl->pci_dev->subordinate->number;
@@ -138,9 +132,11 @@ static int init_slots(struct controller *ctrl)
 		/* register this slot with the hotplug pci core */
 		hotplug_slot->private = slot;
 		hotplug_slot->release = &release_slot;
-		make_slot_name(slot);
 		hotplug_slot->ops = &shpchp_hotplug_slot_ops;
 
+		memset(name, 0, SLOT_NAME_SIZE);
+		snprintf(name, SLOT_NAME_SIZE, "%d", slot->number);
+
 		get_power_status(hotplug_slot, &info->power_status);
 		get_attention_status(hotplug_slot, &info->attention_status);
 		get_latch_status(hotplug_slot, &info->latch_status);
@@ -150,8 +146,7 @@ static int init_slots(struct controller *ctrl)
 		    "slot_device_offset=%x\n", slot->bus, slot->device,
 		    slot->hp_slot, slot->number, ctrl->slot_device_offset);
 		retval = pci_hp_register(slot->hotplug_slot,
-				ctrl->pci_dev->subordinate, slot->device,
-				hotplug_slot->name);
+				ctrl->pci_dev->subordinate, slot->device, name);
 		if (retval) {
 			err("pci_hp_register failed with error %d\n", retval);
 			goto error_info;
@@ -194,7 +189,7 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status)
 {
 	struct slot *slot = get_slot(hotplug_slot);
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	hotplug_slot->info->attention_status = status;
 	slot->hpc_ops->set_attention_status(slot, status);
@@ -206,7 +201,7 @@ static int enable_slot (struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = get_slot(hotplug_slot);
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	return shpchp_sysfs_enable_slot(slot);
 }
@@ -215,7 +210,7 @@ static int disable_slot (struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = get_slot(hotplug_slot);
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	return shpchp_sysfs_disable_slot(slot);
 }
@@ -225,7 +220,7 @@ static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = get_slot(hotplug_slot);
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_power_status(slot, value);
 	if (retval < 0)
@@ -239,7 +234,7 @@ static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = get_slot(hotplug_slot);
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_attention_status(slot, value);
 	if (retval < 0)
@@ -253,7 +248,7 @@ static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = get_slot(hotplug_slot);
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_latch_status(slot, value);
 	if (retval < 0)
@@ -267,7 +262,7 @@ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = get_slot(hotplug_slot);
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_adapter_status(slot, value);
 	if (retval < 0)
@@ -282,7 +277,7 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot,
 	struct slot *slot = get_slot(hotplug_slot);
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_max_bus_speed(slot, value);
 	if (retval < 0)
@@ -296,7 +291,7 @@ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp
 	struct slot *slot = get_slot(hotplug_slot);
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_cur_bus_speed(slot, value);
 	if (retval < 0)
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index dfb5393..919b1ee 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -70,7 +70,7 @@ u8 shpchp_handle_attention_button(u8 hp_slot, struct controller *ctrl)
 	/*
 	 *  Button pressed - See if need to TAKE ACTION!!!
 	 */
-	info("Button pressed on Slot(%s)\n", p_slot->name);
+	info("Button pressed on Slot(%s)\n", slot_name(p_slot));
 	event_type = INT_BUTTON_PRESS;
 
 	queue_interrupt_event(p_slot, event_type);
@@ -98,7 +98,7 @@ u8 shpchp_handle_switch_change(u8 hp_slot, struct controller *ctrl)
 		/*
 		 * Switch opened
 		 */
-		info("Latch open on Slot(%s)\n", p_slot->name);
+		info("Latch open on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_SWITCH_OPEN;
 		if (p_slot->pwr_save && p_slot->presence_save) {
 			event_type = INT_POWER_FAULT;
@@ -108,7 +108,7 @@ u8 shpchp_handle_switch_change(u8 hp_slot, struct controller *ctrl)
 		/*
 		 *  Switch closed
 		 */
-		info("Latch close on Slot(%s)\n", p_slot->name);
+		info("Latch close on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_SWITCH_CLOSE;
 	}
 
@@ -135,13 +135,13 @@ u8 shpchp_handle_presence_change(u8 hp_slot, struct controller *ctrl)
 		/*
 		 * Card Present
 		 */
-		info("Card present on Slot(%s)\n", p_slot->name);
+		info("Card present on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_PRESENCE_ON;
 	} else {
 		/*
 		 * Not Present
 		 */
-		info("Card not present on Slot(%s)\n", p_slot->name);
+		info("Card not present on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_PRESENCE_OFF;
 	}
 
@@ -164,14 +164,14 @@ u8 shpchp_handle_power_fault(u8 hp_slot, struct controller *ctrl)
 		/*
 		 * Power fault Cleared
 		 */
-		info("Power fault cleared on Slot(%s)\n", p_slot->name);
+		info("Power fault cleared on Slot(%s)\n", slot_name(p_slot));
 		p_slot->status = 0x00;
 		event_type = INT_POWER_FAULT_CLEAR;
 	} else {
 		/*
 		 *   Power fault
 		 */
-		info("Power fault on Slot(%s)\n", p_slot->name);
+		info("Power fault on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_POWER_FAULT;
 		/* set power fault status for this board */
 		p_slot->status = 0xFF;
@@ -493,11 +493,11 @@ static void handle_button_press_event(struct slot *p_slot)
 		if (getstatus) {
 			p_slot->state = BLINKINGOFF_STATE;
 			info("PCI slot #%s - powering off due to button "
-			     "press.\n", p_slot->name);
+			     "press.\n", slot_name(p_slot));
 		} else {
 			p_slot->state = BLINKINGON_STATE;
 			info("PCI slot #%s - powering on due to button "
-			     "press.\n", p_slot->name);
+			     "press.\n", slot_name(p_slot));
 		}
 		/* blink green LED and turn off amber */
 		p_slot->hpc_ops->green_led_blink(p_slot);
@@ -512,7 +512,7 @@ static void handle_button_press_event(struct slot *p_slot)
 		 * press the attention again before the 5 sec. limit
 		 * expires to cancel hot-add or hot-remove
 		 */
-		info("Button cancel on Slot(%s)\n", p_slot->name);
+		info("Button cancel on Slot(%s)\n", slot_name(p_slot));
 		dbg("%s: button cancel\n", __func__);
 		cancel_delayed_work(&p_slot->work);
 		if (p_slot->state == BLINKINGOFF_STATE)
@@ -521,7 +521,7 @@ static void handle_button_press_event(struct slot *p_slot)
 			p_slot->hpc_ops->green_led_off(p_slot);
 		p_slot->hpc_ops->set_attention_status(p_slot, 0);
 		info("PCI slot #%s - action canceled due to button press\n",
-		     p_slot->name);
+		     slot_name(p_slot));
 		p_slot->state = STATIC_STATE;
 		break;
 	case POWEROFF_STATE:
@@ -531,7 +531,7 @@ static void handle_button_press_event(struct slot *p_slot)
 		 * this means that the previous attention button action
 		 * to hot-add or hot-remove is undergoing
 		 */
-		info("Button ignore on Slot(%s)\n", p_slot->name);
+		info("Button ignore on Slot(%s)\n", slot_name(p_slot));
 		update_slot_info(p_slot);
 		break;
 	default:
@@ -574,17 +574,17 @@ static int shpchp_enable_slot (struct slot *p_slot)
 	mutex_lock(&p_slot->ctrl->crit_sect);
 	rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
 	if (rc || !getstatus) {
-		info("No adapter on slot(%s)\n", p_slot->name);
+		info("No adapter on slot(%s)\n", slot_name(p_slot));
 		goto out;
 	}
 	rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
 	if (rc || getstatus) {
-		info("Latch open on slot(%s)\n", p_slot->name);
+		info("Latch open on slot(%s)\n", slot_name(p_slot));
 		goto out;
 	}
 	rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
 	if (rc || getstatus) {
-		info("Already enabled on slot(%s)\n", p_slot->name);
+		info("Already enabled on slot(%s)\n", slot_name(p_slot));
 		goto out;
 	}
 
@@ -633,17 +633,17 @@ static int shpchp_disable_slot (struct slot *p_slot)
 
 	rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
 	if (rc || !getstatus) {
-		info("No adapter on slot(%s)\n", p_slot->name);
+		info("No adapter on slot(%s)\n", slot_name(p_slot));
 		goto out;
 	}
 	rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
 	if (rc || getstatus) {
-		info("Latch open on slot(%s)\n", p_slot->name);
+		info("Latch open on slot(%s)\n", slot_name(p_slot));
 		goto out;
 	}
 	rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
 	if (rc || !getstatus) {
-		info("Already disabled slot(%s)\n", p_slot->name);
+		info("Already disabled slot(%s)\n", slot_name(p_slot));
 		goto out;
 	}
 
@@ -671,14 +671,14 @@ int shpchp_sysfs_enable_slot(struct slot *p_slot)
 		break;
 	case POWERON_STATE:
 		info("Slot %s is already in powering on state\n",
-		     p_slot->name);
+		     slot_name(p_slot));
 		break;
 	case BLINKINGOFF_STATE:
 	case POWEROFF_STATE:
-		info("Already enabled on slot %s\n", p_slot->name);
+		info("Already enabled on slot %s\n", slot_name(p_slot));
 		break;
 	default:
-		err("Not a valid state on slot %s\n", p_slot->name);
+		err("Not a valid state on slot %s\n", slot_name(p_slot));
 		break;
 	}
 	mutex_unlock(&p_slot->lock);
@@ -703,14 +703,14 @@ int shpchp_sysfs_disable_slot(struct slot *p_slot)
 		break;
 	case POWEROFF_STATE:
 		info("Slot %s is already in powering off state\n",
-		     p_slot->name);
+		     slot_name(p_slot));
 		break;
 	case BLINKINGON_STATE:
 	case POWERON_STATE:
-		info("Already disabled on slot %s\n", p_slot->name);
+		info("Already disabled on slot %s\n", slot_name(p_slot));
 		break;
 	default:
-		err("Not a valid state on slot %s\n", p_slot->name);
+		err("Not a valid state on slot %s\n", slot_name(p_slot));
 		break;
 	}
 	mutex_unlock(&p_slot->lock);


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

* [PATCH 13/13] PCI: Hotplug core: remove 'name'
  2008-08-17  0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
                   ` (11 preceding siblings ...)
  2008-08-17  0:17 ` [PATCH 12/13] PCI: shcphp: remove 'name' parameter Alex Chiang
@ 2008-08-17  0:17 ` Alex Chiang
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-08-17  0:17 UTC (permalink / raw)
  To: linux-kernel, linux-pci
  Cc: jbarnes, kristen.c.accardi, matthew, kaneshige.kenji, Alex Chiang

Now that the PCI core manages the 'name' for each individual
hotplug driver, and all drivers have been converted to use
hotplug_slot_name(), there is no need for the PCI hotplug
core to drag around its own copy of name either.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: matthew@wil.cx
Cc: kaneshige.kenji@jp.fujitsu.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/pci_hotplug_core.c |    6 +++---
 include/linux/pci_hotplug.h            |    3 ---
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index da5908f..eb2437c 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -533,7 +533,7 @@ static struct hotplug_slot *get_slot_from_name (const char *name)
 	spin_lock(&pci_hotplug_slot_list_lock);
 	list_for_each (tmp, &pci_hotplug_slot_list) {
 		slot = list_entry (tmp, struct hotplug_slot, slot_list);
-		if (strcmp(slot->name, name) == 0)
+		if (strcmp(hotplug_slot_name(slot), name) == 0)
 			goto out;
 	}
 	slot = NULL;
@@ -627,7 +627,7 @@ int pci_hp_deregister(struct hotplug_slot *hotplug)
 	if (!hotplug)
 		return -ENODEV;
 
-	temp = get_slot_from_name(hotplug->name);
+	temp = get_slot_from_name(hotplug_slot_name(hotplug));
 	if (temp != hotplug)
 		return -ENODEV;
 
@@ -637,7 +637,7 @@ int pci_hp_deregister(struct hotplug_slot *hotplug)
 
 	slot = hotplug->pci_slot;
 	fs_remove_slot(slot);
-	dbg("Removed slot %s from the list\n", hotplug->name);
+	dbg("Removed slot %s from the list\n", hotplug_slot_name(hotplug));
 
 	hotplug->release(hotplug);
 	slot->hotplug = NULL;
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index 7184bee..9899ea3 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -142,8 +142,6 @@ struct hotplug_slot_info {
 
 /**
  * struct hotplug_slot - used to register a physical slot with the hotplug pci core
- * @name: the name of the slot being registered.  This string must
- * be unique amoung slots registered on this system.
  * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot
  * @info: pointer to the &struct hotplug_slot_info for the initial values for
  * this slot.
@@ -153,7 +151,6 @@ struct hotplug_slot_info {
  * needs.
  */
 struct hotplug_slot {
-	char				*name;
 	struct hotplug_slot_ops		*ops;
 	struct hotplug_slot_info	*info;
 	void (*release) (struct hotplug_slot *slot);


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

* Re: [PATCH 04/13] PCI: acpiphp: remove 'name' parameter
  2008-08-17  0:16 ` [PATCH 04/13] PCI: acpiphp: remove 'name' parameter Alex Chiang
@ 2008-08-17  8:59   ` Rolf Eike Beer
  2008-08-19 18:39     ` Alex Chiang
  0 siblings, 1 reply; 55+ messages in thread
From: Rolf Eike Beer @ 2008-08-17  8:59 UTC (permalink / raw)
  To: Alex Chiang
  Cc: linux-kernel, linux-pci, jbarnes, kristen.c.accardi, kaneshige.kenji

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

Alex Chiang wrote:
> We do not need to manage our own name parameter, especially since
> the PCI core can change it on our behalf, in the case of duplicate
> slot names.
>
> Remove 'name' from acpiphp's version of struct slot.
>
> Cc: jbarnes@virtuousgeek.org
> Cc: kristen.c.accardi@intel.com
> Cc: kaneshige.kenji@jp.fujitsu.com
> Signed-off-by: Alex Chiang <achiang@hp.com>
> ---
>
>  drivers/pci/hotplug/acpiphp.h      |    9 +++++----
>  drivers/pci/hotplug/acpiphp_core.c |   36
> +++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 21
> deletions(-)
>
> diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
> index 5a58b07..f9e244d 100644
> --- a/drivers/pci/hotplug/acpiphp.h
> +++ b/drivers/pci/hotplug/acpiphp.h
> @@ -50,9 +50,6 @@
>  #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ##
> arg) #define warn(format, arg...) printk(KERN_WARNING "%s: " format,
> MY_NAME , ## arg)
>
> -/* name size which is used for entries in pcihpfs */
> -#define SLOT_NAME_SIZE	20		/* {_SUN} */
> -
>  struct acpiphp_bridge;
>  struct acpiphp_slot;
>
> @@ -63,9 +60,13 @@ struct slot {
>  	struct hotplug_slot	*hotplug_slot;
>  	struct acpiphp_slot	*acpi_slot;
>  	struct hotplug_slot_info info;
> -	char name[SLOT_NAME_SIZE];
>  };
>
> +static inline const char *slot_name(struct slot *slot)
> +{
> +	return hotplug_slot_name(slot->hotplug_slot);
> +}
> +
>  /*
>   * struct acpiphp_bridge - PCI bridge information
>   *

I don't see a point in this function. Why not call hotplug_slot_name() 
directly? 

> diff --git a/drivers/pci/hotplug/acpiphp_core.c
> b/drivers/pci/hotplug/acpiphp_core.c index e984176..687cac3 100644
> --- a/drivers/pci/hotplug/acpiphp_core.c
> +++ b/drivers/pci/hotplug/acpiphp_core.c
> @@ -44,6 +44,9 @@
>
>  #define MY_NAME	"acpiphp"
>
> +/* name size which is used for entries in pcihpfs */
> +#define SLOT_NAME_SIZE  20              /* {_SUN} */
> +
>  static int debug;
>  int acpiphp_debug;
>
> @@ -84,7 +87,6 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops = {
>  	.get_adapter_status	= get_adapter_status,
>  };
>
> -
>  /**
>   * acpiphp_register_attention - set attention LED callback
>   * @info: must be completely filled with LED callbacks

Fuzz.

> @@ -92,7 +94,7 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops = {
>   * Description: This is used to register a hardware specific ACPI
>   * driver that manipulates the attention LED.  All the fields in
>   * info must be set.
> - */
> + **/
>  int acpiphp_register_attention(struct acpiphp_attention_info *info)
>  {
>  	int retval = -EINVAL;

Fuzz. Make the patch look bigger than it actually is. But that's just a note, 
Jesse will have to judge if this is acceptable.

> @@ -113,7 +115,7 @@ int acpiphp_register_attention(struct
> acpiphp_attention_info *info) * Description: This is used to un-register a
> hardware specific acpi * driver that manipulates the attention LED.  The
> pointer to the * info struct must be the same as the one used to set it.
> - */
> + **/
>  int acpiphp_unregister_attention(struct acpiphp_attention_info *info)
>  {
>  	int retval = -EINVAL;
> @@ -136,7 +138,7 @@ static int enable_slot(struct hotplug_slot
> *hotplug_slot) {
>  	struct slot *slot = hotplug_slot->private;
>
> -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
>
>  	/* enable the specified slot */
>  	return acpiphp_enable_slot(slot->acpi_slot);
> @@ -154,7 +156,7 @@ static int disable_slot(struct hotplug_slot
> *hotplug_slot) struct slot *slot = hotplug_slot->private;
>  	int retval;
>
> -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
>
>  	/* disable the specified slot */
>  	retval = acpiphp_disable_slot(slot->acpi_slot);
> @@ -177,7 +179,7 @@ static int disable_slot(struct hotplug_slot
> *hotplug_slot) {
>  	int retval = -ENODEV;
>
> - 	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> +	dbg("%s - physical_slot = %s\n", __func__,
> hotplug_slot_name(hotplug_slot));
>
>  	if (attention_info && try_module_get(attention_info->owner)) {
>  		retval = attention_info->set_attn(hotplug_slot, status);
> @@ -200,7 +202,7 @@ static int get_power_status(struct hotplug_slot
> *hotplug_slot, u8 *value) {
>  	struct slot *slot = hotplug_slot->private;
>
> -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
>
>  	*value = acpiphp_get_power_status(slot->acpi_slot);
>
> @@ -222,7 +224,7 @@ static int get_attention_status(struct hotplug_slot
> *hotplug_slot, u8 *value) {
>  	int retval = -EINVAL;
>
> -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> +	dbg("%s - physical_slot = %s\n", __func__,
> hotplug_slot_name(hotplug_slot));
>
>  	if (attention_info && try_module_get(attention_info->owner)) {
>  		retval = attention_info->get_attn(hotplug_slot, value);
> @@ -245,7 +247,7 @@ static int get_latch_status(struct hotplug_slot
> *hotplug_slot, u8 *value) {
>  	struct slot *slot = hotplug_slot->private;
>
> -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
>
>  	*value = acpiphp_get_latch_status(slot->acpi_slot);
>
> @@ -265,7 +267,7 @@ static int get_adapter_status(struct hotplug_slot
> *hotplug_slot, u8 *value) {
>  	struct slot *slot = hotplug_slot->private;
>
> -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
>
>  	*value = acpiphp_get_adapter_status(slot->acpi_slot);
>
> @@ -299,7 +301,7 @@ static void release_slot(struct hotplug_slot
> *hotplug_slot) {
>  	struct slot *slot = hotplug_slot->private;
>
> -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
>
>  	kfree(slot->hotplug_slot);
>  	kfree(slot);
> @@ -310,6 +312,7 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot
> *acpiphp_slot) {
>  	struct slot *slot;
>  	int retval = -ENOMEM;
> +	char name[SLOT_NAME_SIZE];
>
>  	slot = kzalloc(sizeof(*slot), GFP_KERNEL);
>  	if (!slot)
> @@ -321,8 +324,6 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot
> *acpiphp_slot)
>
>  	slot->hotplug_slot->info = &slot->info;
>
> -	slot->hotplug_slot->name = slot->name;
> -
>  	slot->hotplug_slot->private = slot;
>  	slot->hotplug_slot->release = &release_slot;
>  	slot->hotplug_slot->ops = &acpi_hotplug_slot_ops;
> @@ -336,12 +337,13 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot
> *acpiphp_slot) slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
>
>  	acpiphp_slot->slot = slot;
> -	snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun);
> +	memset(name, 0, SLOT_NAME_SIZE);
> +	snprintf(name, SLOT_NAME_SIZE, "%u", slot->acpi_slot->sun);

The memset() is not needed at all. And the sizeof is IMHO a good idea anyway 
as it allows to get rid of the define.

>  	retval = pci_hp_register(slot->hotplug_slot,
>  					acpiphp_slot->bridge->pci_bus,
>  					acpiphp_slot->device,
> -					slot->name);
> +					name);
>  	if (retval == -EBUSY)
>  		goto error_hpslot;
>  	if (retval) {
> @@ -349,7 +351,7 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot
> *acpiphp_slot) goto error_hpslot;
>   	}
>
> -	info("Slot [%s] registered\n", slot->hotplug_slot->name);
> +	info("Slot [%s] registered\n", slot_name(slot));
>
>  	return 0;
>  error_hpslot:
> @@ -366,7 +368,7 @@ void acpiphp_unregister_hotplug_slot(struct
> acpiphp_slot *acpiphp_slot) struct slot *slot = acpiphp_slot->slot;
>  	int retval = 0;
>
> -	info ("Slot [%s] unregistered\n", slot->hotplug_slot->name);
> +	info ("Slot [%s] unregistered\n", slot_name(slot));
>
>  	retval = pci_hp_deregister(slot->hotplug_slot);
>  	if (retval)

Greetings,

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH 04/13] PCI: acpiphp: remove 'name' parameter
  2008-08-17  8:59   ` Rolf Eike Beer
@ 2008-08-19 18:39     ` Alex Chiang
  2008-08-19 21:01       ` Rolf Eike Beer
  2008-08-19 21:40       ` Jesse Barnes
  0 siblings, 2 replies; 55+ messages in thread
From: Alex Chiang @ 2008-08-19 18:39 UTC (permalink / raw)
  To: Rolf Eike Beer
  Cc: linux-kernel, linux-pci, jbarnes, kristen.c.accardi, kaneshige.kenji

* Rolf Eike Beer <eike-kernel@sf-tec.de>:
> Alex Chiang wrote:
> > We do not need to manage our own name parameter, especially since
> > the PCI core can change it on our behalf, in the case of duplicate
> > slot names.
> >
> > Remove 'name' from acpiphp's version of struct slot.
> >
> > Cc: jbarnes@virtuousgeek.org
> > Cc: kristen.c.accardi@intel.com
> > Cc: kaneshige.kenji@jp.fujitsu.com
> > Signed-off-by: Alex Chiang <achiang@hp.com>
> > ---
> >
> >  drivers/pci/hotplug/acpiphp.h      |    9 +++++----
> >  drivers/pci/hotplug/acpiphp_core.c |   36
> > +++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 21
> > deletions(-)
> >
> > diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
> > index 5a58b07..f9e244d 100644
> > --- a/drivers/pci/hotplug/acpiphp.h
> > +++ b/drivers/pci/hotplug/acpiphp.h
> > @@ -50,9 +50,6 @@
> >  #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ##
> > arg) #define warn(format, arg...) printk(KERN_WARNING "%s: " format,
> > MY_NAME , ## arg)
> >
> > -/* name size which is used for entries in pcihpfs */
> > -#define SLOT_NAME_SIZE	20		/* {_SUN} */
> > -
> >  struct acpiphp_bridge;
> >  struct acpiphp_slot;
> >
> > @@ -63,9 +60,13 @@ struct slot {
> >  	struct hotplug_slot	*hotplug_slot;
> >  	struct acpiphp_slot	*acpi_slot;
> >  	struct hotplug_slot_info info;
> > -	char name[SLOT_NAME_SIZE];
> >  };
> >
> > +static inline const char *slot_name(struct slot *slot)
> > +{
> > +	return hotplug_slot_name(slot->hotplug_slot);
> > +}
> > +
> >  /*
> >   * struct acpiphp_bridge - PCI bridge information
> >   *
> 
> I don't see a point in this function. Why not call hotplug_slot_name() 
> directly? 

You're correct that we don't exactly need it in acpiphp. However,
it is a useful helper function for some of the other drivers, and
I thought it would be better to keep consistency if possible.

Also, it helps later on, when trying to stay below the 80 column
limit. :)

> > diff --git a/drivers/pci/hotplug/acpiphp_core.c
> > b/drivers/pci/hotplug/acpiphp_core.c index e984176..687cac3 100644
> > --- a/drivers/pci/hotplug/acpiphp_core.c
> > +++ b/drivers/pci/hotplug/acpiphp_core.c
> > @@ -44,6 +44,9 @@
> >
> >  #define MY_NAME	"acpiphp"
> >
> > +/* name size which is used for entries in pcihpfs */
> > +#define SLOT_NAME_SIZE  20              /* {_SUN} */
> > +
> >  static int debug;
> >  int acpiphp_debug;
> >
> > @@ -84,7 +87,6 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops = {
> >  	.get_adapter_status	= get_adapter_status,
> >  };
> >
> > -
> >  /**
> >   * acpiphp_register_attention - set attention LED callback
> >   * @info: must be completely filled with LED callbacks
> 
> Fuzz.

Yes, it's fuzz, but my practice has been to clean up* source files
during the course of making actual, functional changes. Better
than sending a mostly-useless whitespace patchbomb, IMO.

* Note that "clean up" here means "reasonable cleanup" that
  doesn't detract from reading the rest of the patch.

> > @@ -92,7 +94,7 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops = {
> >   * Description: This is used to register a hardware specific ACPI
> >   * driver that manipulates the attention LED.  All the fields in
> >   * info must be set.
> > - */
> > + **/
> >  int acpiphp_register_attention(struct acpiphp_attention_info *info)
> >  {
> >  	int retval = -EINVAL;
> 
> Fuzz. Make the patch look bigger than it actually is. But that's just a note, 
> Jesse will have to judge if this is acceptable.

See above. Fixing incorrect kerneldoc doesn't seem so bad, IMO.

> > @@ -113,7 +115,7 @@ int acpiphp_register_attention(struct
> > acpiphp_attention_info *info) * Description: This is used to un-register a
> > hardware specific acpi * driver that manipulates the attention LED.  The
> > pointer to the * info struct must be the same as the one used to set it.
> > - */
> > + **/
> >  int acpiphp_unregister_attention(struct acpiphp_attention_info *info)
> >  {
> >  	int retval = -EINVAL;
> > @@ -136,7 +138,7 @@ static int enable_slot(struct hotplug_slot
> > *hotplug_slot) {
> >  	struct slot *slot = hotplug_slot->private;
> >
> > -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
> >
> >  	/* enable the specified slot */
> >  	return acpiphp_enable_slot(slot->acpi_slot);
> > @@ -154,7 +156,7 @@ static int disable_slot(struct hotplug_slot
> > *hotplug_slot) struct slot *slot = hotplug_slot->private;
> >  	int retval;
> >
> > -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
> >
> >  	/* disable the specified slot */
> >  	retval = acpiphp_disable_slot(slot->acpi_slot);
> > @@ -177,7 +179,7 @@ static int disable_slot(struct hotplug_slot
> > *hotplug_slot) {
> >  	int retval = -ENODEV;
> >
> > - 	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > +	dbg("%s - physical_slot = %s\n", __func__,
> > hotplug_slot_name(hotplug_slot));
> >
> >  	if (attention_info && try_module_get(attention_info->owner)) {
> >  		retval = attention_info->set_attn(hotplug_slot, status);
> > @@ -200,7 +202,7 @@ static int get_power_status(struct hotplug_slot
> > *hotplug_slot, u8 *value) {
> >  	struct slot *slot = hotplug_slot->private;
> >
> > -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
> >
> >  	*value = acpiphp_get_power_status(slot->acpi_slot);
> >
> > @@ -222,7 +224,7 @@ static int get_attention_status(struct hotplug_slot
> > *hotplug_slot, u8 *value) {
> >  	int retval = -EINVAL;
> >
> > -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > +	dbg("%s - physical_slot = %s\n", __func__,
> > hotplug_slot_name(hotplug_slot));
> >
> >  	if (attention_info && try_module_get(attention_info->owner)) {
> >  		retval = attention_info->get_attn(hotplug_slot, value);
> > @@ -245,7 +247,7 @@ static int get_latch_status(struct hotplug_slot
> > *hotplug_slot, u8 *value) {
> >  	struct slot *slot = hotplug_slot->private;
> >
> > -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
> >
> >  	*value = acpiphp_get_latch_status(slot->acpi_slot);
> >
> > @@ -265,7 +267,7 @@ static int get_adapter_status(struct hotplug_slot
> > *hotplug_slot, u8 *value) {
> >  	struct slot *slot = hotplug_slot->private;
> >
> > -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
> >
> >  	*value = acpiphp_get_adapter_status(slot->acpi_slot);
> >
> > @@ -299,7 +301,7 @@ static void release_slot(struct hotplug_slot
> > *hotplug_slot) {
> >  	struct slot *slot = hotplug_slot->private;
> >
> > -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
> >
> >  	kfree(slot->hotplug_slot);
> >  	kfree(slot);
> > @@ -310,6 +312,7 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot
> > *acpiphp_slot) {
> >  	struct slot *slot;
> >  	int retval = -ENOMEM;
> > +	char name[SLOT_NAME_SIZE];
> >
> >  	slot = kzalloc(sizeof(*slot), GFP_KERNEL);
> >  	if (!slot)
> > @@ -321,8 +324,6 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot
> > *acpiphp_slot)
> >
> >  	slot->hotplug_slot->info = &slot->info;
> >
> > -	slot->hotplug_slot->name = slot->name;
> > -
> >  	slot->hotplug_slot->private = slot;
> >  	slot->hotplug_slot->release = &release_slot;
> >  	slot->hotplug_slot->ops = &acpi_hotplug_slot_ops;
> > @@ -336,12 +337,13 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot
> > *acpiphp_slot) slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
> >
> >  	acpiphp_slot->slot = slot;
> > -	snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun);
> > +	memset(name, 0, SLOT_NAME_SIZE);
> > +	snprintf(name, SLOT_NAME_SIZE, "%u", slot->acpi_slot->sun);
> 
> The memset() is not needed at all. And the sizeof is IMHO a good idea anyway 
> as it allows to get rid of the define.

Hm, don't need a memset? I won't have garbage on the stack?
</n00b>

On the other hand, keeping the #define is important, because
again, that's the established convention of the PCI hotplug
drivers.

Thanks for the review.

/ac

> 
> >  	retval = pci_hp_register(slot->hotplug_slot,
> >  					acpiphp_slot->bridge->pci_bus,
> >  					acpiphp_slot->device,
> > -					slot->name);
> > +					name);
> >  	if (retval == -EBUSY)
> >  		goto error_hpslot;
> >  	if (retval) {
> > @@ -349,7 +351,7 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot
> > *acpiphp_slot) goto error_hpslot;
> >   	}
> >
> > -	info("Slot [%s] registered\n", slot->hotplug_slot->name);
> > +	info("Slot [%s] registered\n", slot_name(slot));
> >
> >  	return 0;
> >  error_hpslot:
> > @@ -366,7 +368,7 @@ void acpiphp_unregister_hotplug_slot(struct
> > acpiphp_slot *acpiphp_slot) struct slot *slot = acpiphp_slot->slot;
> >  	int retval = 0;
> >
> > -	info ("Slot [%s] unregistered\n", slot->hotplug_slot->name);
> > +	info ("Slot [%s] unregistered\n", slot_name(slot));
> >
> >  	retval = pci_hp_deregister(slot->hotplug_slot);
> >  	if (retval)
> 
> Greetings,
> 
> Eike



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

* Re: [PATCH 04/13] PCI: acpiphp: remove 'name' parameter
  2008-08-19 18:39     ` Alex Chiang
@ 2008-08-19 21:01       ` Rolf Eike Beer
  2008-08-19 21:26         ` Alex Chiang
  2008-08-19 21:40       ` Jesse Barnes
  1 sibling, 1 reply; 55+ messages in thread
From: Rolf Eike Beer @ 2008-08-19 21:01 UTC (permalink / raw)
  To: Alex Chiang, linux-kernel, linux-pci, jbarnes, kristen.c.accardi,
	kaneshige.kenji

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

Alex Chiang wrote:
> * Rolf Eike Beer <eike-kernel@sf-tec.de>:
> > Alex Chiang wrote:
> > > We do not need to manage our own name parameter, especially since
> > > the PCI core can change it on our behalf, in the case of duplicate
> > > slot names.
> > >
> > > Remove 'name' from acpiphp's version of struct slot.
> > >
> > > Cc: jbarnes@virtuousgeek.org
> > > Cc: kristen.c.accardi@intel.com
> > > Cc: kaneshige.kenji@jp.fujitsu.com
> > > Signed-off-by: Alex Chiang <achiang@hp.com>
> > > ---
> > >
> > >  drivers/pci/hotplug/acpiphp.h      |    9 +++++----
> > >  drivers/pci/hotplug/acpiphp_core.c |   36
> > > +++++++++++++++++++----------------- 2 files changed, 24 insertions(+),
> > > 21 deletions(-)
> > >
> > > diff --git a/drivers/pci/hotplug/acpiphp.h
> > > b/drivers/pci/hotplug/acpiphp.h index 5a58b07..f9e244d 100644
> > > --- a/drivers/pci/hotplug/acpiphp.h
> > > +++ b/drivers/pci/hotplug/acpiphp.h
> > > @@ -50,9 +50,6 @@
> > >  #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME ,
> > > ## arg) #define warn(format, arg...) printk(KERN_WARNING "%s: " format,
> > > MY_NAME , ## arg)
> > >
> > > -/* name size which is used for entries in pcihpfs */
> > > -#define SLOT_NAME_SIZE	20		/* {_SUN} */
> > > -
> > >  struct acpiphp_bridge;
> > >  struct acpiphp_slot;
> > >
> > > @@ -63,9 +60,13 @@ struct slot {
> > >  	struct hotplug_slot	*hotplug_slot;
> > >  	struct acpiphp_slot	*acpi_slot;
> > >  	struct hotplug_slot_info info;
> > > -	char name[SLOT_NAME_SIZE];
> > >  };
> > >
> > > +static inline const char *slot_name(struct slot *slot)
> > > +{
> > > +	return hotplug_slot_name(slot->hotplug_slot);
> > > +}
> > > +
> > >  /*
> > >   * struct acpiphp_bridge - PCI bridge information
> > >   *
> >
> > I don't see a point in this function. Why not call hotplug_slot_name()
> > directly?
>
> You're correct that we don't exactly need it in acpiphp. However,
> it is a useful helper function for some of the other drivers, and
> I thought it would be better to keep consistency if possible.

I looked into all other patches and the function is the same in every one.

> Also, it helps later on, when trying to stay below the 80 column
> limit. :)

Rip it.

> > > diff --git a/drivers/pci/hotplug/acpiphp_core.c
> > > b/drivers/pci/hotplug/acpiphp_core.c index e984176..687cac3 100644
> > > --- a/drivers/pci/hotplug/acpiphp_core.c
> > > +++ b/drivers/pci/hotplug/acpiphp_core.c
> > > @@ -44,6 +44,9 @@
> > >
> > >  #define MY_NAME	"acpiphp"
> > >
> > > +/* name size which is used for entries in pcihpfs */
> > > +#define SLOT_NAME_SIZE  20              /* {_SUN} */
> > > +
> > >  static int debug;
> > >  int acpiphp_debug;
> > >
> > > @@ -84,7 +87,6 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops
> > > = { .get_adapter_status	= get_adapter_status,
> > >  };
> > >
> > > -
> > >  /**
> > >   * acpiphp_register_attention - set attention LED callback
> > >   * @info: must be completely filled with LED callbacks
> >
> > Fuzz.
>
> Yes, it's fuzz, but my practice has been to clean up* source files
> during the course of making actual, functional changes. Better
> than sending a mostly-useless whitespace patchbomb, IMO.
>
> * Note that "clean up" here means "reasonable cleanup" that
>   doesn't detract from reading the rest of the patch.
>
> > > @@ -92,7 +94,7 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops
> > > = { * Description: This is used to register a hardware specific ACPI *
> > > driver that manipulates the attention LED.  All the fields in * info
> > > must be set.
> > > - */
> > > + **/
> > >  int acpiphp_register_attention(struct acpiphp_attention_info *info)
> > >  {
> > >  	int retval = -EINVAL;
> >
> > Fuzz. Make the patch look bigger than it actually is. But that's just a
> > note, Jesse will have to judge if this is acceptable.
>
> See above. Fixing incorrect kerneldoc doesn't seem so bad, IMO.

As I said: Jesse's decision. The smaller the patch is the easier get's the 
review.

> > > @@ -113,7 +115,7 @@ int acpiphp_register_attention(struct
> > > acpiphp_attention_info *info) * Description: This is used to
> > > un-register a hardware specific acpi * driver that manipulates the
> > > attention LED.  The pointer to the * info struct must be the same as
> > > the one used to set it. - */
> > > + **/
> > >  int acpiphp_unregister_attention(struct acpiphp_attention_info *info)
> > >  {
> > >  	int retval = -EINVAL;
> > > @@ -136,7 +138,7 @@ static int enable_slot(struct hotplug_slot
> > > *hotplug_slot) {
> > >  	struct slot *slot = hotplug_slot->private;
> > >
> > > -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > > +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
> > >
> > >  	/* enable the specified slot */
> > >  	return acpiphp_enable_slot(slot->acpi_slot);
> > > @@ -154,7 +156,7 @@ static int disable_slot(struct hotplug_slot
> > > *hotplug_slot) struct slot *slot = hotplug_slot->private;
> > >  	int retval;
> > >
> > > -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > > +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
> > >
> > >  	/* disable the specified slot */
> > >  	retval = acpiphp_disable_slot(slot->acpi_slot);
> > > @@ -177,7 +179,7 @@ static int disable_slot(struct hotplug_slot
> > > *hotplug_slot) {
> > >  	int retval = -ENODEV;
> > >
> > > - 	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > > +	dbg("%s - physical_slot = %s\n", __func__,
> > > hotplug_slot_name(hotplug_slot));
> > >
> > >  	if (attention_info && try_module_get(attention_info->owner)) {
> > >  		retval = attention_info->set_attn(hotplug_slot, status);
> > > @@ -200,7 +202,7 @@ static int get_power_status(struct hotplug_slot
> > > *hotplug_slot, u8 *value) {
> > >  	struct slot *slot = hotplug_slot->private;
> > >
> > > -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > > +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
> > >
> > >  	*value = acpiphp_get_power_status(slot->acpi_slot);
> > >
> > > @@ -222,7 +224,7 @@ static int get_attention_status(struct hotplug_slot
> > > *hotplug_slot, u8 *value) {
> > >  	int retval = -EINVAL;
> > >
> > > -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > > +	dbg("%s - physical_slot = %s\n", __func__,
> > > hotplug_slot_name(hotplug_slot));
> > >
> > >  	if (attention_info && try_module_get(attention_info->owner)) {
> > >  		retval = attention_info->get_attn(hotplug_slot, value);
> > > @@ -245,7 +247,7 @@ static int get_latch_status(struct hotplug_slot
> > > *hotplug_slot, u8 *value) {
> > >  	struct slot *slot = hotplug_slot->private;
> > >
> > > -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > > +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
> > >
> > >  	*value = acpiphp_get_latch_status(slot->acpi_slot);
> > >
> > > @@ -265,7 +267,7 @@ static int get_adapter_status(struct hotplug_slot
> > > *hotplug_slot, u8 *value) {
> > >  	struct slot *slot = hotplug_slot->private;
> > >
> > > -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > > +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
> > >
> > >  	*value = acpiphp_get_adapter_status(slot->acpi_slot);
> > >
> > > @@ -299,7 +301,7 @@ static void release_slot(struct hotplug_slot
> > > *hotplug_slot) {
> > >  	struct slot *slot = hotplug_slot->private;
> > >
> > > -	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
> > > +	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
> > >
> > >  	kfree(slot->hotplug_slot);
> > >  	kfree(slot);
> > > @@ -310,6 +312,7 @@ int acpiphp_register_hotplug_slot(struct
> > > acpiphp_slot *acpiphp_slot) {
> > >  	struct slot *slot;
> > >  	int retval = -ENOMEM;
> > > +	char name[SLOT_NAME_SIZE];
> > >
> > >  	slot = kzalloc(sizeof(*slot), GFP_KERNEL);
> > >  	if (!slot)
> > > @@ -321,8 +324,6 @@ int acpiphp_register_hotplug_slot(struct
> > > acpiphp_slot *acpiphp_slot)
> > >
> > >  	slot->hotplug_slot->info = &slot->info;
> > >
> > > -	slot->hotplug_slot->name = slot->name;
> > > -
> > >  	slot->hotplug_slot->private = slot;
> > >  	slot->hotplug_slot->release = &release_slot;
> > >  	slot->hotplug_slot->ops = &acpi_hotplug_slot_ops;
> > > @@ -336,12 +337,13 @@ int acpiphp_register_hotplug_slot(struct
> > > acpiphp_slot *acpiphp_slot) slot->hotplug_slot->info->cur_bus_speed =
> > > PCI_SPEED_UNKNOWN;
> > >
> > >  	acpiphp_slot->slot = slot;
> > > -	snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun);
> > > +	memset(name, 0, SLOT_NAME_SIZE);
> > > +	snprintf(name, SLOT_NAME_SIZE, "%u", slot->acpi_slot->sun);
> >
> > The memset() is not needed at all. And the sizeof is IMHO a good idea
> > anyway as it allows to get rid of the define.
>
> Hm, don't need a memset? I won't have garbage on the stack?
> </n00b>

Yes, you have garbage on the stack. But snprintf() does not care what is in 
the buffer before it starts and the result is 0-terminated afterwards.

> On the other hand, keeping the #define is important, because
> again, that's the established convention of the PCI hotplug
> drivers.

I would not bet on this. It has been there and copied around from one driver 
to the other. If we can get rid of those I guess noone would be upset. And 
you introduced at least two of them ;) Jesse? 

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH 04/13] PCI: acpiphp: remove 'name' parameter
  2008-08-19 21:01       ` Rolf Eike Beer
@ 2008-08-19 21:26         ` Alex Chiang
  0 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-08-19 21:26 UTC (permalink / raw)
  To: Rolf Eike Beer
  Cc: linux-kernel, linux-pci, jbarnes, kristen.c.accardi, kaneshige.kenji

* Rolf Eike Beer <eike-kernel@sf-tec.de>:
> Alex Chiang wrote:
> > * Rolf Eike Beer <eike-kernel@sf-tec.de>:
> > > Alex Chiang wrote:
> > > >
> > > > +static inline const char *slot_name(struct slot *slot)
> > > > +{
> > > > +	return hotplug_slot_name(slot->hotplug_slot);
> > > > +}
> > > > +
> > > >  /*
> > > >   * struct acpiphp_bridge - PCI bridge information
> > > >   *
> > >
> > > I don't see a point in this function. Why not call hotplug_slot_name()
> > > directly?
> >
> > You're correct that we don't exactly need it in acpiphp. However,
> > it is a useful helper function for some of the other drivers, and
> > I thought it would be better to keep consistency if possible.
> 
> I looked into all other patches and the function is the same in every one.

For example, in shpchp, I use slot_name() in both shpchp_core.c
and in shpchp_ctrl.c. This is the case for a few other drivers
too.

Based on that reasoning, I felt a little consistency across
drivers was warranted. Besides, the generated code should be the
same.

> > > >  	acpiphp_slot->slot = slot;
> > > > -	snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun);
> > > > +	memset(name, 0, SLOT_NAME_SIZE);
> > > > +	snprintf(name, SLOT_NAME_SIZE, "%u", slot->acpi_slot->sun);
> > >
> > > The memset() is not needed at all. And the sizeof is IMHO a good idea
> > > anyway as it allows to get rid of the define.
> >
> > Hm, don't need a memset? I won't have garbage on the stack?
> > </n00b>
> 
> Yes, you have garbage on the stack. But snprintf() does not care what is in 
> the buffer before it starts and the result is 0-terminated afterwards.

Ok, you're right. For some reason, I was thinking that there were
versions of snprintf() that did not NULL-terminate in the event
of truncation, but I checked the kernel implementation, and it
does NULL terminate in either case.

Besides, it looks like I should be using scnprintf() instead. So
I'll rework the patches.
 
> > On the other hand, keeping the #define is important, because
> > again, that's the established convention of the PCI hotplug
> > drivers.
> 
> I would not bet on this. It has been there and copied around
> from one driver to the other. If we can get rid of those I
> guess noone would be upset. And you introduced at least two of
> them ;) Jesse? 

The #define exists in the original pcihp_skeleton.c example.

This is perhaps the 2nd or 3rd time I've swept through the
PCI hotplug drivers for cleanups, and for me, I really prefer
some sort of consistency, otherwise I go insane trying to keep
track of the differences.

But I will defer to Jesse's opinion.

Thanks,

/ac


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

* Re: [PATCH 04/13] PCI: acpiphp: remove 'name' parameter
  2008-08-19 18:39     ` Alex Chiang
  2008-08-19 21:01       ` Rolf Eike Beer
@ 2008-08-19 21:40       ` Jesse Barnes
  2008-08-19 23:50         ` Alex Chiang
  1 sibling, 1 reply; 55+ messages in thread
From: Jesse Barnes @ 2008-08-19 21:40 UTC (permalink / raw)
  To: Alex Chiang
  Cc: Rolf Eike Beer, linux-kernel, linux-pci, kristen.c.accardi,
	kaneshige.kenji

On Tuesday, August 19, 2008 11:39 am Alex Chiang wrote:
> * Rolf Eike Beer <eike-kernel@sf-tec.de>:
> > Alex Chiang wrote:
> > > +static inline const char *slot_name(struct slot *slot)
> > > +{
> > > +	return hotplug_slot_name(slot->hotplug_slot);
> > > +}
> > > +
> > >  /*
> > >   * struct acpiphp_bridge - PCI bridge information
> > >   *
> >
> > I don't see a point in this function. Why not call hotplug_slot_name()
> > directly?
>
> You're correct that we don't exactly need it in acpiphp. However,
> it is a useful helper function for some of the other drivers, and
> I thought it would be better to keep consistency if possible.
>
> Also, it helps later on, when trying to stay below the 80 column
> limit. :)

If they're all identical, maybe we should pull this up into a common function 
(with a short name :).  That can be a subsequent cleanup though.

> > > @@ -84,7 +87,6 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops
> > > = { .get_adapter_status	= get_adapter_status,
> > >  };
> > >
> > > -
> > >  /**
> > >   * acpiphp_register_attention - set attention LED callback
> > >   * @info: must be completely filled with LED callbacks
> >
> > Fuzz.
>
> Yes, it's fuzz, but my practice has been to clean up* source files
> during the course of making actual, functional changes. Better
> than sending a mostly-useless whitespace patchbomb, IMO.
>
> * Note that "clean up" here means "reasonable cleanup" that
>   doesn't detract from reading the rest of the patch.

Yeah the main reason for separating whitespace changes from real ones is to 
avoid making the patch hard to read in case a problem crops up.  Killing an 
extra newline doesn't make things harder to read, imo, so it's fine with me 
if you keep it (though if you *do* end up doing a cleanup patch later you 
could save it for that).

> > > @@ -92,7 +94,7 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops
> > > = { * Description: This is used to register a hardware specific ACPI *
> > > driver that manipulates the attention LED.  All the fields in * info
> > > must be set.
> > > - */
> > > + **/
> > >  int acpiphp_register_attention(struct acpiphp_attention_info *info)
> > >  {
> > >  	int retval = -EINVAL;
> >
> > Fuzz. Make the patch look bigger than it actually is. But that's just a
> > note, Jesse will have to judge if this is acceptable.
>
> See above. Fixing incorrect kerneldoc doesn't seem so bad, IMO.

kerneldoc is ok with either */ or **/ as a closing comment, so you can drop 
these bits.

> > >  	acpiphp_slot->slot = slot;
> > > -	snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun);
> > > +	memset(name, 0, SLOT_NAME_SIZE);
> > > +	snprintf(name, SLOT_NAME_SIZE, "%u", slot->acpi_slot->sun);
> >
> > The memset() is not needed at all. And the sizeof is IMHO a good idea
> > anyway as it allows to get rid of the define.
>
> Hm, don't need a memset? I won't have garbage on the stack?
> </n00b>

Yeah, but you'll overwrite it with snprintf anyway, so the memset is 
redundant.

> On the other hand, keeping the #define is important, because
> again, that's the established convention of the PCI hotplug
> drivers.
>
> Thanks for the review.

Going from the define to sizeof() everywhere could be another cleanup, but I 
don't have strong feelings about that.

Jesse

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

* Re: [PATCH 04/13] PCI: acpiphp: remove 'name' parameter
  2008-08-19 21:40       ` Jesse Barnes
@ 2008-08-19 23:50         ` Alex Chiang
  2008-08-20  2:25           ` Kenji Kaneshige
  0 siblings, 1 reply; 55+ messages in thread
From: Alex Chiang @ 2008-08-19 23:50 UTC (permalink / raw)
  To: Jesse Barnes
  Cc: Rolf Eike Beer, linux-kernel, linux-pci, kristen.c.accardi,
	kaneshige.kenji

* Jesse Barnes <jbarnes@virtuousgeek.org>:
> On Tuesday, August 19, 2008 11:39 am Alex Chiang wrote:
> > * Rolf Eike Beer <eike-kernel@sf-tec.de>:
> > > Alex Chiang wrote:
> > > > +static inline const char *slot_name(struct slot *slot)
> > > > +{
> > > > +	return hotplug_slot_name(slot->hotplug_slot);
> > > > +}
> > > > +
> > > >  /*
> > > >   * struct acpiphp_bridge - PCI bridge information
> > > >   *
> > >
> > > I don't see a point in this function. Why not call hotplug_slot_name()
> > > directly?
> >
> > You're correct that we don't exactly need it in acpiphp. However,
> > it is a useful helper function for some of the other drivers, and
> > I thought it would be better to keep consistency if possible.
> >
> > Also, it helps later on, when trying to stay below the 80 column
> > limit. :)
> 
> If they're all identical, maybe we should pull this up into a
> common function (with a short name :).  That can be a
> subsequent cleanup though.

Ok, I'll save this for next time. Or someone else can have the
git glory. ;)

> > > > @@ -84,7 +87,6 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops
> > > > = { .get_adapter_status	= get_adapter_status,
> > > >  };
> > > >
> > > > -
> > > >  /**
> > > >   * acpiphp_register_attention - set attention LED callback
> > > >   * @info: must be completely filled with LED callbacks
> > >
> > > Fuzz.
> >
> > Yes, it's fuzz, but my practice has been to clean up* source files
> > during the course of making actual, functional changes. Better
> > than sending a mostly-useless whitespace patchbomb, IMO.
> >
> > * Note that "clean up" here means "reasonable cleanup" that
> >   doesn't detract from reading the rest of the patch.
> 
> Yeah the main reason for separating whitespace changes from
> real ones is to avoid making the patch hard to read in case a
> problem crops up.  Killing an extra newline doesn't make things
> harder to read, imo, so it's fine with me if you keep it
> (though if you *do* end up doing a cleanup patch later you
> could save it for that).

I'll keep the 'kill the newline' here but drop the kerneldoc
stuff. As you point out, kerneldoc will take either */ or **/.

> > > >  	acpiphp_slot->slot = slot;
> > > > -	snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun);
> > > > +	memset(name, 0, SLOT_NAME_SIZE);
> > > > +	snprintf(name, SLOT_NAME_SIZE, "%u", slot->acpi_slot->sun);
> > >
> > > The memset() is not needed at all. And the sizeof is IMHO a good idea
> > > anyway as it allows to get rid of the define.
> >
> > Hm, don't need a memset? I won't have garbage on the stack?
> > </n00b>
> 
> Yeah, but you'll overwrite it with snprintf anyway, so the memset is 
> redundant.

Ok. I went through and removed the superfluous memsets, and
changed instances of snprintf() to scnprintf().

> > On the other hand, keeping the #define is important, because
> > again, that's the established convention of the PCI hotplug
> > drivers.
> >
> > Thanks for the review.
> 
> Going from the define to sizeof() everywhere could be another
> cleanup, but I don't have strong feelings about that.

Ok, saving these for next time too.

I'll hold off from sending v2 until I hear comments from
Kenji-san, so if he has any suggestions, I can incorporate them
all in v2.

Thanks.

/ac


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

* Re: [PATCH 04/13] PCI: acpiphp: remove 'name' parameter
  2008-08-19 23:50         ` Alex Chiang
@ 2008-08-20  2:25           ` Kenji Kaneshige
  0 siblings, 0 replies; 55+ messages in thread
From: Kenji Kaneshige @ 2008-08-20  2:25 UTC (permalink / raw)
  To: Alex Chiang, Jesse Barnes, Rolf Eike Beer, linux-kernel,
	linux-pci, kristen.c.accardi, kaneshige.kenji

Alex Chiang wrote:
> * Jesse Barnes <jbarnes@virtuousgeek.org>:
>> On Tuesday, August 19, 2008 11:39 am Alex Chiang wrote:
>>> * Rolf Eike Beer <eike-kernel@sf-tec.de>:
>>>> Alex Chiang wrote:
>>>>> +static inline const char *slot_name(struct slot *slot)
>>>>> +{
>>>>> +	return hotplug_slot_name(slot->hotplug_slot);
>>>>> +}
>>>>> +
>>>>>  /*
>>>>>   * struct acpiphp_bridge - PCI bridge information
>>>>>   *
>>>> I don't see a point in this function. Why not call hotplug_slot_name()
>>>> directly?
>>> You're correct that we don't exactly need it in acpiphp. However,
>>> it is a useful helper function for some of the other drivers, and
>>> I thought it would be better to keep consistency if possible.
>>>
>>> Also, it helps later on, when trying to stay below the 80 column
>>> limit. :)
>> If they're all identical, maybe we should pull this up into a
>> common function (with a short name :).  That can be a
>> subsequent cleanup though.
> 
> Ok, I'll save this for next time. Or someone else can have the
> git glory. ;)
> 
>>>>> @@ -84,7 +87,6 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops
>>>>> = { .get_adapter_status	= get_adapter_status,
>>>>>  };
>>>>>
>>>>> -
>>>>>  /**
>>>>>   * acpiphp_register_attention - set attention LED callback
>>>>>   * @info: must be completely filled with LED callbacks
>>>> Fuzz.
>>> Yes, it's fuzz, but my practice has been to clean up* source files
>>> during the course of making actual, functional changes. Better
>>> than sending a mostly-useless whitespace patchbomb, IMO.
>>>
>>> * Note that "clean up" here means "reasonable cleanup" that
>>>   doesn't detract from reading the rest of the patch.
>> Yeah the main reason for separating whitespace changes from
>> real ones is to avoid making the patch hard to read in case a
>> problem crops up.  Killing an extra newline doesn't make things
>> harder to read, imo, so it's fine with me if you keep it
>> (though if you *do* end up doing a cleanup patch later you
>> could save it for that).
> 
> I'll keep the 'kill the newline' here but drop the kerneldoc
> stuff. As you point out, kerneldoc will take either */ or **/.
> 
>>>>>  	acpiphp_slot->slot = slot;
>>>>> -	snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun);
>>>>> +	memset(name, 0, SLOT_NAME_SIZE);
>>>>> +	snprintf(name, SLOT_NAME_SIZE, "%u", slot->acpi_slot->sun);
>>>> The memset() is not needed at all. And the sizeof is IMHO a good idea
>>>> anyway as it allows to get rid of the define.
>>> Hm, don't need a memset? I won't have garbage on the stack?
>>> </n00b>
>> Yeah, but you'll overwrite it with snprintf anyway, so the memset is 
>> redundant.
> 
> Ok. I went through and removed the superfluous memsets, and
> changed instances of snprintf() to scnprintf().
> 
>>> On the other hand, keeping the #define is important, because
>>> again, that's the established convention of the PCI hotplug
>>> drivers.
>>>
>>> Thanks for the review.
>> Going from the define to sizeof() everywhere could be another
>> cleanup, but I don't have strong feelings about that.
> 
> Ok, saving these for next time too.
> 
> I'll hold off from sending v2 until I hear comments from
> Kenji-san, so if he has any suggestions, I can incorporate them
> all in v2.
> 

Hi Alex-san, and all,

I'm sorry for my delay. I had been on vacation on these days.
I'll review your patches as soon as possible.

Thanks,
Kenji Kaneshige




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

* Re: [PATCH 02/13] PCI: prevent duplicate slot names
  2008-08-17  0:16 ` [PATCH 02/13] PCI: prevent duplicate slot names Alex Chiang
@ 2008-08-21 10:24   ` Kenji Kaneshige
  2008-09-09  9:04     ` Alex Chiang
  0 siblings, 1 reply; 55+ messages in thread
From: Kenji Kaneshige @ 2008-08-21 10:24 UTC (permalink / raw)
  To: Alex Chiang; +Cc: linux-kernel, linux-pci, jbarnes, kristen.c.accardi, matthew

Hi Alex-san,

Thank you for updated patches and I'm sorry for delayed comment.
I reviewed your patch and I found two problems. Please see below.

Alex Chiang wrote:
> Prevent callers of pci_create_slot() from registering slots with
> duplicate names. This condition occurs most often when PCI hotplug
> drivers are loaded on platforms with broken firmware that assigns
> identical names to multiple slots.
> 
> We now rename these duplicate slots on behalf of the user.
> 
> If firmware assigns the name N to multiple slots, then:
> 
> 	The first registered slot is assigned N
> 	The second registered slot is assigned N-1
> 	The third registered slot is assigned N-2
> 	The Mth registered slot becomes N-M
> 
> A side effect of this patch is that the error condition for when
> multiple drivers attempt to claim the same slot becomes much more
> prominent.
> 
> In other words, the previous error condition returned for
> duplicate slot names (-EEXIST) masked the case when multiple
> drivers attempted to claim the same slot. Now, the -EBUSY return
> makes the true error more obvious.
> 
> Finally, since we now prevent duplicate slot names, we remove
> the logic introduced by the following commits:
> 
> 	pci hotplug core: add check of duplicate slot name
> 	a86161b3134465f072d965ca7508ec9c1e2e52c7
> 
> 	pciehp: fix slot name
> 	3800345f723fd130d50434d4717b99d4a9f383c8
> 
> 	pciehp: add message about pciehp_slot_with_bus option
> 	9e4f2e8d4ddb04ad16a3828cd9a369a5a5287009
> 
> 	shpchp: fix slot name
> 	ef0ff95f136f0f2d035667af5d18b824609de320
> 
> 	shpchp: add message about shpchp_slot_with_bus option
> 	b3bd307c628af2f0a581c42d5d7e4bcdbbf64b6a
> 
> Cc: jbarnes@virtuousgeek.org
> Cc: kristen.c.accardi@intel.com
> Cc: matthew@wil.cx
> Cc: kaneshige.kenji@jp.fujitsu.com
> Signed-off-by: Alex Chiang <achiang@hp.com>
> ---
> 
>  drivers/pci/hotplug/pci_hotplug_core.c |    4 -
>  drivers/pci/hotplug/pciehp.h           |    1 
>  drivers/pci/hotplug/pciehp_core.c      |    7 --
>  drivers/pci/hotplug/pciehp_hpc.c       |    6 --
>  drivers/pci/hotplug/shpchp_core.c      |   14 -----
>  drivers/pci/slot.c                     |   93 +++++++++++++++++++++++++-------
>  6 files changed, 76 insertions(+), 49 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
> index 96f274e..da5908f 100644
> --- a/drivers/pci/hotplug/pci_hotplug_core.c
> +++ b/drivers/pci/hotplug/pci_hotplug_core.c
> @@ -570,10 +570,6 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
>  		return -EINVAL;
>  	}
>  
> -	/* Check if we have already registered a slot with the same name. */
> -	if (get_slot_from_name(name))
> -		return -EEXIST;
> -
>  	/*
>  	 * No problems if we call this interface from both ACPI_PCI_SLOT
>  	 * driver and call it here again. If we've already created the
> diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
> index e3a1e7e..9e6cec6 100644
> --- a/drivers/pci/hotplug/pciehp.h
> +++ b/drivers/pci/hotplug/pciehp.h
> @@ -43,7 +43,6 @@ extern int pciehp_poll_mode;
>  extern int pciehp_poll_time;
>  extern int pciehp_debug;
>  extern int pciehp_force;
> -extern int pciehp_slot_with_bus;
>  extern struct workqueue_struct *pciehp_wq;
>  
>  #define dbg(format, arg...)						\
> diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
> index 5952315..bed77af 100644
> --- a/drivers/pci/hotplug/pciehp_core.c
> +++ b/drivers/pci/hotplug/pciehp_core.c
> @@ -41,7 +41,6 @@ int pciehp_debug;
>  int pciehp_poll_mode;
>  int pciehp_poll_time;
>  int pciehp_force;
> -int pciehp_slot_with_bus;
>  struct workqueue_struct *pciehp_wq;
>  
>  #define DRIVER_VERSION	"0.4"
> @@ -56,12 +55,10 @@ module_param(pciehp_debug, bool, 0644);
>  module_param(pciehp_poll_mode, bool, 0644);
>  module_param(pciehp_poll_time, int, 0644);
>  module_param(pciehp_force, bool, 0644);
> -module_param(pciehp_slot_with_bus, bool, 0644);
>  MODULE_PARM_DESC(pciehp_debug, "Debugging mode enabled or not");
>  MODULE_PARM_DESC(pciehp_poll_mode, "Using polling mechanism for hot-plug events or not");
>  MODULE_PARM_DESC(pciehp_poll_time, "Polling mechanism frequency, in seconds");
>  MODULE_PARM_DESC(pciehp_force, "Force pciehp, even if _OSC and OSHP are missing");
> -MODULE_PARM_DESC(pciehp_slot_with_bus, "Use bus number in the slot name");
>  
>  #define PCIE_MODULE_NAME "pciehp"
>  
> @@ -226,10 +223,6 @@ static int init_slots(struct controller *ctrl)
>  					 slot->name);
>  		if (retval) {
>  			err("pci_hp_register failed with error %d\n", retval);
> -			if (retval == -EEXIST)
> -				err("Failed to register slot because of name "
> -				    "collision. Try \'pciehp_slot_with_bus\' "
> -				    "module option.\n");
>  			goto error_info;
>  		}
>  		/* create additional sysfs entries */
> diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
> index ad27e9e..43ff979 100644
> --- a/drivers/pci/hotplug/pciehp_hpc.c
> +++ b/drivers/pci/hotplug/pciehp_hpc.c
> @@ -1032,11 +1032,7 @@ static void pcie_shutdown_notification(struct controller *ctrl)
>  
>  static void make_slot_name(struct slot *slot)
>  {
> -	if (pciehp_slot_with_bus)
> -		snprintf(slot->name, SLOT_NAME_SIZE, "%04d_%04d",
> -			 slot->bus, slot->number);
> -	else
> -		snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number);
> +	snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number);
>  }
>  
>  static int pcie_init_slot(struct controller *ctrl)
> diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
> index 7bc06c0..136d9ea 100644
> --- a/drivers/pci/hotplug/shpchp_core.c
> +++ b/drivers/pci/hotplug/shpchp_core.c
> @@ -39,7 +39,6 @@
>  int shpchp_debug;
>  int shpchp_poll_mode;
>  int shpchp_poll_time;
> -static int shpchp_slot_with_bus;
>  struct workqueue_struct *shpchp_wq;
>  
>  #define DRIVER_VERSION	"0.4"
> @@ -53,11 +52,9 @@ MODULE_LICENSE("GPL");
>  module_param(shpchp_debug, bool, 0644);
>  module_param(shpchp_poll_mode, bool, 0644);
>  module_param(shpchp_poll_time, int, 0644);
> -module_param(shpchp_slot_with_bus, bool, 0644);
>  MODULE_PARM_DESC(shpchp_debug, "Debugging mode enabled or not");
>  MODULE_PARM_DESC(shpchp_poll_mode, "Using polling mechanism for hot-plug events or not");
>  MODULE_PARM_DESC(shpchp_poll_time, "Polling mechanism frequency, in seconds");
> -MODULE_PARM_DESC(shpchp_slot_with_bus, "Use bus number in the slot name");
>  
>  #define SHPC_MODULE_NAME "shpchp"
>  
> @@ -101,12 +98,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
>  
>  static void make_slot_name(struct slot *slot)
>  {
> -	if (shpchp_slot_with_bus)
> -		snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%04d_%04d",
> -			 slot->bus, slot->number);
> -	else
> -		snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%d",
> -			 slot->number);
> +	snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%d", slot->number);
>  }
>  
>  static int init_slots(struct controller *ctrl)
> @@ -162,10 +154,6 @@ static int init_slots(struct controller *ctrl)
>  				hotplug_slot->name);
>  		if (retval) {
>  			err("pci_hp_register failed with error %d\n", retval);
> -			if (retval == -EEXIST)
> -				err("Failed to register slot because of name "
> -                                    "collision. Try \'shpchp_slot_with_bus\' "
> -				    "module option.\n");
>  			goto error_info;
>  		}
>  
> diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
> index 7e5b85c..42f0e12 100644
> --- a/drivers/pci/slot.c
> +++ b/drivers/pci/slot.c
> @@ -73,6 +73,50 @@ static struct kobj_type pci_slot_ktype = {
>  	.default_attrs = pci_slot_default_attrs,
>  };
>  
> +static char *make_slot_name(const char *name)
> +{
> +	char *new_name;
> +	int len, width, dup = 1;
> +	struct kobject *dup_slot;
> +
> +	new_name = kstrdup(name, GFP_KERNEL);
> +	if (!new_name)
> +		goto out;
> +
> +	/*
> +	 * Start off allocating enough room for "name-X"
> +	 */
> +	len = strlen(name) + 2;
> +	width = 1;
> +
> +try_again:
> +	dup_slot = kset_find_obj(pci_slots_kset, new_name);
> +	if (!dup_slot)
> +		goto out;
> +

The kset_find_obj() increments reference counter of specified kobject. So
we must call kobject_put() for 'dup_slot', otherwise it leaks reference
counter of 'dup_slot' kobject and the corresponding slot directory will
never be removed. Here is a sample to fix this problem.

	dup_slot = kset_find_ojb(pci_slots_kset, new_name);
	if (!dup_slot)
		goto out;
	kobject_put(dup_slot);
	^^^^^^^^^^^^^^^^^^^^^^ Added this line


I found another problem in pci_hp_register() that would be more complex
to fix than above-mentioned problem. Here is a pci_hp_register() with
all of your patch applied.

int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
                        const char *name)
{
	(snip...)

        /*
         * No problems if we call this interface from both ACPI_PCI_SLOT
         * driver and call it here again. If we've already created the
         * pci_slot, the interface will simply bump the refcount.
         */
        pci_slot = pci_create_slot(bus, slot_nr, name);
        if (IS_ERR(pci_slot))
                return PTR_ERR(pci_slot);

        if (pci_slot->hotplug) {
                dbg("%s: already claimed\n", __func__);
                pci_destroy_slot(pci_slot);
                return -EBUSY;
        }

        slot->pci_slot = pci_slot;
        pci_slot->hotplug = slot;

        /*
         * Allow pcihp drivers to override the ACPI_PCI_SLOT name.
         */
        if (strcmp(kobject_name(&pci_slot->kobj), name)) {
                result = kobject_rename(&pci_slot->kobj, name);
                if (result) {
                        pci_destroy_slot(pci_slot);
                        return result;
                }
        }

	(snip...)
}

If name duplication was detected in pci_create_slot(), it renames the
slot name like 'N-1' and return successfully. Even though slot's kobject
name was registered as 'N-1', 'name' array still have 'N' at this point.
So the following 'if' statement becomes true unexpectedly.

	/*
         * Allow pcihp drivers to override the ACPI_PCI_SLOT name.
         */
        if (strcmp(kobject_name(&pci_slot->kobj), name)) {

Then pci_hp_register() attempt to rename the slot name with 'N' again
by calling kobject_rename(), but it fails because there already exists
kobject with name 'N'. As a result, pci_hp_register() will fail.

Thanks,
Kenji Kaneshige



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

* Re: [PATCH 02/13] PCI: prevent duplicate slot names
  2008-08-21 10:24   ` Kenji Kaneshige
@ 2008-09-09  9:04     ` Alex Chiang
  2008-09-11  2:43       ` Kenji Kaneshige
  0 siblings, 1 reply; 55+ messages in thread
From: Alex Chiang @ 2008-09-09  9:04 UTC (permalink / raw)
  To: Kenji Kaneshige
  Cc: linux-kernel, linux-pci, jbarnes, kristen.c.accardi, matthew

Hi Kenji-san,

As always, thank you very much for the excellent review.

Sorry for the delay; I've been busy with travel, and trying to
figure out how to solve the issue you pointed out below.

* Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>:
> Hi Alex-san,
>
> Thank you for updated patches and I'm sorry for delayed comment.
> I reviewed your patch and I found two problems. Please see below.
>
> Alex Chiang wrote:
>> Prevent callers of pci_create_slot() from registering slots with
>> duplicate names. This condition occurs most often when PCI hotplug
>> drivers are loaded on platforms with broken firmware that assigns
>> identical names to multiple slots.
>>
>> We now rename these duplicate slots on behalf of the user.
>>
>> If firmware assigns the name N to multiple slots, then:
>>
>> 	The first registered slot is assigned N
>> 	The second registered slot is assigned N-1
>> 	The third registered slot is assigned N-2
>> 	The Mth registered slot becomes N-M
>>
>> A side effect of this patch is that the error condition for when
>> multiple drivers attempt to claim the same slot becomes much more
>> prominent.
>>
>> In other words, the previous error condition returned for
>> duplicate slot names (-EEXIST) masked the case when multiple
>> drivers attempted to claim the same slot. Now, the -EBUSY return
>> makes the true error more obvious.
>>
>> Finally, since we now prevent duplicate slot names, we remove
>> the logic introduced by the following commits:
>>
>>  +static char *make_slot_name(const char *name)
>> +{
>> +	char *new_name;
>> +	int len, width, dup = 1;
>> +	struct kobject *dup_slot;
>> +
>> +	new_name = kstrdup(name, GFP_KERNEL);
>> +	if (!new_name)
>> +		goto out;
>> +
>> +	/*
>> +	 * Start off allocating enough room for "name-X"
>> +	 */
>> +	len = strlen(name) + 2;
>> +	width = 1;
>> +
>> +try_again:
>> +	dup_slot = kset_find_obj(pci_slots_kset, new_name);
>> +	if (!dup_slot)
>> +		goto out;
>> +
>
> The kset_find_obj() increments reference counter of specified kobject. So
> we must call kobject_put() for 'dup_slot', otherwise it leaks reference
> counter of 'dup_slot' kobject and the corresponding slot directory will
> never be removed. Here is a sample to fix this problem.
>
> 	dup_slot = kset_find_ojb(pci_slots_kset, new_name);
> 	if (!dup_slot)
> 		goto out;
> 	kobject_put(dup_slot);
> 	^^^^^^^^^^^^^^^^^^^^^^ Added this line

Yes, thanks for catching that. I've fixed it.

> I found another problem in pci_hp_register() that would be more complex
> to fix than above-mentioned problem. Here is a pci_hp_register() with
> all of your patch applied.
>
> int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
>                        const char *name)
> {
> 	(snip...)
>
>        /*
>         * No problems if we call this interface from both ACPI_PCI_SLOT
>         * driver and call it here again. If we've already created the
>         * pci_slot, the interface will simply bump the refcount.
>         */
>        pci_slot = pci_create_slot(bus, slot_nr, name);
>        if (IS_ERR(pci_slot))
>                return PTR_ERR(pci_slot);
>
>        if (pci_slot->hotplug) {
>                dbg("%s: already claimed\n", __func__);
>                pci_destroy_slot(pci_slot);
>                return -EBUSY;
>        }
>
>        slot->pci_slot = pci_slot;
>        pci_slot->hotplug = slot;
>
>        /*
>         * Allow pcihp drivers to override the ACPI_PCI_SLOT name.
>         */
>        if (strcmp(kobject_name(&pci_slot->kobj), name)) {
>                result = kobject_rename(&pci_slot->kobj, name);
>                if (result) {
>                        pci_destroy_slot(pci_slot);
>                        return result;
>                }
>        }
>
> 	(snip...)
> }
>
> If name duplication was detected in pci_create_slot(), it renames the
> slot name like 'N-1' and return successfully. Even though slot's kobject
> name was registered as 'N-1', 'name' array still have 'N' at this point.
> So the following 'if' statement becomes true unexpectedly.
>
> 	/*
>         * Allow pcihp drivers to override the ACPI_PCI_SLOT name.
>         */
>        if (strcmp(kobject_name(&pci_slot->kobj), name)) {
>
> Then pci_hp_register() attempt to rename the slot name with 'N' again
> by calling kobject_rename(), but it fails because there already exists
> kobject with name 'N'. As a result, pci_hp_register() will fail.

Yes, you are right, that is a problem.

I've taken the following approach:

	- the above code is providing a mechanism to allow a
	  _hotplug_ driver to override a _detection_ driver slot
	  name.

	- in other words, we only have to worry about the case
	  when a _detection_ driver was loaded before a _hotplug_
	  driver.

	- we can ignore the case where another _hotplug_ driver
	  was loaded first, because we'll already return -EBUSY.

	- so, to figure out if a _detection_ driver has already
	  been loaded, we check to see if the pci_dev already has
	  a valid pci_slot pointer.

	- if yes, then we later check to see if the existing slot
	  name matches the requested slot name from the hotplug
	  driver.

	- if the hotplug driver is requesting a different name,
	  then we use a new interface, pci_rename_slot() which
	  will safely attempt to rename the slot without name
	  collision.

I'll send out the patch set soon, it would be great if you could
test it for me, since I don't have systems with duplicate slot
names.

Thank you very much!

/ac


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

* [PATCH v2 00/13] PCI: let the core manage slot names
@ 2008-09-09 10:00         ` Alex Chiang
  2008-09-09 10:00           ` [PATCH v2 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface Alex Chiang
                             ` (12 more replies)
  0 siblings, 13 replies; 55+ messages in thread
From: Alex Chiang @ 2008-09-09 10:00 UTC (permalink / raw)
  To: linux-pci, linux-kernel

Hi Jesse,

This is v2 of the series that implements a series of changes
that allows the PCI core to manage slot names, rather than
individual hotplug drivers.

It addresses comments raised during the first round of review,
most notably the bug that Kenji-san found of possible false name
collisions.

This series applies against linux-next.

I'm including the previous explanation/justification to remind
folks of the raison d'etre for this patchset.

Thanks.

/ac

There are several benefits to this approach:

        1) The core can prevent duplicate slot names on systems
           with broken firmware.

        2) Since the kobject core keeps a copy of the slot name,
           there is no need for each driver to manage a separate
           copy, especially since the core can rename slots from
           underneath drivers. We save runtime memory by only
           referencing the kobject name.

        2.a) The PCI hotplug core doesn't need its own reference
             for slot name either.

        3) Individual hotplug drivers become just a little bit
           simpler by pushing as many kzalloc() calls for 'name'
           down into the PCI core as possible.

---

Alex Chiang (13):
      PCI: Hotplug core: remove 'name'
      PCI: shcphp: remove 'name' parameter
      PCI: SGI Hotplug: stop managing bss_hotplug_slot->name
      PCI: rpaphp: stop managing hotplug_slot->name
      PCI: pciehp: remove 'name' parameter
      PCI: ibmphp: stop managing hotplug_slot->name
      PCI: fakephp: remove 'name' parameter
      PCI: cpqphp: stop managing hotplug_slot->name
      PCI: cpci_hotplug: stop managing hotplug_slot->name
      PCI: acpiphp: remove 'name' parameter
      PCI, PCI Hotplug: introduce slot_name helpers
      PCI: prevent duplicate slot names
      PCI Hotplug core: add 'name' param pci_hp_register interface


 drivers/pci/hotplug/acpiphp.h           |    9 +-
 drivers/pci/hotplug/acpiphp_core.c      |   32 +++++---
 drivers/pci/hotplug/cpci_hotplug.h      |    6 ++
 drivers/pci/hotplug/cpci_hotplug_core.c |   74 +++++++-------------
 drivers/pci/hotplug/cpci_hotplug_pci.c  |    4 +
 drivers/pci/hotplug/cpqphp.h            |   13 +--
 drivers/pci/hotplug/cpqphp_core.c       |   40 +++++------
 drivers/pci/hotplug/fakephp.c           |   18 +++--
 drivers/pci/hotplug/ibmphp.h            |    5 +
 drivers/pci/hotplug/ibmphp_ebda.c       |   19 ++---
 drivers/pci/hotplug/pci_hotplug_core.c  |   38 ++++++----
 drivers/pci/hotplug/pciehp.h            |    9 ++
 drivers/pci/hotplug/pciehp_core.c       |   40 ++++-------
 drivers/pci/hotplug/pciehp_ctrl.c       |   48 ++++++-------
 drivers/pci/hotplug/pciehp_hpc.c        |    1 
 drivers/pci/hotplug/rpaphp.h            |   10 ++-
 drivers/pci/hotplug/rpaphp_core.c       |    6 +-
 drivers/pci/hotplug/rpaphp_pci.c        |    4 +
 drivers/pci/hotplug/rpaphp_slot.c       |   26 ++-----
 drivers/pci/hotplug/sgi_hotplug.c       |   18 ++---
 drivers/pci/hotplug/shpchp.h            |    9 ++
 drivers/pci/hotplug/shpchp_core.c       |   42 ++++-------
 drivers/pci/hotplug/shpchp_ctrl.c       |   48 ++++++-------
 drivers/pci/slot.c                      |  117 ++++++++++++++++++++++++++-----
 include/linux/pci.h                     |    8 ++
 include/linux/pci_hotplug.h             |   13 ++-
 26 files changed, 354 insertions(+), 303 deletions(-)


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

* [PATCH v2 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface
  2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
@ 2008-09-09 10:00           ` Alex Chiang
  2008-09-09 12:05             ` Matthew Wilcox
  2008-09-09 10:00           ` [PATCH v2 02/13] PCI: prevent duplicate slot names Alex Chiang
                             ` (11 subsequent siblings)
  12 siblings, 1 reply; 55+ messages in thread
From: Alex Chiang @ 2008-09-09 10:00 UTC (permalink / raw)
  To: linux-pci, linux-kernel
  Cc: jbarnes, kristen.c.accardi, matthew, kaneshige.kenji, Alex Chiang

Update pci_hp_register() to take a const char *name parameter.

The motivation for this is to clean up the individual hotplug
drivers so that each one does not have to manage its own name.
The PCI core should be the place where we manage the name.

We update the interface and all callsites first, in a
"no functional change" manner, and clean up the drivers later.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: matthew@wil.cx
Cc: kaneshige.kenji@jp.fujitsu.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/acpiphp_core.c      |    3 ++-
 drivers/pci/hotplug/cpci_hotplug_core.c |    3 ++-
 drivers/pci/hotplug/cpqphp_core.c       |    3 ++-
 drivers/pci/hotplug/fakephp.c           |    3 ++-
 drivers/pci/hotplug/ibmphp_ebda.c       |    3 ++-
 drivers/pci/hotplug/pci_hotplug_core.c  |   15 ++++++++-------
 drivers/pci/hotplug/pciehp_core.c       |    3 ++-
 drivers/pci/hotplug/rpaphp_slot.c       |    2 +-
 drivers/pci/hotplug/sgi_hotplug.c       |    3 ++-
 drivers/pci/hotplug/shpchp_core.c       |    3 ++-
 include/linux/pci_hotplug.h             |    5 ++++-
 11 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index 0e496e8..e984176 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -340,7 +340,8 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
 
 	retval = pci_hp_register(slot->hotplug_slot,
 					acpiphp_slot->bridge->pci_bus,
-					acpiphp_slot->device);
+					acpiphp_slot->device,
+					slot->name);
 	if (retval == -EBUSY)
 		goto error_hpslot;
 	if (retval) {
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index 9359479..5e5dee8 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -285,7 +285,8 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
 		info->attention_status = cpci_get_attention_status(slot);
 
 		dbg("registering slot %s", slot->hotplug_slot->name);
-		status = pci_hp_register(slot->hotplug_slot, bus, i);
+		status = pci_hp_register(slot->hotplug_slot, bus, i,
+					 slot->hotplug_slot->name);
 		if (status) {
 			err("pci_hp_register failed with error %d", status);
 			goto error_name;
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index 54defec..a7fe458 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -436,7 +436,8 @@ static int ctrl_slot_setup(struct controller *ctrl,
 				slot_number);
 		result = pci_hp_register(hotplug_slot,
 					 ctrl->pci_dev->subordinate,
-					 slot->device);
+					 slot->device,
+					 hotplug_slot->name);
 		if (result) {
 			err("pci_hp_register failed with error %d\n", result);
 			goto error_name;
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index 40337a0..f1c1817 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -126,7 +126,8 @@ static int add_slot(struct pci_dev *dev)
 	slot->release = &dummy_release;
 	slot->private = dslot;
 
-	retval = pci_hp_register(slot, dev->bus, PCI_SLOT(dev->devfn));
+	retval = pci_hp_register(slot, dev->bus, PCI_SLOT(dev->devfn),
+				 slot->name);
 	if (retval) {
 		err("pci_hp_register failed with error %d\n", retval);
 		goto error_dslot;
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
index 8f286ac..85528d6 100644
--- a/drivers/pci/hotplug/ibmphp_ebda.c
+++ b/drivers/pci/hotplug/ibmphp_ebda.c
@@ -966,7 +966,8 @@ static int __init ebda_rsrc_controller (void)
 	list_for_each_entry(tmp_slot, &ibmphp_slot_head, ibm_slot_list) {
 		snprintf (tmp_slot->hotplug_slot->name, 30, "%s", create_file_name (tmp_slot));
 		pci_hp_register(tmp_slot->hotplug_slot,
-			pci_find_bus(0, tmp_slot->bus), tmp_slot->device);
+			pci_find_bus(0, tmp_slot->bus), tmp_slot->device,
+			tmp_slot->hotplug_slot->name);
 	}
 
 	print_ebda_hpc ();
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index 5f85b1b..3e37d63 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -547,13 +547,15 @@ out:
  * @bus: bus this slot is on
  * @slot: pointer to the &struct hotplug_slot to register
  * @slot_nr: slot number
+ * @name: name registered with kobject core
  *
  * Registers a hotplug slot with the pci hotplug subsystem, which will allow
  * userspace interaction to the slot.
  *
  * Returns 0 if successful, anything else for an error.
  */
-int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
+int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
+			const char *name)
 {
 	int result;
 	struct pci_slot *pci_slot;
@@ -569,7 +571,7 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
 	}
 
 	/* Check if we have already registered a slot with the same name. */
-	if (get_slot_from_name(slot->name))
+	if (get_slot_from_name(name))
 		return -EEXIST;
 
 	/*
@@ -577,7 +579,7 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
 	 * driver and call it here again. If we've already created the
 	 * pci_slot, the interface will simply bump the refcount.
 	 */
-	pci_slot = pci_create_slot(bus, slot_nr, slot->name);
+	pci_slot = pci_create_slot(bus, slot_nr, name);
 	if (IS_ERR(pci_slot))
 		return PTR_ERR(pci_slot);
 
@@ -593,8 +595,8 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
 	/*
 	 * Allow pcihp drivers to override the ACPI_PCI_SLOT name.
 	 */
-	if (strcmp(kobject_name(&pci_slot->kobj), slot->name)) {
-		result = kobject_rename(&pci_slot->kobj, slot->name);
+	if (strcmp(kobject_name(&pci_slot->kobj), name)) {
+		result = kobject_rename(&pci_slot->kobj, name);
 		if (result) {
 			pci_destroy_slot(pci_slot);
 			return result;
@@ -607,8 +609,7 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr)
 
 	result = fs_add_slot(pci_slot);
 	kobject_uevent(&pci_slot->kobj, KOBJ_ADD);
-	dbg("Added slot %s to the list\n", slot->name);
-
+	dbg("Added slot %s to the list\n", name);
 
 	return result;
 }
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 4fd5355..cbd84f8 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -221,7 +221,8 @@ static int init_slots(struct controller *ctrl)
 duplicate_name:
 		retval = pci_hp_register(hotplug_slot,
 					 ctrl->pci_dev->subordinate,
-					 slot->device);
+					 slot->device,
+					 slot->name);
 		if (retval) {
 			/*
 			 * If slot N already exists, we'll try to create
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
index 5088450..736d3b4 100644
--- a/drivers/pci/hotplug/rpaphp_slot.c
+++ b/drivers/pci/hotplug/rpaphp_slot.c
@@ -137,7 +137,7 @@ int rpaphp_register_slot(struct slot *slot)
 		slotno = PCI_SLOT(PCI_DN(slot->dn->child)->devfn);
 	else
 		slotno = -1;
-	retval = pci_hp_register(php_slot, slot->bus, slotno);
+	retval = pci_hp_register(php_slot, slot->bus, slotno, slot->name);
 	if (retval) {
 		err("pci_hp_register failed with error %d\n", retval);
 		return retval;
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index 410fe03..6d20bbd 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -653,7 +653,8 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus)
 		bss_hotplug_slot->ops = &sn_hotplug_slot_ops;
 		bss_hotplug_slot->release = &sn_release_slot;
 
-		rc = pci_hp_register(bss_hotplug_slot, pci_bus, device);
+		rc = pci_hp_register(bss_hotplug_slot, pci_bus, device,
+				     bss_hotplug_slot->name);
 		if (rc)
 			goto register_err;
 
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index cc38615..bf50966 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -146,7 +146,8 @@ static int init_slots(struct controller *ctrl)
 		    slot->hp_slot, slot->number, ctrl->slot_device_offset);
 duplicate_name:
 		retval = pci_hp_register(slot->hotplug_slot,
-				ctrl->pci_dev->subordinate, slot->device);
+				ctrl->pci_dev->subordinate, slot->device,
+				hotplug_slot->name);
 		if (retval) {
 			/*
 			 * If slot N already exists, we'll try to create
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index a08cd06..303834b 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -165,7 +165,10 @@ struct hotplug_slot {
 };
 #define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj)
 
-extern int pci_hp_register(struct hotplug_slot *, struct pci_bus *, int nr);
+extern int pci_hp_register(struct hotplug_slot *,
+			   struct pci_bus *,
+			   int nr,
+			   const char *name);
 extern int pci_hp_deregister(struct hotplug_slot *slot);
 extern int __must_check pci_hp_change_slot_info	(struct hotplug_slot *slot,
 						 struct hotplug_slot_info *info);


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

* [PATCH v2 02/13] PCI: prevent duplicate slot names
  2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
  2008-09-09 10:00           ` [PATCH v2 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface Alex Chiang
@ 2008-09-09 10:00           ` Alex Chiang
  2008-09-09 13:07             ` Matthew Wilcox
                               ` (2 more replies)
  2008-09-09 10:00           ` [PATCH v2 03/13] PCI, PCI Hotplug: introduce slot_name helpers Alex Chiang
                             ` (10 subsequent siblings)
  12 siblings, 3 replies; 55+ messages in thread
From: Alex Chiang @ 2008-09-09 10:00 UTC (permalink / raw)
  To: linux-pci, linux-kernel
  Cc: jbarnes, kristen.c.accardi, matthew, kaneshige.kenji, Alex Chiang

Prevent callers of pci_create_slot() from registering slots with
duplicate names. This condition occurs most often when PCI hotplug
drivers are loaded on platforms with broken firmware that assigns
identical names to multiple slots.

We now rename these duplicate slots on behalf of the user.

If firmware assigns the name N to multiple slots, then:

	The first registered slot is assigned N
	The second registered slot is assigned N-1
	The third registered slot is assigned N-2
	The Mth registered slot becomes N-M

A side effect of this patch is that the error condition for when
multiple drivers attempt to claim the same slot becomes much more
prominent.

In other words, the previous error condition returned for
duplicate slot names (-EEXIST) masked the case when multiple
drivers attempted to claim the same slot. Now, the -EBUSY return
makes the true error more obvious.

This is the permanent fix mentioned in earlier commits:

	shpchp: Rename duplicate slot name N as N-1, N-2, N-M...
	d6a9e9b40be7da84f82eb414c2ad98c5bb69986b

	pciehp: Rename duplicate slot name N as N-1, N-2, N-M...
	167e782e301188c7c7e31e486bbeea5f918324c1

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: matthew@wil.cx
Cc: kaneshige.kenji@jp.fujitsu.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/pci_hotplug_core.c |   23 ++++--
 drivers/pci/hotplug/pciehp_core.c      |   14 ----
 drivers/pci/hotplug/shpchp_core.c      |   15 ----
 drivers/pci/slot.c                     |  117 +++++++++++++++++++++++++++-----
 include/linux/pci.h                    |    3 +
 5 files changed, 117 insertions(+), 55 deletions(-)

diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index 3e37d63..2232608 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -558,7 +558,8 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
 			const char *name)
 {
 	int result;
-	struct pci_slot *pci_slot;
+	struct pci_dev *dev;
+	struct pci_slot *pci_slot, *tmp_slot = NULL;
 
 	if (slot == NULL)
 		return -ENODEV;
@@ -570,9 +571,17 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
 		return -EINVAL;
 	}
 
-	/* Check if we have already registered a slot with the same name. */
-	if (get_slot_from_name(name))
-		return -EEXIST;
+	/*
+	 * If we find a tmp_slot here, it means that another slot
+	 * driver has already created a pci_slot for this device.
+	 * We care (below) if the existing slot has a different name from
+	 * the new name that this particular hotplug driver is requesting.
+	 */
+	dev = pci_get_slot(bus, PCI_DEVFN(slot_nr, 0));
+	if (dev && dev->slot) {
+		tmp_slot = dev->slot;
+		pci_dev_put(dev);
+	}
 
 	/*
 	 * No problems if we call this interface from both ACPI_PCI_SLOT
@@ -593,10 +602,10 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
 	pci_slot->hotplug = slot;
 
 	/*
-	 * Allow pcihp drivers to override the ACPI_PCI_SLOT name.
+	 * Allow pcihp drivers to override existing slot name.
 	 */
-	if (strcmp(kobject_name(&pci_slot->kobj), name)) {
-		result = kobject_rename(&pci_slot->kobj, name);
+	if (tmp_slot && strcmp(kobject_name(&tmp_slot->kobj), name)) {
+		result = pci_rename_slot(pci_slot, name);
 		if (result) {
 			pci_destroy_slot(pci_slot);
 			return result;
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index cbd84f8..bed77af 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -191,7 +191,6 @@ static int init_slots(struct controller *ctrl)
 	struct slot *slot;
 	struct hotplug_slot *hotplug_slot;
 	struct hotplug_slot_info *info;
-	int len, dup = 1;
 	int retval = -ENOMEM;
 
 	list_for_each_entry(slot, &ctrl->slot_list, slot_list) {
@@ -218,24 +217,11 @@ static int init_slots(struct controller *ctrl)
 		dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x "
 		    "slot_device_offset=%x\n", slot->bus, slot->device,
 		    slot->hp_slot, slot->number, ctrl->slot_device_offset);
-duplicate_name:
 		retval = pci_hp_register(hotplug_slot,
 					 ctrl->pci_dev->subordinate,
 					 slot->device,
 					 slot->name);
 		if (retval) {
-			/*
-			 * If slot N already exists, we'll try to create
-			 * slot N-1, N-2 ... N-M, until we overflow.
-			 */
-			if (retval == -EEXIST) {
-				len = snprintf(slot->name, SLOT_NAME_SIZE,
-					       "%d-%d", slot->number, dup++);
-				if (len < SLOT_NAME_SIZE)
-					goto duplicate_name;
-				else
-					err("duplicate slot name overflow\n");
-			}
 			err("pci_hp_register failed with error %d\n", retval);
 			goto error_info;
 		}
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index bf50966..cfdd079 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -102,7 +102,7 @@ static int init_slots(struct controller *ctrl)
 	struct hotplug_slot *hotplug_slot;
 	struct hotplug_slot_info *info;
 	int retval = -ENOMEM;
-	int i, len, dup = 1;
+	int i;
 
 	for (i = 0; i < ctrl->num_slots; i++) {
 		slot = kzalloc(sizeof(*slot), GFP_KERNEL);
@@ -144,23 +144,10 @@ static int init_slots(struct controller *ctrl)
 		dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x "
 		    "slot_device_offset=%x\n", slot->bus, slot->device,
 		    slot->hp_slot, slot->number, ctrl->slot_device_offset);
-duplicate_name:
 		retval = pci_hp_register(slot->hotplug_slot,
 				ctrl->pci_dev->subordinate, slot->device,
 				hotplug_slot->name);
 		if (retval) {
-			/*
-			 * If slot N already exists, we'll try to create
-			 * slot N-1, N-2 ... N-M, until we overflow.
-			 */
-			if (retval == -EEXIST) {
-				len = snprintf(slot->name, SLOT_NAME_SIZE,
-					       "%d-%d", slot->number, dup++);
-				if (len < SLOT_NAME_SIZE)
-					goto duplicate_name;
-				else
-					err("duplicate slot name overflow\n");
-			}
 			err("pci_hp_register failed with error %d\n", retval);
 			goto error_info;
 		}
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
index 0c6db03..93c55ca 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -78,6 +78,51 @@ static struct kobj_type pci_slot_ktype = {
 	.default_attrs = pci_slot_default_attrs,
 };
 
+static char *make_slot_name(const char *name)
+{
+	char *new_name;
+	int len, width, dup = 1;
+	struct kobject *dup_slot;
+
+	new_name = kstrdup(name, GFP_KERNEL);
+	if (!new_name)
+		goto out;
+
+	/*
+	 * Start off allocating enough room for "name-X"
+	 */
+	len = strlen(name) + 2;
+	width = 1;
+
+try_again:
+	dup_slot = kset_find_obj(pci_slots_kset, new_name);
+	if (!dup_slot)
+		goto out;
+	kobject_put(dup_slot);
+
+	/*
+	 * We hit this the first time through, which gives us
+	 * space for terminating NULL, and then every power of 10
+	 * afterwards, which gives us space to add another digit
+	 * to "name-XX..."
+	 */
+	if (dup % width == 0) {
+		len++;
+		width *= 10;
+	}
+
+	new_name = krealloc(new_name, len, GFP_KERNEL);
+	if (!new_name)
+		goto out;
+
+	memset(new_name, 0, len);
+	scnprintf(new_name, len, "%s-%d", name, dup++);
+	goto try_again;
+
+out:
+	return new_name;
+}
+
 /**
  * pci_create_slot - create or increment refcount for physical PCI slot
  * @parent: struct pci_bus of parent bridge
@@ -89,7 +134,19 @@ static struct kobj_type pci_slot_ktype = {
  * either return a new &struct pci_slot to the caller, or if the pci_slot
  * already exists, its refcount will be incremented.
  *
- * Slots are uniquely identified by a @pci_bus, @slot_nr, @name tuple.
+ * Slots are uniquely identified by a @pci_bus, @slot_nr tuple.
+ *
+ * The kobject API imposes a restriction on us, and does not allow sysfs
+ * entries with duplicate names. There are known platforms with broken
+ * firmware that assign the same name to multiple slots.
+ *
+ * We workaround these broken platforms by renaming the slots on behalf
+ * of the caller. If firmware assigns name N to multiple slots:
+ *
+ * The first slot is assigned N
+ * The second slot is assigned N-1
+ * The third slot is assigned N-2
+ * The Mth slot is assigned N-M
  *
  * Placeholder slots:
  * In most cases, @pci_bus, @slot_nr will be sufficient to uniquely identify
@@ -109,13 +166,13 @@ static struct kobj_type pci_slot_ktype = {
  * %struct pci_bus and bb is the bus number. In other words, the devfn of
  * the 'placeholder' slot will not be displayed.
  */
-
 struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
 				 const char *name)
 {
 	struct pci_dev *dev;
 	struct pci_slot *slot;
-	int err;
+	int err = 0;
+	char *slot_name = NULL;
 
 	down_write(&pci_bus_sem);
 
@@ -144,12 +201,18 @@ placeholder:
 
 	slot->bus = parent;
 	slot->number = slot_nr;
-
 	slot->kobj.kset = pci_slots_kset;
+
+	slot_name = make_slot_name(name);
+	if (!slot_name) {
+		slot = ERR_PTR(-ENOMEM);
+		goto err;
+	}
+
 	err = kobject_init_and_add(&slot->kobj, &pci_slot_ktype, NULL,
-				   "%s", name);
+				   "%s", slot_name);
 	if (err) {
-		printk(KERN_ERR "Unable to register kobject %s\n", name);
+		printk(KERN_ERR "Unable to register kobject %s\n", slot_name);
 		goto err;
 	}
 
@@ -165,6 +228,7 @@ placeholder:
 		 __func__, pci_domain_nr(parent), parent->number, slot_nr);
 
  out:
+	kfree(slot_name);
 	up_write(&pci_bus_sem);
 	return slot;
  err:
@@ -175,7 +239,31 @@ placeholder:
 EXPORT_SYMBOL_GPL(pci_create_slot);
 
 /**
- * pci_update_slot_number - update %struct pci_slot -> number
+ * pci_rename_slot - update %struct pci_slot -> name
+ * @slot - %struct pci_slot to update
+ * @name - new requested name for slot
+ *
+ * Allow caller to safely rename a %struct pci_slot without making
+ * the kobject core complain about duplicate names.
+ */
+int pci_rename_slot(struct pci_slot *slot, const char *name)
+{
+	int result;
+	char *slot_name;
+
+	slot_name = make_slot_name(name);
+	if (!slot_name)
+		return -ENOMEM;
+
+	result = kobject_rename(&slot->kobj, slot_name);
+	kfree(slot_name);
+
+	return result;
+}
+EXPORT_SYMBOL_GPL(pci_rename_slot);
+
+/**
+ * pci_renumber_slot - update %struct pci_slot -> number
  * @slot - %struct pci_slot to update
  * @slot_nr - new number for slot
  *
@@ -183,27 +271,19 @@ EXPORT_SYMBOL_GPL(pci_create_slot);
  * created a placeholder slot in pci_create_slot() by passing a -1 as
  * slot_nr, to update their %struct pci_slot with the correct @slot_nr.
  */
-
-void pci_update_slot_number(struct pci_slot *slot, int slot_nr)
+void pci_renumber_slot(struct pci_slot *slot, int slot_nr)
 {
-	int name_count = 0;
 	struct pci_slot *tmp;
 
 	down_write(&pci_bus_sem);
 
-	list_for_each_entry(tmp, &slot->bus->slots, list) {
+	list_for_each_entry(tmp, &slot->bus->slots, list)
 		WARN_ON(tmp->number == slot_nr);
-		if (!strcmp(kobject_name(&tmp->kobj), kobject_name(&slot->kobj)))
-			name_count++;
-	}
-
-	if (name_count > 1)
-		printk(KERN_WARNING "pci_update_slot_number found %d slots with the same name: %s\n", name_count, kobject_name(&slot->kobj));
 
 	slot->number = slot_nr;
 	up_write(&pci_bus_sem);
 }
-EXPORT_SYMBOL_GPL(pci_update_slot_number);
+EXPORT_SYMBOL_GPL(pci_renumber_slot);
 
 /**
  * pci_destroy_slot - decrement refcount for physical PCI slot
@@ -213,7 +293,6 @@ EXPORT_SYMBOL_GPL(pci_update_slot_number);
  * just call kobject_put on its kobj and let our release methods do the
  * rest.
  */
-
 void pci_destroy_slot(struct pci_slot *slot)
 {
 	pr_debug("%s: dec refcount to %d on %04x:%02x:%02x\n", __func__,
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 79dc7ce..fd6efbc 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -510,7 +510,8 @@ struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
 struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
 				 const char *name);
 void pci_destroy_slot(struct pci_slot *slot);
-void pci_update_slot_number(struct pci_slot *slot, int slot_nr);
+int pci_rename_slot(struct pci_slot *slot, const char *name);
+void pci_renumber_slot(struct pci_slot *slot, int slot_nr);
 int pci_scan_slot(struct pci_bus *bus, int devfn);
 struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn);
 void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);


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

* [PATCH v2 03/13] PCI, PCI Hotplug: introduce slot_name helpers
  2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
  2008-09-09 10:00           ` [PATCH v2 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface Alex Chiang
  2008-09-09 10:00           ` [PATCH v2 02/13] PCI: prevent duplicate slot names Alex Chiang
@ 2008-09-09 10:00           ` Alex Chiang
  2008-09-09 14:30             ` Matthew Wilcox
  2008-09-09 10:00           ` [PATCH v2 04/13] PCI: acpiphp: remove 'name' parameter Alex Chiang
                             ` (9 subsequent siblings)
  12 siblings, 1 reply; 55+ messages in thread
From: Alex Chiang @ 2008-09-09 10:00 UTC (permalink / raw)
  To: linux-pci, linux-kernel
  Cc: jbarnes, kristen.c.accardi, matthew, kaneshige.kenji, Alex Chiang

In preparation for cleaning up the various hotplug drivers
such that they don't have to manage their own 'name' parameters
anymore, we provide the following convenience functions:

	pci_slot_name()
	hotplug_slot_name()

These helpers will be used by individual hotplug drivers.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: matthew@wil.cx
Cc: kaneshige.kenji@jp.fujitsu.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 include/linux/pci.h         |    5 +++++
 include/linux/pci_hotplug.h |    5 +++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/linux/pci.h b/include/linux/pci.h
index fd6efbc..bd259c3 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -64,6 +64,11 @@ struct pci_slot {
 	struct kobject kobj;
 };
 
+static inline const char *pci_slot_name(const struct pci_slot *slot)
+{
+	return kobject_name(&slot->kobj);
+}
+
 /* File state for mmap()s on /proc/bus/pci/X/Y */
 enum pci_mmap_state {
 	pci_mmap_io,
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index 303834b..7184bee 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -165,6 +165,11 @@ struct hotplug_slot {
 };
 #define to_hotplug_slot(n) container_of(n, struct hotplug_slot, kobj)
 
+static inline const char *hotplug_slot_name(const struct hotplug_slot *slot)
+{
+	return pci_slot_name(slot->pci_slot);
+}
+
 extern int pci_hp_register(struct hotplug_slot *,
 			   struct pci_bus *,
 			   int nr,


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

* [PATCH v2 04/13] PCI: acpiphp: remove 'name' parameter
  2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
                             ` (2 preceding siblings ...)
  2008-09-09 10:00           ` [PATCH v2 03/13] PCI, PCI Hotplug: introduce slot_name helpers Alex Chiang
@ 2008-09-09 10:00           ` Alex Chiang
  2008-09-09 14:38             ` Matthew Wilcox
  2008-09-09 10:00           ` [PATCH v2 05/13] PCI: cpci_hotplug: stop managing hotplug_slot->name Alex Chiang
                             ` (8 subsequent siblings)
  12 siblings, 1 reply; 55+ messages in thread
From: Alex Chiang @ 2008-09-09 10:00 UTC (permalink / raw)
  To: linux-pci, linux-kernel
  Cc: jbarnes, kristen.c.accardi, kaneshige.kenji, Alex Chiang

We do not need to manage our own name parameter, especially since
the PCI core can change it on our behalf, in the case of duplicate
slot names.

Remove 'name' from acpiphp's version of struct slot.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: kaneshige.kenji@jp.fujitsu.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/acpiphp.h      |    9 +++++----
 drivers/pci/hotplug/acpiphp_core.c |   31 ++++++++++++++++---------------
 2 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index 5a58b07..f9e244d 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -50,9 +50,6 @@
 #define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
 #define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
 
-/* name size which is used for entries in pcihpfs */
-#define SLOT_NAME_SIZE	20		/* {_SUN} */
-
 struct acpiphp_bridge;
 struct acpiphp_slot;
 
@@ -63,9 +60,13 @@ struct slot {
 	struct hotplug_slot	*hotplug_slot;
 	struct acpiphp_slot	*acpi_slot;
 	struct hotplug_slot_info info;
-	char name[SLOT_NAME_SIZE];
 };
 
+static inline const char *slot_name(struct slot *slot)
+{
+	return hotplug_slot_name(slot->hotplug_slot);
+}
+
 /*
  * struct acpiphp_bridge - PCI bridge information
  *
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index e984176..55b2b77 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -44,6 +44,9 @@
 
 #define MY_NAME	"acpiphp"
 
+/* name size which is used for entries in pcihpfs */
+#define SLOT_NAME_SIZE  20              /* {_SUN} */
+
 static int debug;
 int acpiphp_debug;
 
@@ -84,7 +87,6 @@ static struct hotplug_slot_ops acpi_hotplug_slot_ops = {
 	.get_adapter_status	= get_adapter_status,
 };
 
-
 /**
  * acpiphp_register_attention - set attention LED callback
  * @info: must be completely filled with LED callbacks
@@ -136,7 +138,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	/* enable the specified slot */
 	return acpiphp_enable_slot(slot->acpi_slot);
@@ -154,7 +156,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
 	struct slot *slot = hotplug_slot->private;
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	/* disable the specified slot */
 	retval = acpiphp_disable_slot(slot->acpi_slot);
@@ -177,7 +179,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
  {
 	int retval = -ENODEV;
 
- 	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot_name(hotplug_slot));
  
 	if (attention_info && try_module_get(attention_info->owner)) {
 		retval = attention_info->set_attn(hotplug_slot, status);
@@ -200,7 +202,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = acpiphp_get_power_status(slot->acpi_slot);
 
@@ -222,7 +224,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
 	int retval = -EINVAL;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot_name(hotplug_slot));
 
 	if (attention_info && try_module_get(attention_info->owner)) {
 		retval = attention_info->get_attn(hotplug_slot, value);
@@ -245,7 +247,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = acpiphp_get_latch_status(slot->acpi_slot);
 
@@ -265,7 +267,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = acpiphp_get_adapter_status(slot->acpi_slot);
 
@@ -299,7 +301,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	kfree(slot->hotplug_slot);
 	kfree(slot);
@@ -310,6 +312,7 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
 {
 	struct slot *slot;
 	int retval = -ENOMEM;
+	char name[SLOT_NAME_SIZE];
 
 	slot = kzalloc(sizeof(*slot), GFP_KERNEL);
 	if (!slot)
@@ -321,8 +324,6 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
 
 	slot->hotplug_slot->info = &slot->info;
 
-	slot->hotplug_slot->name = slot->name;
-
 	slot->hotplug_slot->private = slot;
 	slot->hotplug_slot->release = &release_slot;
 	slot->hotplug_slot->ops = &acpi_hotplug_slot_ops;
@@ -336,12 +337,12 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
 	slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
 
 	acpiphp_slot->slot = slot;
-	snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun);
+	scnprintf(name, SLOT_NAME_SIZE, "%u", slot->acpi_slot->sun);
 
 	retval = pci_hp_register(slot->hotplug_slot,
 					acpiphp_slot->bridge->pci_bus,
 					acpiphp_slot->device,
-					slot->name);
+					name);
 	if (retval == -EBUSY)
 		goto error_hpslot;
 	if (retval) {
@@ -349,7 +350,7 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
 		goto error_hpslot;
  	}
 
-	info("Slot [%s] registered\n", slot->hotplug_slot->name);
+	info("Slot [%s] registered\n", slot_name(slot));
 
 	return 0;
 error_hpslot:
@@ -366,7 +367,7 @@ void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
 	struct slot *slot = acpiphp_slot->slot;
 	int retval = 0;
 
-	info ("Slot [%s] unregistered\n", slot->hotplug_slot->name);
+	info("Slot [%s] unregistered\n", slot_name(slot));
 
 	retval = pci_hp_deregister(slot->hotplug_slot);
 	if (retval)


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

* [PATCH v2 05/13] PCI: cpci_hotplug: stop managing hotplug_slot->name
  2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
                             ` (3 preceding siblings ...)
  2008-09-09 10:00           ` [PATCH v2 04/13] PCI: acpiphp: remove 'name' parameter Alex Chiang
@ 2008-09-09 10:00           ` Alex Chiang
  2008-09-09 15:04             ` Matthew Wilcox
  2008-09-09 10:00           ` [PATCH v2 06/13] PCI: cpqphp: " Alex Chiang
                             ` (7 subsequent siblings)
  12 siblings, 1 reply; 55+ messages in thread
From: Alex Chiang @ 2008-09-09 10:00 UTC (permalink / raw)
  To: linux-pci, linux-kernel; +Cc: jbarnes, kristen.c.accardi, scottm, Alex Chiang

We no longer need to manage our version of hotplug_slot->name
since the PCI and hotplug core manage it on our behalf.

Now, we simply advise the PCI core of the name that we would
like, and let the core take care of the rest.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: scottm@somanetworks.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/cpci_hotplug.h      |    6 ++
 drivers/pci/hotplug/cpci_hotplug_core.c |   75 ++++++++++++-------------------
 drivers/pci/hotplug/cpci_hotplug_pci.c  |    4 +-
 3 files changed, 36 insertions(+), 49 deletions(-)

diff --git a/drivers/pci/hotplug/cpci_hotplug.h b/drivers/pci/hotplug/cpci_hotplug.h
index d9769b3..9fff878 100644
--- a/drivers/pci/hotplug/cpci_hotplug.h
+++ b/drivers/pci/hotplug/cpci_hotplug.h
@@ -30,6 +30,7 @@
 
 #include <linux/types.h>
 #include <linux/pci.h>
+#include <linux/pci_hotplug.h>
 
 /* PICMG 2.1 R2.0 HS CSR bits: */
 #define HS_CSR_INS	0x0080
@@ -69,6 +70,11 @@ struct cpci_hp_controller {
 	struct cpci_hp_controller_ops *ops;
 };
 
+static inline const char *slot_name(struct slot *slot)
+{
+	return hotplug_slot_name(slot->hotplug_slot);
+}
+
 extern int cpci_hp_register_controller(struct cpci_hp_controller *controller);
 extern int cpci_hp_unregister_controller(struct cpci_hp_controller *controller);
 extern int cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last);
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index 5e5dee8..84cf489 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -108,7 +108,7 @@ enable_slot(struct hotplug_slot *hotplug_slot)
 	struct slot *slot = hotplug_slot->private;
 	int retval = 0;
 
-	dbg("%s - physical_slot = %s", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s", __func__, slot_name(slot));
 
 	if (controller->ops->set_power)
 		retval = controller->ops->set_power(slot, 1);
@@ -121,25 +121,23 @@ disable_slot(struct hotplug_slot *hotplug_slot)
 	struct slot *slot = hotplug_slot->private;
 	int retval = 0;
 
-	dbg("%s - physical_slot = %s", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s", __func__, slot_name(slot));
 
 	down_write(&list_rwsem);
 
 	/* Unconfigure device */
-	dbg("%s - unconfiguring slot %s",
-	    __func__, slot->hotplug_slot->name);
+	dbg("%s - unconfiguring slot %s", __func__, slot_name(slot));
 	if ((retval = cpci_unconfigure_slot(slot))) {
 		err("%s - could not unconfigure slot %s",
-		    __func__, slot->hotplug_slot->name);
+		    __func__, slot_name(slot));
 		goto disable_error;
 	}
-	dbg("%s - finished unconfiguring slot %s",
-	    __func__, slot->hotplug_slot->name);
+	dbg("%s - finished unconfiguring slot %s", __func__, slot_name(slot));
 
 	/* Clear EXT (by setting it) */
 	if (cpci_clear_ext(slot)) {
 		err("%s - could not clear EXT for slot %s",
-		    __func__, slot->hotplug_slot->name);
+		    __func__, slot_name(slot));
 		retval = -ENODEV;
 		goto disable_error;
 	}
@@ -214,7 +212,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 	struct slot *slot = hotplug_slot->private;
 
 	kfree(slot->hotplug_slot->info);
-	kfree(slot->hotplug_slot->name);
 	kfree(slot->hotplug_slot);
 	if (slot->dev)
 		pci_dev_put(slot->dev);
@@ -222,12 +219,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 }
 
 #define SLOT_NAME_SIZE	6
-static void
-make_slot_name(struct slot *slot)
-{
-	snprintf(slot->hotplug_slot->name,
-		 SLOT_NAME_SIZE, "%02x:%02x", slot->bus->number, slot->number);
-}
 
 int
 cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
@@ -235,7 +226,7 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
 	struct slot *slot;
 	struct hotplug_slot *hotplug_slot;
 	struct hotplug_slot_info *info;
-	char *name;
+	char name[SLOT_NAME_SIZE];
 	int status = -ENOMEM;
 	int i;
 
@@ -262,34 +253,29 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
 			goto error_hpslot;
 		hotplug_slot->info = info;
 
-		name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
-		if (!name)
-			goto error_info;
-		hotplug_slot->name = name;
-
 		slot->bus = bus;
 		slot->number = i;
 		slot->devfn = PCI_DEVFN(i, 0);
 
+		scnprintf(name, SLOT_NAME_SIZE, "%02x:%02x", bus->number, i);
+
 		hotplug_slot->private = slot;
 		hotplug_slot->release = &release_slot;
-		make_slot_name(slot);
 		hotplug_slot->ops = &cpci_hotplug_slot_ops;
 
 		/*
 		 * Initialize the slot info structure with some known
 		 * good values.
 		 */
-		dbg("initializing slot %s", slot->hotplug_slot->name);
+		dbg("initializing slot %s", slot_name(slot));
 		info->power_status = cpci_get_power_status(slot);
 		info->attention_status = cpci_get_attention_status(slot);
 
-		dbg("registering slot %s", slot->hotplug_slot->name);
-		status = pci_hp_register(slot->hotplug_slot, bus, i,
-					 slot->hotplug_slot->name);
+		dbg("registering slot %s", slot_name(slot));
+		status = pci_hp_register(slot->hotplug_slot, bus, i, name);
 		if (status) {
 			err("pci_hp_register failed with error %d", status);
-			goto error_name;
+			goto error_info;
 		}
 
 		/* Add slot to our internal list */
@@ -299,8 +285,6 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
 		up_write(&list_rwsem);
 	}
 	return 0;
-error_name:
-	kfree(name);
 error_info:
 	kfree(info);
 error_hpslot:
@@ -328,7 +312,7 @@ cpci_hp_unregister_bus(struct pci_bus *bus)
 			list_del(&slot->slot_list);
 			slots--;
 
-			dbg("deregistering slot %s", slot->hotplug_slot->name);
+			dbg("deregistering slot %s", slot_name(slot));
 			status = pci_hp_deregister(slot->hotplug_slot);
 			if (status) {
 				err("pci_hp_deregister failed with error %d",
@@ -380,11 +364,10 @@ init_slots(int clear_ins)
 		return -1;
 	}
 	list_for_each_entry(slot, &slot_list, slot_list) {
-		dbg("%s - looking at slot %s",
-		    __func__, slot->hotplug_slot->name);
+		dbg("%s - looking at slot %s", __func__, slot_name(slot));
 		if (clear_ins && cpci_check_and_clear_ins(slot))
 			dbg("%s - cleared INS for slot %s",
-			    __func__, slot->hotplug_slot->name);
+			    __func__, slot_name(slot));
 		dev = pci_get_slot(slot->bus, PCI_DEVFN(slot->number, 0));
 		if (dev) {
 			if (update_adapter_status(slot->hotplug_slot, 1))
@@ -415,8 +398,7 @@ check_slots(void)
 	}
 	extracted = inserted = 0;
 	list_for_each_entry(slot, &slot_list, slot_list) {
-		dbg("%s - looking at slot %s",
-		    __func__, slot->hotplug_slot->name);
+		dbg("%s - looking at slot %s", __func__, slot_name(slot));
 		if (cpci_check_and_clear_ins(slot)) {
 			/*
 			 * Some broken hardware (e.g. PLX 9054AB) asserts
@@ -424,35 +406,34 @@ check_slots(void)
 			 */
 			if (slot->dev) {
 				warn("slot %s already inserted",
-				     slot->hotplug_slot->name);
+				     slot_name(slot));
 				inserted++;
 				continue;
 			}
 
 			/* Process insertion */
-			dbg("%s - slot %s inserted",
-			    __func__, slot->hotplug_slot->name);
+			dbg("%s - slot %s inserted", __func__, slot_name(slot));
 
 			/* GSM, debug */
 			hs_csr = cpci_get_hs_csr(slot);
 			dbg("%s - slot %s HS_CSR (1) = %04x",
-			    __func__, slot->hotplug_slot->name, hs_csr);
+			    __func__, slot_name(slot), hs_csr);
 
 			/* Configure device */
 			dbg("%s - configuring slot %s",
-			    __func__, slot->hotplug_slot->name);
+			    __func__, slot_name(slot));
 			if (cpci_configure_slot(slot)) {
 				err("%s - could not configure slot %s",
-				    __func__, slot->hotplug_slot->name);
+				    __func__, slot_name(slot));
 				continue;
 			}
 			dbg("%s - finished configuring slot %s",
-			    __func__, slot->hotplug_slot->name);
+			    __func__, slot_name(slot));
 
 			/* GSM, debug */
 			hs_csr = cpci_get_hs_csr(slot);
 			dbg("%s - slot %s HS_CSR (2) = %04x",
-			    __func__, slot->hotplug_slot->name, hs_csr);
+			    __func__, slot_name(slot), hs_csr);
 
 			if (update_latch_status(slot->hotplug_slot, 1))
 				warn("failure to update latch file");
@@ -465,18 +446,18 @@ check_slots(void)
 			/* GSM, debug */
 			hs_csr = cpci_get_hs_csr(slot);
 			dbg("%s - slot %s HS_CSR (3) = %04x",
-			    __func__, slot->hotplug_slot->name, hs_csr);
+			    __func__, slot_name(slot), hs_csr);
 
 			inserted++;
 		} else if (cpci_check_ext(slot)) {
 			/* Process extraction request */
 			dbg("%s - slot %s extracted",
-			    __func__, slot->hotplug_slot->name);
+			    __func__, slot_name(slot));
 
 			/* GSM, debug */
 			hs_csr = cpci_get_hs_csr(slot);
 			dbg("%s - slot %s HS_CSR = %04x",
-			    __func__, slot->hotplug_slot->name, hs_csr);
+			    __func__, slot_name(slot), hs_csr);
 
 			if (!slot->extracting) {
 				if (update_latch_status(slot->hotplug_slot, 0)) {
@@ -494,7 +475,7 @@ check_slots(void)
 				 * bother trying to tell the driver or not?
 				 */
 				err("card in slot %s was improperly removed",
-				    slot->hotplug_slot->name);
+				    slot_name(slot));
 				if (update_adapter_status(slot->hotplug_slot, 0))
 					warn("failure to update adapter file");
 				slot->extracting = 0;
diff --git a/drivers/pci/hotplug/cpci_hotplug_pci.c b/drivers/pci/hotplug/cpci_hotplug_pci.c
index df82b95..829c327 100644
--- a/drivers/pci/hotplug/cpci_hotplug_pci.c
+++ b/drivers/pci/hotplug/cpci_hotplug_pci.c
@@ -209,7 +209,7 @@ int cpci_led_on(struct slot* slot)
 					      hs_cap + 2,
 					      hs_csr)) {
 			err("Could not set LOO for slot %s",
-			    slot->hotplug_slot->name);
+			    hotplug_slot_name(slot->hotplug_slot));
 			return -ENODEV;
 		}
 	}
@@ -238,7 +238,7 @@ int cpci_led_off(struct slot* slot)
 					      hs_cap + 2,
 					      hs_csr)) {
 			err("Could not clear LOO for slot %s",
-			    slot->hotplug_slot->name);
+			    hotplug_slot_name(slot->hotplug_slot));
 			return -ENODEV;
 		}
 	}


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

* [PATCH v2 06/13] PCI: cpqphp: stop managing hotplug_slot->name
  2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
                             ` (4 preceding siblings ...)
  2008-09-09 10:00           ` [PATCH v2 05/13] PCI: cpci_hotplug: stop managing hotplug_slot->name Alex Chiang
@ 2008-09-09 10:00           ` Alex Chiang
  2008-09-09 15:08             ` Matthew Wilcox
  2008-09-09 10:00           ` [PATCH v2 07/13] PCI: fakephp: remove 'name' parameter Alex Chiang
                             ` (6 subsequent siblings)
  12 siblings, 1 reply; 55+ messages in thread
From: Alex Chiang @ 2008-09-09 10:00 UTC (permalink / raw)
  To: linux-pci, linux-kernel; +Cc: jbarnes, kristen.c.accardi, Alex Chiang

We no longer need to manage our version of hotplug_slot->name
since the PCI and hotplug core manage it on our behalf.

Now, we simply advise the PCI core of the name that we would
like, and let the core take care of the rest.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/cpqphp.h      |   13 +++++-------
 drivers/pci/hotplug/cpqphp_core.c |   39 +++++++++++++++++--------------------
 2 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h
index b1decfa..afaf8f6 100644
--- a/drivers/pci/hotplug/cpqphp.h
+++ b/drivers/pci/hotplug/cpqphp.h
@@ -449,6 +449,11 @@ extern u8 cpqhp_disk_irq;
 
 /* inline functions */
 
+static inline char *slot_name(struct slot *slot)
+{
+	return hotplug_slot_name(slot->hotplug_slot);
+}
+
 /*
  * return_resource
  *
@@ -696,14 +701,6 @@ static inline int get_presence_status(struct controller *ctrl, struct slot *slot
 	return presence_save;
 }
 
-#define SLOT_NAME_SIZE 10
-
-static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot)
-{
-	snprintf(buffer, buffer_size, "%d", slot->number);
-}
-
-
 static inline int wait_for_ctrl_irq(struct controller *ctrl)
 {
         DECLARE_WAITQUEUE(wait, current);
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index a7fe458..008ae5d 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -315,14 +315,15 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	kfree(slot->hotplug_slot->info);
-	kfree(slot->hotplug_slot->name);
 	kfree(slot->hotplug_slot);
 	kfree(slot);
 }
 
+#define SLOT_NAME_SIZE 10
+
 static int ctrl_slot_setup(struct controller *ctrl,
 			void __iomem *smbios_start,
 			void __iomem *smbios_table)
@@ -335,6 +336,7 @@ static int ctrl_slot_setup(struct controller *ctrl,
 	u8 slot_number;
 	u8 ctrl_slot;
 	u32 tempdword;
+	char name[SLOT_NAME_SIZE];
 	void __iomem *slot_entry= NULL;
 	int result = -ENOMEM;
 
@@ -363,10 +365,6 @@ static int ctrl_slot_setup(struct controller *ctrl,
 		if (!hotplug_slot->info)
 			goto error_hpslot;
 		hotplug_slot_info = hotplug_slot->info;
-		hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
-
-		if (!hotplug_slot->name)
-			goto error_info;
 
 		slot->ctrl = ctrl;
 		slot->bus = ctrl->bus;
@@ -418,8 +416,9 @@ static int ctrl_slot_setup(struct controller *ctrl,
 		/* register this slot with the hotplug pci core */
 		hotplug_slot->release = &release_slot;
 		hotplug_slot->private = slot;
-		make_slot_name(hotplug_slot->name, SLOT_NAME_SIZE, slot);
 		hotplug_slot->ops = &cpqphp_hotplug_slot_ops;
+
+		scnprintf(name, SLOT_NAME_SIZE, "%d", slot->number);
 		
 		hotplug_slot_info->power_status = get_slot_enabled(ctrl, slot);
 		hotplug_slot_info->attention_status =
@@ -437,10 +436,10 @@ static int ctrl_slot_setup(struct controller *ctrl,
 		result = pci_hp_register(hotplug_slot,
 					 ctrl->pci_dev->subordinate,
 					 slot->device,
-					 hotplug_slot->name);
+					 name);
 		if (result) {
 			err("pci_hp_register failed with error %d\n", result);
-			goto error_name;
+			goto error_info;
 		}
 		
 		slot->next = ctrl->slot;
@@ -452,8 +451,6 @@ static int ctrl_slot_setup(struct controller *ctrl,
 	}
 
 	return 0;
-error_name:
-	kfree(hotplug_slot->name);
 error_info:
 	kfree(hotplug_slot_info);
 error_hpslot:
@@ -639,7 +636,7 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status)
 	u8 device;
 	u8 function;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	if (cpqhp_get_bus_dev(ctrl, &bus, &devfn, slot->number) == -1)
 		return -ENODEV;
@@ -666,7 +663,7 @@ static int process_SI(struct hotplug_slot *hotplug_slot)
 	u8 device;
 	u8 function;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	if (cpqhp_get_bus_dev(ctrl, &bus, &devfn, slot->number) == -1)
 		return -ENODEV;
@@ -698,7 +695,7 @@ static int process_SS(struct hotplug_slot *hotplug_slot)
 	u8 device;
 	u8 function;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	if (cpqhp_get_bus_dev(ctrl, &bus, &devfn, slot->number) == -1)
 		return -ENODEV;
@@ -721,7 +718,7 @@ static int hardware_test(struct hotplug_slot *hotplug_slot, u32 value)
 	struct slot *slot = hotplug_slot->private;
 	struct controller *ctrl = slot->ctrl;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	return cpqhp_hardware_test(ctrl, value);	
 }
@@ -732,7 +729,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	struct controller *ctrl = slot->ctrl;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = get_slot_enabled(ctrl, slot);
 	return 0;
@@ -743,7 +740,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	struct controller *ctrl = slot->ctrl;
 	
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = cpq_get_attention_status(ctrl, slot);
 	return 0;
@@ -754,7 +751,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	struct controller *ctrl = slot->ctrl;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = cpq_get_latch_status(ctrl, slot);
 
@@ -766,7 +763,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	struct controller *ctrl = slot->ctrl;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = get_presence_status(ctrl, slot);
 
@@ -778,7 +775,7 @@ static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp
 	struct slot *slot = hotplug_slot->private;
 	struct controller *ctrl = slot->ctrl;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = ctrl->speed_capability;
 
@@ -790,7 +787,7 @@ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp
 	struct slot *slot = hotplug_slot->private;
 	struct controller *ctrl = slot->ctrl;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	*value = ctrl->speed;
 


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

* [PATCH v2 07/13] PCI: fakephp: remove 'name' parameter
  2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
                             ` (5 preceding siblings ...)
  2008-09-09 10:00           ` [PATCH v2 06/13] PCI: cpqphp: " Alex Chiang
@ 2008-09-09 10:00           ` Alex Chiang
  2008-09-09 10:00           ` [PATCH v2 08/13] PCI: ibmphp: stop managing hotplug_slot->name Alex Chiang
                             ` (5 subsequent siblings)
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-09-09 10:00 UTC (permalink / raw)
  To: linux-pci, linux-kernel; +Cc: jbarnes, kristen.c.accardi, Alex Chiang

Remove 'name' from fakephp's struct dummy_slot, as the PCI core
will now manage our slot name for us.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/fakephp.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index f1c1817..7447faf 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -66,7 +66,6 @@ struct dummy_slot {
 	struct pci_dev *dev;
 	struct work_struct remove_work;
 	unsigned long removed;
-	char name[8];
 };
 
 static int debug;
@@ -96,10 +95,13 @@ static void dummy_release(struct hotplug_slot *slot)
 	kfree(dslot);
 }
 
+#define SLOT_NAME_SIZE	8
+
 static int add_slot(struct pci_dev *dev)
 {
 	struct dummy_slot *dslot;
 	struct hotplug_slot *slot;
+	char name[SLOT_NAME_SIZE];
 	int retval = -ENOMEM;
 	static int count = 1;
 
@@ -119,15 +121,13 @@ static int add_slot(struct pci_dev *dev)
 	if (!dslot)
 		goto error_info;
 
-	slot->name = dslot->name;
-	snprintf(slot->name, sizeof(dslot->name), "fake%d", count++);
-	dbg("slot->name = %s\n", slot->name);
+	scnprintf(name, SLOT_NAME_SIZE, "fake%d", count++);
+	dbg("slot->name = %s\n", name);
 	slot->ops = &dummy_hotplug_slot_ops;
 	slot->release = &dummy_release;
 	slot->private = dslot;
 
-	retval = pci_hp_register(slot, dev->bus, PCI_SLOT(dev->devfn),
-				 slot->name);
+	retval = pci_hp_register(slot, dev->bus, PCI_SLOT(dev->devfn), name);
 	if (retval) {
 		err("pci_hp_register failed with error %d\n", retval);
 		goto error_dslot;
@@ -168,10 +168,11 @@ static void remove_slot(struct dummy_slot *dslot)
 {
 	int retval;
 
-	dbg("removing slot %s\n", dslot->slot->name);
+	dbg("removing slot %s\n", hotplug_slot_name(dslot->slot));
 	retval = pci_hp_deregister(dslot->slot);
 	if (retval)
-		err("Problem unregistering a slot %s\n", dslot->slot->name);
+		err("Problem unregistering a slot %s\n",
+			hotplug_slot_name(dslot->slot));
 }
 
 /* called from the single-threaded workqueue handler to remove a slot */
@@ -309,7 +310,7 @@ static int disable_slot(struct hotplug_slot *slot)
 		return -ENODEV;
 	dslot = slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot_name(slot));
 
 	for (func = 7; func >= 0; func--) {
 		dev = pci_get_slot(dslot->dev->bus, dslot->dev->devfn + func);


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

* [PATCH v2 08/13] PCI: ibmphp: stop managing hotplug_slot->name
  2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
                             ` (6 preceding siblings ...)
  2008-09-09 10:00           ` [PATCH v2 07/13] PCI: fakephp: remove 'name' parameter Alex Chiang
@ 2008-09-09 10:00           ` Alex Chiang
  2008-09-09 10:00           ` [PATCH v2 09/13] PCI: pciehp: remove 'name' parameter Alex Chiang
                             ` (4 subsequent siblings)
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-09-09 10:00 UTC (permalink / raw)
  To: linux-pci, linux-kernel; +Cc: jbarnes, kristen.c.accardi, Alex Chiang

We no longer need to manage our version of hotplug_slot->name
since the PCI and hotplug core manage it on our behalf.

Now, we simply advise the PCI core of the name that we would
like, and let the core take care of the rest.

Additionally, slightly rearrange the members of struct slot
so they are naturally aligned to eliminate holes.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/ibmphp.h      |    5 ++---
 drivers/pci/hotplug/ibmphp_ebda.c |   20 +++++++-------------
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h
index 612d963..a8d391a 100644
--- a/drivers/pci/hotplug/ibmphp.h
+++ b/drivers/pci/hotplug/ibmphp.h
@@ -707,17 +707,16 @@ struct slot {
 	u8 device;
 	u8 number;
 	u8 real_physical_slot_num;
-	char name[100];
 	u32 capabilities;
 	u8 supported_speed;
 	u8 supported_bus_mode;
+	u8 flag;		/* this is for disable slot and polling */
+	u8 ctlr_index;
 	struct hotplug_slot *hotplug_slot;
 	struct controller *ctrl;
 	struct pci_func *func;
 	u8 irq[4];
-	u8 flag;		/* this is for disable slot and polling */
 	int bit_mode;		/* 0 = 32, 1 = 64 */
-	u8 ctlr_index;
 	struct bus_info *bus_on;
 	struct list_head ibm_slot_list;
 	u8 status;
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
index 85528d6..402dc10 100644
--- a/drivers/pci/hotplug/ibmphp_ebda.c
+++ b/drivers/pci/hotplug/ibmphp_ebda.c
@@ -587,11 +587,14 @@ static u8 calculate_first_slot (u8 slot_num)
 	return first_slot + 1;
 
 }
+
+#define SLOT_NAME_SIZE 30
+
 static char *create_file_name (struct slot * slot_cur)
 {
 	struct opt_rio *opt_vg_ptr = NULL;
 	struct opt_rio_lo *opt_lo_ptr = NULL;
-	static char str[30];
+	static char str[SLOT_NAME_SIZE];
 	int which = 0; /* rxe = 1, chassis = 0 */
 	u8 number = 1; /* either chassis or rxe # */
 	u8 first_slot = 1;
@@ -703,7 +706,6 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 
 	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;
@@ -734,6 +736,7 @@ static int __init ebda_rsrc_controller (void)
 	struct bus_info *bus_info_ptr1, *bus_info_ptr2;
 	int rc;
 	struct slot *tmp_slot;
+	char name[SLOT_NAME_SIZE];
 
 	addr = hpc_list_ptr->phys_addr;
 	for (ctlr = 0; ctlr < hpc_list_ptr->num_ctlrs; ctlr++) {
@@ -897,12 +900,6 @@ static int __init ebda_rsrc_controller (void)
 				goto error_no_hp_info;
 			}
 
-			hp_slot_ptr->name = kmalloc(30, GFP_KERNEL);
-			if (!hp_slot_ptr->name) {
-				rc = -ENOMEM;
-				goto error_no_hp_name;
-			}
-
 			tmp_slot = kzalloc(sizeof(*tmp_slot), GFP_KERNEL);
 			if (!tmp_slot) {
 				rc = -ENOMEM;
@@ -964,10 +961,9 @@ static int __init ebda_rsrc_controller (void)
 	}			/* each hpc  */
 
 	list_for_each_entry(tmp_slot, &ibmphp_slot_head, ibm_slot_list) {
-		snprintf (tmp_slot->hotplug_slot->name, 30, "%s", create_file_name (tmp_slot));
+		snprintf(name, SLOT_NAME_SIZE, "%s", create_file_name(tmp_slot));
 		pci_hp_register(tmp_slot->hotplug_slot,
-			pci_find_bus(0, tmp_slot->bus), tmp_slot->device,
-			tmp_slot->hotplug_slot->name);
+			pci_find_bus(0, tmp_slot->bus), tmp_slot->device, name);
 	}
 
 	print_ebda_hpc ();
@@ -977,8 +973,6 @@ static int __init ebda_rsrc_controller (void)
 error:
 	kfree (hp_slot_ptr->private);
 error_no_slot:
-	kfree (hp_slot_ptr->name);
-error_no_hp_name:
 	kfree (hp_slot_ptr->info);
 error_no_hp_info:
 	kfree (hp_slot_ptr);


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

* [PATCH v2 09/13] PCI: pciehp: remove 'name' parameter
  2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
                             ` (7 preceding siblings ...)
  2008-09-09 10:00           ` [PATCH v2 08/13] PCI: ibmphp: stop managing hotplug_slot->name Alex Chiang
@ 2008-09-09 10:00           ` Alex Chiang
  2008-09-09 10:00           ` [PATCH v2 10/13] PCI: rpaphp: stop managing hotplug_slot->name Alex Chiang
                             ` (3 subsequent siblings)
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-09-09 10:00 UTC (permalink / raw)
  To: linux-pci, linux-kernel
  Cc: jbarnes, kristen.c.accardi, kaneshige.kenji, Alex Chiang

We do not need to manage our own name parameter, especially since
the PCI core can change it on our behalf, in the case of duplicate
slot names.

Remove 'name' from pciehp's version of struct slot, and remove
unused 'task_list' as well.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: kaneshige.kenji@jp.fujitsu.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/pciehp.h      |    9 +++++--
 drivers/pci/hotplug/pciehp_core.c |   25 ++++++++++---------
 drivers/pci/hotplug/pciehp_ctrl.c |   48 +++++++++++++++++++------------------
 3 files changed, 43 insertions(+), 39 deletions(-)

diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 217427a..3be5dde 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -61,15 +61,13 @@ extern struct workqueue_struct *pciehp_wq;
 struct slot {
 	u8 bus;
 	u8 device;
-	u32 number;
 	u8 state;
-	struct timer_list task_event;
 	u8 hp_slot;
+	u32 number;
 	struct controller *ctrl;
 	struct hpc_ops *hpc_ops;
 	struct hotplug_slot *hotplug_slot;
 	struct list_head	slot_list;
-	char name[SLOT_NAME_SIZE];
 	unsigned long last_emi_toggle;
 	struct delayed_work work;	/* work for button event */
 	struct mutex lock;
@@ -162,6 +160,11 @@ int pciehp_enable_slot(struct slot *p_slot);
 int pciehp_disable_slot(struct slot *p_slot);
 int pcie_enable_notification(struct controller *ctrl);
 
+static inline const char *slot_name(struct slot *slot)
+{
+	return hotplug_slot_name(slot->hotplug_slot);
+}
+
 static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
 {
 	struct slot *slot;
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index bed77af..0466e64 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -180,7 +180,7 @@ static struct hotplug_slot_attribute hotplug_slot_attr_lock = {
  */
 static void release_slot(struct hotplug_slot *hotplug_slot)
 {
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot_name(hotplug_slot));
 
 	kfree(hotplug_slot->info);
 	kfree(hotplug_slot);
@@ -191,6 +191,7 @@ static int init_slots(struct controller *ctrl)
 	struct slot *slot;
 	struct hotplug_slot *hotplug_slot;
 	struct hotplug_slot_info *info;
+	char name[SLOT_NAME_SIZE];
 	int retval = -ENOMEM;
 
 	list_for_each_entry(slot, &ctrl->slot_list, slot_list) {
@@ -204,7 +205,6 @@ static int init_slots(struct controller *ctrl)
 
 		/* register this slot with the hotplug pci core */
 		hotplug_slot->info = info;
-		hotplug_slot->name = slot->name;
 		hotplug_slot->private = slot;
 		hotplug_slot->release = &release_slot;
 		hotplug_slot->ops = &pciehp_hotplug_slot_ops;
@@ -213,6 +213,7 @@ static int init_slots(struct controller *ctrl)
 		get_latch_status(hotplug_slot, &info->latch_status);
 		get_adapter_status(hotplug_slot, &info->adapter_status);
 		slot->hotplug_slot = hotplug_slot;
+		scnprintf(name, SLOT_NAME_SIZE, "%d", slot->number);
 
 		dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x "
 		    "slot_device_offset=%x\n", slot->bus, slot->device,
@@ -220,7 +221,7 @@ static int init_slots(struct controller *ctrl)
 		retval = pci_hp_register(hotplug_slot,
 					 ctrl->pci_dev->subordinate,
 					 slot->device,
-					 slot->name);
+					 name);
 		if (retval) {
 			err("pci_hp_register failed with error %d\n", retval);
 			goto error_info;
@@ -265,7 +266,7 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	hotplug_slot->info->attention_status = status;
 
@@ -280,7 +281,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	return pciehp_sysfs_enable_slot(slot);
 }
@@ -290,7 +291,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	return pciehp_sysfs_disable_slot(slot);
 }
@@ -300,7 +301,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_power_status(slot, value);
 	if (retval < 0)
@@ -314,7 +315,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_attention_status(slot, value);
 	if (retval < 0)
@@ -328,7 +329,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_latch_status(slot, value);
 	if (retval < 0)
@@ -342,7 +343,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = hotplug_slot->private;
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_adapter_status(slot, value);
 	if (retval < 0)
@@ -357,7 +358,7 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot,
 	struct slot *slot = hotplug_slot->private;
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_max_bus_speed(slot, value);
 	if (retval < 0)
@@ -371,7 +372,7 @@ static int get_cur_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
 	struct slot *slot = hotplug_slot->private;
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_cur_bus_speed(slot, value);
 	if (retval < 0)
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 96a5d55..7266fbd 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -65,7 +65,7 @@ u8 pciehp_handle_attention_button(struct slot *p_slot)
 	/*
 	 *  Button pressed - See if need to TAKE ACTION!!!
 	 */
-	info("Button pressed on Slot(%s)\n", p_slot->name);
+	info("Button pressed on Slot(%s)\n", slot_name(p_slot));
 	event_type = INT_BUTTON_PRESS;
 
 	queue_interrupt_event(p_slot, event_type);
@@ -86,13 +86,13 @@ u8 pciehp_handle_switch_change(struct slot *p_slot)
 		/*
 		 * Switch opened
 		 */
-		info("Latch open on Slot(%s)\n", p_slot->name);
+		info("Latch open on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_SWITCH_OPEN;
 	} else {
 		/*
 		 *  Switch closed
 		 */
-		info("Latch close on Slot(%s)\n", p_slot->name);
+		info("Latch close on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_SWITCH_CLOSE;
 	}
 
@@ -117,13 +117,13 @@ u8 pciehp_handle_presence_change(struct slot *p_slot)
 		/*
 		 * Card Present
 		 */
-		info("Card present on Slot(%s)\n", p_slot->name);
+		info("Card present on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_PRESENCE_ON;
 	} else {
 		/*
 		 * Not Present
 		 */
-		info("Card not present on Slot(%s)\n", p_slot->name);
+		info("Card not present on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_PRESENCE_OFF;
 	}
 
@@ -143,13 +143,13 @@ u8 pciehp_handle_power_fault(struct slot *p_slot)
 		/*
 		 * power fault Cleared
 		 */
-		info("Power fault cleared on Slot(%s)\n", p_slot->name);
+		info("Power fault cleared on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_POWER_FAULT_CLEAR;
 	} else {
 		/*
 		 *   power fault
 		 */
-		info("Power fault on Slot(%s)\n", p_slot->name);
+		info("Power fault on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_POWER_FAULT;
 		info("power fault bit %x set\n", 0);
 	}
@@ -404,11 +404,11 @@ static void handle_button_press_event(struct slot *p_slot)
 		if (getstatus) {
 			p_slot->state = BLINKINGOFF_STATE;
 			info("PCI slot #%s - powering off due to button "
-			     "press.\n", p_slot->name);
+			     "press.\n", slot_name(p_slot));
 		} else {
 			p_slot->state = BLINKINGON_STATE;
 			info("PCI slot #%s - powering on due to button "
-			     "press.\n", p_slot->name);
+			     "press.\n", slot_name(p_slot));
 		}
 		/* blink green LED and turn off amber */
 		if (PWR_LED(ctrl))
@@ -425,7 +425,7 @@ static void handle_button_press_event(struct slot *p_slot)
 		 * press the attention again before the 5 sec. limit
 		 * expires to cancel hot-add or hot-remove
 		 */
-		info("Button cancel on Slot(%s)\n", p_slot->name);
+		info("Button cancel on Slot(%s)\n", slot_name(p_slot));
 		dbg("%s: button cancel\n", __func__);
 		cancel_delayed_work(&p_slot->work);
 		if (p_slot->state == BLINKINGOFF_STATE) {
@@ -438,7 +438,7 @@ static void handle_button_press_event(struct slot *p_slot)
 		if (ATTN_LED(ctrl))
 			p_slot->hpc_ops->set_attention_status(p_slot, 0);
 		info("PCI slot #%s - action canceled due to button press\n",
-		     p_slot->name);
+		     slot_name(p_slot));
 		p_slot->state = STATIC_STATE;
 		break;
 	case POWEROFF_STATE:
@@ -448,7 +448,7 @@ static void handle_button_press_event(struct slot *p_slot)
 		 * this means that the previous attention button action
 		 * to hot-add or hot-remove is undergoing
 		 */
-		info("Button ignore on Slot(%s)\n", p_slot->name);
+		info("Button ignore on Slot(%s)\n", slot_name(p_slot));
 		update_slot_info(p_slot);
 		break;
 	default:
@@ -529,7 +529,7 @@ int pciehp_enable_slot(struct slot *p_slot)
 	rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
 	if (rc || !getstatus) {
 		info("%s: no adapter on slot(%s)\n", __func__,
-		     p_slot->name);
+		     slot_name(p_slot));
 		mutex_unlock(&p_slot->ctrl->crit_sect);
 		return -ENODEV;
 	}
@@ -537,7 +537,7 @@ int pciehp_enable_slot(struct slot *p_slot)
 		rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
 		if (rc || getstatus) {
 			info("%s: latch open on slot(%s)\n", __func__,
-			     p_slot->name);
+			     slot_name(p_slot));
 			mutex_unlock(&p_slot->ctrl->crit_sect);
 			return -ENODEV;
 		}
@@ -547,7 +547,7 @@ int pciehp_enable_slot(struct slot *p_slot)
 		rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
 		if (rc || getstatus) {
 			info("%s: already enabled on slot(%s)\n", __func__,
-			     p_slot->name);
+			     slot_name(p_slot));
 			mutex_unlock(&p_slot->ctrl->crit_sect);
 			return -EINVAL;
 		}
@@ -582,7 +582,7 @@ int pciehp_disable_slot(struct slot *p_slot)
 		ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
 		if (ret || !getstatus) {
 			info("%s: no adapter on slot(%s)\n", __func__,
-			     p_slot->name);
+			     slot_name(p_slot));
 			mutex_unlock(&p_slot->ctrl->crit_sect);
 			return -ENODEV;
 		}
@@ -592,7 +592,7 @@ int pciehp_disable_slot(struct slot *p_slot)
 		ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
 		if (ret || getstatus) {
 			info("%s: latch open on slot(%s)\n", __func__,
-			     p_slot->name);
+			     slot_name(p_slot));
 			mutex_unlock(&p_slot->ctrl->crit_sect);
 			return -ENODEV;
 		}
@@ -602,7 +602,7 @@ int pciehp_disable_slot(struct slot *p_slot)
 		ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
 		if (ret || !getstatus) {
 			info("%s: already disabled slot(%s)\n", __func__,
-			     p_slot->name);
+			     slot_name(p_slot));
 			mutex_unlock(&p_slot->ctrl->crit_sect);
 			return -EINVAL;
 		}
@@ -632,14 +632,14 @@ int pciehp_sysfs_enable_slot(struct slot *p_slot)
 		break;
 	case POWERON_STATE:
 		info("Slot %s is already in powering on state\n",
-		     p_slot->name);
+		     slot_name(p_slot));
 		break;
 	case BLINKINGOFF_STATE:
 	case POWEROFF_STATE:
-		info("Already enabled on slot %s\n", p_slot->name);
+		info("Already enabled on slot %s\n", slot_name(p_slot));
 		break;
 	default:
-		err("Not a valid state on slot %s\n", p_slot->name);
+		err("Not a valid state on slot %s\n", slot_name(p_slot));
 		break;
 	}
 	mutex_unlock(&p_slot->lock);
@@ -664,14 +664,14 @@ int pciehp_sysfs_disable_slot(struct slot *p_slot)
 		break;
 	case POWEROFF_STATE:
 		info("Slot %s is already in powering off state\n",
-		     p_slot->name);
+		     slot_name(p_slot));
 		break;
 	case BLINKINGON_STATE:
 	case POWERON_STATE:
-		info("Already disabled on slot %s\n", p_slot->name);
+		info("Already disabled on slot %s\n", slot_name(p_slot));
 		break;
 	default:
-		err("Not a valid state on slot %s\n", p_slot->name);
+		err("Not a valid state on slot %s\n", slot_name(p_slot));
 		break;
 	}
 	mutex_unlock(&p_slot->lock);


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

* [PATCH v2 10/13] PCI: rpaphp: stop managing hotplug_slot->name
  2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
                             ` (8 preceding siblings ...)
  2008-09-09 10:00           ` [PATCH v2 09/13] PCI: pciehp: remove 'name' parameter Alex Chiang
@ 2008-09-09 10:00           ` Alex Chiang
  2008-09-09 10:00           ` [PATCH v2 11/13] PCI: SGI Hotplug: stop managing bss_hotplug_slot->name Alex Chiang
                             ` (2 subsequent siblings)
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-09-09 10:00 UTC (permalink / raw)
  To: linux-pci, linux-kernel; +Cc: jbarnes, kristen.c.accardi, benh, Alex Chiang

We no longer need to manage our version of hotplug_slot->name
since the PCI and hotplug core manage it on our behalf.

This means that alloc_slot_struct() no longer needs to take
a 'name' param. On the other hand, we give rpaphp_register_slot()
a 'name' param now to simplify the hotplug registration process.
rpaphp_register_slot() can directly pass the drc_name to the
PCI hotplug core.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: benh@kernel.crashing.org
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/rpaphp.h      |   10 +++++++---
 drivers/pci/hotplug/rpaphp_core.c |    6 +++---
 drivers/pci/hotplug/rpaphp_pci.c  |    4 ++--
 drivers/pci/hotplug/rpaphp_slot.c |   26 +++++++++-----------------
 4 files changed, 21 insertions(+), 25 deletions(-)

diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
index 7d5921b..12f8aa7 100644
--- a/drivers/pci/hotplug/rpaphp.h
+++ b/drivers/pci/hotplug/rpaphp.h
@@ -73,13 +73,17 @@ struct slot {
 	u32 index;
 	u32 type;
 	u32 power_domain;
-	char *name;
 	struct device_node *dn;
 	struct pci_bus *bus;
 	struct list_head *pci_devs;
 	struct hotplug_slot *hotplug_slot;
 };
 
+static inline const char *slot_name(struct slot *slot)
+{
+	return hotplug_slot_name(slot->hotplug_slot);
+}
+
 extern struct hotplug_slot_ops rpaphp_hotplug_slot_ops;
 extern struct list_head rpaphp_slot_head;
 
@@ -96,8 +100,8 @@ extern int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
 
 /* rpaphp_slot.c */
 extern void dealloc_slot_struct(struct slot *slot);
-extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_name, int power_domain);
-extern int rpaphp_register_slot(struct slot *slot);
+extern struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, int power_domain);
+extern int rpaphp_register_slot(struct slot *slot, const char *name);
 extern int rpaphp_deregister_slot(struct slot *slot);
 	
 #endif				/* _PPC64PHP_H */
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 1f84f40..c989005 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -324,7 +324,7 @@ int rpaphp_add_slot(struct device_node *dn)
 	type = (char *) &types[1];
 	for (i = 0; i < indexes[0]; i++) {
 
-		slot = alloc_slot_struct(dn, indexes[i + 1], name, power_domains[i + 1]);
+		slot = alloc_slot_struct(dn, indexes[i + 1], power_domains[i + 1]);
 		if (!slot)
 			return -ENOMEM;
 
@@ -335,7 +335,7 @@ int rpaphp_add_slot(struct device_node *dn)
 
 		retval = rpaphp_enable_slot(slot);
 		if (!retval)
-			retval = rpaphp_register_slot(slot);
+			retval = rpaphp_register_slot(slot, name);
 
 		if (retval)
 			dealloc_slot_struct(slot);
@@ -404,7 +404,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
 	} else if (state == EMPTY) {
 		slot->state = EMPTY;
 	} else {
-		err("%s: slot[%s] is in invalid state\n", __func__, slot->name);
+		err("%s: slot[%s] is in invalid state\n", __func__, slot_name(slot));
 		slot->state = NOT_VALID;
 		return -EINVAL;
 	}
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index 5acfd4f..46eed88 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -51,7 +51,7 @@ int rpaphp_get_sensor_state(struct slot *slot, int *state)
 						  &setlevel);
 			if (rc < 0) {
 				dbg("%s: power on slot[%s] failed rc=%d.\n",
-				    __func__, slot->name, rc);
+				    __func__, slot_name(slot), rc);
 			} else {
 				rc = rtas_get_sensor(DR_ENTITY_SENSE,
 						     slot->index, state);
@@ -111,7 +111,7 @@ int rpaphp_enable_slot(struct slot *slot)
 		/* non-empty slot has to have child */
 		if (!slot->dn->child) {
 			err("%s: slot[%s]'s device_node doesn't have child for adapter\n",
-			    __func__, slot->name);
+			    __func__, slot_name(slot));
 			return -EINVAL;
 		}
 
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
index 736d3b4..2d167c3 100644
--- a/drivers/pci/hotplug/rpaphp_slot.c
+++ b/drivers/pci/hotplug/rpaphp_slot.c
@@ -43,13 +43,12 @@ static void rpaphp_release_slot(struct hotplug_slot *hotplug_slot)
 void dealloc_slot_struct(struct slot *slot)
 {
 	kfree(slot->hotplug_slot->info);
-	kfree(slot->hotplug_slot->name);
 	kfree(slot->hotplug_slot);
 	kfree(slot);
 }
 
 struct slot *alloc_slot_struct(struct device_node *dn,
-                       int drc_index, char *drc_name, int power_domain)
+			int drc_index, int power_domain)
 {
 	struct slot *slot;
 	
@@ -63,11 +62,6 @@ struct slot *alloc_slot_struct(struct device_node *dn,
 					   GFP_KERNEL);
 	if (!slot->hotplug_slot->info)
 		goto error_hpslot;
-	slot->hotplug_slot->name = kmalloc(strlen(drc_name) + 1, GFP_KERNEL);
-	if (!slot->hotplug_slot->name)
-		goto error_info;	
-	slot->name = slot->hotplug_slot->name;
-	strcpy(slot->name, drc_name);
 	slot->dn = dn;
 	slot->index = drc_index;
 	slot->power_domain = power_domain;
@@ -77,8 +71,6 @@ struct slot *alloc_slot_struct(struct device_node *dn,
 	
 	return (slot);
 
-error_info:
-	kfree(slot->hotplug_slot->info);
 error_hpslot:
 	kfree(slot->hotplug_slot);
 error_slot:
@@ -92,7 +84,7 @@ static int is_registered(struct slot *slot)
 	struct slot *tmp_slot;
 
 	list_for_each_entry(tmp_slot, &rpaphp_slot_head, rpaphp_slot_list) {
-		if (!strcmp(tmp_slot->name, slot->name))
+		if (!strcmp(slot_name(tmp_slot), slot_name(slot)))
 			return 1;
 	}	
 	return 0;
@@ -104,32 +96,32 @@ int rpaphp_deregister_slot(struct slot *slot)
 	struct hotplug_slot *php_slot = slot->hotplug_slot;
 
 	 dbg("%s - Entry: deregistering slot=%s\n",
-		__func__, slot->name);
+		__func__, slot_name(slot));
 
 	list_del(&slot->rpaphp_slot_list);
 	
 	retval = pci_hp_deregister(php_slot);
 	if (retval)
-		err("Problem unregistering a slot %s\n", slot->name);
+		err("Problem unregistering a slot %s\n", slot_name(slot));
 
 	dbg("%s - Exit: rc[%d]\n", __func__, retval);
 	return retval;
 }
 EXPORT_SYMBOL_GPL(rpaphp_deregister_slot);
 
-int rpaphp_register_slot(struct slot *slot)
+int rpaphp_register_slot(struct slot *slot, const char *name)
 {
 	struct hotplug_slot *php_slot = slot->hotplug_slot;
 	int retval;
 	int slotno;
 
 	dbg("%s registering slot:path[%s] index[%x], name[%s] pdomain[%x] type[%d]\n", 
-		__func__, slot->dn->full_name, slot->index, slot->name,
+		__func__, slot->dn->full_name, slot->index, slot_name(slot),
 		slot->power_domain, slot->type);
 
 	/* should not try to register the same slot twice */
 	if (is_registered(slot)) {
-		err("rpaphp_register_slot: slot[%s] is already registered\n", slot->name);
+		err("rpaphp_register_slot: slot[%s] is already registered\n", slot_name(slot));
 		return -EAGAIN;
 	}	
 
@@ -137,7 +129,7 @@ int rpaphp_register_slot(struct slot *slot)
 		slotno = PCI_SLOT(PCI_DN(slot->dn->child)->devfn);
 	else
 		slotno = -1;
-	retval = pci_hp_register(php_slot, slot->bus, slotno, slot->name);
+	retval = pci_hp_register(php_slot, slot->bus, slotno, name);
 	if (retval) {
 		err("pci_hp_register failed with error %d\n", retval);
 		return retval;
@@ -145,7 +137,7 @@ int rpaphp_register_slot(struct slot *slot)
 
 	/* add slot to our internal list */
 	list_add(&slot->rpaphp_slot_list, &rpaphp_slot_head);
-	info("Slot [%s] registered\n", slot->name);
+	info("Slot [%s] registered\n", name);
 	return 0;
 }
 


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

* [PATCH v2 11/13] PCI: SGI Hotplug: stop managing bss_hotplug_slot->name
  2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
                             ` (9 preceding siblings ...)
  2008-09-09 10:00           ` [PATCH v2 10/13] PCI: rpaphp: stop managing hotplug_slot->name Alex Chiang
@ 2008-09-09 10:00           ` Alex Chiang
  2008-09-09 10:01           ` [PATCH v2 12/13] PCI: shcphp: remove 'name' parameter Alex Chiang
  2008-09-09 10:01           ` [PATCH v2 13/13] PCI: Hotplug core: remove 'name' Alex Chiang
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-09-09 10:00 UTC (permalink / raw)
  To: linux-pci, linux-kernel; +Cc: jbarnes, kristen.c.accardi, jpk, Alex Chiang

We no longer need to manage our version of hotplug_slot->name
since the PCI and hotplug core manage it on our behalf.

Update the sn_hp_slot_private_alloc() interface to fill in
the correct name for us, as that function already has all
the parameters needed to determine the name.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: jpk@sgi.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/sgi_hotplug.c |   19 ++++++-------------
 1 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index 6d20bbd..d748698 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -161,7 +161,8 @@ static int sn_pci_bus_valid(struct pci_bus *pci_bus)
 }
 
 static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot,
-				    struct pci_bus *pci_bus, int device)
+				    struct pci_bus *pci_bus, int device,
+				    char *name)
 {
 	struct pcibus_info *pcibus_info;
 	struct slot *slot;
@@ -173,15 +174,9 @@ static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot,
 		return -ENOMEM;
 	bss_hotplug_slot->private = slot;
 
-	bss_hotplug_slot->name = kmalloc(SN_SLOT_NAME_SIZE, GFP_KERNEL);
-	if (!bss_hotplug_slot->name) {
-		kfree(bss_hotplug_slot->private);
-		return -ENOMEM;
-	}
-
 	slot->device_num = device;
 	slot->pci_bus = pci_bus;
-	sprintf(bss_hotplug_slot->name, "%04x:%02x:%02x",
+	sprintf(name, "%04x:%02x:%02x",
 		pci_domain_nr(pci_bus),
 		((u16)pcibus_info->pbi_buscommon.bs_persist_busnum),
 		device + 1);
@@ -608,7 +603,6 @@ static inline int get_power_status(struct hotplug_slot *bss_hotplug_slot,
 static void sn_release_slot(struct hotplug_slot *bss_hotplug_slot)
 {
 	kfree(bss_hotplug_slot->info);
-	kfree(bss_hotplug_slot->name);
 	kfree(bss_hotplug_slot->private);
 	kfree(bss_hotplug_slot);
 }
@@ -618,6 +612,7 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus)
 	int device;
 	struct pci_slot *pci_slot;
 	struct hotplug_slot *bss_hotplug_slot;
+	char name[SN_SLOT_NAME_SIZE];
 	int rc = 0;
 
 	/*
@@ -645,16 +640,14 @@ static int sn_hotplug_slot_register(struct pci_bus *pci_bus)
 		}
 
 		if (sn_hp_slot_private_alloc(bss_hotplug_slot,
-					     pci_bus, device)) {
+					     pci_bus, device, name)) {
 			rc = -ENOMEM;
 			goto alloc_err;
 		}
-
 		bss_hotplug_slot->ops = &sn_hotplug_slot_ops;
 		bss_hotplug_slot->release = &sn_release_slot;
 
-		rc = pci_hp_register(bss_hotplug_slot, pci_bus, device,
-				     bss_hotplug_slot->name);
+		rc = pci_hp_register(bss_hotplug_slot, pci_bus, device, name);
 		if (rc)
 			goto register_err;
 


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

* [PATCH v2 12/13] PCI: shcphp: remove 'name' parameter
  2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
                             ` (10 preceding siblings ...)
  2008-09-09 10:00           ` [PATCH v2 11/13] PCI: SGI Hotplug: stop managing bss_hotplug_slot->name Alex Chiang
@ 2008-09-09 10:01           ` Alex Chiang
  2008-09-09 10:01           ` [PATCH v2 13/13] PCI: Hotplug core: remove 'name' Alex Chiang
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-09-09 10:01 UTC (permalink / raw)
  To: linux-pci, linux-kernel
  Cc: jbarnes, kristen.c.accardi, kaneshige.kenji, Alex Chiang

We do not need to manage our own name parameter, especially since
the PCI core can change it on our behalf, in the case of duplicate
slot names.

Remove 'name' from shpchp's version of struct slot.

This change also removes the unused struct task_event from the
slot structure.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: kaneshige.kenji@jp.fujitsu.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/pciehp_hpc.c  |    1 -
 drivers/pci/hotplug/shpchp.h      |    9 +++++--
 drivers/pci/hotplug/shpchp_core.c |   28 ++++++++++------------
 drivers/pci/hotplug/shpchp_ctrl.c |   48 +++++++++++++++++++------------------
 4 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 1cfe172..be5fc12 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -1044,7 +1044,6 @@ static int pcie_init_slot(struct controller *ctrl)
 	slot->device = ctrl->slot_device_offset + slot->hp_slot;
 	slot->hpc_ops = ctrl->hpc_ops;
 	slot->number = ctrl->first_slot;
-	snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number);
 	mutex_init(&slot->lock);
 	INIT_DELAYED_WORK(&slot->work, pciehp_queue_pushbutton_work);
 	list_add(&slot->slot_list, &ctrl->slot_list);
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index 8a026f7..4d9fed0 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -69,15 +69,13 @@ struct slot {
 	u8 state;
 	u8 presence_save;
 	u8 pwr_save;
-	struct timer_list task_event;
-	u8 hp_slot;
 	struct controller *ctrl;
 	struct hpc_ops *hpc_ops;
 	struct hotplug_slot *hotplug_slot;
 	struct list_head	slot_list;
-	char name[SLOT_NAME_SIZE];
 	struct delayed_work work;	/* work for button event */
 	struct mutex lock;
+	u8 hp_slot;
 };
 
 struct event_info {
@@ -169,6 +167,11 @@ extern void cleanup_slots(struct controller *ctrl);
 extern void shpchp_queue_pushbutton_work(struct work_struct *work);
 extern int shpc_init( struct controller *ctrl, struct pci_dev *pdev);
 
+static inline const char *slot_name(struct slot *slot)
+{
+	return hotplug_slot_name(slot->hotplug_slot);
+}
+
 #ifdef CONFIG_ACPI
 #include <linux/pci-acpi.h>
 static inline int get_hp_params_from_firmware(struct pci_dev *dev,
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index cfdd079..ad6db88 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -89,7 +89,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = hotplug_slot->private;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	kfree(slot->hotplug_slot->info);
 	kfree(slot->hotplug_slot);
@@ -101,6 +101,7 @@ static int init_slots(struct controller *ctrl)
 	struct slot *slot;
 	struct hotplug_slot *hotplug_slot;
 	struct hotplug_slot_info *info;
+	char name[SLOT_NAME_SIZE];
 	int retval = -ENOMEM;
 	int i;
 
@@ -119,8 +120,6 @@ static int init_slots(struct controller *ctrl)
 			goto error_hpslot;
 		hotplug_slot->info = info;
 
-		hotplug_slot->name = slot->name;
-
 		slot->hp_slot = i;
 		slot->ctrl = ctrl;
 		slot->bus = ctrl->pci_dev->subordinate->number;
@@ -133,7 +132,7 @@ static int init_slots(struct controller *ctrl)
 		/* register this slot with the hotplug pci core */
 		hotplug_slot->private = slot;
 		hotplug_slot->release = &release_slot;
-		snprintf(slot->name, SLOT_NAME_SIZE, "%d", slot->number);
+		snprintf(name, SLOT_NAME_SIZE, "%d", slot->number);
 		hotplug_slot->ops = &shpchp_hotplug_slot_ops;
 
 		get_power_status(hotplug_slot, &info->power_status);
@@ -145,8 +144,7 @@ static int init_slots(struct controller *ctrl)
 		    "slot_device_offset=%x\n", slot->bus, slot->device,
 		    slot->hp_slot, slot->number, ctrl->slot_device_offset);
 		retval = pci_hp_register(slot->hotplug_slot,
-				ctrl->pci_dev->subordinate, slot->device,
-				hotplug_slot->name);
+				ctrl->pci_dev->subordinate, slot->device, name);
 		if (retval) {
 			err("pci_hp_register failed with error %d\n", retval);
 			goto error_info;
@@ -189,7 +187,7 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status)
 {
 	struct slot *slot = get_slot(hotplug_slot);
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	hotplug_slot->info->attention_status = status;
 	slot->hpc_ops->set_attention_status(slot, status);
@@ -201,7 +199,7 @@ static int enable_slot (struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = get_slot(hotplug_slot);
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	return shpchp_sysfs_enable_slot(slot);
 }
@@ -210,7 +208,7 @@ static int disable_slot (struct hotplug_slot *hotplug_slot)
 {
 	struct slot *slot = get_slot(hotplug_slot);
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	return shpchp_sysfs_disable_slot(slot);
 }
@@ -220,7 +218,7 @@ static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = get_slot(hotplug_slot);
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_power_status(slot, value);
 	if (retval < 0)
@@ -234,7 +232,7 @@ static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = get_slot(hotplug_slot);
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_attention_status(slot, value);
 	if (retval < 0)
@@ -248,7 +246,7 @@ static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = get_slot(hotplug_slot);
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_latch_status(slot, value);
 	if (retval < 0)
@@ -262,7 +260,7 @@ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value)
 	struct slot *slot = get_slot(hotplug_slot);
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_adapter_status(slot, value);
 	if (retval < 0)
@@ -277,7 +275,7 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot,
 	struct slot *slot = get_slot(hotplug_slot);
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_max_bus_speed(slot, value);
 	if (retval < 0)
@@ -291,7 +289,7 @@ static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp
 	struct slot *slot = get_slot(hotplug_slot);
 	int retval;
 
-	dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
+	dbg("%s - physical_slot = %s\n", __func__, slot_name(slot));
 
 	retval = slot->hpc_ops->get_cur_bus_speed(slot, value);
 	if (retval < 0)
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index dfb5393..919b1ee 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -70,7 +70,7 @@ u8 shpchp_handle_attention_button(u8 hp_slot, struct controller *ctrl)
 	/*
 	 *  Button pressed - See if need to TAKE ACTION!!!
 	 */
-	info("Button pressed on Slot(%s)\n", p_slot->name);
+	info("Button pressed on Slot(%s)\n", slot_name(p_slot));
 	event_type = INT_BUTTON_PRESS;
 
 	queue_interrupt_event(p_slot, event_type);
@@ -98,7 +98,7 @@ u8 shpchp_handle_switch_change(u8 hp_slot, struct controller *ctrl)
 		/*
 		 * Switch opened
 		 */
-		info("Latch open on Slot(%s)\n", p_slot->name);
+		info("Latch open on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_SWITCH_OPEN;
 		if (p_slot->pwr_save && p_slot->presence_save) {
 			event_type = INT_POWER_FAULT;
@@ -108,7 +108,7 @@ u8 shpchp_handle_switch_change(u8 hp_slot, struct controller *ctrl)
 		/*
 		 *  Switch closed
 		 */
-		info("Latch close on Slot(%s)\n", p_slot->name);
+		info("Latch close on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_SWITCH_CLOSE;
 	}
 
@@ -135,13 +135,13 @@ u8 shpchp_handle_presence_change(u8 hp_slot, struct controller *ctrl)
 		/*
 		 * Card Present
 		 */
-		info("Card present on Slot(%s)\n", p_slot->name);
+		info("Card present on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_PRESENCE_ON;
 	} else {
 		/*
 		 * Not Present
 		 */
-		info("Card not present on Slot(%s)\n", p_slot->name);
+		info("Card not present on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_PRESENCE_OFF;
 	}
 
@@ -164,14 +164,14 @@ u8 shpchp_handle_power_fault(u8 hp_slot, struct controller *ctrl)
 		/*
 		 * Power fault Cleared
 		 */
-		info("Power fault cleared on Slot(%s)\n", p_slot->name);
+		info("Power fault cleared on Slot(%s)\n", slot_name(p_slot));
 		p_slot->status = 0x00;
 		event_type = INT_POWER_FAULT_CLEAR;
 	} else {
 		/*
 		 *   Power fault
 		 */
-		info("Power fault on Slot(%s)\n", p_slot->name);
+		info("Power fault on Slot(%s)\n", slot_name(p_slot));
 		event_type = INT_POWER_FAULT;
 		/* set power fault status for this board */
 		p_slot->status = 0xFF;
@@ -493,11 +493,11 @@ static void handle_button_press_event(struct slot *p_slot)
 		if (getstatus) {
 			p_slot->state = BLINKINGOFF_STATE;
 			info("PCI slot #%s - powering off due to button "
-			     "press.\n", p_slot->name);
+			     "press.\n", slot_name(p_slot));
 		} else {
 			p_slot->state = BLINKINGON_STATE;
 			info("PCI slot #%s - powering on due to button "
-			     "press.\n", p_slot->name);
+			     "press.\n", slot_name(p_slot));
 		}
 		/* blink green LED and turn off amber */
 		p_slot->hpc_ops->green_led_blink(p_slot);
@@ -512,7 +512,7 @@ static void handle_button_press_event(struct slot *p_slot)
 		 * press the attention again before the 5 sec. limit
 		 * expires to cancel hot-add or hot-remove
 		 */
-		info("Button cancel on Slot(%s)\n", p_slot->name);
+		info("Button cancel on Slot(%s)\n", slot_name(p_slot));
 		dbg("%s: button cancel\n", __func__);
 		cancel_delayed_work(&p_slot->work);
 		if (p_slot->state == BLINKINGOFF_STATE)
@@ -521,7 +521,7 @@ static void handle_button_press_event(struct slot *p_slot)
 			p_slot->hpc_ops->green_led_off(p_slot);
 		p_slot->hpc_ops->set_attention_status(p_slot, 0);
 		info("PCI slot #%s - action canceled due to button press\n",
-		     p_slot->name);
+		     slot_name(p_slot));
 		p_slot->state = STATIC_STATE;
 		break;
 	case POWEROFF_STATE:
@@ -531,7 +531,7 @@ static void handle_button_press_event(struct slot *p_slot)
 		 * this means that the previous attention button action
 		 * to hot-add or hot-remove is undergoing
 		 */
-		info("Button ignore on Slot(%s)\n", p_slot->name);
+		info("Button ignore on Slot(%s)\n", slot_name(p_slot));
 		update_slot_info(p_slot);
 		break;
 	default:
@@ -574,17 +574,17 @@ static int shpchp_enable_slot (struct slot *p_slot)
 	mutex_lock(&p_slot->ctrl->crit_sect);
 	rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
 	if (rc || !getstatus) {
-		info("No adapter on slot(%s)\n", p_slot->name);
+		info("No adapter on slot(%s)\n", slot_name(p_slot));
 		goto out;
 	}
 	rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
 	if (rc || getstatus) {
-		info("Latch open on slot(%s)\n", p_slot->name);
+		info("Latch open on slot(%s)\n", slot_name(p_slot));
 		goto out;
 	}
 	rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
 	if (rc || getstatus) {
-		info("Already enabled on slot(%s)\n", p_slot->name);
+		info("Already enabled on slot(%s)\n", slot_name(p_slot));
 		goto out;
 	}
 
@@ -633,17 +633,17 @@ static int shpchp_disable_slot (struct slot *p_slot)
 
 	rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
 	if (rc || !getstatus) {
-		info("No adapter on slot(%s)\n", p_slot->name);
+		info("No adapter on slot(%s)\n", slot_name(p_slot));
 		goto out;
 	}
 	rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
 	if (rc || getstatus) {
-		info("Latch open on slot(%s)\n", p_slot->name);
+		info("Latch open on slot(%s)\n", slot_name(p_slot));
 		goto out;
 	}
 	rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
 	if (rc || !getstatus) {
-		info("Already disabled slot(%s)\n", p_slot->name);
+		info("Already disabled slot(%s)\n", slot_name(p_slot));
 		goto out;
 	}
 
@@ -671,14 +671,14 @@ int shpchp_sysfs_enable_slot(struct slot *p_slot)
 		break;
 	case POWERON_STATE:
 		info("Slot %s is already in powering on state\n",
-		     p_slot->name);
+		     slot_name(p_slot));
 		break;
 	case BLINKINGOFF_STATE:
 	case POWEROFF_STATE:
-		info("Already enabled on slot %s\n", p_slot->name);
+		info("Already enabled on slot %s\n", slot_name(p_slot));
 		break;
 	default:
-		err("Not a valid state on slot %s\n", p_slot->name);
+		err("Not a valid state on slot %s\n", slot_name(p_slot));
 		break;
 	}
 	mutex_unlock(&p_slot->lock);
@@ -703,14 +703,14 @@ int shpchp_sysfs_disable_slot(struct slot *p_slot)
 		break;
 	case POWEROFF_STATE:
 		info("Slot %s is already in powering off state\n",
-		     p_slot->name);
+		     slot_name(p_slot));
 		break;
 	case BLINKINGON_STATE:
 	case POWERON_STATE:
-		info("Already disabled on slot %s\n", p_slot->name);
+		info("Already disabled on slot %s\n", slot_name(p_slot));
 		break;
 	default:
-		err("Not a valid state on slot %s\n", p_slot->name);
+		err("Not a valid state on slot %s\n", slot_name(p_slot));
 		break;
 	}
 	mutex_unlock(&p_slot->lock);


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

* [PATCH v2 13/13] PCI: Hotplug core: remove 'name'
  2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
                             ` (11 preceding siblings ...)
  2008-09-09 10:01           ` [PATCH v2 12/13] PCI: shcphp: remove 'name' parameter Alex Chiang
@ 2008-09-09 10:01           ` Alex Chiang
  12 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-09-09 10:01 UTC (permalink / raw)
  To: linux-pci, linux-kernel
  Cc: jbarnes, kristen.c.accardi, matthew, kaneshige.kenji, Alex Chiang

Now that the PCI core manages the 'name' for each individual
hotplug driver, and all drivers have been converted to use
hotplug_slot_name(), there is no need for the PCI hotplug
core to drag around its own copy of name either.

Cc: jbarnes@virtuousgeek.org
Cc: kristen.c.accardi@intel.com
Cc: matthew@wil.cx
Cc: kaneshige.kenji@jp.fujitsu.com
Signed-off-by: Alex Chiang <achiang@hp.com>
---

 drivers/pci/hotplug/pci_hotplug_core.c |    6 +++---
 include/linux/pci_hotplug.h            |    3 ---
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index 2232608..c2ca365 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -533,7 +533,7 @@ static struct hotplug_slot *get_slot_from_name (const char *name)
 	spin_lock(&pci_hotplug_slot_list_lock);
 	list_for_each (tmp, &pci_hotplug_slot_list) {
 		slot = list_entry (tmp, struct hotplug_slot, slot_list);
-		if (strcmp(slot->name, name) == 0)
+		if (strcmp(hotplug_slot_name(slot), name) == 0)
 			goto out;
 	}
 	slot = NULL;
@@ -640,7 +640,7 @@ int pci_hp_deregister(struct hotplug_slot *hotplug)
 	if (!hotplug)
 		return -ENODEV;
 
-	temp = get_slot_from_name(hotplug->name);
+	temp = get_slot_from_name(hotplug_slot_name(hotplug));
 	if (temp != hotplug)
 		return -ENODEV;
 
@@ -650,7 +650,7 @@ int pci_hp_deregister(struct hotplug_slot *hotplug)
 
 	slot = hotplug->pci_slot;
 	fs_remove_slot(slot);
-	dbg("Removed slot %s from the list\n", hotplug->name);
+	dbg("Removed slot %s from the list\n", hotplug_slot_name(hotplug));
 
 	hotplug->release(hotplug);
 	slot->hotplug = NULL;
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index 7184bee..9899ea3 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -142,8 +142,6 @@ struct hotplug_slot_info {
 
 /**
  * struct hotplug_slot - used to register a physical slot with the hotplug pci core
- * @name: the name of the slot being registered.  This string must
- * be unique amoung slots registered on this system.
  * @ops: pointer to the &struct hotplug_slot_ops to be used for this slot
  * @info: pointer to the &struct hotplug_slot_info for the initial values for
  * this slot.
@@ -153,7 +151,6 @@ struct hotplug_slot_info {
  * needs.
  */
 struct hotplug_slot {
-	char				*name;
 	struct hotplug_slot_ops		*ops;
 	struct hotplug_slot_info	*info;
 	void (*release) (struct hotplug_slot *slot);


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

* Re: [PATCH v2 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface
  2008-09-09 10:00           ` [PATCH v2 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface Alex Chiang
@ 2008-09-09 12:05             ` Matthew Wilcox
  2008-09-09 17:18               ` Alex Chiang
  0 siblings, 1 reply; 55+ messages in thread
From: Matthew Wilcox @ 2008-09-09 12:05 UTC (permalink / raw)
  To: Alex Chiang
  Cc: linux-pci, linux-kernel, jbarnes, kristen.c.accardi, kaneshige.kenji

On Tue, Sep 09, 2008 at 04:00:07AM -0600, Alex Chiang wrote:
> -extern int pci_hp_register(struct hotplug_slot *, struct pci_bus *, int nr);
> +extern int pci_hp_register(struct hotplug_slot *,
> +			   struct pci_bus *,
> +			   int nr,
> +			   const char *name);

Not a huge fan of this style ... the usual style would be:

extern int pci_hp_register(struct hotplug_slot *, struct pci_bus *, int nr,
				const char *name);

Otherwise Acked-by: Matthew Wilcox <willy@linux.intel.com>

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

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

* Re: [PATCH v2 02/13] PCI: prevent duplicate slot names
  2008-09-09 10:00           ` [PATCH v2 02/13] PCI: prevent duplicate slot names Alex Chiang
@ 2008-09-09 13:07             ` Matthew Wilcox
  2008-09-22 21:38               ` Alex Chiang
  2008-09-10 14:58             ` Rolf Eike Beer
  2008-09-11  2:47             ` Kenji Kaneshige
  2 siblings, 1 reply; 55+ messages in thread
From: Matthew Wilcox @ 2008-09-09 13:07 UTC (permalink / raw)
  To: Alex Chiang
  Cc: linux-pci, linux-kernel, jbarnes, kristen.c.accardi, kaneshige.kenji

On Tue, Sep 09, 2008 at 04:00:12AM -0600, Alex Chiang wrote:
> If firmware assigns the name N to multiple slots, then:
> 
> 	The first registered slot is assigned N
> 	The second registered slot is assigned N-1
> 	The third registered slot is assigned N-2
> 	The Mth registered slot becomes N-M

Not quite true ... the Mth registered slot becomes N-(M-1).  With the
first '-' being a literal and the second being a minus sign ;-)

> -	 * Allow pcihp drivers to override the ACPI_PCI_SLOT name.
> +	 * Allow pcihp drivers to override existing slot name.

I would leave "the" in here.

> +static char *make_slot_name(const char *name)
> +{
> +	char *new_name;
> +	int len, width, dup = 1;
> +	struct kobject *dup_slot;
> +
> +	new_name = kstrdup(name, GFP_KERNEL);
> +	if (!new_name)
> +		goto out;
> +
> +	/*
> +	 * Start off allocating enough room for "name-X"
> +	 */
> +	len = strlen(name) + 2;
> +	width = 1;
> +
> +try_again:
> +	dup_slot = kset_find_obj(pci_slots_kset, new_name);
> +	if (!dup_slot)
> +		goto out;
> +	kobject_put(dup_slot);
> +
> +	/*
> +	 * We hit this the first time through, which gives us
> +	 * space for terminating NULL, and then every power of 10
> +	 * afterwards, which gives us space to add another digit
> +	 * to "name-XX..."
> +	 */
> +	if (dup % width == 0) {
> +		len++;
> +		width *= 10;
> +	}
> +
> +	new_name = krealloc(new_name, len, GFP_KERNEL);
> +	if (!new_name)
> +		goto out;
> +
> +	memset(new_name, 0, len);
> +	scnprintf(new_name, len, "%s-%d", name, dup++);
> +	goto try_again;
> +
> +out:
> +	return new_name;
> +}

I don't like the goto-loop style (yes, I know we do it elsewhere), and I
think we only need to krealloc inside the 'if' condition.  Something
like this, perhaps:

static char *make_slot_name(const char *name)
{
	char *new_name;
	int len, max, dup;

	new_name = kstrdup(name, GFP_KERNEL);
	if (!new_name)
		return NULL;

	/*
	 * Make sure we hit the realloc case the first time through the
	 * loop.  'len' will be strlen(name) + 3 at that point which is
	 * enough space for "name-X" and the trailing NUL.
	 */
	len = strlen(name) + 2;
	max = 1;
	dup = 1;

	for (;;) {
		struct kobject *dup_slot;
		dup_slot = kset_find_obj(pci_slots_kset, new_name);
		if (!dup_slot)
			break;
		kobject_put(dup_slot);
		if (dup == max) {
			len++;
			max *= 10;
			new_name = krealloc(new_name, len, GFP_KERNEL);
			if (!new_name)
				break;
		}
		sprintf(new_name, "%s-%d", name, dup++);
	}

	return new_name;
}
	

> @@ -89,7 +134,19 @@ static struct kobj_type pci_slot_ktype = {
>   * either return a new &struct pci_slot to the caller, or if the pci_slot
>   * already exists, its refcount will be incremented.
>   *
> - * Slots are uniquely identified by a @pci_bus, @slot_nr, @name tuple.
> + * Slots are uniquely identified by a @pci_bus, @slot_nr tuple.
> + *
> + * The kobject API imposes a restriction on us, and does not allow sysfs
> + * entries with duplicate names. There are known platforms with broken
> + * firmware that assign the same name to multiple slots.
> + *
> + * We workaround these broken platforms by renaming the slots on behalf
> + * of the caller. If firmware assigns name N to multiple slots:
> + *
> + * The first slot is assigned N
> + * The second slot is assigned N-1
> + * The third slot is assigned N-2
> + * The Mth slot is assigned N-M

How about simply replacing this last line with:

> + * etc.

>  struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
>  				 const char *name)
>  {
>  	struct pci_dev *dev;
>  	struct pci_slot *slot;
> -	int err;
> +	int err = 0;
> +	char *slot_name = NULL;
>  
>  	down_write(&pci_bus_sem);
>  
> @@ -144,12 +201,18 @@ placeholder:
>  
>  	slot->bus = parent;
>  	slot->number = slot_nr;
> -
>  	slot->kobj.kset = pci_slots_kset;
> +
> +	slot_name = make_slot_name(name);
> +	if (!slot_name) {
> +		slot = ERR_PTR(-ENOMEM);
> +		goto err;
> +	}

I think you need to kfree() slot before you assign an ERR_PTR to it.
Actually, since the 'err' label does that, just make that:

	if (!slot_name) {
		err = -ENOMEM;
		goto err;
	}

> -void pci_update_slot_number(struct pci_slot *slot, int slot_nr)
> +void pci_renumber_slot(struct pci_slot *slot, int slot_nr)
>  {
> -	int name_count = 0;
>  	struct pci_slot *tmp;
>  
>  	down_write(&pci_bus_sem);
>  
> -	list_for_each_entry(tmp, &slot->bus->slots, list) {
> +	list_for_each_entry(tmp, &slot->bus->slots, list)
>  		WARN_ON(tmp->number == slot_nr);
> -		if (!strcmp(kobject_name(&tmp->kobj), kobject_name(&slot->kobj)))
> -			name_count++;
> -	}
> -
> -	if (name_count > 1)
> -		printk(KERN_WARNING "pci_update_slot_number found %d slots with the same name: %s\n", name_count, kobject_name(&slot->kobj));

Are you going to get enough information to debug problems with just this
WARN_ON?  And do we want to decline to renumber a slot to the same
number as an existing one?

Anyway, looks good, and I really like the name-change for this function.

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

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

* Re: [PATCH v2 03/13] PCI, PCI Hotplug: introduce slot_name helpers
  2008-09-09 10:00           ` [PATCH v2 03/13] PCI, PCI Hotplug: introduce slot_name helpers Alex Chiang
@ 2008-09-09 14:30             ` Matthew Wilcox
  0 siblings, 0 replies; 55+ messages in thread
From: Matthew Wilcox @ 2008-09-09 14:30 UTC (permalink / raw)
  To: Alex Chiang
  Cc: linux-pci, linux-kernel, jbarnes, kristen.c.accardi, kaneshige.kenji

On Tue, Sep 09, 2008 at 04:00:17AM -0600, Alex Chiang wrote:
> In preparation for cleaning up the various hotplug drivers
> such that they don't have to manage their own 'name' parameters
> anymore, we provide the following convenience functions:
> 
> 	pci_slot_name()
> 	hotplug_slot_name()
> 
> These helpers will be used by individual hotplug drivers.
> 
> Cc: jbarnes@virtuousgeek.org
> Cc: kristen.c.accardi@intel.com
> Cc: matthew@wil.cx
> Cc: kaneshige.kenji@jp.fujitsu.com
> Signed-off-by: Alex Chiang <achiang@hp.com>

Acked-by: Matthew Wilcox <willy@linux.intel.com>

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

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

* Re: [PATCH v2 04/13] PCI: acpiphp: remove 'name' parameter
  2008-09-09 10:00           ` [PATCH v2 04/13] PCI: acpiphp: remove 'name' parameter Alex Chiang
@ 2008-09-09 14:38             ` Matthew Wilcox
  2008-09-23  1:16               ` Alex Chiang
  0 siblings, 1 reply; 55+ messages in thread
From: Matthew Wilcox @ 2008-09-09 14:38 UTC (permalink / raw)
  To: Alex Chiang
  Cc: linux-pci, linux-kernel, jbarnes, kristen.c.accardi, kaneshige.kenji

On Tue, Sep 09, 2008 at 04:00:22AM -0600, Alex Chiang wrote:
> We do not need to manage our own name parameter, especially since
> the PCI core can change it on our behalf, in the case of duplicate
> slot names.

Looks good, just a question ...

>  	acpiphp_slot->slot = slot;
> -	snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun);
> +	scnprintf(name, SLOT_NAME_SIZE, "%u", slot->acpi_slot->sun);
>  

What's the difference between snprintf and scnprintf?

And why were we bothering to use snprintf anyway?  For when we fall into a
parallel universe where a u32 can have more than twenty digits?

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

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

* Re: [PATCH v2 05/13] PCI: cpci_hotplug: stop managing hotplug_slot->name
  2008-09-09 10:00           ` [PATCH v2 05/13] PCI: cpci_hotplug: stop managing hotplug_slot->name Alex Chiang
@ 2008-09-09 15:04             ` Matthew Wilcox
  2008-09-09 21:11               ` Scott Murray
  0 siblings, 1 reply; 55+ messages in thread
From: Matthew Wilcox @ 2008-09-09 15:04 UTC (permalink / raw)
  To: Alex Chiang; +Cc: linux-pci, linux-kernel, jbarnes, kristen.c.accardi, scottm

On Tue, Sep 09, 2008 at 04:00:27AM -0600, Alex Chiang wrote:
> We no longer need to manage our version of hotplug_slot->name
> since the PCI and hotplug core manage it on our behalf.
> 
> Now, we simply advise the PCI core of the name that we would
> like, and let the core take care of the rest.

> -static void
> -make_slot_name(struct slot *slot)
> -{
> -	snprintf(slot->hotplug_slot->name,
> -		 SLOT_NAME_SIZE, "%02x:%02x", slot->bus->number, slot->number);
> -}
>  
>  
> +		scnprintf(name, SLOT_NAME_SIZE, "%02x:%02x", bus->number, i);
> +
>  		hotplug_slot->private = slot;

Unfortunately, our name is kind of crappy.  Can we not give the user
anything better than this?  I can't seem to find the CompactPCI
specification to see if we have a better name available.

I wonder if we can use DMI data on this class of machine.  Scott?

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

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

* Re: [PATCH v2 06/13] PCI: cpqphp: stop managing hotplug_slot->name
  2008-09-09 10:00           ` [PATCH v2 06/13] PCI: cpqphp: " Alex Chiang
@ 2008-09-09 15:08             ` Matthew Wilcox
  2008-09-23  1:20               ` Alex Chiang
  0 siblings, 1 reply; 55+ messages in thread
From: Matthew Wilcox @ 2008-09-09 15:08 UTC (permalink / raw)
  To: Alex Chiang; +Cc: linux-pci, linux-kernel, jbarnes, kristen.c.accardi

On Tue, Sep 09, 2008 at 04:00:32AM -0600, Alex Chiang wrote:
> -static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot)
> -{
> -	snprintf(buffer, buffer_size, "%d", slot->number);
> -}

> +
> +		scnprintf(name, SLOT_NAME_SIZE, "%d", slot->number);

So ... we're using %d here and %u in acpiphp.  Obviously we don't expect
to get a number above 2 billion, but I think if we do have some utterly
bogus firmware that gives us a number above 2 billion, printing a
positive number is a better user experience than a negative number.

We clearly have a common pattern here where hotplug drivers have a
number insteaqd of a name (I would venture this is the most common).
Maybe we need a common helper?  I think this is a subject for the
long-term todo list, not something that needs to be addressed in the
context of this patch series.

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

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

* Re: [PATCH v2 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface
  2008-09-09 12:05             ` Matthew Wilcox
@ 2008-09-09 17:18               ` Alex Chiang
  0 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-09-09 17:18 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: linux-pci, linux-kernel, jbarnes, kristen.c.accardi, kaneshige.kenji

* Matthew Wilcox <matthew@wil.cx>:
> On Tue, Sep 09, 2008 at 04:00:07AM -0600, Alex Chiang wrote:
> > -extern int pci_hp_register(struct hotplug_slot *, struct pci_bus *, int nr);
> > +extern int pci_hp_register(struct hotplug_slot *,
> > +			   struct pci_bus *,
> > +			   int nr,
> > +			   const char *name);
> 
> Not a huge fan of this style ... the usual style would be:
> 
> extern int pci_hp_register(struct hotplug_slot *, struct pci_bus *, int nr,
> 				const char *name);

Ok, will fix.

> Otherwise Acked-by: Matthew Wilcox <willy@linux.intel.com>

Thanks.

/ac


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

* Re: [PATCH v2 05/13] PCI: cpci_hotplug: stop managing hotplug_slot->name
  2008-09-09 15:04             ` Matthew Wilcox
@ 2008-09-09 21:11               ` Scott Murray
  0 siblings, 0 replies; 55+ messages in thread
From: Scott Murray @ 2008-09-09 21:11 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Alex Chiang, linux-pci, linux-kernel, jbarnes, kristen.c.accardi

On Tue, 9 Sep 2008, Matthew Wilcox wrote:

> On Tue, Sep 09, 2008 at 04:00:27AM -0600, Alex Chiang wrote:
> > We no longer need to manage our version of hotplug_slot->name
> > since the PCI and hotplug core manage it on our behalf.
> >
> > Now, we simply advise the PCI core of the name that we would
> > like, and let the core take care of the rest.
>
> > -static void
> > -make_slot_name(struct slot *slot)
> > -{
> > -	snprintf(slot->hotplug_slot->name,
> > -		 SLOT_NAME_SIZE, "%02x:%02x", slot->bus->number, slot->number);
> > -}
> >
> >
> > +		scnprintf(name, SLOT_NAME_SIZE, "%02x:%02x", bus->number, i);
> > +
> >  		hotplug_slot->private = slot;
>
> Unfortunately, our name is kind of crappy.  Can we not give the user
> anything better than this?  I can't seem to find the CompactPCI
> specification to see if we have a better name available.
>
> I wonder if we can use DMI data on this class of machine.  Scott?

This is about all that can be done, unfortunately.  I've never seen
anything useful with regards to this in DMI on the boards I've looked
at, and we would have to rework the board driver -> CPCI hotplug core
interface to pass that information along even if we could get it for
some boards.  In general, it is a difficult problem to solve since the
same set of system master and peripheral boards in a different chassis
could very well be at different geographic addresses depending on where
the chassis vendor has placed the system master slot(s).

Scott


-- 
Scott Murray
SOMA Networks, Inc.
Toronto, Ontario
e-mail: scottm@somanetworks.com

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

* Re: [PATCH v2 02/13] PCI: prevent duplicate slot names
  2008-09-09 10:00           ` [PATCH v2 02/13] PCI: prevent duplicate slot names Alex Chiang
  2008-09-09 13:07             ` Matthew Wilcox
@ 2008-09-10 14:58             ` Rolf Eike Beer
  2008-09-22 21:40               ` Alex Chiang
  2008-09-11  2:47             ` Kenji Kaneshige
  2 siblings, 1 reply; 55+ messages in thread
From: Rolf Eike Beer @ 2008-09-10 14:58 UTC (permalink / raw)
  To: Alex Chiang
  Cc: linux-pci, linux-kernel, jbarnes, kristen.c.accardi, matthew,
	kaneshige.kenji

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

Alex Chiang wrote:
> Prevent callers of pci_create_slot() from registering slots with
> duplicate names. This condition occurs most often when PCI hotplug
> drivers are loaded on platforms with broken firmware that assigns
> identical names to multiple slots.
>
> We now rename these duplicate slots on behalf of the user.
>
> If firmware assigns the name N to multiple slots, then:
>
> 	The first registered slot is assigned N
> 	The second registered slot is assigned N-1
> 	The third registered slot is assigned N-2
> 	The Mth registered slot becomes N-M
>
> A side effect of this patch is that the error condition for when
> multiple drivers attempt to claim the same slot becomes much more
> prominent.
>
> In other words, the previous error condition returned for
> duplicate slot names (-EEXIST) masked the case when multiple
> drivers attempted to claim the same slot. Now, the -EBUSY return
> makes the true error more obvious.
>
> This is the permanent fix mentioned in earlier commits:
>
> 	shpchp: Rename duplicate slot name N as N-1, N-2, N-M...
> 	d6a9e9b40be7da84f82eb414c2ad98c5bb69986b
>
> 	pciehp: Rename duplicate slot name N as N-1, N-2, N-M...
> 	167e782e301188c7c7e31e486bbeea5f918324c1
>
> Cc: jbarnes@virtuousgeek.org
> Cc: kristen.c.accardi@intel.com
> Cc: matthew@wil.cx
> Cc: kaneshige.kenji@jp.fujitsu.com
> Signed-off-by: Alex Chiang <achiang@hp.com>
> ---
>
>  drivers/pci/hotplug/pci_hotplug_core.c |   23 ++++--
>  drivers/pci/hotplug/pciehp_core.c      |   14 ----
>  drivers/pci/hotplug/shpchp_core.c      |   15 ----
>  drivers/pci/slot.c                     |  117
> +++++++++++++++++++++++++++----- include/linux/pci.h                    |  
>  3 +
>  5 files changed, 117 insertions(+), 55 deletions(-)
>
> diff --git a/drivers/pci/hotplug/pci_hotplug_core.c
> b/drivers/pci/hotplug/pci_hotplug_core.c index 3e37d63..2232608 100644
> --- a/drivers/pci/hotplug/pci_hotplug_core.c
> +++ b/drivers/pci/hotplug/pci_hotplug_core.c
> @@ -558,7 +558,8 @@ int pci_hp_register(struct hotplug_slot *slot, struct
> pci_bus *bus, int slot_nr, const char *name)
>  {
>  	int result;
> -	struct pci_slot *pci_slot;
> +	struct pci_dev *dev;
> +	struct pci_slot *pci_slot, *tmp_slot = NULL;
>
>  	if (slot == NULL)
>  		return -ENODEV;
> @@ -570,9 +571,17 @@ int pci_hp_register(struct hotplug_slot *slot, struct
> pci_bus *bus, int slot_nr, return -EINVAL;
>  	}
>
> -	/* Check if we have already registered a slot with the same name. */
> -	if (get_slot_from_name(name))
> -		return -EEXIST;
> +	/*
> +	 * If we find a tmp_slot here, it means that another slot
> +	 * driver has already created a pci_slot for this device.
> +	 * We care (below) if the existing slot has a different name from
> +	 * the new name that this particular hotplug driver is requesting.
> +	 */
> +	dev = pci_get_slot(bus, PCI_DEVFN(slot_nr, 0));
> +	if (dev && dev->slot) {
> +		tmp_slot = dev->slot;
> +		pci_dev_put(dev);
> +	}
>
>  	/*
>  	 * No problems if we call this interface from both ACPI_PCI_SLOT
> @@ -593,10 +602,10 @@ int pci_hp_register(struct hotplug_slot *slot, struct
> pci_bus *bus, int slot_nr, pci_slot->hotplug = slot;
>
>  	/*
> -	 * Allow pcihp drivers to override the ACPI_PCI_SLOT name.
> +	 * Allow pcihp drivers to override existing slot name.
>  	 */
> -	if (strcmp(kobject_name(&pci_slot->kobj), name)) {
> -		result = kobject_rename(&pci_slot->kobj, name);
> +	if (tmp_slot && strcmp(kobject_name(&tmp_slot->kobj), name)) {
> +		result = pci_rename_slot(pci_slot, name);
>  		if (result) {
>  			pci_destroy_slot(pci_slot);
>  			return result;
> diff --git a/drivers/pci/hotplug/pciehp_core.c
> b/drivers/pci/hotplug/pciehp_core.c index cbd84f8..bed77af 100644
> --- a/drivers/pci/hotplug/pciehp_core.c
> +++ b/drivers/pci/hotplug/pciehp_core.c
> @@ -191,7 +191,6 @@ static int init_slots(struct controller *ctrl)
>  	struct slot *slot;
>  	struct hotplug_slot *hotplug_slot;
>  	struct hotplug_slot_info *info;
> -	int len, dup = 1;
>  	int retval = -ENOMEM;
>
>  	list_for_each_entry(slot, &ctrl->slot_list, slot_list) {
> @@ -218,24 +217,11 @@ static int init_slots(struct controller *ctrl)
>  		dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x "
>  		    "slot_device_offset=%x\n", slot->bus, slot->device,
>  		    slot->hp_slot, slot->number, ctrl->slot_device_offset);
> -duplicate_name:
>  		retval = pci_hp_register(hotplug_slot,
>  					 ctrl->pci_dev->subordinate,
>  					 slot->device,
>  					 slot->name);
>  		if (retval) {
> -			/*
> -			 * If slot N already exists, we'll try to create
> -			 * slot N-1, N-2 ... N-M, until we overflow.
> -			 */
> -			if (retval == -EEXIST) {
> -				len = snprintf(slot->name, SLOT_NAME_SIZE,
> -					       "%d-%d", slot->number, dup++);
> -				if (len < SLOT_NAME_SIZE)
> -					goto duplicate_name;
> -				else
> -					err("duplicate slot name overflow\n");
> -			}
>  			err("pci_hp_register failed with error %d\n", retval);
>  			goto error_info;
>  		}
> diff --git a/drivers/pci/hotplug/shpchp_core.c
> b/drivers/pci/hotplug/shpchp_core.c index bf50966..cfdd079 100644
> --- a/drivers/pci/hotplug/shpchp_core.c
> +++ b/drivers/pci/hotplug/shpchp_core.c
> @@ -102,7 +102,7 @@ static int init_slots(struct controller *ctrl)
>  	struct hotplug_slot *hotplug_slot;
>  	struct hotplug_slot_info *info;
>  	int retval = -ENOMEM;
> -	int i, len, dup = 1;
> +	int i;
>
>  	for (i = 0; i < ctrl->num_slots; i++) {
>  		slot = kzalloc(sizeof(*slot), GFP_KERNEL);
> @@ -144,23 +144,10 @@ static int init_slots(struct controller *ctrl)
>  		dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x "
>  		    "slot_device_offset=%x\n", slot->bus, slot->device,
>  		    slot->hp_slot, slot->number, ctrl->slot_device_offset);
> -duplicate_name:
>  		retval = pci_hp_register(slot->hotplug_slot,
>  				ctrl->pci_dev->subordinate, slot->device,
>  				hotplug_slot->name);
>  		if (retval) {
> -			/*
> -			 * If slot N already exists, we'll try to create
> -			 * slot N-1, N-2 ... N-M, until we overflow.
> -			 */
> -			if (retval == -EEXIST) {
> -				len = snprintf(slot->name, SLOT_NAME_SIZE,
> -					       "%d-%d", slot->number, dup++);
> -				if (len < SLOT_NAME_SIZE)
> -					goto duplicate_name;
> -				else
> -					err("duplicate slot name overflow\n");
> -			}
>  			err("pci_hp_register failed with error %d\n", retval);
>  			goto error_info;
>  		}
> diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
> index 0c6db03..93c55ca 100644
> --- a/drivers/pci/slot.c
> +++ b/drivers/pci/slot.c
> @@ -78,6 +78,51 @@ static struct kobj_type pci_slot_ktype = {
>  	.default_attrs = pci_slot_default_attrs,
>  };
>
> +static char *make_slot_name(const char *name)
> +{
> +	char *new_name;
> +	int len, width, dup = 1;
> +	struct kobject *dup_slot;
> +
> +	new_name = kstrdup(name, GFP_KERNEL);
> +	if (!new_name)
> +		goto out;
> +
> +	/*
> +	 * Start off allocating enough room for "name-X"
> +	 */
> +	len = strlen(name) + 2;
> +	width = 1;
> +
> +try_again:
> +	dup_slot = kset_find_obj(pci_slots_kset, new_name);
> +	if (!dup_slot)
> +		goto out;
> +	kobject_put(dup_slot);
> +
> +	/*
> +	 * We hit this the first time through, which gives us
> +	 * space for terminating NULL, and then every power of 10
> +	 * afterwards, which gives us space to add another digit
> +	 * to "name-XX..."
> +	 */
> +	if (dup % width == 0) {
> +		len++;
> +		width *= 10;
> +	}
> +
> +	new_name = krealloc(new_name, len, GFP_KERNEL);
> +	if (!new_name)
> +		goto out;

If krealloc() fails you will leak the old new_name here.

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH 02/13] PCI: prevent duplicate slot names
  2008-09-09  9:04     ` Alex Chiang
@ 2008-09-11  2:43       ` Kenji Kaneshige
  2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
  0 siblings, 1 reply; 55+ messages in thread
From: Kenji Kaneshige @ 2008-09-11  2:43 UTC (permalink / raw)
  To: Alex Chiang, Kenji Kaneshige, linux-kernel, linux-pci, jbarnes,
	kristen.c.accardi, matthew

Hi Alex-san,

Thank you very much for your continuous effort.
I have one comment about the new design. Please see below.

 >> I found another problem in pci_hp_register() that would be more complex
>> to fix than above-mentioned problem. Here is a pci_hp_register() with
>> all of your patch applied.
>>
>> int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
>>                        const char *name)
>> {
>> 	(snip...)
>>
>>        /*
>>         * No problems if we call this interface from both ACPI_PCI_SLOT
>>         * driver and call it here again. If we've already created the
>>         * pci_slot, the interface will simply bump the refcount.
>>         */
>>        pci_slot = pci_create_slot(bus, slot_nr, name);
>>        if (IS_ERR(pci_slot))
>>                return PTR_ERR(pci_slot);
>>
>>        if (pci_slot->hotplug) {
>>                dbg("%s: already claimed\n", __func__);
>>                pci_destroy_slot(pci_slot);
>>                return -EBUSY;
>>        }
>>
>>        slot->pci_slot = pci_slot;
>>        pci_slot->hotplug = slot;
>>
>>        /*
>>         * Allow pcihp drivers to override the ACPI_PCI_SLOT name.
>>         */
>>        if (strcmp(kobject_name(&pci_slot->kobj), name)) {
>>                result = kobject_rename(&pci_slot->kobj, name);
>>                if (result) {
>>                        pci_destroy_slot(pci_slot);
>>                        return result;
>>                }
>>        }
>>
>> 	(snip...)
>> }
>>
>> If name duplication was detected in pci_create_slot(), it renames the
>> slot name like 'N-1' and return successfully. Even though slot's kobject
>> name was registered as 'N-1', 'name' array still have 'N' at this point.
>> So the following 'if' statement becomes true unexpectedly.
>>
>> 	/*
>>         * Allow pcihp drivers to override the ACPI_PCI_SLOT name.
>>         */
>>        if (strcmp(kobject_name(&pci_slot->kobj), name)) {
>>
>> Then pci_hp_register() attempt to rename the slot name with 'N' again
>> by calling kobject_rename(), but it fails because there already exists
>> kobject with name 'N'. As a result, pci_hp_register() will fail.
> 
> Yes, you are right, that is a problem.
> 
> I've taken the following approach:
> 
> 	- the above code is providing a mechanism to allow a
> 	  _hotplug_ driver to override a _detection_ driver slot
> 	  name.
> 
> 	- in other words, we only have to worry about the case
> 	  when a _detection_ driver was loaded before a _hotplug_
> 	  driver.
> 
> 	- we can ignore the case where another _hotplug_ driver
> 	  was loaded first, because we'll already return -EBUSY.
> 
> 	- so, to figure out if a _detection_ driver has already
> 	  been loaded, we check to see if the pci_dev already has
> 	  a valid pci_slot pointer.

We need to take into account that the hotplug slot can be empty.
In this case, we cannot do this check because pci_dev doesn't
exist, I think.

> 
> 	- if yes, then we later check to see if the existing slot
> 	  name matches the requested slot name from the hotplug
> 	  driver.
> 
> 	- if the hotplug driver is requesting a different name,
> 	  then we use a new interface, pci_rename_slot() which
> 	  will safely attempt to rename the slot without name
> 	  collision.
> 
> I'll send out the patch set soon, it would be great if you could
> test it for me, since I don't have systems with duplicate slot
> names.
> 

Sure.

P.S.
I also don't have the system with duplicate slot names. So I use
the debug patch that emulates this kind of system for testing.

Thanks,
Kenji Kaneshige



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

* Re: [PATCH v2 02/13] PCI: prevent duplicate slot names
  2008-09-09 10:00           ` [PATCH v2 02/13] PCI: prevent duplicate slot names Alex Chiang
  2008-09-09 13:07             ` Matthew Wilcox
  2008-09-10 14:58             ` Rolf Eike Beer
@ 2008-09-11  2:47             ` Kenji Kaneshige
  2008-09-11 10:37               ` Alex Chiang
  2008-09-23  0:05               ` Alex Chiang
  2 siblings, 2 replies; 55+ messages in thread
From: Kenji Kaneshige @ 2008-09-11  2:47 UTC (permalink / raw)
  To: Alex Chiang; +Cc: linux-pci, linux-kernel, jbarnes, kristen.c.accardi, matthew

Alex Chiang wrote:
> Prevent callers of pci_create_slot() from registering slots with
> duplicate names. This condition occurs most often when PCI hotplug
> drivers are loaded on platforms with broken firmware that assigns
> identical names to multiple slots.
> 
> We now rename these duplicate slots on behalf of the user.
> 
> If firmware assigns the name N to multiple slots, then:
> 
> 	The first registered slot is assigned N
> 	The second registered slot is assigned N-1
> 	The third registered slot is assigned N-2
> 	The Mth registered slot becomes N-M
> 
> A side effect of this patch is that the error condition for when
> multiple drivers attempt to claim the same slot becomes much more
> prominent.
> 
> In other words, the previous error condition returned for
> duplicate slot names (-EEXIST) masked the case when multiple
> drivers attempted to claim the same slot. Now, the -EBUSY return
> makes the true error more obvious.
> 
> This is the permanent fix mentioned in earlier commits:
> 
> 	shpchp: Rename duplicate slot name N as N-1, N-2, N-M...
> 	d6a9e9b40be7da84f82eb414c2ad98c5bb69986b
> 
> 	pciehp: Rename duplicate slot name N as N-1, N-2, N-M...
> 	167e782e301188c7c7e31e486bbeea5f918324c1
> 
> Cc: jbarnes@virtuousgeek.org
> Cc: kristen.c.accardi@intel.com
> Cc: matthew@wil.cx
> Cc: kaneshige.kenji@jp.fujitsu.com
> Signed-off-by: Alex Chiang <achiang@hp.com>
> ---
> 
>  drivers/pci/hotplug/pci_hotplug_core.c |   23 ++++--
>  drivers/pci/hotplug/pciehp_core.c      |   14 ----
>  drivers/pci/hotplug/shpchp_core.c      |   15 ----
>  drivers/pci/slot.c                     |  117 +++++++++++++++++++++++++++-----
>  include/linux/pci.h                    |    3 +
>  5 files changed, 117 insertions(+), 55 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
> index 3e37d63..2232608 100644
> --- a/drivers/pci/hotplug/pci_hotplug_core.c
> +++ b/drivers/pci/hotplug/pci_hotplug_core.c
> @@ -558,7 +558,8 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
>  			const char *name)
>  {
>  	int result;
> -	struct pci_slot *pci_slot;
> +	struct pci_dev *dev;
> +	struct pci_slot *pci_slot, *tmp_slot = NULL;
>  
>  	if (slot == NULL)
>  		return -ENODEV;
> @@ -570,9 +571,17 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
>  		return -EINVAL;
>  	}
>  
> -	/* Check if we have already registered a slot with the same name. */
> -	if (get_slot_from_name(name))
> -		return -EEXIST;
> +	/*
> +	 * If we find a tmp_slot here, it means that another slot
> +	 * driver has already created a pci_slot for this device.
> +	 * We care (below) if the existing slot has a different name from
> +	 * the new name that this particular hotplug driver is requesting.
> +	 */
> +	dev = pci_get_slot(bus, PCI_DEVFN(slot_nr, 0));
> +	if (dev && dev->slot) {
> +		tmp_slot = dev->slot;
> +		pci_dev_put(dev);
> +	}
>

I have two comments here.

(1) I think the reference counter of the device will be leaked if
(dev == NULL) && (dev->slot != NULL). We need pci_dev_put() whenever
dev is not NULL.

(2) When the slot is empty, the 'dev' will be always NULL. Therefore,
'tmp_slot' will be always NULL on the empty slot here. Because of
this, the following code to rename the slot will not work on the
empty slot, I think.

>  	/*
> -	 * Allow pcihp drivers to override the ACPI_PCI_SLOT name.
> +	 * Allow pcihp drivers to override existing slot name.
>  	 */
> -	if (strcmp(kobject_name(&pci_slot->kobj), name)) {
> -		result = kobject_rename(&pci_slot->kobj, name);
> +	if (tmp_slot && strcmp(kobject_name(&tmp_slot->kobj), name)) {
> +		result = pci_rename_slot(pci_slot, name);
>  		if (result) {
>  			pci_destroy_slot(pci_slot);
>  			return result;

Thanks,
Kenji Kaneshige


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

* Re: [PATCH v2 02/13] PCI: prevent duplicate slot names
  2008-09-11  2:47             ` Kenji Kaneshige
@ 2008-09-11 10:37               ` Alex Chiang
  2008-09-23  0:05               ` Alex Chiang
  1 sibling, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-09-11 10:37 UTC (permalink / raw)
  To: Kenji Kaneshige
  Cc: linux-pci, linux-kernel, jbarnes, kristen.c.accardi, matthew

* Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>:
> Alex Chiang wrote:
>> @@ -570,9 +571,17 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
>>  		return -EINVAL;
>>  	}
>>  -	/* Check if we have already registered a slot with the same name. */
>> -	if (get_slot_from_name(name))
>> -		return -EEXIST;
>> +	/*
>> +	 * If we find a tmp_slot here, it means that another slot
>> +	 * driver has already created a pci_slot for this device.
>> +	 * We care (below) if the existing slot has a different name from
>> +	 * the new name that this particular hotplug driver is requesting.
>> +	 */
>> +	dev = pci_get_slot(bus, PCI_DEVFN(slot_nr, 0));
>> +	if (dev && dev->slot) {
>> +		tmp_slot = dev->slot;
>> +		pci_dev_put(dev);
>> +	}
>>
>
> I have two comments here.
>
> (1) I think the reference counter of the device will be leaked if
> (dev == NULL) && (dev->slot != NULL). We need pci_dev_put() whenever
> dev is not NULL.

You're right, thank you.

[one day, I _will_ learn how to get refcounting correct. :-/]

> (2) When the slot is empty, the 'dev' will be always NULL. Therefore,
> 'tmp_slot' will be always NULL on the empty slot here. Because of
> this, the following code to rename the slot will not work on the
> empty slot, I think.

Ok, I was trying to avoid creating a new interface called
"pci_find_phys_slot()" or something similar, but I think we need
it, and it will fix this issue.

Thanks again for the review.

/ac


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

* Re: [PATCH v2 02/13] PCI: prevent duplicate slot names
  2008-09-09 13:07             ` Matthew Wilcox
@ 2008-09-22 21:38               ` Alex Chiang
  2008-09-22 22:42                 ` Matthew Wilcox
  0 siblings, 1 reply; 55+ messages in thread
From: Alex Chiang @ 2008-09-22 21:38 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: linux-pci, linux-kernel, jbarnes, kristen.c.accardi, kaneshige.kenji

Hi Willy,

Thanks for the review. I've pretty much incorporated all your
comments with a few exceptions...

> static char *make_slot_name(const char *name)
> {
> 	char *new_name;
> 	int len, max, dup;
> 
> 	new_name = kstrdup(name, GFP_KERNEL);
> 	if (!new_name)
> 		return NULL;
> 
> 	/*
> 	 * Make sure we hit the realloc case the first time through the
> 	 * loop.  'len' will be strlen(name) + 3 at that point which is
> 	 * enough space for "name-X" and the trailing NUL.
> 	 */
> 	len = strlen(name) + 2;
> 	max = 1;
> 	dup = 1;
> 
> 	for (;;) {
> 		struct kobject *dup_slot;
> 		dup_slot = kset_find_obj(pci_slots_kset, new_name);
> 		if (!dup_slot)
> 			break;
> 		kobject_put(dup_slot);
> 		if (dup == max) {
> 			len++;
> 			max *= 10;
> 			new_name = krealloc(new_name, len, GFP_KERNEL);

As Rolf Eike Beer pointed out, a failed krealloc() will leak the
old version of new_name, so I did this instead:

			kfree(new_name);
			new_name = kmalloc(len, GFP_KERNEL);

This is better than krealloc() in several ways:

	1. we avoid the unneeded memcpy that krealloc() does for
	us. we don't need it because we're going to sprintf over
	it anyway.

	2. the explicit kfree(new_name) means we won't leak
	anything.

> 			if (!new_name)
> 				break;
> 		}
> 		sprintf(new_name, "%s-%d", name, dup++);
> 	}
> 
> 	return new_name;
> }
>
> > -void pci_update_slot_number(struct pci_slot *slot, int slot_nr)
> > +void pci_renumber_slot(struct pci_slot *slot, int slot_nr)
> >  {
> > -	int name_count = 0;
> >  	struct pci_slot *tmp;
> >  
> >  	down_write(&pci_bus_sem);
> >  
> > -	list_for_each_entry(tmp, &slot->bus->slots, list) {
> > +	list_for_each_entry(tmp, &slot->bus->slots, list)
> >  		WARN_ON(tmp->number == slot_nr);
> > -		if (!strcmp(kobject_name(&tmp->kobj), kobject_name(&slot->kobj)))
> > -			name_count++;
> > -	}
> > -
> > -	if (name_count > 1)
> > -		printk(KERN_WARNING "pci_update_slot_number found %d slots with the same name: %s\n", name_count, kobject_name(&slot->kobj));
> 
> Are you going to get enough information to debug problems with just this
> WARN_ON?  And do we want to decline to renumber a slot to the same
> number as an existing one?

I think this should be sufficient for the following reasons:

	1. This API was added for ppc; I can't imagine any other
	arch actually needing to renumber a slot after create.

	2. I added this check at BenH's request as a "belt and
	suspenders" sort of thing; neither of us expects to
	really get a collision here ever, and if we do, it's an
	OFW error (iirc).

	3. I think I will return early though, because otherwise,
	the refcounting will get very confused.

> Anyway, looks good, and I really like the name-change for this function.

Thanks.

/ac


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

* Re: [PATCH v2 02/13] PCI: prevent duplicate slot names
  2008-09-10 14:58             ` Rolf Eike Beer
@ 2008-09-22 21:40               ` Alex Chiang
  0 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-09-22 21:40 UTC (permalink / raw)
  To: Rolf Eike Beer
  Cc: linux-pci, linux-kernel, jbarnes, kristen.c.accardi, matthew,
	kaneshige.kenji

* Rolf Eike Beer <eike-kernel@sf-tec.de>:
> > +
> > +	/*
> > +	 * We hit this the first time through, which gives us
> > +	 * space for terminating NULL, and then every power of 10
> > +	 * afterwards, which gives us space to add another digit
> > +	 * to "name-XX..."
> > +	 */
> > +	if (dup % width == 0) {
> > +		len++;
> > +		width *= 10;
> > +	}
> > +
> > +	new_name = krealloc(new_name, len, GFP_KERNEL);
> > +	if (!new_name)
> > +		goto out;
> 
> If krealloc() fails you will leak the old new_name here.

Thanks for catching this. I already responded to Willy that I'm
changing it to:

	kfree(new_name);
	new_name = kmalloc(len, GFP_KERNEL);

That will prevent any leaks.

Thanks for the review.

/ac


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

* Re: [PATCH v2 02/13] PCI: prevent duplicate slot names
  2008-09-22 21:38               ` Alex Chiang
@ 2008-09-22 22:42                 ` Matthew Wilcox
  0 siblings, 0 replies; 55+ messages in thread
From: Matthew Wilcox @ 2008-09-22 22:42 UTC (permalink / raw)
  To: Alex Chiang, linux-pci, linux-kernel, jbarnes, kristen.c.accardi,
	kaneshige.kenji

On Mon, Sep 22, 2008 at 03:38:45PM -0600, Alex Chiang wrote:
> As Rolf Eike Beer pointed out, a failed krealloc() will leak the
> old version of new_name, so I did this instead:
> 
> 			kfree(new_name);
> 			new_name = kmalloc(len, GFP_KERNEL);
> 
> This is better than krealloc() in several ways:
> 
> 	1. we avoid the unneeded memcpy that krealloc() does for
> 	us. we don't need it because we're going to sprintf over
> 	it anyway.
> 
> 	2. the explicit kfree(new_name) means we won't leak
> 	anything.

Agreed.

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

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

* Re: [PATCH v2 02/13] PCI: prevent duplicate slot names
  2008-09-11  2:47             ` Kenji Kaneshige
  2008-09-11 10:37               ` Alex Chiang
@ 2008-09-23  0:05               ` Alex Chiang
  1 sibling, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-09-23  0:05 UTC (permalink / raw)
  To: Kenji Kaneshige
  Cc: linux-pci, linux-kernel, jbarnes, kristen.c.accardi, matthew

Hi Kenji-san,

* Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>:
> Hi Alex-san,
>
> Thank you very much for your continuous effort.

We'll get there some day. ;)

>>> If name duplication was detected in pci_create_slot(), it renames the
>>> slot name like 'N-1' and return successfully. Even though slot's kobject
>>> name was registered as 'N-1', 'name' array still have 'N' at this point.
>>> So the following 'if' statement becomes true unexpectedly.
>>>
>>> 	/*
>>>         * Allow pcihp drivers to override the ACPI_PCI_SLOT name.
>>>         */
>>>        if (strcmp(kobject_name(&pci_slot->kobj), name)) {
>>>
>>> Then pci_hp_register() attempt to rename the slot name with 'N' again
>>> by calling kobject_rename(), but it fails because there already exists
>>> kobject with name 'N'. As a result, pci_hp_register() will fail.
>>
>> Yes, you are right, that is a problem.
>>
>> I've taken the following approach:
>>
>> 	- the above code is providing a mechanism to allow a
>> 	  _hotplug_ driver to override a _detection_ driver slot
>> 	  name.
>>
>> 	- in other words, we only have to worry about the case
>> 	  when a _detection_ driver was loaded before a _hotplug_
>> 	  driver.
>>
>> 	- we can ignore the case where another _hotplug_ driver
>> 	  was loaded first, because we'll already return -EBUSY.
>>
>> 	- so, to figure out if a _detection_ driver has already
>> 	  been loaded, we check to see if the pci_dev already has
>> 	  a valid pci_slot pointer.
>
> We need to take into account that the hotplug slot can be empty.
> In this case, we cannot do this check because pci_dev doesn't
> exist, I think.

You are right. We still only have to worry about the case where a
_detection_ driver was loaded before a _hotplug_ driver, and we
need to worry abou the case of an empty slot.

I created a new interface called pci_get_physical_slot() that
will tell us if we've already created a slot or not. This will
work even if the slot is empty.

Using this inteface should simplify the tortured logic in my last
patch and make pci_hp_register easier to read.

>> 	- if yes, then we later check to see if the existing slot
>> 	  name matches the requested slot name from the hotplug
>> 	  driver.
>>
>> 	- if the hotplug driver is requesting a different name,
>> 	  then we use a new interface, pci_rename_slot() which
>> 	  will safely attempt to rename the slot without name
>> 	  collision.
>>
>> I'll send out the patch set soon, it would be great if you could
>> test it for me, since I don't have systems with duplicate slot
>> names.
>>
>
> Sure.
>
> P.S.
> I also don't have the system with duplicate slot names. So I use
> the debug patch that emulates this kind of system for testing.

Hm, ok. I might think about adding some code to the fakephp
driver to use it as a debug tool as well...

A little more below...

>> diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
>> index 3e37d63..2232608 100644
>> --- a/drivers/pci/hotplug/pci_hotplug_core.c
>> +++ b/drivers/pci/hotplug/pci_hotplug_core.c
>> @@ -558,7 +558,8 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
>>  			const char *name)
>>  {
>>  	int result;
>> -	struct pci_slot *pci_slot;
>> +	struct pci_dev *dev;
>> +	struct pci_slot *pci_slot, *tmp_slot = NULL;
>>   	if (slot == NULL)
>>  		return -ENODEV;
>> @@ -570,9 +571,17 @@ int pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus, int slot_nr,
>>  		return -EINVAL;
>>  	}
>>  -	/* Check if we have already registered a slot with the same name. */
>> -	if (get_slot_from_name(name))
>> -		return -EEXIST;
>> +	/*
>> +	 * If we find a tmp_slot here, it means that another slot
>> +	 * driver has already created a pci_slot for this device.
>> +	 * We care (below) if the existing slot has a different name from
>> +	 * the new name that this particular hotplug driver is requesting.
>> +	 */
>> +	dev = pci_get_slot(bus, PCI_DEVFN(slot_nr, 0));
>> +	if (dev && dev->slot) {
>> +		tmp_slot = dev->slot;
>> +		pci_dev_put(dev);
>> +	}
>>
>
> I have two comments here.
>
> (1) I think the reference counter of the device will be leaked if
> (dev == NULL) && (dev->slot != NULL). We need pci_dev_put() whenever
> dev is not NULL.
>
> (2) When the slot is empty, the 'dev' will be always NULL. Therefore,
> 'tmp_slot' will be always NULL on the empty slot here. Because of
> this, the following code to rename the slot will not work on the
> empty slot, I think.

The new pci_get_physical_slot() interface will solve both issues.

Thanks.

/ac


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

* Re: [PATCH v2 04/13] PCI: acpiphp: remove 'name' parameter
  2008-09-09 14:38             ` Matthew Wilcox
@ 2008-09-23  1:16               ` Alex Chiang
  0 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-09-23  1:16 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: linux-pci, linux-kernel, jbarnes, kristen.c.accardi, kaneshige.kenji

* Matthew Wilcox <matthew@wil.cx>:
> On Tue, Sep 09, 2008 at 04:00:22AM -0600, Alex Chiang wrote:
> > We do not need to manage our own name parameter, especially since
> > the PCI core can change it on our behalf, in the case of duplicate
> > slot names.
> 
> Looks good, just a question ...
> 
> >  	acpiphp_slot->slot = slot;
> > -	snprintf(slot->name, sizeof(slot->name), "%u", slot->acpi_slot->sun);
> > +	scnprintf(name, SLOT_NAME_SIZE, "%u", slot->acpi_slot->sun);
> >  
> 
> What's the difference between snprintf and scnprintf?

I think this may have already been answered somewhere else, but
scnprintf tells you number of characters that actually fits into
the buffer whereas snprintf tells you the number of characters
that _would_ have fit into the buffer it were big enough.

> And why were we bothering to use snprintf anyway?  For when we fall into a
> parallel universe where a u32 can have more than twenty digits?

Well, I think there are some in-flight patches that want to
change sun to a 64 bit value, which makes me think we want to
change SLOT_NAME_SIZE to 21...

/ac


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

* Re: [PATCH v2 06/13] PCI: cpqphp: stop managing hotplug_slot->name
  2008-09-09 15:08             ` Matthew Wilcox
@ 2008-09-23  1:20               ` Alex Chiang
  0 siblings, 0 replies; 55+ messages in thread
From: Alex Chiang @ 2008-09-23  1:20 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-pci, linux-kernel, jbarnes, kristen.c.accardi

* Matthew Wilcox <matthew@wil.cx>:
> On Tue, Sep 09, 2008 at 04:00:32AM -0600, Alex Chiang wrote:
> > -static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot)
> > -{
> > -	snprintf(buffer, buffer_size, "%d", slot->number);
> > -}
> 
> > +
> > +		scnprintf(name, SLOT_NAME_SIZE, "%d", slot->number);
> 
> So ... we're using %d here and %u in acpiphp.  Obviously we don't expect
> to get a number above 2 billion, but I think if we do have some utterly
> bogus firmware that gives us a number above 2 billion, printing a
> positive number is a better user experience than a negative number.

Well, on some HP machines, a slot number >2 billion actually does
make sense, if you convert it to hex, and then consider that to
be some sort of encoding for topology.

But your point here stands, I can change this driver to a %u.

> We clearly have a common pattern here where hotplug drivers have a
> number insteaqd of a name (I would venture this is the most common).
> Maybe we need a common helper?  I think this is a subject for the
> long-term todo list, not something that needs to be addressed in the
> context of this patch series.

Yeah, ok -- long term todo. ;)

/ac


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

end of thread, other threads:[~2008-09-23  1:20 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-17  0:14 [PATCH 00/13] PCI: let the core manage slot names Alex Chiang
2008-08-17  0:15 ` [PATCH 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface Alex Chiang
2008-08-17  0:16 ` [PATCH 02/13] PCI: prevent duplicate slot names Alex Chiang
2008-08-21 10:24   ` Kenji Kaneshige
2008-09-09  9:04     ` Alex Chiang
2008-09-11  2:43       ` Kenji Kaneshige
2008-09-09 10:00         ` [PATCH v2 00/13] PCI: let the core manage " Alex Chiang
2008-09-09 10:00           ` [PATCH v2 01/13] PCI Hotplug core: add 'name' param pci_hp_register interface Alex Chiang
2008-09-09 12:05             ` Matthew Wilcox
2008-09-09 17:18               ` Alex Chiang
2008-09-09 10:00           ` [PATCH v2 02/13] PCI: prevent duplicate slot names Alex Chiang
2008-09-09 13:07             ` Matthew Wilcox
2008-09-22 21:38               ` Alex Chiang
2008-09-22 22:42                 ` Matthew Wilcox
2008-09-10 14:58             ` Rolf Eike Beer
2008-09-22 21:40               ` Alex Chiang
2008-09-11  2:47             ` Kenji Kaneshige
2008-09-11 10:37               ` Alex Chiang
2008-09-23  0:05               ` Alex Chiang
2008-09-09 10:00           ` [PATCH v2 03/13] PCI, PCI Hotplug: introduce slot_name helpers Alex Chiang
2008-09-09 14:30             ` Matthew Wilcox
2008-09-09 10:00           ` [PATCH v2 04/13] PCI: acpiphp: remove 'name' parameter Alex Chiang
2008-09-09 14:38             ` Matthew Wilcox
2008-09-23  1:16               ` Alex Chiang
2008-09-09 10:00           ` [PATCH v2 05/13] PCI: cpci_hotplug: stop managing hotplug_slot->name Alex Chiang
2008-09-09 15:04             ` Matthew Wilcox
2008-09-09 21:11               ` Scott Murray
2008-09-09 10:00           ` [PATCH v2 06/13] PCI: cpqphp: " Alex Chiang
2008-09-09 15:08             ` Matthew Wilcox
2008-09-23  1:20               ` Alex Chiang
2008-09-09 10:00           ` [PATCH v2 07/13] PCI: fakephp: remove 'name' parameter Alex Chiang
2008-09-09 10:00           ` [PATCH v2 08/13] PCI: ibmphp: stop managing hotplug_slot->name Alex Chiang
2008-09-09 10:00           ` [PATCH v2 09/13] PCI: pciehp: remove 'name' parameter Alex Chiang
2008-09-09 10:00           ` [PATCH v2 10/13] PCI: rpaphp: stop managing hotplug_slot->name Alex Chiang
2008-09-09 10:00           ` [PATCH v2 11/13] PCI: SGI Hotplug: stop managing bss_hotplug_slot->name Alex Chiang
2008-09-09 10:01           ` [PATCH v2 12/13] PCI: shcphp: remove 'name' parameter Alex Chiang
2008-09-09 10:01           ` [PATCH v2 13/13] PCI: Hotplug core: remove 'name' Alex Chiang
2008-08-17  0:16 ` [PATCH 03/13] PCI, PCI Hotplug: introduce slot_name helpers Alex Chiang
2008-08-17  0:16 ` [PATCH 04/13] PCI: acpiphp: remove 'name' parameter Alex Chiang
2008-08-17  8:59   ` Rolf Eike Beer
2008-08-19 18:39     ` Alex Chiang
2008-08-19 21:01       ` Rolf Eike Beer
2008-08-19 21:26         ` Alex Chiang
2008-08-19 21:40       ` Jesse Barnes
2008-08-19 23:50         ` Alex Chiang
2008-08-20  2:25           ` Kenji Kaneshige
2008-08-17  0:16 ` [PATCH 05/13] PCI: cpci_hotplug: stop managing hotplug_slot->name Alex Chiang
2008-08-17  0:16 ` [PATCH 06/13] PCI: cpqphp: " Alex Chiang
2008-08-17  0:17 ` [PATCH 07/13] PCI: fakephp: remove 'name' parameter Alex Chiang
2008-08-17  0:17 ` [PATCH 08/13] PCI: ibmphp: stop managing hotplug_slot->name Alex Chiang
2008-08-17  0:17 ` [PATCH 09/13] PCI: pciehp: remove 'name' parameter Alex Chiang
2008-08-17  0:17 ` [PATCH 10/13] PCI: rpaphp: stop managing hotplug_slot->name Alex Chiang
2008-08-17  0:17 ` [PATCH 11/13] PCI: SGI Hotplug: stop managing bss_hotplug_slot->name Alex Chiang
2008-08-17  0:17 ` [PATCH 12/13] PCI: shcphp: remove 'name' parameter Alex Chiang
2008-08-17  0:17 ` [PATCH 13/13] PCI: Hotplug core: remove 'name' Alex Chiang

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).