From: Benjamin Block <bblock@linux.ibm.com>
To: Benjamin Block <bebl@ategam.org>, Bjorn Helgaas <bhelgaas@google.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
linux-intel-xe <intel-xe@lists.freedesktop.org>,
piotr.piorkowski@intel.com, Farhan Ali <alifm@linux.ibm.com>,
Halil Pasic <pasic@linux.ibm.com>,
Gerd Bayer <gbayer@linux.ibm.com>, Lukas Wunner <lukas@wunner.de>,
Guenter Roeck <linux@roeck-us.net>,
Manivannan Sadhasivam <mani@kernel.org>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Ionut Nechita <ionut_n2001@yahoo.com>,
Tobias Schumacher <ts@linux.ibm.com>,
Niklas Schnelle <schnelle@linux.ibm.com>,
Ramesh Errabolu <ramesh@linux.ibm.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Sven Schnelle <svens@linux.ibm.com>,
Keith Busch <kbusch@kernel.org>,
Andreas Krebbel <krebbel@linux.ibm.com>,
Julian Ruess <julianr@linux.ibm.com>,
Matthew Brost <matthew.brost@intel.com>,
Ionut Nechita <ionut.nechita@windriver.com>,
Omar Elghoul <oelghoul@linux.ibm.com>,
Michal Wajdeczko <michal.wajdeczko@intel.com>,
linux-pci <linux-pci@vger.kernel.org>,
Ionut Nechita <sunlightlinux@gmail.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
linux-s390 <linux-s390@vger.kernel.org>,
Dragos Tatulea <dtatulea@nvidia.com>,
Benjamin Block <bblock@linux.ibm.com>
Subject: [PATCH v15 3/5] PCI: Move declaration of pci_rescan_remove_lock into public pci.h
Date: Thu, 24 Sep 2026 18:29:29 +0200 [thread overview]
Message-ID: <d15370f96120f007db5717839a313f1a7bbfe010.1790267348.git.bblock@linux.ibm.com> (raw)
In-Reply-To: <cover.1790267348.git.bblock@linux.ibm.com>
So far it is possible to use and call the functions
pci_lock_rescan_remove() and pci_unlock_rescan_remove() from any PCI
code, including modules and architecture code; but the lock variable
`pci_rescan_remove_lock` itself is private to objects residing in
`drivers/pci/` via the header `drivers/pci/pci.h`.
This makes it possible to use the lock - lock it, unlock it - from
anywhere, but it is not possible to use lockdep annotations such as
lockdep_assert_held(), or sparse annotations such as __must_hold() in
modules or architecture code for PCI to make the usage more safe.
Since it is useful for `pci_rescan_remove_lock` to have such
annotations, move the variable declaration into `include/linux/pci.h`.
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
---
drivers/pci/pci.h | 2 --
drivers/pci/probe.c | 1 +
include/linux/pci.h | 2 ++
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index ba3c3fddddc2..811958807b63 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -114,8 +114,6 @@ unsigned char pcie_get_link_speed(unsigned int speed);
extern bool pci_early_dump;
-extern struct mutex pci_rescan_remove_lock;
-
bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
bool pcie_cap_has_lnkctl2(const struct pci_dev *dev);
bool pcie_cap_has_rtctl(const struct pci_dev *dev);
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index cff9f0bf4c4b..85b96a8e40e7 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -3510,6 +3510,7 @@ EXPORT_SYMBOL_GPL(pci_rescan_bus);
* routines should always be executed under this mutex.
*/
DEFINE_MUTEX(pci_rescan_remove_lock);
+EXPORT_SYMBOL_GPL(pci_rescan_remove_lock);
static const struct task_struct *pci_rescan_remove_owner;
static size_t pci_rescan_remove_depth;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d31a8d107b1e..d704a32ff988 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -40,6 +40,7 @@
#include <linux/io.h>
#include <linux/resource_ext.h>
#include <linux/msi_api.h>
+#include <linux/mutex.h>
#include <uapi/linux/pci.h>
#include <linux/pci_ids.h>
@@ -1551,6 +1552,7 @@ void set_pcie_hotplug_bridge(struct pci_dev *pdev);
/* Functions for PCI Hotplug drivers to use */
unsigned int pci_rescan_bus(struct pci_bus *bus);
+extern struct mutex pci_rescan_remove_lock;
void pci_lock_rescan_remove(void);
void pci_unlock_rescan_remove(void);
--
2.55.0
next prev parent reply other threads:[~2026-09-24 16:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 16:29 [PATCH v15 0/5] PCI/IOV: Fix SR-IOV locking races and AB-BA deadlocks Benjamin Block
2026-09-24 16:29 ` [PATCH v15 1/5] PCI/IOV: Make pci_lock_rescan_remove() reentrant and protect sriov_add_vfs/sriov_del_vfs Benjamin Block
2026-09-24 16:29 ` [PATCH v15 2/5] PCI: Fix AB-BA deadlock between device_lock and pci_rescan_remove_lock in remove_store Benjamin Block
2026-09-24 16:29 ` Benjamin Block [this message]
2026-09-24 16:29 ` [PATCH v15 4/5] PCI: Provide lock guard for pci_rescan_remove_lock Benjamin Block
2026-09-24 16:29 ` [PATCH v15 5/5] s390/pci: Fix circular/recursive deadlocks in PCI-bus and -device release Benjamin Block
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d15370f96120f007db5717839a313f1a7bbfe010.1790267348.git.bblock@linux.ibm.com \
--to=bblock@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=alifm@linux.ibm.com \
--cc=bebl@ategam.org \
--cc=bhelgaas@google.com \
--cc=borntraeger@linux.ibm.com \
--cc=dtatulea@nvidia.com \
--cc=gbayer@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=ionut.nechita@windriver.com \
--cc=ionut_n2001@yahoo.com \
--cc=julianr@linux.ibm.com \
--cc=kbusch@kernel.org \
--cc=krebbel@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lukas@wunner.de \
--cc=mani@kernel.org \
--cc=matthew.brost@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=mjrosato@linux.ibm.com \
--cc=oelghoul@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=piotr.piorkowski@intel.com \
--cc=ramesh@linux.ibm.com \
--cc=schnelle@linux.ibm.com \
--cc=sunlightlinux@gmail.com \
--cc=svens@linux.ibm.com \
--cc=ts@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®