linux-kernel-test/drivers/pci/hotplug
Alex Chiang 5fe6cc6068 PCI: prevent duplicate slot names
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
	etc.

This is the permanent fix mentioned in earlier commits d6a9e9b4 and
167e782e (shpchp/pciehp: Rename duplicate slot name...).

We take advantage of the new 'hotplug' parameter in pci_create_slot()
to prevent a slot create/rename race between hotplug drivers and
detection drivers.

	Scenario A:
	hotplug driver                  detection driver
	--------------                  ----------------
	pci_create_slot(hotplug=set)
					pci_create_slot(hotplug=NULL)

The hotplug driver creates the slot with its desired name, and then
releases the semaphore. Now, the detection driver tries to create
the same slot, but it already exists. We don't care about renaming,
so return the existing slot.

	Scenario B:
	hotplug driver                  detection driver
	--------------                  ----------------
					pci_create_slot(hotplug=NULL)
	pci_create_slot(hotplug=set)

The detection driver creates the slot with name "X". Then the hotplug
driver tries to create the same slot, but wants the name "Y" instead.
We detect that we're trying to create the same slot and that we also
want a rename, so rename the slot to "Y" and return.

	Scenario C:
	hotplug driver                  hotplug driver
	--------------                  ----------------
	pci_create_slot(hotplug=set)
					pci_create_slot(hotplug=set)

Two separate hotplug drivers are attempting to claim the slot and
are passing valid hotplug_slot args to pci_create_slot(). We detect
that the slot already has a ->hotplug callback, prevent a rename,
and return -EBUSY.

Cc: kristen.c.accardi@intel.com
Cc: matthew@wil.cx
Acked-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Signed-off-by: Alex Chiang <achiang@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2008-10-22 16:42:39 -07:00
..
acpi_pcihp.c PCI: add acpi_find_root_bridge_handle 2008-08-18 13:48:04 -07:00
acpiphp_core.c PCI Hotplug core: add 'name' param pci_hp_register interface 2008-10-22 16:42:37 -07:00
acpiphp_glue.c Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6 2008-07-16 17:25:46 -07:00
acpiphp_ibm.c PCI: introduce pci_slot 2008-06-10 14:37:03 -07:00
acpiphp.h driver core: remove KOBJ_NAME_LEN define 2008-07-21 21:54:52 -07:00
cpci_hotplug_core.c PCI Hotplug core: add 'name' param pci_hp_register interface 2008-10-22 16:42:37 -07:00
cpci_hotplug_pci.c PCI: replace remaining __FUNCTION__ occurrences 2008-04-20 21:47:09 -07:00
cpci_hotplug.h
cpcihp_generic.c PCI Hotplug: make cpcihp driver use modern apis 2008-04-20 21:46:56 -07:00
cpcihp_zt5550.c
cpcihp_zt5550.h
cpqphp_core.c PCI Hotplug core: add 'name' param pci_hp_register interface 2008-10-22 16:42:37 -07:00
cpqphp_ctrl.c PCI: replace remaining __FUNCTION__ occurrences 2008-04-20 21:47:09 -07:00
cpqphp_nvram.c PCI: replace remaining __FUNCTION__ occurrences 2008-04-20 21:47:09 -07:00
cpqphp_nvram.h
cpqphp_pci.c PCI: replace remaining __FUNCTION__ occurrences 2008-04-20 21:47:09 -07:00
cpqphp_sysfs.c
cpqphp.h PCI: replace remaining __FUNCTION__ occurrences 2008-04-20 21:47:09 -07:00
fakephp.c PCI Hotplug core: add 'name' param pci_hp_register interface 2008-10-22 16:42:37 -07:00
ibmphp_core.c PCI: replace remaining __FUNCTION__ occurrences 2008-04-20 21:47:09 -07:00
ibmphp_ebda.c PCI Hotplug core: add 'name' param pci_hp_register interface 2008-10-22 16:42:37 -07:00
ibmphp_hpc.c PCI: replace remaining __FUNCTION__ occurrences 2008-04-20 21:47:09 -07:00
ibmphp_pci.c PCI: replace remaining __FUNCTION__ occurrences 2008-04-20 21:47:09 -07:00
ibmphp_res.c PCI: replace remaining __FUNCTION__ occurrences 2008-04-20 21:47:09 -07:00
ibmphp.h
Kconfig PCI Hotplug: the ibm driver is not dependant on PCI_LEGACY 2008-04-20 21:46:57 -07:00
Makefile PCI: hotplug: Link fakephp last 2008-02-01 15:04:20 -08:00
pci_hotplug_core.c PCI: prevent duplicate slot names 2008-10-22 16:42:39 -07:00
pciehp_core.c PCI: prevent duplicate slot names 2008-10-22 16:42:39 -07:00
pciehp_ctrl.c PCI: pciehp: replace printk with dev_printk 2008-10-20 10:53:49 -07:00
pciehp_hpc.c PCI: pciehp: replace printk with dev_printk 2008-10-20 10:53:49 -07:00
pciehp_pci.c PCI: pciehp: replace printk with dev_printk 2008-10-20 10:53:49 -07:00
pciehp.h PCI: pciehp: replace printk with dev_printk 2008-10-20 10:53:49 -07:00
pcihp_skeleton.c PCI: replace remaining __FUNCTION__ occurrences 2008-04-20 21:47:09 -07:00
rpadlpar_core.c PCI: replace remaining __FUNCTION__ occurrences 2008-04-20 21:47:09 -07:00
rpadlpar_sysfs.c PCI: introduce pci_slot 2008-06-10 14:37:03 -07:00
rpadlpar.h
rpaphp_core.c PCI hotplug: rpaphp: make debug var unique 2008-10-20 10:54:27 -07:00
rpaphp_pci.c PCI hotplug: rpaphp: make debug var unique 2008-10-20 10:54:27 -07:00
rpaphp_slot.c PCI Hotplug core: add 'name' param pci_hp_register interface 2008-10-22 16:42:37 -07:00
rpaphp.h PCI hotplug: rpaphp: make debug var unique 2008-10-20 10:54:27 -07:00
sgi_hotplug.c PCI Hotplug core: add 'name' param pci_hp_register interface 2008-10-22 16:42:37 -07:00
shpchp_core.c PCI: prevent duplicate slot names 2008-10-22 16:42:39 -07:00
shpchp_ctrl.c PCI: replace remaining __FUNCTION__ occurrences 2008-04-20 21:47:09 -07:00
shpchp_hpc.c shpchp: check firmware before taking control 2008-06-10 10:59:53 -07:00
shpchp_pci.c PCI: replace remaining __FUNCTION__ occurrences 2008-04-20 21:47:09 -07:00
shpchp_sysfs.c
shpchp.h shpchp: check firmware before taking control 2008-06-10 10:59:53 -07:00