mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH RESEND] tools/testing/cxl: Resolve auto-region decoder targets like real HW
@ 2026-06-12  1:12 Richard Cheng
  2026-06-12  1:53 ` Dave Jiang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Richard Cheng @ 2026-06-12  1:12 UTC (permalink / raw)
  To: dave, jic23, dave.jiang, alison.schofield, vishal.l.verma,
	ira.weiny, djbw, shiju.jose, ming.li
  Cc: alucerop, linux-cxl, linux-kernel, newtonl, kristinc, kaihengf,
	kobak, Richard Cheng

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>
---
cxl_mock_mem didn't load together when I manually modprobe cxl_test
module, should we make them loaded together automatically for better
user experience?

Best regards,
Richard Cheng.
---
 tools/testing/cxl/test/cxl.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c
index 418669927fb0..5266aa3733cb 100644
--- a/tools/testing/cxl/test/cxl.c
+++ b/tools/testing/cxl/test/cxl.c
@@ -1181,15 +1181,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;
@@ -1212,6 +1208,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);
 	}
-- 
2.43.0


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

* Re: [PATCH RESEND] tools/testing/cxl: Resolve auto-region decoder targets like real HW
  2026-06-12  1:12 [PATCH RESEND] tools/testing/cxl: Resolve auto-region decoder targets like real HW Richard Cheng
@ 2026-06-12  1:53 ` Dave Jiang
  2026-06-12  5:41 ` Alison Schofield
  2026-06-12 16:39 ` Dave Jiang
  2 siblings, 0 replies; 4+ messages in thread
From: Dave Jiang @ 2026-06-12  1:53 UTC (permalink / raw)
  To: Richard Cheng, dave, jic23, alison.schofield, vishal.l.verma,
	ira.weiny, djbw, shiju.jose, ming.li
  Cc: alucerop, linux-cxl, linux-kernel, newtonl, kristinc, kaihengf, kobak



On 6/11/26 6:12 PM, Richard Cheng wrote:
> 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: Dave Jiang <dave.jiang@intel.com>
Tested-by: Dave Jiang <dave.jiang@intel.com>

> ---
> cxl_mock_mem didn't load together when I manually modprobe cxl_test
> module, should we make them loaded together automatically for better
> user experience?
> 
> Best regards,
> Richard Cheng.
> ---
>  tools/testing/cxl/test/cxl.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c
> index 418669927fb0..5266aa3733cb 100644
> --- a/tools/testing/cxl/test/cxl.c
> +++ b/tools/testing/cxl/test/cxl.c
> @@ -1181,15 +1181,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;
> @@ -1212,6 +1208,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);
>  	}


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

* Re: [PATCH RESEND] tools/testing/cxl: Resolve auto-region decoder targets like real HW
  2026-06-12  1:12 [PATCH RESEND] tools/testing/cxl: Resolve auto-region decoder targets like real HW Richard Cheng
  2026-06-12  1:53 ` Dave Jiang
@ 2026-06-12  5:41 ` Alison Schofield
  2026-06-12 16:39 ` Dave Jiang
  2 siblings, 0 replies; 4+ messages in thread
From: Alison Schofield @ 2026-06-12  5:41 UTC (permalink / raw)
  To: Richard Cheng
  Cc: dave, jic23, dave.jiang, vishal.l.verma, ira.weiny, djbw,
	shiju.jose, ming.li, alucerop, linux-cxl, linux-kernel, newtonl,
	kristinc, kaihengf, kobak

On Fri, Jun 12, 2026 at 09:12:27AM +0800, Richard Cheng wrote:
> 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.

Reviewed-by: Alison Schofield <alison.schofield@intel.com?


> 
> 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>
> ---
> cxl_mock_mem didn't load together when I manually modprobe cxl_test
> module, should we make them loaded together automatically for better
> user experience?

Is this a documentation issue w cxl-test?

There's an autoload path. cxl_mock_mem has a MODULE_DEVICE_TABLE for the
cxl_mem/cxl_rcd platform devices that cxl_test registers, so udev should
modprobe it automatically. That only works if the modules are installed
and depmod'd, though. Did you make modules_install && depmod -a  or are
you insmod-ing from the build tree? 

Are you thinking of a MODULE_SOFTDEP?  I think that would be harmless
in our cxl-test suite loads.

Maybe explain more of the environment for me.

-- Alison

> 
> Best regards,
> Richard Cheng.
> ---
>  tools/testing/cxl/test/cxl.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c
> index 418669927fb0..5266aa3733cb 100644
> --- a/tools/testing/cxl/test/cxl.c
> +++ b/tools/testing/cxl/test/cxl.c
> @@ -1181,15 +1181,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;
> @@ -1212,6 +1208,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);
>  	}
> -- 
> 2.43.0
> 

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

* Re: [PATCH RESEND] tools/testing/cxl: Resolve auto-region decoder targets like real HW
  2026-06-12  1:12 [PATCH RESEND] tools/testing/cxl: Resolve auto-region decoder targets like real HW Richard Cheng
  2026-06-12  1:53 ` Dave Jiang
  2026-06-12  5:41 ` Alison Schofield
@ 2026-06-12 16:39 ` Dave Jiang
  2 siblings, 0 replies; 4+ messages in thread
From: Dave Jiang @ 2026-06-12 16:39 UTC (permalink / raw)
  To: Richard Cheng, dave, jic23, alison.schofield, vishal.l.verma,
	ira.weiny, djbw, shiju.jose, ming.li
  Cc: alucerop, linux-cxl, linux-kernel, newtonl, kristinc, kaihengf, kobak



On 6/11/26 6:12 PM, Richard Cheng wrote:
> 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>

Applied to cxl/next
769f0b350c81

> ---
> cxl_mock_mem didn't load together when I manually modprobe cxl_test
> module, should we make them loaded together automatically for better
> user experience?
> 
> Best regards,
> Richard Cheng.
> ---
>  tools/testing/cxl/test/cxl.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c
> index 418669927fb0..5266aa3733cb 100644
> --- a/tools/testing/cxl/test/cxl.c
> +++ b/tools/testing/cxl/test/cxl.c
> @@ -1181,15 +1181,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;
> @@ -1212,6 +1208,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);
>  	}


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

end of thread, other threads:[~2026-06-12 16:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-12  1:12 [PATCH RESEND] tools/testing/cxl: Resolve auto-region decoder targets like real HW Richard Cheng
2026-06-12  1:53 ` Dave Jiang
2026-06-12  5:41 ` Alison Schofield
2026-06-12 16:39 ` Dave Jiang

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®