]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
s390/pci: Serialize device addition and removal
authorNiklas Schnelle <schnelle@linux.ibm.com>
Thu, 22 May 2025 12:13:15 +0000 (14:13 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:11:14 +0000 (11:11 +0100)
commitf2e8a863fdc93abc29929df61ddf7edf5a246acf
tree074db94f73a53e3f0ee62d1d9fd129c8e0181ce4
parent31a7dc5a24c06887184191e500f592e47cd1a6d9
s390/pci: Serialize device addition and removal

commit 774a1fa880bc949d88b5ddec9494a13be733dfa8 upstream.

Prior changes ensured that when zpci_release_device() is called and it
removed the zdev from the zpci_list this instance can not be found via
the zpci_list anymore even while allowing re-add of reserved devices.
This only accounts for the overall lifetime and zpci_list addition and
removal, it does not yet prevent concurrent add of a new instance for
the same underlying device. Such concurrent add would subsequently cause
issues such as attempted re-use of the same IOMMU sysfs directory and is
generally undesired.

Introduce a new zpci_add_remove_lock mutex to serialize adding a new
device with removal. Together this ensures that if a struct zpci_dev is
not found in the zpci_list it was either already removed and torn down,
or its removal and tear down is in progress with the
zpci_add_remove_lock held.

Cc: stable@vger.kernel.org
Fixes: a46044a92add ("s390/pci: fix zpci_zdev_put() on reserve")
Reviewed-by: Gerd Bayer <gbayer@linux.ibm.com>
Tested-by: Gerd Bayer <gbayer@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/s390/pci/pci.c