linux_dsm_epyc7002/drivers/pci
Ian Abbott 5c796ae7a7 PCI: Fix fakephp deadlock
If the fakephp driver is used to emulate removal of a PCI device by
writing text string "0" to the "power" sysfs attribute file, this causes
its parent directory and its contents (including the "power" file) to be
deleted before the write operation returns.  Unfortunately, it ends up
in a deadlock waiting for itself to complete.

The deadlock is as follows: sysfs_write_file calls flush_write_buffer
which calls sysfs_get_active_two before calling power_write_file in
pci_hotplug_core.c via the sysfs store operation. The power_write_file
function calls disable_slot in fakephp.c via the slot operation.  The
disable_slot function calls remove_slot which calls pci_hp_deregister
(back in pci_hotplug_core.c) which calls fs_remove_slot which calls
sysfs_remove_file to remove the "power" file. The sysfs_remove_file
function calls sysfs_hash_and_remove which calls sysfs_addrm_finish
which calls sysfs_deactivate. The sysfs_deactivate function sees that
something has an active reference on the sysfs_dirent (from the
previous call to sysfs_get_active_two back up the call stack somewhere)
so waits for the active reference to go away, which is of course
impossible.

The problem has been present since 2.6.21.

This patch breaks the deadlock by queuing work queue items on a single-
threaded work queue to remove a slot from sysfs, and to rescan the PCI
buses.  There is also some protection against disabling a slot that is
already being removed.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: Kristen Accardi <kristen.c.accardi@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-02-01 15:04:30 -08:00
..
hotplug PCI: Fix fakephp deadlock 2008-02-01 15:04:30 -08:00
pcie PCI: Run ACPI _OSC method on root bridges only 2008-02-01 15:04:30 -08:00
.gitignore Add some basic .gitignore files 2005-10-18 08:26:15 -07:00
access.c [PATCH] severing module.h->sched.h 2006-12-04 02:00:22 -05:00
bus.c PCI: drivers/pci/: remove unused exports 2008-02-01 15:04:18 -08:00
dmar.c PCI: More Sanity checks for DMAR 2008-02-01 15:04:21 -08:00
hotplug.c Driver core: change add_uevent_var to use a struct 2007-10-12 14:51:01 -07:00
htirq.c PCI: Use pci_find_ht_capability() in drivers/pci/htirq.c 2006-12-20 10:54:42 -08:00
intel-iommu.c PCI: Spelling fixes 2008-02-01 15:04:26 -08:00
intel-iommu.h intel-iommu fixes 2007-10-29 07:41:32 -07:00
iova.c intel-iommu: optimize sg map/unmap calls 2007-10-22 08:13:19 -07:00
iova.h intel-iommu: optimize sg map/unmap calls 2007-10-22 08:13:19 -07:00
Kconfig PCI: Add Kconfig option to disable deprecated pci_find_* API 2007-11-05 13:35:17 -08:00
Makefile [POWERPC] Always build setup-bus.c on powerpc 2008-01-27 14:07:37 -06:00
msi.c PCI: drivers/pci/msi.c: move arch hooks to the top 2008-02-01 15:04:25 -08:00
msi.h PCI: Make some MSI-X #defines generic 2006-12-01 14:36:56 -08:00
pci-acpi.c PCI ACPI: Added a function to register _OSC with only PCIe devices. 2008-02-01 15:04:29 -08:00
pci-driver.c PCI: Mem Policy: fix mempolicy usage in pci driver 2008-02-01 15:04:20 -08:00
pci-sysfs.c PCI: drivers/pci/pci-sysfs.c: Add missing pci_dev_put 2007-11-28 14:35:26 -08:00
pci.c PCI: Remove pci_enable_device_bars() 2008-02-01 15:04:28 -08:00
pci.h PCI: export pci_restore_msi_state() 2008-02-01 15:04:22 -08:00
probe.c PCI: Add missing "space" in printk messages 2008-02-01 15:04:22 -08:00
proc.c PCI: constify function pointer tables 2008-02-01 15:04:29 -08:00
quirks.c PCI: modify SB700 SATA MSI quirk 2008-02-01 15:04:30 -08:00
remove.c PCI: add pci_stop_bus_device 2006-09-26 17:43:54 -07:00
rom.c PCI: drivers/pci/rom.c: #if 0 two functions 2008-02-01 15:04:18 -08:00
search.c PCI: Add Kconfig option to disable deprecated pci_find_* API 2007-11-05 13:35:17 -08:00
setup-bus.c PCI: Fix bus resource assignment on 32 bits with 64b resources 2008-02-01 15:04:25 -08:00
setup-irq.c kobjects: fix up improper use of the kobject name field 2007-10-12 14:51:02 -07:00
setup-res.c PCI: Fix warning in setup-res.c on 32-bit platforms with 64-bit resources 2008-02-01 15:04:25 -08:00
syscall.c PCI: remove unneeded lock_kernel() in drivers/pci/syscall.c. 2008-02-01 15:04:21 -08:00