Linux PCI subsystem development
 help / color / mirror / Atom feed
* [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

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