Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Cercueil <paul.cercueil@bootlin.com>
To: "Will Deacon" <will@kernel.org>,
	"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
	"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Rob Herring" <robh@kernel.org>, "Lukas Wunner" <lukas@wunner.de>
Cc: Frank Li <Frank.Li@nxp.com>, Qiang Yu <qiang.yu@oss.qualcomm.com>,
	Manivannan Sadhasivam <mani@kernel.org>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Paul Cercueil <paul.cercueil@bootlin.com>,
	stable@vger.kernel.org
Subject: [PATCH v2] PCI: Fix root port reset lock ordering issue
Date: Tue,  1 Dec 2026 12:01:30 +0100	[thread overview]
Message-ID: <20261201110130.87336-1-paul.cercueil@bootlin.com> (raw)

Currently, pci_host_reset_root_port() calls pci_lock_rescan_remove(),
to protect pci_bus_error_reset() racing against
pciehp_unconfigure_device().

The reset function then calls pci_reset_bridge(), then pci_slot_reset(),
pci_reset_hotplug_slot(), which will call the .reset_slot callback.
For a pciehp root port, this calls the pciehp_reset_slot() function,
which will grab the 'reset_lock'.

On the other hand, the pciehp IRQ handler pciehp_ist() gets the
'reset_lock' first, then calls pciehp_handle_presence_or_link_change(),
which will call pciehp_enable_slot(), __pciehp_enable_slot(),
board_added(), then finally pciehp_configure_device(), which will call
pci_lock_rescan_remove().

This is a typical ABBA locking issue. However, the rescan lock is used
in pci_host_reset_root_port() only to protect against the PCI device
disappearing. We can keep this protection while fixing this locking
issue by getting a reference to the PCI device instead.

Fixes: 4c99bace4f4e ("PCI: host-common: Add link down handling for Root Ports")
Cc: stable@vger.kernel.org
Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---

Changelog:

v2:
- Grab a reference to the PCI device in pci_host_reset_root_port()
  instead of grabbing the rescan lock. This makes the ABBA locking issue
  disappear.
---
 drivers/pci/controller/pci-host-common.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pci/controller/pci-host-common.c b/drivers/pci/controller/pci-host-common.c
index 35ee51cf9d06..157328f393f4 100644
--- a/drivers/pci/controller/pci-host-common.c
+++ b/drivers/pci/controller/pci-host-common.c
@@ -327,11 +327,10 @@ EXPORT_SYMBOL_GPL(pci_host_common_d3cold_possible);
 
 static pci_ers_result_t pci_host_reset_root_port(struct pci_dev *dev)
 {
+	struct pci_dev *pdev __free(pci_dev_put) = pci_dev_get(dev);
 	int ret;
 
-	pci_lock_rescan_remove();
 	ret = pci_bus_error_reset(dev);
-	pci_unlock_rescan_remove();
 	if (ret) {
 		pci_err(dev, "Failed to reset Root Port: %d\n", ret);
 		return PCI_ERS_RESULT_DISCONNECT;
-- 
2.47.3



             reply	other threads:[~2026-12-01 11:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 11:01 Paul Cercueil [this message]
2026-12-01 11:11 ` [PATCH v2] PCI: Fix root port reset lock ordering issue Lukas Wunner

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=20261201110130.87336-1-paul.cercueil@bootlin.com \
    --to=paul.cercueil@bootlin.com \
    --cc=Frank.Li@nxp.com \
    --cc=bhelgaas@google.com \
    --cc=kwilczynski@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=lukas@wunner.de \
    --cc=mani@kernel.org \
    --cc=qiang.yu@oss.qualcomm.com \
    --cc=robh@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=will@kernel.org \
    /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