* [PATCH] PCI: fix recusive device locking
@ 2024-06-28 19:35 Keith Busch
2024-06-28 19:48 ` Dan Williams
2024-06-30 8:07 ` Markus Elfring
0 siblings, 2 replies; 3+ messages in thread
From: Keith Busch @ 2024-06-28 19:35 UTC (permalink / raw)
To: linux-kernel, bhelgaas; +Cc: Keith Busch, Dan Williams
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI: fix recusive device locking
2024-06-28 19:35 [PATCH] PCI: fix recusive device locking Keith Busch
@ 2024-06-28 19:48 ` Dan Williams
2024-06-30 8:07 ` Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: Dan Williams @ 2024-06-28 19:48 UTC (permalink / raw)
To: Keith Busch, linux-kernel, bhelgaas; +Cc: Keith Busch, Dan Williams, linux-pci
[ add linux-pci ]
Keith Busch wrote:
> 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>
Looks good, thanks for the fixup Keith!
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] PCI: fix recusive device locking
2024-06-28 19:35 [PATCH] PCI: fix recusive device locking Keith Busch
2024-06-28 19:48 ` Dan Williams
@ 2024-06-30 8:07 ` Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2024-06-30 8:07 UTC (permalink / raw)
To: Keith Busch, kernel-janitors, Bjorn Helgaas, Dan Williams
Cc: Keith Busch, LKML
> 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
…
recursion?
Would you like to avoid another typo also in the summary phrase?
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-30 8:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-28 19:35 [PATCH] PCI: fix recusive device locking Keith Busch
2024-06-28 19:48 ` Dan Williams
2024-06-30 8:07 ` Markus Elfring
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®