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

Dave Jiang
2026-01-21T22:32:33Z

On 1/20/26 3:26 PM, smadhavan@nvidia.com wrote:
> 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.

Instead of putting dependency on the cxl core, maybe just move the code in the previous patch here since it's just a few lines of config read/writes. But an explanation of why the DVSEC needs to be preserved on the device regardless of whether a driver is present is needed in the commit log.

DJ

>
> 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
>