[PATCH v3 01/17] PCI: Add pci_bus_size_and_assign_resources()

Greg Ungerer gerg at linux-m68k.org
Tue Dec 1 21:21:37 PST 2026



On 26/11/26 09:09, Ilpo Järvinen wrote:
> Bridge window sizing and resource assignment must not run concurrently
> with another sizing and assignment pass or with device removal.
> Preventing that requires holding locks across both phases. Many callers
> outside of PCI core call pci_bus_size_bridges() immediately followed by
> pci_bus_assign_resources() and cannot hold the PCI core internal locks
> across the two calls.
> 
> Add pci_bus_size_and_assign_resources() into PCI core which combines
> these two operations and convert the callers that call them back to
> back.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen at linux.intel.com>
> Acked-by: Rafael J. Wysocki (Intel) <rafael at kernel.org>
> Cc: stable at vger.kernel.org

For the coldfire changes:

Acked-by: Greg Ungerer <gerg at linux-m68k.org>

Regards
Greg



> ---
>  arch/arm/kernel/bios32.c           | 5 ++---
>  arch/m68k/coldfire/pci.c           | 3 +--
>  arch/mips/pci/pci-legacy.c         | 5 ++---
>  arch/sh/drivers/pci/pci.c          | 3 +--
>  drivers/parisc/lba_pci.c           | 7 ++-----
>  drivers/pci/hotplug/acpiphp_glue.c | 3 +--
>  drivers/pci/setup-bus.c            | 7 +++++++
>  drivers/pcmcia/cardbus.c           | 3 +--
>  include/linux/pci.h                | 1 +
>  9 files changed, 18 insertions(+), 19 deletions(-)
> 
> diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
> index ac0e890510da..555bfb091d30 100644
> --- a/arch/arm/kernel/bios32.c
> +++ b/arch/arm/kernel/bios32.c
> @@ -510,15 +510,14 @@ void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
>  		/*
>  		 * We insert PCI resources into the iomem_resource and
>  		 * ioport_resource trees in either pci_bus_claim_resources()
> -		 * or pci_bus_assign_resources().
> +		 * or pci_bus_size_and_assign_resources().
>  		 */
>  		if (pci_has_flag(PCI_PROBE_ONLY)) {
>  			pci_bus_claim_resources(bus);
>  		} else {
>  			struct pci_bus *child;
>  
> -			pci_bus_size_bridges(bus);
> -			pci_bus_assign_resources(bus);
> +			pci_bus_size_and_assign_resources(bus);
>  
>  			list_for_each_entry(child, &bus->children, node)
>  				pcie_bus_configure_settings(child);
> diff --git a/arch/m68k/coldfire/pci.c b/arch/m68k/coldfire/pci.c
> index 5afb207ccc51..dd21c77c43a6 100644
> --- a/arch/m68k/coldfire/pci.c
> +++ b/arch/m68k/coldfire/pci.c
> @@ -250,8 +250,7 @@ static int __init mcf_pci_init(void)
>  	rootbus->resource[0] = &mcf_pci_io;
>  	rootbus->resource[1] = &mcf_pci_mem;
>  
> -	pci_bus_size_bridges(rootbus);
> -	pci_bus_assign_resources(rootbus);
> +	pci_bus_size_and_assign_resources(rootbus);
>  	pci_bus_add_devices(rootbus);
>  	return 0;
>  }
> diff --git a/arch/mips/pci/pci-legacy.c b/arch/mips/pci/pci-legacy.c
> index dae6dafdd6e0..ec0e42d9a895 100644
> --- a/arch/mips/pci/pci-legacy.c
> +++ b/arch/mips/pci/pci-legacy.c
> @@ -129,15 +129,14 @@ static void pcibios_scanbus(struct pci_controller *hose)
>  	/*
>  	 * We insert PCI resources into the iomem_resource and
>  	 * ioport_resource trees in either pci_bus_claim_resources()
> -	 * or pci_bus_assign_resources().
> +	 * or pci_bus_size_and_assign_resources().
>  	 */
>  	if (pci_has_flag(PCI_PROBE_ONLY)) {
>  		pci_bus_claim_resources(bus);
>  	} else {
>  		struct pci_bus *child;
>  
> -		pci_bus_size_bridges(bus);
> -		pci_bus_assign_resources(bus);
> +		pci_bus_size_and_assign_resources(bus);
>  		list_for_each_entry(child, &bus->children, node)
>  			pcie_bus_configure_settings(child);
>  	}
> diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
> index 878a27a1acfb..c91ca8f4cb1c 100644
> --- a/arch/sh/drivers/pci/pci.c
> +++ b/arch/sh/drivers/pci/pci.c
> @@ -81,8 +81,7 @@ static void pcibios_scanbus(struct pci_channel *hose)
>  		need_domain_info = 1;
>  	}
>  
> -	pci_bus_size_bridges(hose->bus);
> -	pci_bus_assign_resources(hose->bus);
> +	pci_bus_size_and_assign_resources(hose->bus);
>  	pci_bus_add_devices(hose->bus);
>  }
>  
> diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
> index 5197a3c93c70..39ab93ba458b 100644
> --- a/drivers/parisc/lba_pci.c
> +++ b/drivers/parisc/lba_pci.c
> @@ -1639,11 +1639,8 @@ lba_driver_probe(struct parisc_device *dev)
>  	if (is_pdc_pat()) {
>  		/* assign resources to un-initialized devices */
>  
> -		DBG_PAT("LBA pci_bus_size_bridges()\n");
> -		pci_bus_size_bridges(lba_bus);
> -
> -		DBG_PAT("LBA pci_bus_assign_resources()\n");
> -		pci_bus_assign_resources(lba_bus);
> +		DBG_PAT("LBA pci_bus_size_and_assign_resources()\n");
> +		pci_bus_size_and_assign_resources(lba_bus);
>  
>  #ifdef DEBUG_LBA_PAT
>  		DBG_PAT("\nLBA PIOP resource tree\n");
> diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
> index 78e3effbb32d..632344f34cae 100644
> --- a/drivers/pci/hotplug/acpiphp_glue.c
> +++ b/drivers/pci/hotplug/acpiphp_glue.c
> @@ -465,8 +465,7 @@ static void acpiphp_native_scan_bridge(struct pci_dev *bridge)
>  		max = pci_scan_bridge(bus, dev, max, 1);
>  		if (dev->subordinate) {
>  			pcibios_resource_survey_bus(dev->subordinate);
> -			pci_bus_size_bridges(dev->subordinate);
> -			pci_bus_assign_resources(dev->subordinate);
> +			pci_bus_size_and_assign_resources(dev->subordinate);
>  		}
>  	}
>  }
> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> index ed16ef7c26fa..29ec9ba59d92 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
> @@ -2492,3 +2492,10 @@ void pci_assign_unassigned_bus_resources(struct pci_bus *bus)
>  	__pci_bus_assign_resources(bus, &add_list, NULL);
>  }
>  EXPORT_SYMBOL_GPL(pci_assign_unassigned_bus_resources);
> +
> +void pci_bus_size_and_assign_resources(struct pci_bus *bus)
> +{
> +	pci_bus_size_bridges(bus);
> +	__pci_bus_assign_resources(bus, NULL, NULL);
> +}
> +EXPORT_SYMBOL_GPL(pci_bus_size_and_assign_resources);
> diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c
> index 5e5cf2c3e2c8..19df3f9228a7 100644
> --- a/drivers/pcmcia/cardbus.c
> +++ b/drivers/pcmcia/cardbus.c
> @@ -81,8 +81,7 @@ int __ref cb_alloc(struct pcmcia_socket *s)
>  	/*
>  	 * Size all resources below the CardBus controller.
>  	 */
> -	pci_bus_size_bridges(bus);
> -	pci_bus_assign_resources(bus);
> +	pci_bus_size_and_assign_resources(bus);
>  	cardbus_config_irq_and_cls(bus, s->pci_irq);
>  
>  	/* socket specific tune function */
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index aa3765a20a96..d89aeb7c9ff7 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1569,6 +1569,7 @@ resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx);
>  void pci_bus_assign_resources(const struct pci_bus *bus);
>  void pci_bus_claim_resources(struct pci_bus *bus);
>  void pci_bus_size_bridges(struct pci_bus *bus);
> +void pci_bus_size_and_assign_resources(struct pci_bus *bus);
>  int pci_claim_resource(struct pci_dev *, int);
>  int pci_claim_bridge_resource(struct pci_dev *bridge, int i);
>  void pci_assign_unassigned_resources(void);




More information about the linux-arm-kernel mailing list