]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
cxl/test: Add mock version of devm_cxl_add_dport_by_dev()
authorDave Jiang <dave.jiang@intel.com>
Fri, 29 Aug 2025 18:09:25 +0000 (11:09 -0700)
committerDave Jiang <dave.jiang@intel.com>
Thu, 18 Sep 2025 16:55:23 +0000 (09:55 -0700)
commitd96eb90d9ca6e4652c8a23d48c94364aa061fdc4
tree5a441084e3068afcadac81bf960166e453ba1f06
parent4f06d81e7c6a02f850bfe9812295b1e859ab2db0
cxl/test: Add mock version of devm_cxl_add_dport_by_dev()

devm_cxl_add_dport_by_dev() outside of cxl_test is done through PCI
hierarchy. However with cxl_test, it needs to be done through the
platform device hierarchy. Add the mock function for
devm_cxl_add_dport_by_dev().

When cxl_core calls a cxl_core exported function and that function is
mocked by cxl_test, the call chain causes a circular dependency issue. Dan
provided a workaround to avoid this issue. Apply the method to changes from
the late dport allocation changes in order to enable cxl-test.

In cxl_core they are defined with "__" added in front of the function. A
macro is used to define the original function names for when non-test
version of the kernel is built. A bit of macros and typedefs are used to
allow mocking of those functions in cxl_test.

Co-developed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Li Ming <ming.li@zohomail.com>
Tested-by: Alison Schofield <alison.schofield@intel.com>
Tested-by: Robert Richter <rrichter@amd.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
drivers/cxl/core/core.h
drivers/cxl/core/pci.c
drivers/cxl/cxl.h
tools/testing/cxl/Kbuild
tools/testing/cxl/cxl_core_exports.c
tools/testing/cxl/exports.h [new file with mode: 0644]
tools/testing/cxl/test/cxl.c
tools/testing/cxl/test/mock.c
tools/testing/cxl/test/mock.h