]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tools/testing/cxl: Resolve auto-region decoder targets like real HW
authorRichard Cheng <icheng@nvidia.com>
Fri, 12 Jun 2026 01:12:27 +0000 (09:12 +0800)
committerDave Jiang <dave.jiang@intel.com>
Fri, 12 Jun 2026 15:14:46 +0000 (08:14 -0700)
The mock auto-region created at module load wrote switch and host-bridge
decoder target[] directly, in addition to target_map[]. Real HW programs
only target_map[] and resolves target[] as dports enumerate, via
update_decoder_targets(). Region replay already follows that ordering,
the initial auto-region did not.

Drop the direct target[] writes and call
cxl_port_update_decoder_targets() so target[] is resolved the same way
as real HW and region replay, exercising more of the auto-region driver
path.

This is inspired by the discussion [1] below:

[1]: https://lore.kernel.org/all/20260521084806.28232-1-icheng@nvidia.com/

Suggested-by: Alison Schofield <alison.schofield@intel.com>
Signed-off-by: Richard Cheng <icheng@nvidia.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com?>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Tested-by: Dave Jiang <dave.jiang@intel.com>
Link: https://patch.msgid.link/20260612011227.4220-1-icheng@nvidia.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
tools/testing/cxl/test/cxl.c

index 9a0faf70e9b133edb6ea39da00dbf1da1894ff79..ef92dd35e030ce0df759fcb34e9fbb571ed08cb9 100644 (file)
@@ -1188,15 +1188,11 @@ static bool mock_init_hdm_decoder(struct cxl_decoder *cxld)
                cxlsd = to_cxl_switch_decoder(dev);
                if (i == 0) {
                        /* put cxl_mem.4 second in the decode order */
-                       if (pdev->id == 4) {
-                               cxlsd->target[1] = dport;
+                       if (pdev->id == 4)
                                cxlsd->cxld.target_map[1] = dport->port_id;
-                       } else {
-                               cxlsd->target[0] = dport;
+                       else
                                cxlsd->cxld.target_map[0] = dport->port_id;
-                       }
                } else {
-                       cxlsd->target[0] = dport;
                        cxlsd->cxld.target_map[0] = dport->port_id;
                }
                cxld = &cxlsd->cxld;
@@ -1219,6 +1215,16 @@ static bool mock_init_hdm_decoder(struct cxl_decoder *cxld)
                cxld->commit = mock_decoder_commit;
                cxld->reset = mock_decoder_reset;
 
+               /*
+                * Only target_map[] is programmed above, mimicking
+                * firmware. On real hardware target[] is populated as
+                * dports enumerate, via update_decoder_targets(). The
+                * mock's dports are already bound by now, so fire that
+                * resolution explicitly here rather than stamping
+                * target[] directly.
+                */
+               cxl_port_update_decoder_targets(iter, dport);
+
                cxld_registry_update(cxld);
                put_device(dev);
        }