kernel-aes67/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
..
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
TODO
acpi_pcihp.c
acpiphp.h
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
cpci_hotplug.h
cpci_hotplug_core.c
cpci_hotplug_pci.c
cpcihp_generic.c
cpcihp_zt5550.c
cpcihp_zt5550.h
cpqphp.h
cpqphp_core.c
cpqphp_ctrl.c PCI: Use PCI_HEADER_TYPE_* instead of literals 2023-10-03 11:55:59 -05:00
cpqphp_nvram.c
cpqphp_nvram.h
cpqphp_pci.c PCI: Use PCI_HEADER_TYPE_* instead of literals 2023-10-03 11:55:59 -05:00
cpqphp_sysfs.c
ibmphp.h PCI: Use PCI_HEADER_TYPE_* instead of literals 2023-10-03 11:55:59 -05:00
ibmphp_core.c
ibmphp_ebda.c
ibmphp_hpc.c
ibmphp_pci.c PCI: Use PCI_HEADER_TYPE_* instead of literals 2023-10-03 11:55:59 -05:00
ibmphp_res.c
pci_hotplug_core.c
pciehp.h
pciehp_core.c PCI: hotplug: Use FIELD_GET/PREP() 2023-10-24 10:54:04 -05:00
pciehp_ctrl.c
pciehp_hpc.c PCI: hotplug: Use FIELD_GET/PREP() 2023-10-24 10:54:04 -05:00
pciehp_pci.c
pnv_php.c PCI: hotplug: Use FIELD_GET/PREP() 2023-10-24 10:54:04 -05:00
rpadlpar.h
rpadlpar_core.c
rpadlpar_sysfs.c
rpaphp.h
rpaphp_core.c
rpaphp_pci.c
rpaphp_slot.c
s390_pci_hpc.c s390/pci: introduce lock to synchronize state of zpci_dev's 2024-02-20 14:37:32 +01:00
shpchp.h
shpchp_core.c
shpchp_ctrl.c
shpchp_hpc.c
shpchp_pci.c
shpchp_sysfs.c