From: Li Ming <ming.li@zohomail.com>
To: dave@stgolabs.net, jic23@kernel.org, dave.jiang@intel.com,
alison.schofield@intel.com, vishal.l.verma@intel.com,
djbw@kernel.org, iweiny@kernel.org
Cc: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] cxl/test: Rework cxl_type2_mem_init() to use cxl_mock_platform_device_add()
Date: Mon, 13 Jul 2026 14:15:31 +0800 [thread overview]
Message-ID: <20260713061531.56322-1-ming.li@zohomail.com> (raw)
cxl_type2_mem_init() is used to set up mock CXL type2 memory device for
cxl testing, it introduces a known bug fixed by the following commit:
commit d90f236f8b9e ("cxl/test: Update mock dev array before calling platform_device_add()")
Mock CXL devices require updating the mock device array prior to
platform_device_add(), otherwise, the CXL subsystem could fail to
recognize the newly added mock device. Switch to
cxl_mock_platform_device_add() helper to resolve this ordering issue.
Besides, this patch also includes two minor changes.
1. Preserve the original error code returned by
cxl_mock_platform_device_add(), rather than unconditionally
overriding it with -ENOMEM.
2. Drop redundant NULL check before platform_device_unregister(), as the
function internally handles NULL pointer.
Fixes: 6b2e585142e6 ("cxl/test: Add hierarchy enumeration support for type2 device")
Signed-off-by: Li Ming <ming.li@zohomail.com>
---
base-commit: 31adec5c3dc489966e6061cbe427dddb81d2e6b5 cxl/next
---
tools/testing/cxl/test/cxl.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c
index 8ab2ce1262f3..62bd92b3be45 100644
--- a/tools/testing/cxl/test/cxl.c
+++ b/tools/testing/cxl/test/cxl.c
@@ -1947,25 +1947,16 @@ static int cxl_type2_mem_init(void)
pdev->dev.parent = &dport->dev;
set_dev_node(&pdev->dev, i % 2);
- rc = platform_device_add(pdev);
- if (rc) {
- rc = -ENOMEM;
- platform_device_put(pdev);
+ rc = cxl_mock_platform_device_add(pdev, &cxl_mem[i]);
+ if (rc)
goto err_mem;
- }
- cxl_mem[i] = pdev;
}
return 0;
err_mem:
- for (i = NR_CXL_TYPE2_ACCEL - 1; i >= 0; i--) {
- struct platform_device *pdev = cxl_mem[i];
-
- if (!pdev)
- continue;
- platform_device_unregister(pdev);
- }
+ for (i = NR_CXL_TYPE2_ACCEL - 1; i >= 0; i--)
+ platform_device_unregister(cxl_mem[i]);
return rc;
}
--
2.43.0
next reply other threads:[~2026-07-13 6:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 6:15 Li Ming [this message]
2026-07-13 17:15 ` Dave Jiang
2026-07-14 16:48 ` Dave Jiang
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=20260713061531.56322-1-ming.li@zohomail.com \
--to=ming.li@zohomail.com \
--cc=alison.schofield@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=djbw@kernel.org \
--cc=iweiny@kernel.org \
--cc=jic23@kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®