Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+19 -2
+19 -2
tools/testing/cxl/test/cxl.c
··· 641 641 platform_device_put(pdev); 642 642 goto err_bridge; 643 643 } 644 + 644 645 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; 645 650 } 646 651 647 652 for (i = 0; i < ARRAY_SIZE(cxl_root_port); i++) { ··· 750 745 for (i = ARRAY_SIZE(cxl_root_port) - 1; i >= 0; i--) 751 746 platform_device_unregister(cxl_root_port[i]); 752 747 err_bridge: 753 - for (i = ARRAY_SIZE(cxl_host_bridge) - 1; i >= 0; i--) 748 + for (i = ARRAY_SIZE(cxl_host_bridge) - 1; i >= 0; i--) { 749 + struct platform_device *pdev = cxl_host_bridge[i]; 750 + 751 + if (!pdev) 752 + continue; 753 + sysfs_remove_link(&pdev->dev.kobj, "physical_node"); 754 754 platform_device_unregister(cxl_host_bridge[i]); 755 + } 755 756 err_populate: 756 757 depopulate_all_mock_resources(); 757 758 err_gen_pool_add: ··· 780 769 platform_device_unregister(cxl_switch_uport[i]); 781 770 for (i = ARRAY_SIZE(cxl_root_port) - 1; i >= 0; i--) 782 771 platform_device_unregister(cxl_root_port[i]); 783 - for (i = ARRAY_SIZE(cxl_host_bridge) - 1; i >= 0; i--) 772 + for (i = ARRAY_SIZE(cxl_host_bridge) - 1; i >= 0; i--) { 773 + struct platform_device *pdev = cxl_host_bridge[i]; 774 + 775 + if (!pdev) 776 + continue; 777 + sysfs_remove_link(&pdev->dev.kobj, "physical_node"); 784 778 platform_device_unregister(cxl_host_bridge[i]); 779 + } 785 780 depopulate_all_mock_resources(); 786 781 gen_pool_destroy(cxl_mock_pool); 787 782 unregister_cxl_mock_ops(&cxl_mock_ops);