public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC/PATCH] PCI: Protect pci_reassign_bridge_resources() against concurrent addition/removal
@ 2019-06-24  4:32 Benjamin Herrenschmidt
  2019-08-21 13:08 ` Bjorn Helgaas
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2019-06-24  4:32 UTC (permalink / raw)
  To: linux-pci@vger.kernel.org

pci_reassign_bridge_resources() can be called by pci_resize_resource()
at runtime.

It will walk the PCI tree up and down, and isn't currently protected
against any changes or hotplug operation.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -2104,6 +2104,8 @@ int pci_reassign_bridge_resources(struct pci_dev *bridge, unsigned long type)
 	unsigned int i;
 	int ret;
 
+	down_read(&pci_bus_sem);
+
 	/* Walk to the root hub, releasing bridge BARs when possible */
 	next = bridge;
 	do {
@@ -2160,6 +2162,7 @@ int pci_reassign_bridge_resources(struct pci_dev *bridge, unsigned long type)
 	}
 
 	free_list(&saved);
+	up_read(&pci_bus_sem);
 	return 0;
 
 cleanup:
@@ -2188,6 +2191,7 @@ int pci_reassign_bridge_resources(struct pci_dev *bridge, unsigned long type)
 		pci_setup_bridge(bridge->subordinate);
 	}
 	free_list(&saved);
+	up_read(&pci_bus_sem);
 
 	return ret;
 }


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-09-23 21:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-24  4:32 [RFC/PATCH] PCI: Protect pci_reassign_bridge_resources() against concurrent addition/removal Benjamin Herrenschmidt
2019-08-21 13:08 ` Bjorn Helgaas
2019-09-23 21:50   ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox