[PATCH 0/2] pciehp/shpchp prevent duplicate slot names

Previous thread: refcount leak in pci_get_device()? by Alex Chiang on Thursday, August 21, 2008 - 1:19 pm. (19 messages)

Next thread: Re: char/tpm: tpm_infineon no longer loaded for HP 2510p laptop by Kay Sievers on Thursday, August 21, 2008 - 2:18 pm. (9 messages)
From: Alex Chiang
Date: Thursday, August 21, 2008 - 2:11 pm

Hi Jesse,

Here are patches:

	[PATCH 1/2] pciehp: Rename duplicate slot name N as N-1, N-2, N-M...
	[PATCH 2/2] shpchp: Rename duplicate slot name N as N-1, N-2, N-M...

Against Linus's 2.6.27-rc4.

As noted in the changelogs, these are temporary patches, meant as
placeholders until I complete the longer patch series that allows
the PCI core to manage the slot names on behalf of the drivers.

The longer patch series will keep the same behavior that these
temp patches implement, so that's goodness.

These patches have already been tested and acked by Kenji-san.

	http://article.gmane.org/gmane.linux.kernel/714583
	http://article.gmane.org/gmane.linux.kernel/714582

So I think you can add his sign-offs too.

Thanks,

/ac

--

From: Alex Chiang
Date: Thursday, August 21, 2008 - 2:13 pm

Commit 3800345f723fd130d50434d4717b99d4a9f383c8 (pciehp: fix slot name)
introduces the pciehp_slot_with_bus module parameter, which was intended
to help work around broken firmware that assigns the same name to multiple
slots.

Commit 9e4f2e8d4ddb04ad16a3828cd9a369a5a5287009 (pciehp: add message about
pciehp_slot_with_bus option) tells the user to use the above parameter
in the event of a name collision.

This approach is sub-optimal because it requires too much work from
the user.

Instead, let's rename the slot 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

In the event we overflow the slot->name parameter, we report an
error to the user.

This is a temporary fix until the entire PCI core can be reworked
such that individual drivers no longer have to manage their own
slot names.

Signed-off-by: Alex Chiang <achiang@hp.com>
---
 drivers/pci/hotplug/pciehp.h      |    1 -
 drivers/pci/hotplug/pciehp_core.c |   21 ++++++++++++++-------
 drivers/pci/hotplug/pciehp_hpc.c  |   11 +----------
 3 files changed, 15 insertions(+), 18 deletions(-)

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 3677495..4fd5355 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 ...
From: Alex Chiang
Date: Thursday, August 21, 2008 - 2:13 pm

Commit ef0ff95f136f0f2d035667af5d18b824609de320 (shpchp: fix slot name)
introduces the shpchp_slot_with_bus module parameter, which was intended
to help work around broken firmware that assigns the same name to multiple
slots.

Commit b3bd307c628af2f0a581c42d5d7e4bcdbbf64b6a (shpchp: add message about
shpchp_slot_with_bus option) tells the user to use the above parameter
in the event of a name collision.

This approach is sub-optimal because it requires too much work from
the user.

Instead, let's rename the slot 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

In the event we overflow the slot->name parameter, we report an
error to the user.

This is a temporary fix until the entire PCI core can be reworked
such that individual drivers no longer have to manage their own
slot names.

Signed-off-by: Alex Chiang <achiang@hp.com>
---
 drivers/pci/hotplug/shpchp_core.c |   34 +++++++++++++++-------------------
 1 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index a8cbd03..cc38615 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, ...
From: Jesse Barnes
Date: Thursday, August 21, 2008 - 3:16 pm

Excellent, thanks Alex & Kenji-san.  I applied this to my for-linus branch.  
I'll have Linus pull it soon.

Thanks,
-- 
Jesse Barnes, Intel Open Source Technology Center
--

Previous thread: refcount leak in pci_get_device()? by Alex Chiang on Thursday, August 21, 2008 - 1:19 pm. (19 messages)

Next thread: Re: char/tpm: tpm_infineon no longer loaded for HP 2510p laptop by Kay Sievers on Thursday, August 21, 2008 - 2:18 pm. (9 messages)