From: Bjorn Helgaas <helgaas@kernel.org>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: linux-pci@vger.kernel.org, "Bjorn Helgaas" <bhelgaas@google.com>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Tudor Ambarus" <tudor.ambarus@linaro.org>, Rio <rio@r26.me>,
"D Scott Phillips" <scott@os.amperecomputing.com>,
linux-kernel@vger.kernel.org,
"Christian König" <christian.koenig@amd.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v2 2/3] PCI: Fix pdev_resources_assignable() disparity
Date: Thu, 21 Aug 2025 10:11:32 -0500 [thread overview]
Message-ID: <20250821151132.GA674480@bhelgaas> (raw)
In-Reply-To: <20250630142641.3516-3-ilpo.jarvinen@linux.intel.com>
On Mon, Jun 30, 2025 at 05:26:40PM +0300, Ilpo Järvinen wrote:
> pdev_sort_resources() uses pdev_resources_assignable() helper to decide
> if device's resources cannot be assigned. pbus_size_mem(), on the other
> hand, does not do the same check. This could lead into a situation
> where a resource ends up on realloc_head list but is not on the head
> list, which is turn prevents emptying the resource from the
> realloc_head list in __assign_resources_sorted().
>
> A non-empty realloc_head is unacceptable because it triggers an
> internal sanity check as show in this log with a device that has class
> 0 (PCI_CLASS_NOT_DEFINED):
Is the class relevant here?
> pci 0001:01:00.0: [144d:a5a5] type 00 class 0x000000 PCIe Endpoint
> pci 0001:01:00.0: BAR 0 [mem 0x00000000-0x000fffff 64bit]
> pci 0001:01:00.0: ROM [mem 0x00000000-0x0000ffff pref]
> pci 0001:01:00.0: enabling Extended Tags
> pci 0001:01:00.0: PME# supported from D0 D3hot D3cold
> pci 0001:01:00.0: 15.752 Gb/s available PCIe bandwidth, limited by 8.0 GT/s PCIe x2 link at 0001:00:00.0 (capable of 31.506 Gb/s with 16.0 GT/s PCIe x2 link)
> pcieport 0001:00:00.0: bridge window [mem 0x00100000-0x001fffff] to [bus 01-ff] add_size 100000 add_align 100000
> pcieport 0001:00:00.0: bridge window [mem 0x40000000-0x401fffff]: assigned
> ------------[ cut here ]------------
> kernel BUG at drivers/pci/setup-bus.c:2532!
> Internal error: Oops - BUG: 00000000f2000800 [#1] SMP
> ...
> Call trace:
> pci_assign_unassigned_bus_resources+0x110/0x114 (P)
> pci_rescan_bus+0x28/0x48
>
> Use pdev_resources_assignable() also within pbus_size_mem() to skip
> processing of non-assignable resources which removes the disparity in
> between what resources pdev_sort_resources() and pbus_size_mem()
> consider. As non-assignable resources are no longer processed, they are
> not added to the realloc_head list, thus the sanity check no longer
> triggers.
>
> This disparity problem is very old but only now became apparent after
> the commit 2499f5348431 ("PCI: Rework optional resource handling") that
> made the ROM resources optional when calculating bridge window sizes
> which required adding the resource to the realloc_head list.
> Previously, bridge windows were just sized larger than necessary.
>
> Fixes: 2499f5348431 ("PCI: Rework optional resource handling")
> Reported-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Any URL we can include here for the report?
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Cc: <stable@vger.kernel.org>
> ---
> drivers/pci/setup-bus.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> index f90d49cd07da..24863d8d0053 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
> @@ -1191,6 +1191,7 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
> resource_size_t r_size;
>
> if (r->parent || (r->flags & IORESOURCE_PCI_FIXED) ||
> + !pdev_resources_assignable(dev) ||
> ((r->flags & mask) != type &&
> (r->flags & mask) != type2 &&
> (r->flags & mask) != type3))
> --
> 2.39.5
>
next prev parent reply other threads:[~2025-08-21 15:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-30 14:26 [PATCH v2 0/3] PCI: Resource fitting algorith fixes Ilpo Järvinen
2025-06-30 14:26 ` [PATCH v2 1/3] PCI: Relaxed tail alignment should never increase min_align Ilpo Järvinen
2025-08-21 15:10 ` Bjorn Helgaas
2025-08-21 15:15 ` Ilpo Järvinen
2025-08-21 15:24 ` Ilpo Järvinen
2025-08-21 15:47 ` Bjorn Helgaas
2025-08-21 16:28 ` Markus Elfring
2025-08-21 16:45 ` Ilpo Järvinen
2025-08-21 17:00 ` Markus Elfring
2025-06-30 14:26 ` [PATCH v2 2/3] PCI: Fix pdev_resources_assignable() disparity Ilpo Järvinen
2025-08-21 15:11 ` Bjorn Helgaas [this message]
2025-08-21 15:21 ` Ilpo Järvinen
2025-06-30 14:26 ` [PATCH v2 3/3] PCI: Fix failure detection during resource resize Ilpo Järvinen
2025-08-21 15:14 ` Bjorn Helgaas
2025-08-21 15:22 ` Ilpo Järvinen
2025-07-23 13:07 ` [PATCH v2 0/3] PCI: Resource fitting algorith fixes Ilpo Järvinen
2025-08-21 14:58 ` Ilpo Järvinen
2025-08-21 15:17 ` 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=20250821151132.GA674480@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=christian.koenig@amd.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=rio@r26.me \
--cc=scott@os.amperecomputing.com \
--cc=stable@vger.kernel.org \
--cc=tudor.ambarus@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.