PCI: Use preserve_config in place of pci_flags
authorVidya Sagar <vidyas@nvidia.com>
Wed, 8 May 2024 17:41:38 +0000 (23:11 +0530)
committerBjorn Helgaas <bhelgaas@google.com>
Mon, 3 Jun 2024 21:18:13 +0000 (16:18 -0500)
Use preserve_config in place of checking for PCI_PROBE_ONLY flag to enable
support for "linux,pci-probe-only" on a per host bridge basis.

This also obviates the use of adding PCI_REASSIGN_ALL_BUS flag if
!PCI_PROBE_ONLY, as pci_assign_unassigned_root_bus_resources() takes care
of reassigning the resources that are not already claimed.

Link: https://lore.kernel.org/r/20240508174138.3630283-5-vidyas@nvidia.com
Signed-off-by: Vidya Sagar <vidyas@nvidia.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/controller/pci-host-common.c
drivers/pci/probe.c

index 45b71806182d2b8f9ae7cd876465684f6418abca..c96b2de163b5a977e1e66cf6507ca69972f88b3f 100644 (file)
@@ -73,10 +73,6 @@ int pci_host_common_probe(struct platform_device *pdev)
        if (IS_ERR(cfg))
                return PTR_ERR(cfg);
 
-       /* Do not reassign resources if probe only */
-       if (!pci_has_flag(PCI_PROBE_ONLY))
-               pci_add_flags(PCI_REASSIGN_ALL_BUS);
-
        bridge->sysdata = cfg;
        bridge->ops = (struct pci_ops *)&ops->pci_ops;
        bridge->msi_domain = true;
index 8786d2c1a0bdeb95ec7716519cb6e6464d4d2ef5..20475ca30505f1400872214f2afb9cb5b921df17 100644 (file)
@@ -3094,20 +3094,18 @@ int pci_host_probe(struct pci_host_bridge *bridge)
 
        bus = bridge->bus;
 
+       /* If we must preserve the resource configuration, claim now */
+       if (bridge->preserve_config)
+               pci_bus_claim_resources(bus);
+
        /*
-        * We insert PCI resources into the iomem_resource and
-        * ioport_resource trees in either pci_bus_claim_resources()
-        * or pci_bus_assign_resources().
+        * Assign whatever was left unassigned. If we didn't claim above,
+        * this will reassign everything.
         */
-       if (pci_has_flag(PCI_PROBE_ONLY)) {
-               pci_bus_claim_resources(bus);
-       } else {
-               pci_bus_size_bridges(bus);
-               pci_bus_assign_resources(bus);
+       pci_assign_unassigned_root_bus_resources(bus);
 
-               list_for_each_entry(child, &bus->children, node)
-                       pcie_bus_configure_settings(child);
-       }
+       list_for_each_entry(child, &bus->children, node)
+               pcie_bus_configure_settings(child);
 
        pci_bus_add_devices(bus);
        return 0;