]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI: Don't claim disabled bridge windows
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 3 Feb 2026 17:21:38 +0000 (19:21 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 6 Feb 2026 22:12:42 +0000 (16:12 -0600)
The commit 8278c6914306 ("PCI: Preserve bridge window resource type flags")
changed bridge window resource behavior such that flags are no longer zero
if the bridge window is not valid or is disabled (mainly to preserve the
type flags for later use). If a bridge window has its limit smaller than
base address, pci_read_bridge_*() sets both IORESOURCE_UNSET and
IORESOURCE_DISABLED to indicate the bridge window exists but is not valid
with the current base and limit configuration.

The code in pci_claim_bridge_resources() still depends on the old behavior
of checking validity of the bridge window solely based on !r->flags,
whereas after 8278c6914306, also IORESOURCE_DISABLED may indicate bridge
window addresses are not valid.

While pci_claim_resource() does check IORESOURCE_UNSET,
pci_claim_bridge_resource() attempts to clip the resource if
pci_claim_resource() fails, which is not correct for bridge window
resources that are not valid. As pci_bus_clip_resource() performs clipping
regardless of flags and then clears IORESOURCE_UNSET, it should not be
called unless the resource is valid.

The problem is visible in this log:

  pci 0000:20:00.0: PCI bridge to [bus 21]
  pci 0000:20:00.0: bridge window [io  size 0x0000 disabled]: can't claim; no address assigned
  pci 0000:20:00.0: [io  0x0000-0xffffffffffffffff disabled] clipped to [io 0x0000-0xffff disabled]

Add IORESOURCE_DISABLED check in pci_claim_bridge_resources() to only
claim bridge windows that appear to have a valid configuration.

Fixes: 8278c6914306 ("PCI: Preserve bridge window resource type flags")
Reported-by: Sizhe Liu <liusizhe5@huawei.com>
Link: https://lore.kernel.org/all/20260203023545.2753811-1-liusizhe5@huawei.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/4d9228d6-a230-6ddf-e300-fbf42d523863@linux.intel.com
drivers/pci/setup-bus.c

index e680f75a5b5ea3cc51f8c90119ee16b3cddba936..69abb11b7e47f953c986bba11f2a2617dc5ee5de 100644 (file)
@@ -1549,6 +1549,8 @@ static void pci_claim_bridge_resources(struct pci_dev *dev)
 
                if (!r->flags || resource_assigned(r))
                        continue;
+               if (r->flags & IORESOURCE_DISABLED)
+                       continue;
 
                pci_claim_bridge_resource(dev, i);
        }