From: sashiko-bot@kernel.org
To: "Liz Fong-Jones" <lizf@honeycomb.io>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v5] PCI: Fix BAR resize for devices on a root bus
Date: Tue, 08 Sep 2026 23:13:48 +0000 [thread overview]
Message-ID: <20260908231349.682101F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908-pci-rebar-root-bus-v5-1-a210f405ea81@honeycomb.io>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Stricter resource assignment check on root bus fails BAR resize if optional resources (like ROM BARs) cannot be assigned.
Pre-existing issues:
- [High] Space stolen by other devices during resource assignment breaks the rollback in the `restore` path.
--
commit 72e60fcada94a7186e28648f6c748fdfeb09e254
Author: Liz Fong-Jones <lizf@honeycomb.io>
PCI: Fix BAR resize for devices on a root bus
pci_do_resource_release_and_resize() releases the device BARs that share a
bridge window with the BAR being resized, but when the device sits directly on
a root bus it skips resource assignment and leaves the BARs unassigned.
When there is no upstream bridge, this patch calls pci_bus_assign_resources()
on the root bus to place the released BARs. A stricter validation is then used
to fail if any unplaced resources remain.
Link: https://bugs.launchpad.net/ubuntu/+source/linux-hwe-7.0/+bug/2159596
> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> index e8c94aa1d3c12..ed16ef7c26fa7 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
[ ... ]
> @@ -2415,13 +2418,21 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int size
>
> pci_resize_resource_set_size(pdev, resno, size);
>
> - if (!bus->self)
> - goto out;
> + if (bridge) {
> + ret = pbus_reassign_bridge_resources(bus, res, &saved);
> + if (ret)
> + goto restore;
> + } else {
> + /* No bridge window to adjust; let the core reassign the bus. */
> + pci_bus_assign_resources(bus);
>
> - down_read(&pci_bus_sem);
> - ret = pbus_reassign_bridge_resources(bus, res, &saved);
> - if (ret)
> - goto restore;
> + list_for_each_entry(dev_res, &saved, list) {
> + if (!resource_assigned(dev_res->res)) {
> + ret = -ENOSPC;
> + goto restore;
^^^^^^^^^^^^
[Severity: High]
This isn't a bug introduced by this patch, but does jumping to the restore
path risk leaving the device unassigned if the original resource space was
stolen?
If another device on the same bus is assigned into the space just freed by the
target device during pci_bus_assign_resources(), the restore path in
pci_do_resource_release_and_resize() will fail to claim it back:
list_for_each_entry(dev_res, &saved, list) {
...
if (pci_claim_resource(dev, i))
continue;
...
}
Since pci_claim_resource() fails when the space is occupied, could the device
be left with unassigned BARs and completely broken?
> + }
[Severity: High]
Does this stricter check unintentionally fail the BAR resize if an optional
resource (like a ROM BAR) could not be assigned?
If a driver requests a BAR resize and pci_bus_assign_resources() succeeds for
the resized BAR but leaves an optional ROM BAR unassigned, the check for
!resource_assigned(dev_res->res) will trigger a rollback with -ENOSPC.
Could this functionally break valid BAR resizes on root buses just because an
optional resource was unassigned?
> + }
> + }
>
> out:
> up_read(&pci_bus_sem);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260908-pci-rebar-root-bus-v5-1-a210f405ea81@honeycomb.io?part=1
next prev parent reply other threads:[~2026-09-08 23:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 23:03 [PATCH v5] PCI: Fix BAR resize for devices on a root bus Liz Fong-Jones
2026-09-08 23:13 ` sashiko-bot [this message]
2026-09-08 23:25 ` Liz Fong-Jones
2026-09-09 10:17 ` Ilpo Järvinen
2026-09-10 16:23 ` Liz Fong-Jones
2026-09-10 16:23 ` Liz Fong-Jones
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=20260908231349.682101F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lizf@honeycomb.io \
--cc=sashiko-reviews@lists.linux.dev \
/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.