From: sashiko-bot@kernel.org
To: "Rosen Penev" <rosenp@gmail.com>, linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: Save Root Port state before resetting it with reset_root_port()
Date: Fri, 04 Dec 2026 06:35:52 +0000 [thread overview]
Message-ID: <sashiko-outbox-249234@kernel.org> (raw)
In-Reply-To: <20261204060150.1239223-1-rosenp@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] pci: retry after failed reset_root_port() clobbers saved Root
Port state
--
commit 77ceb3990e3d801d01b81aa8059b11a31337a68a
Author: Rosen Penev <rosenp@gmail.com>
PCI: Save Root Port state before resetting it with reset_root_port()
This commit calls pci_save_state() on the Root Port before invoking
host->reset_root_port() in pcibios_reset_secondary_bus().
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index e2607cc84ff1c..50e8e248058a8 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -5100,6 +5100,12 @@ void __weak pcibios_reset_secondary_bus(struct pci_dev *dev)
> int ret;
>
> if (pci_is_root_bus(dev->bus) && host->reset_root_port) {
> + /*
> + * The state saved when the port was enumerated or probed may
> + * predate changes made since, e.g. memory decoding enabled
> + * once a device below the port was enabled.
> + */
> + pci_save_state(dev);
> ret = host->reset_root_port(host, dev);
> if (ret)
> pci_err(dev, "Failed to reset Root Port: %d\n", ret);
[Severity: Medium]
Can a retry after a failed host->reset_root_port() clobber the Root Port's
saved config space?
When host->reset_root_port() fails, pcibios_reset_secondary_bus() skips
pci_restore_state(). In qcom_pcie_reset_root_port(), if
dw_pcie_wait_for_link() returns -ETIMEDOUT or -EIO after dw_pcie_setup_rc(),
the hardware is left with bare reset defaults such as zeroed bridge windows.
A later reset attempt then calls pci_save_state() and overwrites the valid
saved state with those defaults, so even a successful retry restores broken
state and leaves downstream devices unreachable.
If host->reset_root_port() fails with clocks disabled or reset asserted, as
on error paths in rockchip_pcie_rc_reset_root_port(), a retry's
pci_save_state() also reads unclocked DBI registers, risking an external
abort or bus hang.
Skipping pci_save_state() when a prior reset_root_port() failed would keep
the last valid saved state and avoid touching an unclocked controller.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204060150.1239223-1-rosenp@gmail.com?part=1
prev parent reply other threads:[~2026-12-04 6:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 6:01 [PATCH] PCI: Save Root Port state before resetting it with reset_root_port() Rosen Penev
2026-12-04 6:35 ` sashiko-bot [this message]
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=sashiko-outbox-249234@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=rosenp@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox