]> git.ipfire.org Git - thirdparty/linux.git/commit
cxl/test: Update mock dev array before calling platform_device_add()
authorLi Ming <ming.li@zohomail.com>
Wed, 20 May 2026 12:14:57 +0000 (20:14 +0800)
committerDave Jiang <dave.jiang@intel.com>
Tue, 26 May 2026 20:54:17 +0000 (13:54 -0700)
commitd90f236f8b9e354848bd226f581db27755ab901d
treeff43b778bb4ac8e00fc4a2df670ae191c9cce752
parente7ae89a0c97ce2b68b0983cd01eda67cf373517d
cxl/test: Update mock dev array before calling platform_device_add()

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 device to a mock
device array before calling platform_device_add() for it. It can
guarantee the new mock device is visible to CXL subsystem.

This patch introduces a new helped called cxl_mock_platform_device_add()
to handle the issue, and uses the function for all mock devices addition.

Fixes: 3a2b97b3210b ("cxl/test: Improve init-order fidelity relative to real-world systems")
Signed-off-by: Li Ming <ming.li@zohomail.com>
Tested-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Link: https://patch.msgid.link/20260520121457.234404-1-ming.li@zohomail.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
tools/testing/cxl/test/cxl.c