android_kernel_xiaomi_sm8350/drivers/pci/hotplug
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
..
acpi_pcihp.c
acpiphp_core.c
acpiphp_glue.c PCI Hotplug: acpiphp: remove unneeded acpi_get_name function call 2008-02-01 15:04:24 -08:00
acpiphp_ibm.c kset: convert pci hotplug to use kset_create_and_add 2008-01-24 20:40:14 -08:00
acpiphp.h PCI: hotplug: acpiphp: Remove unused variable from acpiphp 2008-02-01 15:04:20 -08:00
cpci_hotplug_core.c
cpci_hotplug_pci.c
cpci_hotplug.h
cpcihp_generic.c
cpcihp_zt5550.c
cpcihp_zt5550.h
cpqphp_core.c
cpqphp_ctrl.c
cpqphp_nvram.c
cpqphp_nvram.h
cpqphp_pci.c
cpqphp_sysfs.c
cpqphp.h
fakephp.c PCI: Fix fakephp deadlock 2008-02-01 15:04:30 -08:00
ibmphp_core.c PCI: hotplug: Switch to pci_get_bus_and_slot 2008-02-01 15:04:19 -08:00
ibmphp_ebda.c
ibmphp_hpc.c
ibmphp_pci.c
ibmphp_res.c
ibmphp.h
Kconfig PCI: hotplug: remove Experimental 2008-02-01 15:04:19 -08:00
Makefile PCI: hotplug: Link fakephp last 2008-02-01 15:04:20 -08:00
pci_hotplug_core.c PCI: Add missing "space" in printk messages 2008-02-01 15:04:22 -08:00
pciehp_core.c PCI Hotplug: pciehp: remove needless members from struct controller 2008-02-01 15:04:24 -08:00
pciehp_ctrl.c pciehp: wait for 1000ms before LED operation after power off 2008-02-01 15:04:28 -08:00
pciehp_hpc.c pciehp: workaround against Bad DLLP during power off 2008-02-01 15:04:28 -08:00
pciehp_pci.c pciehp: block new requests from the device before power off 2008-02-01 15:04:28 -08:00
pciehp.h PCI Hotplug: pciehp: remove needless members from struct controller 2008-02-01 15:04:24 -08:00
pcihp_skeleton.c
rpadlpar_core.c [POWERPC] Merge PCI resource fixups 2007-12-20 16:18:09 +11:00
rpadlpar_sysfs.c Kobject: convert drivers/* from kobject_unregister() to kobject_put() 2008-01-24 20:40:40 -08:00
rpadlpar.h
rpaphp_core.c
rpaphp_pci.c pci hotplug: fix rpaphp directory naming 2008-02-01 15:04:22 -08:00
rpaphp_slot.c pci hotplug: fix rpaphp directory naming 2008-02-01 15:04:22 -08:00
rpaphp.h pci hotplug: fix rpaphp directory naming 2008-02-01 15:04:22 -08:00
sgi_hotplug.c
shpchp_core.c
shpchp_ctrl.c
shpchp_hpc.c PCI: Spelling fixes 2008-02-01 15:04:26 -08:00
shpchp_pci.c
shpchp_sysfs.c
shpchp.h