linux/drivers/pci/hotplug
Gerd Bayer bcb5d6c769 s390/pci: introduce lock to synchronize state of zpci_dev's
There's a number of tasks that need the state of a zpci device
to be stable. Other tasks need to be synchronized as they change the state.

State changes could be generated by the system as availability or error
events, or be requested by the user through manipulations in sysfs.
Some other actions accessible through sysfs - like device resets - need the
state to be stable.

Unsynchronized state handling could lead to unusable devices. This has
been observed in cases of concurrent state changes through systemd udev
rules and DPM boot control. Some breakage can be provoked by artificial
tests, e.g. through repetitively injecting "recover" on a PCI function
through sysfs while running a "hotplug remove/add" in a loop through a
PCI slot's "power" attribute in sysfs. After a few iterations this could
result in a kernel oops.

So introduce a new mutex "state_lock" to guard the state property of the
struct zpci_dev. Acquire this lock in all task that modify the state:

- hotplug add and remove, through the PCI hotplug slot entry,
- avaiability events, as reported by the platform,
- error events, as reported by the platform,
- during device resets, explicit through sysfs requests or
  implict through the common PCI layer.

Break out an inner _do_recover() routine out of recover_store() to
separte the necessary synchronizations from the actual manipulations of
the zpci_dev required for the reset.

With the following changes I was able to run the inject loops for hours
without hitting an error.

Signed-off-by: Gerd Bayer <gbayer@linux.ibm.com>
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
2024-02-20 14:37:32 +01:00
..
acpi_pcihp.c PCI: Fix kernel-doc errors 2021-03-11 17:37:20 -06:00
acpiphp_ampere_altra.c PCI: hotplug: Add Ampere Altra Attention Indicator extension driver 2023-10-26 06:02:10 -05:00
acpiphp_core.c PCI: acpiphp: Allow built-in drivers for Attention Indicators 2023-10-25 13:05:37 -05:00
acpiphp_glue.c Revert "PCI: acpiphp: Reassign resources on bridge if necessary" 2023-12-15 14:55:10 -06:00
acpiphp_ibm.c PCI/ACPI: Replace acpi_bus_get_device() with acpi_fetch_acpi_dev() 2022-02-04 17:10:44 -06:00
acpiphp.h PCI: Remove unused function declarations 2023-08-24 15:38:59 -05:00
cpci_hotplug_core.c PCI: Remove unnecessary returns 2019-08-30 14:00:34 -05:00
cpci_hotplug_pci.c PCI: cpcihp: Declare cpci_debug in header file 2021-07-01 15:32:45 -05:00
cpci_hotplug.h PCI: Remove unused function declarations 2023-08-24 15:38:59 -05:00
cpcihp_generic.c
cpcihp_zt5550.c
cpcihp_zt5550.h
cpqphp_core.c PCI: cpqphp: Remove unused assignments 2022-03-22 11:24:40 -05:00
cpqphp_ctrl.c PCI: Use PCI_HEADER_TYPE_* instead of literals 2023-10-03 11:55:59 -05:00
cpqphp_nvram.c PCI: cpqphp: Use DEFINE_SPINLOCK() for int15_lock 2021-04-14 15:24:10 -05:00
cpqphp_nvram.h PCI: Remove unnecessary returns 2019-08-30 14:00:34 -05:00
cpqphp_pci.c PCI: Use PCI_HEADER_TYPE_* instead of literals 2023-10-03 11:55:59 -05:00
cpqphp_sysfs.c
cpqphp.h PCI: cpqphp: Use <linux/io.h> instead of <asm/io.h> 2021-11-02 14:41:58 -05:00
ibmphp_core.c PCI: ibmphp: Remove commented-out functions 2021-12-10 09:55:47 -06:00
ibmphp_ebda.c PCI: ibmphp: Fix double unmap of io_mem 2021-09-02 12:02:50 -05:00
ibmphp_hpc.c PCI: ibmphp: Remove unused assignments 2022-03-22 11:24:48 -05:00
ibmphp_pci.c PCI: Use PCI_HEADER_TYPE_* instead of literals 2023-10-03 11:55:59 -05:00
ibmphp_res.c PCI: ibmphp: Remove unused assignments 2022-03-22 11:24:48 -05:00
ibmphp.h PCI: Use PCI_HEADER_TYPE_* instead of literals 2023-10-03 11:55:59 -05:00
Kconfig PCI: hotplug: Add Ampere Altra Attention Indicator extension driver 2023-10-26 06:02:10 -05:00
Makefile PCI: hotplug: Add Ampere Altra Attention Indicator extension driver 2023-10-26 06:02:10 -05:00
pci_hotplug_core.c PCI/sysfs: Use sysfs_emit() and sysfs_emit_at() in "show" functions 2021-06-03 22:14:47 -05:00
pciehp_core.c PCI: hotplug: Use FIELD_GET/PREP() 2023-10-24 10:54:04 -05:00
pciehp_ctrl.c PCI: pciehp: Cancel bringup sequence if card is not present 2023-05-24 11:52:38 -05:00
pciehp_hpc.c PCI: hotplug: Use FIELD_GET/PREP() 2023-10-24 10:54:04 -05:00
pciehp_pci.c PCI: pciehp: Fix AB-BA deadlock between reset_lock and device_lock 2023-04-11 13:18:30 -05:00
pciehp.h PCI: pciehp: Use down_read/write_nested(reset_lock) to fix lockdep errors 2022-01-12 06:42:51 -06:00
pnv_php.c PCI: hotplug: Use FIELD_GET/PREP() 2023-10-24 10:54:04 -05:00
rpadlpar_core.c PCI: hotplug: Clean up include files 2022-04-05 11:13:33 -05:00
rpadlpar_sysfs.c PCI/sysfs: Use sysfs_emit() and sysfs_emit_at() in "show" functions 2021-06-03 22:14:47 -05:00
rpadlpar.h
rpaphp_core.c PCI: Use of_property_present() for testing DT property presence 2023-04-18 16:01:37 -05:00
rpaphp_pci.c PCI: rpaphp: Error out on busy status from get-sensor-state 2023-08-18 23:30:22 +10:00
rpaphp_slot.c PCI: hotplug: Clean up include files 2022-04-05 11:13:33 -05:00
rpaphp.h PCI: hotplug: Embed hotplug_slot 2018-09-18 17:52:15 -05:00
s390_pci_hpc.c s390/pci: introduce lock to synchronize state of zpci_dev's 2024-02-20 14:37:32 +01:00
shpchp_core.c PCI: Remove MODULE_LICENSE so boolean drivers don't look like modules 2023-02-17 08:47:58 -06:00
shpchp_ctrl.c pci-v5.10-changes 2020-10-22 12:41:00 -07:00
shpchp_hpc.c PCI: shpchp: Remove unused get_mode1_ECC_cap callback 2022-11-22 14:09:51 -06:00
shpchp_pci.c PCI: shpchp: Make shpchp_unconfigure_device() void 2020-05-21 15:23:20 -05:00
shpchp_sysfs.c PCI: Make pci_bus_for_each_resource() index optional 2023-04-05 15:10:09 -05:00
shpchp.h PCI: shpchp: Remove unused get_mode1_ECC_cap callback 2022-11-22 14:09:51 -06:00
TODO PCI: shpchp: Remove unused get_mode1_ECC_cap callback 2022-11-22 14:09:51 -06:00