Re: [PATCH v17 16/19] PCI/CXL: Expose CXL Reset as a PCI reset method
From: Alison Schofield
Date: Tue Nov 17 2026 - 12:38:13 EST
On Thu, Nov 05, 2026 at 06:59:14PM +0000, Srirangan Madhavan wrote:
> Register cxl_reset with the PCI reset-method interface and place it before
> FLR, which does not reset CXL.cache or CXL.mem protocol state.
Same theme, trying to understand -
Can you clarify when cxl_reset first becomes visible in reset_method
and when it can actually execute? Can userspace initiate reset before
endpoint and region discovery have completed, and is that intentional?
-- Alison
>
> Return -ENOTTY when device capabilities, function scope, cached HDM state,
> or required cache synchronization do not permit a safe reset.
>
> Signed-off-by: Srirangan Madhavan <smadhavan@xxxxxxxxxx>
> Reviewed-by: Richard Cheng <icheng@xxxxxxxxxx>
> ---
> drivers/pci/cxl.c | 12 +++++++++---
> drivers/pci/pci.c | 1 +
> include/linux/pci.h | 2 +-
> 3 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/cxl.c b/drivers/pci/cxl.c
> index 77d0e30841d9..c68b08f7f95b 100644
> --- a/drivers/pci/cxl.c
> +++ b/drivers/pci/cxl.c
> @@ -679,7 +679,7 @@ int cxl_reset_function(struct pci_dev *pdev, bool probe)
>
> rc = cxl_pci_device_dvsec(pdev, &dvsec, &cap);
> if (rc)
> - return rc;
> + return probe ? -ENOTTY : rc;
> if (!(cap & PCI_DVSEC_CXL_CACHE_CAPABLE) ||
> !(cap & PCI_DVSEC_CXL_MEM_CAPABLE) ||
> !(cap & PCI_DVSEC_CXL_RST_CAPABLE) ||
> @@ -688,9 +688,9 @@ int cxl_reset_function(struct pci_dev *pdev, bool probe)
>
> rc = pci_read_config_word(pdev, dvsec + PCI_DVSEC_CXL_CTRL, &ctrl);
> if (rc)
> - return pcibios_err_to_errno(rc);
> + return probe ? -ENOTTY : pcibios_err_to_errno(rc);
> if (PCI_POSSIBLE_ERROR(ctrl))
> - return -ENODEV;
> + return probe ? -ENOTTY : -ENODEV;
> if (!(ctrl & PCI_DVSEC_CXL_CACHE_ENABLE) ||
> !(ctrl & PCI_DVSEC_CXL_MEM_ENABLE))
> return -ENOTTY;
> @@ -710,5 +710,11 @@ int cxl_reset_function(struct pci_dev *pdev, bool probe)
> !IS_ENABLED(CONFIG_CXL_REGION_INVALIDATION_TEST))
> return -ENOTTY;
>
> + /* Raw reset callers may not have saved the PCI state needed for restore. */
> + if (!pdev->state_saved) {
> + pci_err(pdev, "CXL reset requires saved PCI state\n");
> + return -EINVAL;
> + }
> +
> return cxl_reset_execute(pdev, dvsec, cap);
> }
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index aef976d0c850..426b5ee38d04 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -5152,6 +5152,7 @@ const struct pci_reset_fn_method pci_reset_fn_methods[] = {
> { },
> { pci_dev_specific_reset, .name = "device_specific" },
> { pci_dev_acpi_reset, .name = "acpi" },
> + { cxl_reset_function, .name = "cxl_reset" },
> { pcie_reset_flr, .name = "flr" },
> { pci_af_flr, .name = "af_flr" },
> { pci_pm_reset, .name = "pm" },
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 7bb37fcb556d..743b57ff885a 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -52,7 +52,7 @@
> PCI_STATUS_PARITY)
>
> /* Number of reset methods used in pci_reset_fn_methods array in pci.c */
> -#define PCI_NUM_RESET_METHODS 8
> +#define PCI_NUM_RESET_METHODS 9
>
> #define PCI_RESET_PROBE true
> #define PCI_RESET_DO_RESET false
> --
> 2.43.0
>