mbox series

[v2,0/2] Add CXL Reset Support for CXL Devices

Message ID 20250221043906.1593189-1-smadhavan@nvidia.com
Headers show
Series Add CXL Reset Support for CXL Devices | expand

Message

Srirangan Madhavan Feb. 21, 2025, 4:39 a.m. UTC
This patch series introduces support for the CXL Reset method
for CXL devices, implementing the reset procedure outlined in
CXL Spec [1] v3.2, Sections 9.6 and 9.7.

v2 changes:
- de-duplicate CXL DVSEC register defines under include/cxl/pci.h
- fix style related issues.

v1 changes:
- Added cover letter and dropped the RFC.

The RFC patche can be found here [2]

Motivation:
-----------
This change is broadly useful for reasons including but not limited to the
following:
- As support for Type 2 devices [3] is being introduced, more devices will
  require finer-grained reset mechanisms beyond bus-wide reset methods.
- FLR does not affect CXL.cache or CXL.mem protocols, making CXL Reset
  the preferred method in some cases.
- The CXL spec (Sections 7.2.3 Binding and Unbinding, 9.5 FLR) highlights use
  cases like function rebinding and error recovery, where CXL Reset is
  explicitly mentioned.

Change Description:
-------------------
The patch implements the required steps for CXL reset and introduces a new reset
method in the pci_reset_fn_methods. It also defines the necessary CXL DVSEC
register macros. The actual steps for rest are broadly: disable cache lines and
asserts WB+I, wait for cache and memory clear signals, initial reset, wait for
complete and return status.

Command line to test the CXL reset on a capable device:
    echo cxl_reset > /sys/bus/pci/devices/<pci_device>/reset_method
    echo 1 > /sys/bus/pci/devices/<pci_device>/reset

[1] https://computeexpresslink.org/cxl-specification/
[2] https://lore.kernel.org/all/20241213074143.374-1-smadhavan@nvidia.com/
[3] https://lore.kernel.org/linux-cxl/20241216161042.42108-1-alejandro.lucero-palau@amd.com/

Srirangan Madhavan (2):
  cxl: de-duplicate cxl DVSEC reg defines
  cxl: add support for cxl reset

 drivers/cxl/core/pci.c        |   1 +
 drivers/cxl/core/regs.c       |   1 +
 drivers/cxl/cxlpci.h          |  53 -----------
 drivers/cxl/pci.c             |   1 +
 drivers/pci/pci.c             | 163 ++++++++++++++++++++++++++++++++--
 include/cxl/pci.h             |  76 ++++++++++++++++
 include/linux/pci.h           |   2 +-
 include/uapi/linux/pci_regs.h |   5 --
 8 files changed, 235 insertions(+), 67 deletions(-)
 create mode 100644 include/cxl/pci.h