Skip to content

cxl: Introduce devm_cxl_probe_mem() and fix region deletion

Dan Williams linux-cxl 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 17 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5cxl/region: Block region delete during region creationdrivers/cxl/core/port.c drivers/cxl/core/region.c drivers/cxl/cxl.h+13 -52 replies
2/5cxl/region: Resolve region deletion racesdrivers/cxl/core/core.h drivers/cxl/core/port.c drivers/cxl/core/region.c +1 more+44 -272 replies
3/5cxl/memdev: Pin parents for entire memdev lifetimedrivers/cxl/core/memdev.c+3 -12 replies
4/5cxl/memdev: Introduce cxl_class_memdev_typedrivers/cxl/core/memdev.c drivers/cxl/mem.c+47 -142 replies
5/5cxl/region: Introduce devm_cxl_probe_mem()drivers/cxl/core/region.c drivers/cxl/cxlmem.h drivers/cxl/mem.c +3 more+191 -173 replies

Reviews trailers per patch

All 5 patches have a Reviewed-by or Acked-by.

PatchDave JiangAlejandro Lucero
1/5R-b R-b T-b
2/5R-b R-b T-b
3/5R-b R-b T-b
4/5R-b T-b
5/5R-b R-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/5] cxl: Introduce devm_cxl_probe_mem() and fix region deletion

The devm_cxl_probe_mem() helper creates a memdev and retrieves a mapped HPA range for the device. At present the retrieved region information is expected to be established by platform firmware. A future update will auto-establish a region if one is not already present. This arranges for a simple CXL topology detach == Accelerator driver detach scheme.

Now, automatic region establishment on behalf of an accelerator driver also requires automatic region teardown. The existing scheme of triggering devm_release_action() of a cxl root device to destroy a region is racy [1]. There is no path to coordinate multiple devres actions, or conflicting devres actions, without using the devm_remove_action_nowarn() workaround.

Instead, move final region cleanup responsibility to the root decoder teardown path (devres action cxld_unregister()). Expand the root decoder @range_lock, renamed @regions_lock, to coordinate region creation, sysfs manageability, and deletion. The @regions_lock also prevents regions from disappearing mid-auto-assembly.

Changes from the initial RFC [2]:
* tested with Dave's type2 cxl_test
* fix region remove by endpoints (Dave, Alejandro)
* fix user triggered region remove (Sungwoo)
* fix lifetime of the @attach ops (Alison, sashiko)
* hide @attach details inside the CXL core

[1]: http://lore.kernel.org/[email protected]
[2]: http://lore.kernel.org/[email protected]

Dan Williams (5):
cxl/region: Block region delete during region creation cxl/region: Resolve region deletion races cxl/memdev: Pin parents for entire memdev lifetime cxl/memdev: Introduce cxl_class_memdev_type cxl/region: Introduce devm_cxl_probe_mem()

 drivers/cxl/core/core.h      |   2 +
 drivers/cxl/cxl.h            |   8 +-
 drivers/cxl/cxlmem.h         |  27 +++--
 include/cxl/cxl.h            |   3 +
 drivers/cxl/core/memdev.c    |  20 +++-
 drivers/cxl/core/port.c      |   7 +-
 drivers/cxl/core/region.c    | 194 ++++++++++++++++++++++++++++++-----
 drivers/cxl/mem.c            |  95 +++++++++++++----
 drivers/cxl/pci.c            |   2 +-
 tools/testing/cxl/test/mem.c |   2 +-
 10 files changed, 297 insertions(+), 63 deletions(-)

base-commit: 5d6919055dec134de3c40167a490f33c74c12581

Signature · 1 line
2.53.0