From: Keith Busch <kbusch@meta.com>
To: <linux-kernel@vger.kernel.org>, <bhelgaas@google.com>
Cc: Keith Busch <kbusch@kernel.org>, Dan Williams <dan.j.williams@intel.com>
Subject: [PATCH] PCI: fix recusive device locking
Date: Fri, 28 Jun 2024 12:35:14 -0700 [thread overview]
Message-ID: <20240628193514.1680137-1-kbusch@meta.com> (raw)
From: Keith Busch <kbusch@kernel.org>
If one of the bus' devices has subordinates, the recursive call locks
itself, so no need to lock the device before the recusion or it will
surely deadlock.
Fixes: dbc5b5c0d268f87 ("PCI: Add missing bridge lock to pci_bus_lock()"
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
drivers/pci/pci.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 46beaf1815fab..d9f357812b3c5 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -5487,9 +5487,10 @@ static void pci_bus_lock(struct pci_bus *bus)
pci_dev_lock(bus->self);
list_for_each_entry(dev, &bus->devices, bus_list) {
- pci_dev_lock(dev);
if (dev->subordinate)
pci_bus_lock(dev->subordinate);
+ else
+ pci_dev_lock(dev);
}
}
@@ -5501,7 +5502,8 @@ static void pci_bus_unlock(struct pci_bus *bus)
list_for_each_entry(dev, &bus->devices, bus_list) {
if (dev->subordinate)
pci_bus_unlock(dev->subordinate);
- pci_dev_unlock(dev);
+ else
+ pci_dev_unlock(dev);
}
pci_dev_unlock(bus->self);
}
--
2.43.0
next reply other threads:[~2024-06-28 19:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-28 19:35 Keith Busch [this message]
2024-06-28 19:48 ` Dan Williams
2024-06-30 8:07 ` Markus Elfring
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=20240628193514.1680137-1-kbusch@meta.com \
--to=kbusch@meta.com \
--cc=bhelgaas@google.com \
--cc=dan.j.williams@intel.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®