Linux CXL
 help / color / mirror / Atom feed
* [RFC PATCH 0/4] cxl/memdev: Activate firmware without a reset
@ 2026-11-25 12:43 Unsung Lee
  2026-11-25 12:43 ` [RFC PATCH 1/4] cxl/memdev: Poll for completion of Activate FW Unsung Lee
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Unsung Lee @ 2026-11-25 12:43 UTC (permalink / raw)
  To: linux-cxl
  Cc: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
	Vishal Verma, Ira Weiny, Dan Williams, John Groves

This series lets userspace activate an uploaded slot online once the
device no longer decodes any memory, the same condition sanitize uses.
Uploads keep their current behaviour; activation is a separate,
explicit step:

  1. upload as today (slot N becomes pending for the next cold reset)
  2. move the data away, offline the memory, destroy the region
  3. echo N > /sys/bus/cxl/devices/memX/firmware_activate
  4. recreate the region and online the memory

Patch 1 lets Activate FW complete as a background command; without a
poll budget the mailbox reports a timeout at once.
Patch 2 keeps the pending slot and the activation capability from Get
FW Info.
Patch 3 adds the attribute.
Patch 4 lets cxl_test advertise online activation.

Questions:
- Patch 3 requires that the device decode no memory, as sanitize does.
  The driver cannot tell how long a device holds CXL.mem requests while
  it switches firmware, and the comment on the RAW command block list
  says activation "requires adjustment / coordination of transaction
  timeout values at the root bridge level". With no memory decoded
  nothing can time out. Is that the right condition, or too strict? It
  means moving the data away first.
- The Online FW Activation Capabilities ECN to CXL 3.1 allows Activate
  FW to complete as a background command (8.2.9.3.3), so patch 1 waits
  for it like Transfer FW. Should it carry a Fixes: tag? John Groves
  raised activations longer than the 2 s mailbox timeout at the June
  2025 CXL collab sync; patch 1 may overlap with a patch from that.
- Patch 3 holds cxl_rwsem.region only to check the decoders and set a
  FW state bit that makes decoder commit refuse the device with EBUSY,
  as sanitize does. An earlier version held the rwsem across the
  command (up to 30 s); with an activation emulated in the kernel,
  create-region and region sysfs reads on other devices then waited
  for the whole activation. The cost is that a create-region on this
  device that races the write fails instead of waiting. Is that the
  preferred trade-off?
- After a timeout the device may still be activating, so patch 3 keeps
  refusing regions, uploads and sanitize until the slot shows as
  running or a later activation succeeds. A later error does not count,
  since it may come while the device is still busy. A device that ends
  up on its old firmware stays refused until cxl_pci is bound again.
  Reading the Background Command Status register would end this
  sooner, but needs a new mailbox callback. Would that be acceptable?
- Should the pending slot stay set after an online activation? QEMU
  keeps it, cxl_test clears it.

Not addressed in this series:
- State cached at probe (CEL, timestamp, event interrupt policy,
  features, Identify, CDAT) is not re-read after activation.
- Unbinding the port above the endpoint during the command tears the
  endpoint down, which clears HDM decoder enable and Mem_Enable on the
  activating device (exercised in QEMU without kernel warnings).

Testing (QEMU 11.1.3, one type3 device, guest v7.3.1 unless noted; no
real hardware, so an activation that really takes long, polling while
it runs, other hosts and other CCIs are not covered):
- Functional and race tests (concurrent writes, upload, create-region,
  cxl_mem and cxl_pci unbind, mailbox readers, kill -9, sanitize,
  upload cancel) on release and lockdep/KASAN kernels, 20-50x: no
  warnings; kprobes showed no activation while a decoder was committed
  and no commit while activating.
- A test-only build emulating slow and timed-out activations, release
  and debug, 20x each: refusal during and after a timeout; a failed
  activation after a timeout stays refused, with uploads and sanitize,
  until cxl_pci is bound again; a cxl_mem unbind waits for the command;
  a port unbind during the command. Create-region failing after the
  port is bound again also happens on plain v7.3.1, so that test does
  not check regions afterwards.
- The whole flow (move the data away, offline, activate, online, move
  it back): 100x without data; 20x with a process rewriting 2 GB on
  the device's node (longest write stall 78 ms, in QEMU only); through
  a maintenance script, deferring when there is no room (10x), rolling
  back when room runs out (20x), and SIGINT/SIGTERM/SIGKILL at each step
  (60x); and these mixed for 4 hours (1,462 iterations). No failures,
  and the data was intact after every iteration.
- cxl/next 32af781935: applies cleanly, no W=1 warnings; QEMU gets no
  root decoder there (CFMWS with both HDM-H and HDM-DB, rejected since
  e4c3f0d966), so only the tests without a region ran (all passing).

I designed the change and directed the work. An LLM coding assistant
(Claude Code) wrote parts of the code, the changelogs and the test
harness at my direction, and was used to review the code and run the
tests. I reviewed every line of the series and take responsibility for
it.

Unsung Lee (4):
  cxl/memdev: Poll for completion of Activate FW
  cxl/memdev: Keep pending slot and activation capabilities from Get FW
    Info
  cxl/memdev: Add firmware_activate to activate firmware without a reset
  tools/testing/cxl: Add a knob to advertise online FW activation

 Documentation/ABI/testing/sysfs-bus-cxl |  45 +++++
 drivers/cxl/core/hdm.c                  |   7 +
 drivers/cxl/core/mbox.c                 |   5 +
 drivers/cxl/core/memdev.c               | 209 +++++++++++++++++++++++-
 drivers/cxl/cxlmem.h                    |   8 +
 tools/testing/cxl/test/mem.c            |   8 +-
 6 files changed, 274 insertions(+), 8 deletions(-)


base-commit: 32af7819352bae9c690ebe277a44eceb501d5c68
-- 
2.34.1


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

end of thread, other threads:[~2026-11-25 12:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 12:43 [RFC PATCH 0/4] cxl/memdev: Activate firmware without a reset Unsung Lee
2026-11-25 12:43 ` [RFC PATCH 1/4] cxl/memdev: Poll for completion of Activate FW Unsung Lee
2026-11-25 12:43 ` [RFC PATCH 2/4] cxl/memdev: Keep pending slot and activation capabilities from Get FW Info Unsung Lee
2026-11-25 12:43 ` [RFC PATCH 3/4] cxl/memdev: Add firmware_activate to activate firmware without a reset Unsung Lee
2026-11-25 12:57   ` sashiko-bot
2026-11-25 12:43 ` [RFC PATCH 4/4] tools/testing/cxl: Add a knob to advertise online FW activation Unsung Lee
2026-11-25 12:53 ` [RFC PATCH 0/4] cxl/memdev: Activate firmware without a reset Unsung Lee

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