Re: [RFC PATCH] tools/testing/cxl: Support multi-decoder shared-dport topology
From: Alison Schofield
Date: Thu May 21 2026 - 21:29:43 EST
On Thu, May 21, 2026 at 04:48:06PM +0800, Richard Cheng wrote:
> Add "multi_decoder" module param to the cxl_test emulator. When enabled,
> mock_init_hdm_decoder() addtionally programs decoder X.1 on cxl_mem.0
> and cxl_mem.4 as a second auto-region carved from the next
> mock_auto_region_size of HPA in the same CFMWS window.
> The result is 2 committed switch decoders that share the same
> downstream-port target_map[].
>
> This is inspired by [1] so the emulator can detect and test for scenario
> like that.
>
> [1]: https://lore.kernel.org/all/20260108101324.509667-1-rrichter@xxxxxxx/
> Signed-off-by: Richard Cheng <icheng@xxxxxxxxxx>
> ---
Hi Richard,
Welcome to cxl-test and thanks for the patch and the explanation.
Before we add another module param and hardcoded auto-region, I
want to walk through what's already available and see if it covers
your need.
The fix for `3e8aaacdad4f` ("cxl/port: Fix target list setup for
multiple decoders sharing the same dport") can be duplicated with
the user create region path using cxl-test default topology as is,
and that can be replayed as an auto region.
I've appended a script to demonstrate it. FWIW, I didn't know
this for sure, and was wondering if the auto and user paths might
diverge somewhere in this config, but they didn't. I was able to
watch it fail without Roberts fix, then pass with it applied.
ICYMI there is a test case in cxl-topology.sh that detects the
failure pattern but not a config to verify it like you point
out here.
Your implemenation did make me aware of a gap in the region replay
capability. On real HW, BIOS programs the decoders, then the OS walks
the dports, and update_decoder_targets() is what populates target[]
from target_map[]. But cxl-test bypasses that ordering. In cxl-test,
mock_init_hdm_decoder() writes cxlsd->target[] itself on replay,
which IIUC is why your patch called cxl_port_update_decoder_targets()
from the mock to reach Robert's line. Lifting that call into the mock
unconditionally, so replay goes through the same dport-enumeration
path as real HW would widen what replay actually exercises. I'm not
sure how we get there, but if you'd have interest and time to take
a look at that, patches welcomed.
Does the user-create followed by region replay flow cover your need?
-- Alison