Skip to content

Commit 64cda3a

Browse files
committed
tools/testing/cxl: Add a physical_node link
Emulate what ACPI does to link a host bridge platform firmware device to device node on the PCI bus. In this case it's just self referencing link, but it otherwise lets the tooling test out its lookup code. Link: https://lore.kernel.org/r/164298433209.3018233.18101085948127163720.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 7c7d68d commit 64cda3a

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

  • tools/testing/cxl/test

tools/testing/cxl/test/cxl.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,12 @@ static __init int cxl_test_init(void)
641641
platform_device_put(pdev);
642642
goto err_bridge;
643643
}
644+
644645
cxl_host_bridge[i] = pdev;
646+
rc = sysfs_create_link(&pdev->dev.kobj, &pdev->dev.kobj,
647+
"physical_node");
648+
if (rc)
649+
goto err_bridge;
645650
}
646651

647652
for (i = 0; i < ARRAY_SIZE(cxl_root_port); i++) {
@@ -745,8 +750,14 @@ static __init int cxl_test_init(void)
745750
for (i = ARRAY_SIZE(cxl_root_port) - 1; i >= 0; i--)
746751
platform_device_unregister(cxl_root_port[i]);
747752
err_bridge:
748-
for (i = ARRAY_SIZE(cxl_host_bridge) - 1; i >= 0; i--)
753+
for (i = ARRAY_SIZE(cxl_host_bridge) - 1; i >= 0; i--) {
754+
struct platform_device *pdev = cxl_host_bridge[i];
755+
756+
if (!pdev)
757+
continue;
758+
sysfs_remove_link(&pdev->dev.kobj, "physical_node");
749759
platform_device_unregister(cxl_host_bridge[i]);
760+
}
750761
err_populate:
751762
depopulate_all_mock_resources();
752763
err_gen_pool_add:
@@ -769,8 +780,14 @@ static __exit void cxl_test_exit(void)
769780
platform_device_unregister(cxl_switch_uport[i]);
770781
for (i = ARRAY_SIZE(cxl_root_port) - 1; i >= 0; i--)
771782
platform_device_unregister(cxl_root_port[i]);
772-
for (i = ARRAY_SIZE(cxl_host_bridge) - 1; i >= 0; i--)
783+
for (i = ARRAY_SIZE(cxl_host_bridge) - 1; i >= 0; i--) {
784+
struct platform_device *pdev = cxl_host_bridge[i];
785+
786+
if (!pdev)
787+
continue;
788+
sysfs_remove_link(&pdev->dev.kobj, "physical_node");
773789
platform_device_unregister(cxl_host_bridge[i]);
790+
}
774791
depopulate_all_mock_resources();
775792
gen_pool_destroy(cxl_mock_pool);
776793
unregister_cxl_mock_ops(&cxl_mock_ops);

0 commit comments

Comments
 (0)