From: Kai-Heng Feng <kaihengf@nvidia.com>
To: bhelgaas@google.com
Cc: ilpo.jarvinen@linux.intel.com, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org, Kai-Heng Feng <kaihengf@nvidia.com>
Subject: [PATCH] PCI: Validate window resource type in pbus_select_window_for_type()
Date: Tue, 10 Feb 2026 22:20:57 +0800 [thread overview]
Message-ID: <20260210142058.82701-1-kaihengf@nvidia.com> (raw)
Afer commit ebe091ad81e1 ("PCI: Use pbus_select_window_for_type() during
IO window sizing") and commit ae88d0b9c57f ("PCI: Use
pbus_select_window_for_type() during mem window sizing"), many bridge
window can't get resource assigned:
pci 0006:05:00.0: bridge window [??? 0x00001000-0x00001fff flags 0x20080000]: can't assign; no space
pci 0006:05:00.0: bridge window [??? 0x00001000-0x00001fff flags 0x20080000]: failed to assign
pci 0006:05:04.0: bridge window [??? 0x00001000-0x00001fff flags 0x20080000]: can't assign; no space
pci 0006:05:04.0: bridge window [??? 0x00001000-0x00001fff flags 0x20080000]: failed to assign
pci 0006:05:08.0: bridge window [??? 0x00001000-0x00001fff flags 0x20080000]: can't assign; no space
pci 0006:05:08.0: bridge window [??? 0x00001000-0x00001fff flags 0x20080000]: failed to assign
pci 0006:05:0c.0: bridge window [??? 0x00001000-0x00001fff flags 0x20080000]: can't assign; no space
pci 0006:05:0c.0: bridge window [??? 0x00001000-0x00001fff flags 0x20080000]: failed to assign
Those commits replace find_bus_resource_of_type() with
pbus_select_window_for_type(), and the latter lacks resource type
validation.
This commit adds the resource type validation back to
pbus_select_window_for_type() to match the original behavior.
Fixes: 74afce3dfcba ("PCI: Add bridge window selection functions")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=221072
Signed-off-by: Kai-Heng Feng <kaihengf@nvidia.com>
---
drivers/pci/setup-bus.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index e680f75a5b5e..1b5185697011 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -224,14 +224,21 @@ static struct resource *pbus_select_window_for_type(struct pci_bus *bus,
switch (iores_type) {
case IORESOURCE_IO:
- return pci_bus_resource_n(bus, PCI_BUS_BRIDGE_IO_WINDOW);
+ win = pci_bus_resource_n(bus, PCI_BUS_BRIDGE_IO_WINDOW);
+ if (win && (win->flags & IORESOURCE_IO))
+ return win;
+ return NULL;
case IORESOURCE_MEM:
mmio = pci_bus_resource_n(bus, PCI_BUS_BRIDGE_MEM_WINDOW);
mmio_pref = pci_bus_resource_n(bus, PCI_BUS_BRIDGE_PREF_MEM_WINDOW);
- if (!(type & IORESOURCE_PREFETCH) ||
- !(mmio_pref->flags & IORESOURCE_MEM))
+ if (mmio && !(mmio->flags & IORESOURCE_MEM))
+ mmio = NULL;
+ if (mmio_pref && !(mmio_pref->flags & IORESOURCE_MEM))
+ mmio_pref = NULL;
+
+ if (!(type & IORESOURCE_PREFETCH) || !mmio_pref)
return mmio;
if ((type & IORESOURCE_MEM_64) ||
--
2.43.0
next reply other threads:[~2026-02-10 14:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-10 14:20 Kai-Heng Feng [this message]
2026-02-10 15:19 ` [PATCH] PCI: Validate window resource type in pbus_select_window_for_type() Ilpo Järvinen
2026-02-10 17:26 ` Bjorn Helgaas
2026-02-12 15:13 ` Ilpo Järvinen
2026-02-12 17:09 ` Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260210142058.82701-1-kaihengf@nvidia.com \
--to=kaihengf@nvidia.com \
--cc=bhelgaas@google.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox