public inbox for linux-cxl@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Li Ming <ming.li@zohomail.com>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Jonathan Cameron <jonathan.cameron@huawei.com>,
	Alison Schofield <alison.schofield@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Ira Weiny <ira.weiny@intel.com>,
	Dan Williams <dan.j.williams@intel.com>
Cc: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cxl/test: Update mock memdev array before calling platform_device_add()
Date: Fri, 6 Mar 2026 08:01:38 -0700	[thread overview]
Message-ID: <34f85830-5fc2-4568-afe8-3172d587d318@intel.com> (raw)
In-Reply-To: <20260306-update_array_before_adding_mock_memdev-v1-1-a1a6af0952f1@zohomail.com>



On 3/6/26 7:28 AM, Li Ming wrote:
> CXL test environment hits the following error sometimes.
> 
>  cxl_mem mem9: endpoint7 failed probe
> 
> All mock memdevs are platform firmware devices added by cxl_test module,
> and cxl_test module also provides a platform device driver for them to
> create a memdev device to CXL subsystem. cxl_test module uses
> cxl_rcd/mem_single/mem arrays to store different types of mock memdevs.
> CXL drivers calls registered mock functions for a mock memdev by
> checking if a given memdev is in these arrays.
> 
> When cxl_test module adds these mock memdevs, it always calls
> platform_device_add() before adding them to a suitable mock memdev
> array. However, there is a small window where CXL drivers calls mock
> function for a added memdev before it added to a mock memdev array. In
> above case, cxl endpoint driver considers a added memdev was not a mock
> memdev, then calling devm_cxl_endpoint_decoders_setup() for it rather
> than mock_endpoint_decoders_setup().
> 
> An appropriate solution is that adding a new mock memdev to a mock
> memdev array before calling platform_device_add() for it. It can
> guarantee the new mock memdev is visible to CXL subsystem.
> 
> Fixes: 3a2b97b3210b ("cxl/test: Improve init-order fidelity relative to real-world systems")
> Signed-off-by: Li Ming <ming.li@zohomail.com>

Makes sense.
Reviewed-by: Dave Jiang <dave.jiang@intel.com>


> ---
>  tools/testing/cxl/test/cxl.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c
> index 81e2aef3627a..2664c9de8dd6 100644
> --- a/tools/testing/cxl/test/cxl.c
> +++ b/tools/testing/cxl/test/cxl.c
> @@ -1356,12 +1356,13 @@ static int cxl_mem_init(void)
>  		pdev->dev.parent = &dport->dev;
>  		set_dev_node(&pdev->dev, i % 2);
>  
> +		cxl_mem[i] = pdev;
>  		rc = platform_device_add(pdev);
>  		if (rc) {
>  			platform_device_put(pdev);
> +			cxl_mem[i] = NULL;
>  			goto err_mem;
>  		}
> -		cxl_mem[i] = pdev;
>  	}
>  
>  	for (i = 0; i < ARRAY_SIZE(cxl_mem_single); i++) {
> @@ -1374,12 +1375,13 @@ static int cxl_mem_init(void)
>  		pdev->dev.parent = &dport->dev;
>  		set_dev_node(&pdev->dev, i % 2);
>  
> +		cxl_mem_single[i] = pdev;
>  		rc = platform_device_add(pdev);
>  		if (rc) {
>  			platform_device_put(pdev);
> +			cxl_mem_single[i] = NULL;
>  			goto err_single;
>  		}
> -		cxl_mem_single[i] = pdev;
>  	}
>  
>  	for (i = 0; i < ARRAY_SIZE(cxl_rcd); i++) {
> @@ -1393,12 +1395,13 @@ static int cxl_mem_init(void)
>  		pdev->dev.parent = &rch->dev;
>  		set_dev_node(&pdev->dev, i % 2);
>  
> +		cxl_rcd[i] = pdev;
>  		rc = platform_device_add(pdev);
>  		if (rc) {
>  			platform_device_put(pdev);
> +			cxl_rcd[i] = NULL;
>  			goto err_rcd;
>  		}
> -		cxl_rcd[i] = pdev;
>  	}
>  
>  	return 0;
> 
> ---
> base-commit: 19d2f0b97a131198efc2c4ca3eb7f980bba8c2b4
> change-id: 20260306-update_array_before_adding_mock_memdev-89673b4d9118
> 
> Best regards,


      reply	other threads:[~2026-03-06 15:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-06 14:28 [PATCH] cxl/test: Update mock memdev array before calling platform_device_add() Li Ming
2026-03-06 15:01 ` Dave Jiang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34f85830-5fc2-4568-afe8-3172d587d318@intel.com \
    --to=dave.jiang@intel.com \
    --cc=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave@stgolabs.net \
    --cc=ira.weiny@intel.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.li@zohomail.com \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox