* [PATCH] PCI: Save Root Port state before resetting it with reset_root_port()
@ 2026-12-04 6:01 Rosen Penev
2026-12-04 6:35 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-12-04 6:01 UTC (permalink / raw)
To: linux-pci; +Cc: Bjorn Helgaas, Manivannan Sadhasivam, Frank Li
pcibios_reset_secondary_bus() restores the Root Port's config space after
host->reset_root_port(), but doesn't save it first, so it restores
whatever was saved last. For a Root Port that is the state saved when
portdrv probed it, before a device below it was enabled, which turns
memory decoding and bus mastering of the port off again: a function
reset of the device through its parent bus (e.g. pci_reset_function()
on a device whose only reset method is "bus") leaves the device
unreachable.
Save the Root Port's state right before resetting it.
Fixes: 3fc686d550f6 ("PCI/ERR: Add support for resetting the Root Ports in a platform-specific way")
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/pci/pci.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index e2607cc84ff1..50e8e248058a 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);
--
2.56.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] PCI: Save Root Port state before resetting it with reset_root_port()
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
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-04 6:35 UTC (permalink / raw)
To: Rosen Penev, linux-pci
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-04 6:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox