mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v13 00/15] PCI/CXL: Add CXL reset support for Type 2 devices
@ 2026-09-22  8:39 Srirangan Madhavan
  2026-09-22  8:39 ` [PATCH v13 01/15] cxl: Drop stale decoder interleave limit comment Srirangan Madhavan
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: Srirangan Madhavan @ 2026-09-22  8:39 UTC (permalink / raw)
  To: Alison Schofield, Bjorn Helgaas, Dave Jiang, Davidlohr Bueso,
	Ira Weiny, Jonathan Cameron, Vishal Verma, linux-cxl, linux-pci,
	linux-kernel
  Cc: Alex Williamson, vsethi, alwilliamson,
	Sai Yashwanth Reddy Kancherla, Vishal Aslot, Manish Honap,
	Jiandi An, Richard Cheng, linux-tegra, Srirangan Madhavan

Hi folks!

This series adds CXL Reset support for CXL Type 2 devices through the
existing PCI reset_method ABI. The reset sequence follows the CXL 4.0
specification [1], including CXL.cache disable, optional cache
writeback, CXL Reset Memory Clear, ResetComplete polling, and ResetError
reporting.

The userspace ABI is the existing PCI reset interface:

    /sys/bus/pci/devices/.../reset_method
    /sys/bus/pci/devices/.../reset

Userspace can select "cxl_reset" in reset_method and then trigger reset
through the existing reset attribute.

CXL Reset is exposed conservatively. The target must be a
single-function CXL Type 2 device with no enabled VFs, CXL.cache and
CXL.mem must be enabled, and CXL Reset Memory Clear must be supported.
The kernel must also have cached HDM state sufficient to validate
affected ranges and restore decoder programming.

For reset through the sysfs reset attribute, the generic PCI path calls
the driver's reset_prepare() callback when provided and disables PCI I/O,
memory decoding, and bus mastering. The CXL reset path then temporarily
reserves each affected HDM range exclusively for the duration of the
reset, synchronizes CPU and device caches, and blocks IOMMU translations
where applicable. It restores HDM decoder state and the CXL Device DVSEC
Control register before PCI operation resumes. The path does not offline
memory or revoke mappings; it relies on CXL.mem users retaining
conflicting iomem resources while access remains active.

Following Dan's v6 feedback, this uses the existing PCI reset_method
interface instead of adding a memdev-specific sysfs ABI.

v13 changes from v12 [2]:
- Split HDM helper movement from semantic changes. Patches 1--7 now
  separate the stale-comment cleanup, shared port lookup, pure code
  movement, declaration movement, settings abstraction, build changes,
  and register unpacking.
- Make cxl_commit_start() and the low-level settings writer void, and
  keep fallible commit polling separate.
- Rename the shared register parser to cxl_hdm_unpack_decoder(), build
  all values in locals, and publish a complete settings object only
  after validation succeeds. Committed and locked state are represented
  with the other decoder flags.
- Store exactly the detected number of decoder settings in a flexible
  array. Discover and validate the Register Locator BAR and offset
  directly, avoiding the resource-to-BAR round trip.
- Move CXL_RESET out of the CXL_BUS dependency block so built-in PCI
  reset support remains valid when cxl_core is modular.
- Simplify DVSEC Control2 command handling, clear Memory Clear on every
  post-programming exit, and perform a final WBI status read at the
  timeout boundary.
- Abort when IOMMU reset preparation fails. Require CPU cache
  invalidation for active HDM ranges and invalidate both before reset
  and after state restoration while the ranges remain reserved.
- Make restoration fail fast. Stop at the first mapping, decoder,
  DVSEC, PCI command, or state-save failure and retain a disabled PCI
  command state on post-reset failure.
- Restore the complete cached CXL Device DVSEC Control register rather
  than only Cache_Enable and Mem_Enable.
- Drop the method-specific reset_method ABI text; the existing ABI file
  does not document individual PCI reset methods.
- Retain the v12 Type 2 eligibility policy. The questions about
  CXL.mem-only devices and Type 2 devices with CXL.cache disabled are
  left for follow-up discussion rather than expanding this series.
- Retain the existing bus/cxl_bus method priority and carry forward the
  v12 CXL state restoration after cxl_bus reset.

Patch overview:

Patch 1 removes the stale interleave-limit comment in isolation.

Patch 2 factors the referenced upstream PCI-device lookup out of the
existing CDAT path before the HDM cache becomes its second user.

Patch 3 mechanically moves HDM programming helpers to resource.c.

Patch 4 mechanically moves shared decoder declarations to include/cxl/.

Patch 5 introduces the reusable decoder-settings snapshot and separates
infallible programming from fallible commit polling.

Patch 6 makes reset helpers available to built-in PCI code with modular
cxl_core configurations.

Patch 7 shares transactional HDM register unpacking between normal CXL
enumeration and early PCI discovery.

Patch 8 refreshes cached PCI HDM settings as CXL decoder state changes.

Patch 9 caches endpoint HDM and DVSEC state during PCI enumeration using
direct BAR-relative Register Locator metadata.

Patch 10 implements the CXL Device Reset sequence and its Control2
cleanup and timeout handling.

Patch 11 reserves active HDM ranges and performs mandatory pre-reset and
post-restore CPU cache invalidation.

Patch 12 rejects reset where function scope is unsafe, including
multifunction devices and PFs with enabled VFs.

Patch 13 restores cached global and per-decoder HDM state, decoder locks,
and the complete CXL Device DVSEC Control register with fail-closed error
handling.

Patch 14 exposes cxl_reset through the PCI reset-method table ahead of
FLR.

Patch 15 restores cached CXL state after cxl_bus reset while its existing
IOMMU exclusion remains active.

The CXL.cache/CXL.mem eligibility requirements are intentionally
unchanged from v12. I would appreciate clarification on whether support
for CXL.mem-only devices, or Type 2 devices whose CXL.cache protocol is
disabled by platform policy, should be handled as a separate follow-up.

Testing:
- Built `vmlinux` and modules with `W=1` on the
  for-7.4/cxl-zero-size-decoder topic tip.
- The corresponding v13 reset paths were built and boot-tested on an
  arm64 NVIDIA system, including CXL Reset and cxl_bus restoration.

References:
[1] https://computeexpresslink.org/wp-content/uploads/2026/02/CXL-Specification_rev4p0_ver1p0_2026February26_clean_evalcopy_v2.pdf
[2] https://lore.kernel.org/linux-cxl/20260910070808.1444264-1-smadhavan@nvidia.com/

Srirangan Madhavan (15):
  cxl: Drop stale decoder interleave limit comment
  cxl: Share CXL port upstream PCI device lookup
  cxl: Move HDM decoder programming helpers
  cxl: Move decoder declarations to shared header
  cxl: Introduce reusable HDM decoder settings
  cxl: Make HDM reset helpers available to built-in PCI code
  cxl: Share HDM decoder register unpacking
  cxl: Refresh cached PCI HDM decoder settings
  cxl: Cache endpoint HDM state during PCI enumeration
  cxl: Add CXL Device Reset sequencing
  cxl: Validate and synchronize HDM ranges around reset
  PCI/CXL: Reject reset with unsafe function scope
  cxl: Restore CXL state after PCI reset
  PCI/CXL: Expose CXL Reset as a PCI reset method
  PCI/CXL: Restore CXL state after CXL bus reset

 drivers/cxl/Kconfig           |    4 +
 drivers/cxl/core/Makefile     |    2 +-
 drivers/cxl/core/core.h       |    8 +
 drivers/cxl/core/hdm.c        |  241 ++++----
 drivers/cxl/core/pci.c        |   38 +-
 drivers/cxl/core/port.c       |   26 +
 drivers/cxl/core/regs.c       |    9 +
 drivers/cxl/core/resource.c   | 1280 +++++++++++++++++++++++++++++++++++++++++
 drivers/cxl/cxl.h             |   41 --
 drivers/pci/bus.c             |    2 +
 drivers/pci/pci.c             |   13 +
 drivers/pci/probe.c           |    2 +
 include/cxl/cxl.h             |  121 +++-
 include/linux/pci.h           |    8 +-
 include/uapi/linux/pci_regs.h |   14 +
 tools/testing/cxl/Kbuild      |    1 -
 16 files changed, 1614 insertions(+), 196 deletions(-)
 create mode 100644 drivers/cxl/core/resource.c


base-commit: fef22d37d47043b63e4007f2f5fe762fa21fae0c
-- 
2.43.0

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2026-09-22  8:40 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-22  8:39 [PATCH v13 00/15] PCI/CXL: Add CXL reset support for Type 2 devices Srirangan Madhavan
2026-09-22  8:39 ` [PATCH v13 01/15] cxl: Drop stale decoder interleave limit comment Srirangan Madhavan
2026-09-22  8:39 ` [PATCH v13 02/15] cxl: Share CXL port upstream PCI device lookup Srirangan Madhavan
2026-09-22  8:39 ` [PATCH v13 03/15] cxl: Move HDM decoder programming helpers Srirangan Madhavan
2026-09-22  8:39 ` [PATCH v13 04/15] cxl: Move decoder declarations to shared header Srirangan Madhavan
2026-09-22  8:39 ` [PATCH v13 05/15] cxl: Introduce reusable HDM decoder settings Srirangan Madhavan
2026-09-22  8:39 ` [PATCH v13 06/15] cxl: Make HDM reset helpers available to built-in PCI code Srirangan Madhavan
2026-09-22  8:39 ` [PATCH v13 07/15] cxl: Share HDM decoder register unpacking Srirangan Madhavan
2026-09-22  8:39 ` [PATCH v13 08/15] cxl: Refresh cached PCI HDM decoder settings Srirangan Madhavan
2026-09-22  8:39 ` [PATCH v13 09/15] cxl: Cache endpoint HDM state during PCI enumeration Srirangan Madhavan
2026-09-22  8:39 ` [PATCH v13 10/15] cxl: Add CXL Device Reset sequencing Srirangan Madhavan
2026-09-22  8:39 ` [PATCH v13 11/15] cxl: Validate and synchronize HDM ranges around reset Srirangan Madhavan
2026-09-22  8:39 ` [PATCH v13 12/15] PCI/CXL: Reject reset with unsafe function scope Srirangan Madhavan
2026-09-22  8:39 ` [PATCH v13 13/15] cxl: Restore CXL state after PCI reset Srirangan Madhavan
2026-09-22  8:39 ` [PATCH v13 14/15] PCI/CXL: Expose CXL Reset as a PCI reset method Srirangan Madhavan
2026-09-22  8:39 ` [PATCH v13 15/15] PCI/CXL: Restore CXL state after CXL bus reset Srirangan Madhavan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®