tools/testing/cxl: Add bridge mocking support
authorDan Williams <dan.j.williams@intel.com>
Mon, 14 Nov 2022 18:29:52 +0000 (10:29 -0800)
committerDan Williams <dan.j.williams@intel.com>
Mon, 14 Nov 2022 18:39:10 +0000 (10:39 -0800)
In preparation for cxl_acpi walking pci_root->bus->bridge, add that
association to the mock pci_root instances.

Note that the missing 3rd entry in mock_pci_root[] was not noticed until
now given that the test version of to_cxl_host_bridge()
(tools/testing/cxl/mock_acpi.c), obviated the need for that entry.
However, "cxl/acpi: Improve debug messages in cxl_acpi_probe()" [1]
needs pci_root->bus->bridge to be populated.

Link: https://lore.kernel.org/r/20221018132341.76259-6-rrichter@amd.com
Cc: Robert Richter <rrichter@amd.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
tools/testing/cxl/test/cxl.c

index a5146d80ecc48077949519e4613af74656817caf..facfcd11cb675b374c8a912042b320d242e65c64 100644 (file)
@@ -439,14 +439,18 @@ mock_acpi_evaluate_integer(acpi_handle handle, acpi_string pathname,
        return AE_OK;
 }
 
-static struct pci_bus mock_pci_bus[NR_CXL_HOST_BRIDGES];
-static struct acpi_pci_root mock_pci_root[NR_CXL_HOST_BRIDGES] = {
+static struct pci_bus mock_pci_bus[NR_CXL_HOST_BRIDGES + NR_CXL_SINGLE_HOST];
+static struct acpi_pci_root mock_pci_root[ARRAY_SIZE(mock_pci_bus)] = {
        [0] = {
                .bus = &mock_pci_bus[0],
        },
        [1] = {
                .bus = &mock_pci_bus[1],
        },
+       [2] = {
+               .bus = &mock_pci_bus[2],
+       },
+
 };
 
 static bool is_mock_bus(struct pci_bus *bus)
@@ -744,6 +748,7 @@ static __init int cxl_single_init(void)
                }
 
                cxl_hb_single[i] = pdev;
+               mock_pci_bus[i + NR_CXL_HOST_BRIDGES].bridge = &pdev->dev;
                rc = sysfs_create_link(&pdev->dev.kobj, &pdev->dev.kobj,
                                       "physical_node");
                if (rc)
@@ -910,6 +915,7 @@ static __init int cxl_test_init(void)
                }
 
                cxl_host_bridge[i] = pdev;
+               mock_pci_bus[i].bridge = &pdev->dev;
                rc = sysfs_create_link(&pdev->dev.kobj, &pdev->dev.kobj,
                                       "physical_node");
                if (rc)