WSL2-Linux-Kernel/drivers/pci
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
..
hotplug PCI: prevent duplicate slot names 2008-10-22 16:42:39 -07:00
pcie PCI: fix AER capability check 2008-10-20 11:01:52 -07:00
.gitignore Add some basic .gitignore files 2005-10-18 08:26:15 -07:00
Kconfig PCI: Add Kconfig option to disable deprecated pci_find_* API 2007-11-05 13:35:17 -08:00
Makefile Merge branch 'linus' into x86/x2apic 2008-07-18 22:50:34 +02:00
access.c PCI: Limit VPD read/write lengths for Broadcom 5706, 5708, 5709 rev. 2008-07-02 11:25:54 -07:00
bus.c PCI: make CPU list affinity visible 2008-10-20 10:53:51 -07:00
dmar.c 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
hotplug-pci.c PCI: fix section mismatch warning in pci_scan_child_bus 2008-03-04 15:07:03 -08:00
hotplug.c Driver core: change add_uevent_var to use a struct 2007-10-12 14:51:01 -07:00
htirq.c genirq: remove sparse irq code 2008-10-16 16:53:15 +02:00
intel-iommu.c intel-iommu: typo fix and correct word in the comment 2008-10-20 08:52:34 -07:00
intr_remapping.c 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
intr_remapping.h VT-d: Changes to support KVM 2008-10-15 14:24:08 +02:00
iova.c VT-d: Changes to support KVM 2008-10-15 14:24:08 +02:00
msi.c ACPI/PCI: Set support bit for MSI in support field of _OSC 2008-10-22 16:42:35 -07:00
msi.h PCI: Make some MSI-X #defines generic 2006-12-01 14:36:56 -08:00
pci-acpi.c ACPI/PCI: Fix return value of acpi_cuery_osc() 2008-10-22 16:42:34 -07:00
pci-driver.c PCI: Check dynids driver_data value for validity 2008-10-20 10:48:35 -07:00
pci-sysfs.c PCI: Add ability to mmap legacy_io on some platforms 2008-10-20 11:01:46 -07:00
pci.c PCI: add support for function level reset 2008-10-22 16:42:35 -07:00
pci.h ACPI/PCI: Set support bit for MSI in support field of _OSC 2008-10-22 16:42:35 -07:00
probe.c PCI: Add ability to mmap legacy_io on some platforms 2008-10-20 11:01:46 -07:00
proc.c PCI: fixup sparse endianness warnings in proc.c 2008-07-22 15:19:44 -07:00
quirks.c PCI: remove #ifdef DEBUG around dev_dbg call 2008-10-20 11:01:50 -07:00
remove.c PCI: fix sparse warning in pci_remove_behind_bridge 2008-10-20 10:54:25 -07:00
rom.c Export the ROM enable/disable helpers 2008-09-26 18:59:05 -06:00
search.c PCI: Fix reference counting bug 2008-10-22 16:42:35 -07:00
setup-bus.c PCI: use resource_size() everywhere. 2008-10-20 10:54:28 -07:00
setup-irq.c PCI: use dev_printk when possible 2008-06-25 16:05:13 -07:00
setup-res.c PCI: use resource_size() everywhere. 2008-10-20 10:54:28 -07:00
slot.c PCI: prevent duplicate slot names 2008-10-22 16:42:39 -07:00
syscall.c PCI: remove unneeded lock_kernel() in drivers/pci/syscall.c. 2008-02-01 15:04:21 -08:00