mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH v2 0/3] cxl: Provide explicit RAM region creation for Type-2 providers
@ 2026-10-07  9:05 Richard Cheng
  2026-10-07  9:05 ` [RFC PATCH v2 1/3] cxl/mem: Separate provider registration from region attachment Richard Cheng
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Richard Cheng @ 2026-10-07  9:05 UTC (permalink / raw)
  To: jic23, dave, dave.jiang, alison.schofield, vishal.l.verma,
	iweiny, ming.li, icheng
  Cc: kaihengf, kobak, newtonl, kristinc, linux-cxl, linux-kernel

A Type-2 provider uses devm_cxl_probe_mem() to register its memdev
and obtain an HPA range. This requires an existing committed region,
so registration fails when firmware has not configured one.

Firmware may provide a suitable CFMWS window without programming a
region. Hot-added devices can have the same requirement. A provider
needs its endpoint topology established before deciding when to
create a region and how much memory to map.

V1 created a region implicitly during attachment and allocated the
device's full volatile capacity. Following the review discussion,
v2 separates registration, region creation, and attachment:

- devm_cxl_register_mem() registers a provider-owned memdev without
  requiring a committed region.
- devm_cxl_create_ram_region() explicitly creates a RAM region of
  the caller-selected size.
- devm_cxl_attach_mem_region() obtains the HPA range of an existing
  committed region.

The existing devm_cxl_probe_mem() interface retains its behavior.
Providers can attach to a firmware-configured region or explicitly
request creation after registration.

The creation helper reuses core DPA/HPA allocation, decoder setup,
and commit handling. Failures unwind the new allocations, and
managed teardown resets software-created mappings before releasing
their DPA.

This RFC supports single-target RAM regions with IW=1 and sizes
that are multiples of 256 MiB. It requires a compatible CFMWS window
and a programmable endpoint decoder. Persistent memory, normalized
addressing, and extended linear cache support are outside this
initial implementation.

The mock retains the firmware-configured accelerator on the original
API and adds an unconfigured accelerator using the new APIs. The
second accelerator requests 256 MiB from its 512 MiB capacity and
checks the returned HPA range. It is the caller of the new API in
this RFC; no real hardware provider is converted.

Changes since v1:
- Separate provider registration from region attachment.
- Replace implicit creation with an explicit, caller-sized RAM API.
- Use existing AUTO/LOCK flags instead of reset-context plumbing.
- Reset non-AUTO regions, including user-created regions under FIXED
  windows, while continuing to honor hardware decoder locks.
- Serialize creation against sysfs decoder configuration.
- Retry another compatible window on HPA exhaustion (-ERANGE).
- Use explicit locking and reference cleanup in the goto unwind path.
- Update the mock for the new APIs, partial-capacity allocation, and
  MANUAL DEVMEM preservation after failed saved-state restoration.



Best regards,
Richard Cheng

Richard Cheng (3):
  cxl/mem: Separate provider registration from region attachment
  cxl/mem: Add explicit RAM region creation for providers
  cxl/test: Exercise explicit Type-2 RAM region creation

 drivers/cxl/core/port.c        |   6 +
 drivers/cxl/core/region.c      | 367 ++++++++++++++++++++++++++++-----
 drivers/cxl/cxlmem.h           |  29 ++-
 drivers/cxl/mem.c              | 100 ++++++++-
 include/cxl/cxl.h              |   3 +
 tools/testing/cxl/test/accel.c |  28 ++-
 tools/testing/cxl/test/cxl.c   |  47 ++++-
 7 files changed, 518 insertions(+), 62 deletions(-)


base-commit: f2e9991100c903ec2d8eb62c3a1d6e0b9c67432e
-- 
2.43.0


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

end of thread, other threads:[~2026-10-07  9:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-07  9:05 [RFC PATCH v2 0/3] cxl: Provide explicit RAM region creation for Type-2 providers Richard Cheng
2026-10-07  9:05 ` [RFC PATCH v2 1/3] cxl/mem: Separate provider registration from region attachment Richard Cheng
2026-10-07  9:05 ` [RFC PATCH v2 2/3] cxl/mem: Add explicit RAM region creation for providers Richard Cheng
2026-10-07  9:05 ` [RFC PATCH v2 3/3] cxl/test: Exercise explicit Type-2 RAM region creation Richard Cheng

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®