Skip to content

RFC cxl: Auto-create a region for Type-2 memdev attach

Richard Cheng linux-cxl lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest3 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3cxl/region: Reset software-created regions on memdev detachdrivers/cxl/core/region.c+91 -210 replies
2/3cxl/region: Auto-create a region for memdev attachdrivers/cxl/core/region.c+284 -281 reply
3/3cxl/test: Exercise Type-2 automatic region creationtools/testing/cxl/test/accel.c tools/testing/cxl/test/cxl.c+65 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/3] cxl: Auto-create a region for Type-2 memdev attach

A Type-2 accelerator driver calls devm_cxl_probe_mem() to register its memdev and get an HPA range, but today only if FW already committed a region. Real accelerators can have usable memory with no committed decoder, so get nothing.

If no FW region is mapped, the core picks the device's unused manual DEVMEM decoder and a compatible x1 Type-2 RAM root, allocates the full volatile DPA and HPA, commits the decoder, and returns the range. Unbind resets and removes it. Strict first cut with single decoder, IW=1, minimum granularity, first-compatible root.

The design intent is that the provider F_LOCKs its region against userspace but must reset its own software region on detach. A plain flag would also allow reset on generic kill/delete paths, so we thread a reset context through teardown and commit rollback. devm_cxl_probe_mem() may now commit decoders.

Testing result is in the following.
- Built clean with clang/LLVM on arm64
- cxl_test, type2_test=1. accel0 takes the unchanged attach path. accel1 drives auto_create -> a committed 512 MB RAM region. The test asserts the 512 MB HPA range. committed state and 256 byte granularity confirmed via sysfs.
- Unbind tears the region down with no orphaned decoder, rebind re-creates a fresh committed region.
- Mock test only. Real accelerators whose FW commits a decoder take the attach path, and vfio-cxl binds only FW-committed devices, so auto-create has no real-HW caller yet.

Best regards,
Richard Cheng.

Richard Cheng (3):
cxl/region: Reset software-created regions on memdev detach cxl/region: Auto-create a region for memdev attach cxl/test: Exercise Type-2 automatic region creation

 drivers/cxl/core/region.c      | 422 +++++++++++++++++++++++++++++----
 tools/testing/cxl/test/accel.c |   7 +
 tools/testing/cxl/test/cxl.c   |  61 ++++-
 3 files changed, 439 insertions(+), 51 deletions(-)

base-commit: 1c6b4ceafc3b994871c29340e0c1ddb0af5800e7

Signature · 1 line
2.43.0