linux/drivers
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
..
accessibility braille_console: only register notifiers when the braille console is used 2008-10-02 15:53:13 -07:00
acpi PCI: update pci_create_slot() to take a 'hotplug' param 2008-10-22 16:42:38 -07:00
amba
ata Merge commit 'origin' 2008-10-15 11:31:54 +11:00
atm Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 2008-10-11 12:39:35 -07:00
auxdisplay
base memory_probe: fix wrong sysfs file attribute 2008-10-20 08:52:32 -07:00
block x86: sysfs: kill owner field from attribute 2008-10-20 08:52:42 -07:00
bluetooth Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6 2008-10-13 14:12:40 -07:00
cdrom gdrom: change to use __blk_end_request() 2008-10-09 08:56:21 +02:00
char Merge git://git.kernel.org/pub/scm/linux/kernel/git/kyle/parisc-2.6 2008-10-20 14:40:31 -07:00
clocksource Merge branches 'timers/clocksource', 'timers/hrtimers', 'timers/nohz', 'timers/ntp', 'timers/posixtimers' and 'timers/debug' into v28-timers-for-linus 2008-10-20 13:14:06 +02:00
connector
cpufreq [CPUFREQ] Fix BUG: using smp_processor_id() in preemptible code 2008-10-09 13:52:44 -04:00
cpuidle
crypto
dca device create: misc: convert device_create_drvdata to device_create 2008-10-16 09:24:43 -07:00
dio
dma Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/djbw/async_tx 2008-10-20 12:54:30 -07:00
edac edac cell: fix incorrect edac_mode 2008-10-20 08:52:40 -07:00
eisa
firewire firewire: fix ioctl() return code 2008-10-15 22:21:10 +02:00
firmware x86: sysfs: kill owner field from attribute 2008-10-20 08:52:42 -07:00
gpio Merge branch 'genirq-v28-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2008-10-20 13:23:01 -07:00
gpu Export tiny shmem_file_setup for DRM-GEM 2008-10-20 16:17:42 -07:00
hid USB: remove warn macro from HID core 2008-10-17 14:41:09 -07:00
hwmon hwmon: applesmc: lighter wait mechanism, drastic improvement 2008-10-20 08:52:35 -07:00
i2c PCI: Check dynids driver_data value for validity 2008-10-20 10:48:35 -07:00
ide Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6 2008-10-20 13:12:39 -07:00
ieee1394 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6 2008-10-16 15:02:24 -07:00
infiniband x86: sysfs: kill owner field from attribute 2008-10-20 08:52:42 -07:00
input Merge branch 'for-next' of git://git.o-hand.com/linux-mfd 2008-10-20 09:22:47 -07:00
isdn device create: misc: convert device_create_drvdata to device_create 2008-10-16 09:24:43 -07:00
leds Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6 2008-10-20 13:12:39 -07:00
lguest
macintosh device create: misc: convert device_create_drvdata to device_create 2008-10-16 09:24:43 -07:00
mca
md Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6 2008-10-17 09:00:23 -07:00
media byteorder: remove direct includes of linux/byteorder/swab[b].h 2008-10-20 08:52:40 -07:00
memstick x86: sysfs: kill owner field from attribute 2008-10-20 08:52:42 -07:00
message i2o: Fix 32/64bit DMA locking 2008-10-16 11:21:38 -07:00
mfd Merge branch 'genirq-v28-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2008-10-20 13:23:01 -07:00
misc HP-WMI: additional keycode (or typo) 2008-10-20 08:52:34 -07:00
mmc Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/drzeus/mmc 2008-10-20 10:17:42 -07:00
mtd Merge git://git.infradead.org/mtd-2.6 2008-10-20 09:03:12 -07:00
net misc: replace remaining __FUNCTION__ with __func__ 2008-10-20 16:17:42 -07:00
nubus nubus: fix mis-indented statement 2008-10-16 11:21:30 -07:00
of Merge commit 'gcl/gcl-next' 2008-10-14 10:11:27 +11:00
oprofile Merge branch 'linus' into oprofile-v2 2008-10-13 11:05:51 +02:00
parisc Merge git://git.kernel.org/pub/scm/linux/kernel/git/kyle/parisc-2.6 2008-10-20 14:40:31 -07:00
parport parport: remove CVS keywords 2008-10-16 11:21:49 -07:00
pci PCI: prevent duplicate slot names 2008-10-22 16:42:39 -07:00
pcmcia Merge branch 'genirq-v28-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2008-10-20 13:23:01 -07:00
pnp {pci,pnp} quirks.c: don't use deprecated print_fn_descriptor_symbol() 2008-10-16 16:11:43 -07:00
power Merge git://git.infradead.org/battery-2.6 2008-10-20 09:44:30 -07:00
ps3 ps3: Add passthru support for non-audio streams 2008-10-20 08:05:15 +02:00
rapidio
regulator da903x: add regulator support for DA9030/DA9034 2008-10-13 21:51:57 +01:00
rtc Merge git://git.kernel.org/pub/scm/linux/kernel/git/kyle/parisc-2.6 2008-10-20 14:40:31 -07:00
s390 Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block 2008-10-17 09:29:55 -07:00
sbus
scsi Merge branch 'linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jbarnes/pci-2.6 2008-10-20 13:40:47 -07:00
serial Merge branch 'genirq-v28-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2008-10-20 13:23:01 -07:00
sh sh: Move the shared INTC code out to drivers/sh/ 2008-10-01 16:13:54 +09:00
sn
spi Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6 2008-10-16 12:40:26 -07:00
ssb Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6 2008-10-13 14:12:40 -07:00
staging Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6 2008-10-20 09:09:56 -07:00
tc
telephony phonedev: remove BKL 2008-10-20 08:52:36 -07:00
thermal
uio Merge branch 'bkl-removal' of git://git.lwn.net/linux-2.6 2008-10-20 13:42:14 -07:00
usb USB: Fix unused label warnings in drivers/usb/host/ehci-hcd.c 2008-10-20 14:23:29 -07:00
video Remove empty imacfb.c file 2008-10-20 11:32:09 -07:00
virtio
w1 x86: sysfs: kill owner field from attribute 2008-10-20 08:52:42 -07:00
watchdog [WATCHDOG] ib700wdt.c - fix buffer_underflow bug 2008-10-15 08:53:06 +00:00
xen genirq: use iterators for irq_desc loops 2008-10-16 16:53:30 +02:00
zorro
Kconfig Staging: add Kconfig entries and Makefile infrastructure 2008-10-10 15:31:06 -07:00
Makefile Staging: add Kconfig entries and Makefile infrastructure 2008-10-10 15:31:06 -07:00