linux_dsm_epyc7002/drivers
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
..
acorn/char
acpi
amba
ata PCI: Remove users of pci_enable_device_bars() 2008-02-01 15:04:27 -08:00
atm
auxdisplay
base
block
bluetooth
cdrom
char
clocksource
connector
cpufreq
cpuidle
crypto
dca
dio
dma
edac
eisa
firewire
firmware
hid
hwmon
i2c PCI: Remove users of pci_enable_device_bars() 2008-02-01 15:04:27 -08:00
ide PCI: Remove users of pci_enable_device_bars() 2008-02-01 15:04:27 -08:00
ieee1394
infiniband
input
isdn
leds
lguest
macintosh
mca
md
media
message
mfd
misc
mmc
mtd
net
nubus
of
oprofile
parisc
parport
pci PCI: Fix fakephp deadlock 2008-02-01 15:04:30 -08:00
pcmcia
pnp
power
ps3
rapidio
rtc
s390
sbus
scsi PCI: Remove users of pci_enable_device_bars() 2008-02-01 15:04:27 -08:00
serial
sh
sn
spi
ssb
tc
telephony
uio
usb PCI: use dev_printk in quirk messages 2008-02-01 15:04:26 -08:00
video
virtio
w1
watchdog
xen
zorro
Kconfig
Makefile