[PATCH v4 09/10] PCI: save/restore CXL config around reset

smadhavan
2026-01-20T22:27:18Z

From: Srirangan Madhavan <smadhavan@nvidia.com>

Save PCI and CXL configuration state before cxl_reset and restore it
after reset completes. This preserves DVSEC state alongside standard
PCI state and avoids losing reset-sensitive CXL configuration.

Signed-off-by: Srirangan Madhavan <smadhavan@nvidia.com>
---
drivers/pci/pci.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 18047c893b0c..0bc85c4cc5fd 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4960,6 +4960,7 @@ static int cxl_reset_init(struct pci_dev *dev, u16 dvsec)
*/
static int cxl_reset(struct pci_dev *dev, bool probe)
{
+ struct cxl_type2_saved_state cxl_state;
u16 dvsec, reg;
int rc;

@@ -4989,6 +4990,11 @@ static int cxl_reset(struct pci_dev *dev, bool probe)
if (probe)
return 0;

+ pci_save_state(dev);
+ rc = cxl_config_save_state(dev, &cxl_state);
+ if (rc)
+ pci_warn(dev, "Failed to save CXL config state: %d\n", rc);
+
/*
* CXL-reset-specific preparation: validate memory offline,
* tear down regions, flush device caches.
@@ -5004,10 +5010,16 @@ static int cxl_reset(struct pci_dev *dev, bool probe)
if (rc)
goto out_cleanup;

+ pci_restore_state(dev);
+ rc = cxl_config_restore_state(dev, &cxl_state);
+ if (rc)
+ pci_warn(dev, "Failed to restore CXL config state: %d\n", rc);
+
cxl_reset_cleanup_device(dev);
return 0;

out_cleanup:
+ pci_restore_state(dev);
cxl_reset_cleanup_device(dev);
return rc;
}
--
2.34.1