All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v8 0/3] Support zero-sized HDM decoders
@ 2026-07-31  6:48 Richard Cheng
  2026-07-31  6:49 ` [PATCH v8 1/3] cxl/region: Simplify poison_by_decoder() error handling Richard Cheng
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Richard Cheng @ 2026-07-31  6:48 UTC (permalink / raw)
  To: jic23, dave, dave.jiang, vishal.l.verma, djbw, danwilliams,
	alison.schofield
  Cc: iweiny, ming.li, linux-cxl, linux-kernel, newtonl, kristinc,
	kaihengf, kobak, vaslot, mochs, Richard Cheng

CXL r4.0 §8.2.4.20.12 ("Committing Decoder Programming") and
§14.13.10 ("CXL HDM Decoder Zero Size Commit") permit committing an
HDM decoder with size 0. Firmware may commit and lock such decoders so
the OS cannot program regions through them; this is a platform design
choice rather than a specification requirement.

The kernel currently rejects these decoders with -ENXIO during port
enumeration and aborts enumeration of the entire port. On affected
systems, this prevents the CXL topology from appearing in userspace.

This series enumerates empty committed decoders into the topology while
keeping them out of region assembly.

Patch 1 is a preparatory cleanup with no functional change. In
poison_by_decoder(), "rc" carries both an error code and the loop
control signal for device_for_each_child(), so returning it bare is
misleading, the early guards mean "keep walking", not "no error".
Zeroing "rc" to forgive an -EFAULT on a RAM partition adds to that by
discarding what the device actually returned. Return a literal 0 where
the walk should continue, and test the forgiven case directly instead
of rewriting "rc". Patch 2 extends this function, so cleaning it up
first keeps the functional change free of unrelated churn.

Patch 2 makes zero-size DPA reservations first-class. Since the resource
tree cannot represent an empty range, an empty decoder is backed by a
separately allocated resource. This keeps port->hdm_end, skip handling,
and in-order DPA accounting consistent. Operations requiring non-empty
capacity, including region attachment and poison queries, are guarded
appropriately.

Patch 3 adds the mock_zero_size_decoders cxl_test module parameter,
disabled by default. When enabled, it installs committed, locked,
zero-sized endpoint, switch, and host-bridge decoders under
host-bridge0.

Tested on arm64 with cxl_test and the ndctl unit suite (ndctl
v85), on a kernel built with KASAN and lockdep enabled.

Full cxl suite with mock_zero_size_decoders off -- no failures:
"""
$ sudo env "PATH=$PATH" meson test -C build --suite cxl \
    --num-processes 1 -t 6 --print-errorlogs
 1/16 ndctl:cxl / cxl-topology.sh       OK                7.81s
 2/16 ndctl:cxl / cxl-region-sysfs.sh   OK                5.28s
 3/16 ndctl:cxl / cxl-labels.sh         OK                3.27s
 4/16 ndctl:cxl / cxl-create-region.sh  OK               10.70s
 5/16 ndctl:cxl / cxl-xor-region.sh     OK                5.76s
 6/16 ndctl:cxl / cxl-events.sh         OK                2.77s
 7/16 ndctl:cxl / cxl-sanitize.sh       OK                5.73s
 8/16 ndctl:cxl / cxl-destroy-region.sh OK                4.16s
 9/16 ndctl:cxl / cxl-qos-class.sh      OK                3.25s
10/16 ndctl:cxl / cxl-translate.sh      OK                0.94s
11/16 ndctl:cxl / cxl-elc.sh            OK                4.21s
12/16 ndctl:cxl / cxl-dax-hmem.sh       OK                4.56s
13/16 ndctl:cxl / cxl-region-replay.sh  OK                8.66s
14/16 ndctl:cxl / cxl-security.sh       SKIP              0.02s
15/16 ndctl:cxl / cxl-features.sh       OK                1.42s
16/16 ndctl:cxl / cxl-poison.sh         SKIP             11.23s

Ok:                 14
Expected Fail:      0
Fail:               0
Unexpected Pass:    0
Skipped:            2
Timeout:            0
"""

The subset Alison asked about:
"""
1/6 ndctl:cxl / cxl-region-sysfs.sh   OK                5.28s
2/6 ndctl:cxl / cxl-create-region.sh  OK               10.04s
3/6 ndctl:cxl / cxl-xor-region.sh     OK                5.67s
4/6 ndctl:cxl / cxl-destroy-region.sh OK                3.77s
5/6 ndctl:cxl / cxl-qos-class.sh      OK                3.22s
6/6 ndctl:cxl / cxl-poison.sh         SKIP             11.52s

Ok:                 5
Expected Fail:      0
Fail:               0
Unexpected Pass:    0
Skipped:            1
Timeout:            0
"""

With mock_zero_size_decoders=1 the topology enumerates with no -ENXIO:
11 memdevs, and eight committed locked zero-size decoders. Two sit on
each host-bridge0 endpoint (decoder16.1, decoder16.2, decoder19.1 and
decoder19.2), each with dpa_size=0x0, that is a real zero-size DPA
reservation rather than a bypassed one, mirrored on the parent switch
and host bridge (decoder1.1, decoder1.2, decoder11.1, decoder11.2).

Poison by memdev by DPA on a host-bridge0 endpoint returns all four
injected records and clears back to zero. Teardown, and three module
reload and unload cycles with the empty decoders live, produce no KASAN,
lockdep or WARN output.

The core patch was also validated on a Montage CXL Type 3 device.

The corresponding ndctl test is attached at
https://lore.kernel.org/linux-cxl/20260709022857.18732-1-icheng@nvidia.com/

Changelog:

v7->v8:
- Split the poison_by_decoder() readability cleanup out of the core
  patch into a new preparatory patch 1.
- cxl_dpa_request_region(): split the declaration from the allocation
  so the allocation and its error check sit together.
- Add the missing blank line between commit message paragraphs in
  patch 2.
- Patch 3 is unchanged.

v6->v7:
- Rebase onto cxl/for-7.3/cxl-type2-test.
- Patch 1 is unchanged.
- Adapt patch 2 to the refactored Type-2/Type-3 decoder initialization
  paths.
- Integrate mock_zero_size_decoders with special-topology parameter
  validation and reject its incompatible use with fail_autoassemble.

Richard Cheng (3):
  cxl/region: Simplify poison_by_decoder() error handling
  cxl/hdm: Allow zero sized HDM decoders
  tools/testing/cxl: Enable zero sized decoders under hb0

 drivers/cxl/core/hdm.c       |  55 ++++++++++++------
 drivers/cxl/core/mbox.c      |   3 +
 drivers/cxl/core/region.c    |  57 ++++++++++--------
 drivers/cxl/cxl.h            |  10 ++++
 drivers/cxl/port.c           |   3 +
 tools/testing/cxl/test/cxl.c | 109 ++++++++++++++++++++++++++++++-----
 6 files changed, 182 insertions(+), 55 deletions(-)


base-commit: 1c6b4ceafc3b994871c29340e0c1ddb0af5800e7
-- 
2.43.0


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

end of thread, other threads:[~2026-07-31  7:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-31  6:48 [PATCH v8 0/3] Support zero-sized HDM decoders Richard Cheng
2026-07-31  6:49 ` [PATCH v8 1/3] cxl/region: Simplify poison_by_decoder() error handling Richard Cheng
2026-07-31  7:04   ` sashiko-bot
2026-07-31  6:49 ` [PATCH v8 2/3] cxl/hdm: Allow zero sized HDM decoders Richard Cheng
2026-07-31  7:01   ` sashiko-bot
2026-07-31  6:49 ` [PATCH v8 3/3] tools/testing/cxl: Enable zero sized decoders under hb0 Richard Cheng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.