[PATCH v8 12/17] PCI: hold the rescan mutex when scanning for the first time

Bartosz Golaszewski posted 17 patches 1 year, 6 months ago
[PATCH v8 12/17] PCI: hold the rescan mutex when scanning for the first time
Posted by Bartosz Golaszewski 1 year, 6 months ago
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

With the introduction of PCI device power control drivers that will be
able to trigger the port rescan when probing, we need to hold the rescan
mutex during the initial pci_host_probe() too or the two could get in
each other's way.

Tested-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/pci/probe.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 8e696e547565..604fc96b1098 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -3072,7 +3072,9 @@ int pci_host_probe(struct pci_host_bridge *bridge)
 	struct pci_bus *bus, *child;
 	int ret;
 
+	pci_lock_rescan_remove();
 	ret = pci_scan_root_bus_bridge(bridge);
+	pci_unlock_rescan_remove();
 	if (ret < 0) {
 		dev_err(bridge->dev.parent, "Scanning root bridge failed");
 		return ret;

-- 
2.43.0
Re: [PATCH v8 12/17] PCI: hold the rescan mutex when scanning for the first time
Posted by Bjorn Helgaas 1 year, 6 months ago
On Tue, May 28, 2024 at 09:03:20PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> With the introduction of PCI device power control drivers that will be
> able to trigger the port rescan when probing, we need to hold the rescan
> mutex during the initial pci_host_probe() too or the two could get in
> each other's way.
> 
> Tested-by: Amit Pundir <amit.pundir@linaro.org>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

With s/hold the/Hold the/ in subject to match history,

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

> ---
>  drivers/pci/probe.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 8e696e547565..604fc96b1098 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -3072,7 +3072,9 @@ int pci_host_probe(struct pci_host_bridge *bridge)
>  	struct pci_bus *bus, *child;
>  	int ret;
>  
> +	pci_lock_rescan_remove();
>  	ret = pci_scan_root_bus_bridge(bridge);
> +	pci_unlock_rescan_remove();
>  	if (ret < 0) {
>  		dev_err(bridge->dev.parent, "Scanning root bridge failed");
>  		return ret;
> 
> -- 
> 2.43.0
>