]> www.infradead.org Git - users/jedix/linux-maple.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)
committerHeiko Carstens <hca@linux.ibm.com>
Thu, 22 May 2025 14:12:53 +0000 (16:12 +0200)
commit774a1fa880bc949d88b5ddec9494a13be733dfa8
treea4042a0d020327d5dc0a64fd1d314dc779bafc7d
parent4b1815a52d7eb03b3e0e6742c6728bc16a4b2d1d
s390/pci: Serialize device addition and removal

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>
arch/s390/pci/pci.c