]> Gentwo Git Trees - linux/.git/commitdiff
cxl/test: Add support for acpi extended linear cache
authorDave Jiang <dave.jiang@intel.com>
Mon, 17 Nov 2025 14:46:11 +0000 (07:46 -0700)
committerDave Jiang <dave.jiang@intel.com>
Mon, 17 Nov 2025 16:46:44 +0000 (09:46 -0700)
Add the mock wrappers for hmat_get_extended_linear_cache_size() in order
to emulate the ACPI helper function for the regions that are mock'd by
cxl_test.

Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Tested-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: Fabio M. De Francesco <fabio.m.de.francesco@linux.intel.com>
Link: https://patch.msgid.link/20251117144611.903692-4-dave.jiang@intel.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
tools/testing/cxl/Kbuild
tools/testing/cxl/test/cxl.c
tools/testing/cxl/test/mock.c
tools/testing/cxl/test/mock.h

index 0d5ce4b74b9f7d14f83cea9bd1aae9f74aa25892..65e9ac227aee27691ec0e61e51388e50537f296e 100644 (file)
@@ -11,6 +11,7 @@ ldflags-y += --wrap=cxl_rcd_component_reg_phys
 ldflags-y += --wrap=cxl_endpoint_parse_cdat
 ldflags-y += --wrap=cxl_dport_init_ras_reporting
 ldflags-y += --wrap=devm_cxl_endpoint_decoders_setup
+ldflags-y += --wrap=hmat_get_extended_linear_cache_size
 
 DRIVERS := ../../../drivers
 CXL_SRC := $(DRIVERS)/cxl
index bdb7e7366b6d6bf1eb0b1dee7e0474c36d3d0968..4d5714d077b25e6c32151008c560b5677ad408b7 100644 (file)
@@ -612,6 +612,25 @@ mock_acpi_evaluate_integer(acpi_handle handle, acpi_string pathname,
        return AE_OK;
 }
 
+static int
+mock_hmat_get_extended_linear_cache_size(struct resource *backing_res,
+                                        int nid, resource_size_t *cache_size)
+{
+       struct acpi_cedt_cfmws *window = mock_cfmws[0];
+       struct resource cfmws0_res =
+               DEFINE_RES_MEM(window->base_hpa, window->window_size);
+
+       if (!extended_linear_cache ||
+           !resource_contains(&cfmws0_res, backing_res)) {
+               return hmat_get_extended_linear_cache_size(backing_res,
+                                                          nid, cache_size);
+       }
+
+       *cache_size = mock_auto_region_size;
+
+       return 0;
+}
+
 static struct pci_bus mock_pci_bus[NR_BRIDGES];
 static struct acpi_pci_root mock_pci_root[ARRAY_SIZE(mock_pci_bus)] = {
        [0] = {
@@ -1140,6 +1159,8 @@ static struct cxl_mock_ops cxl_mock_ops = {
        .devm_cxl_port_enumerate_dports = mock_cxl_port_enumerate_dports,
        .cxl_endpoint_parse_cdat = mock_cxl_endpoint_parse_cdat,
        .devm_cxl_add_dport_by_dev = mock_cxl_add_dport_by_dev,
+       .hmat_get_extended_linear_cache_size =
+               mock_hmat_get_extended_linear_cache_size,
        .list = LIST_HEAD_INIT(cxl_mock_ops.list),
 };
 
index 995269a75cbd1946b62cbbf3f0a47ad3c43846ea..bff5853717f028b0cf296993f3ab1ef8dab7e5d0 100644 (file)
@@ -111,6 +111,26 @@ acpi_status __wrap_acpi_evaluate_integer(acpi_handle handle,
 }
 EXPORT_SYMBOL(__wrap_acpi_evaluate_integer);
 
+int __wrap_hmat_get_extended_linear_cache_size(struct resource *backing_res,
+                                              int nid,
+                                              resource_size_t *cache_size)
+{
+       int index, rc;
+       struct cxl_mock_ops *ops = get_cxl_mock_ops(&index);
+
+       if (ops)
+               rc = ops->hmat_get_extended_linear_cache_size(backing_res, nid,
+                                                             cache_size);
+       else
+               rc = hmat_get_extended_linear_cache_size(backing_res, nid,
+                                                        cache_size);
+
+       put_cxl_mock_ops(index);
+
+       return rc;
+}
+EXPORT_SYMBOL_GPL(__wrap_hmat_get_extended_linear_cache_size);
+
 struct acpi_pci_root *__wrap_acpi_pci_find_root(acpi_handle handle)
 {
        int index;
index 4ed932e76aae89fd75aa39ffe97244ab2e7f1001..bfd36cbdbae27bae54271dd33ed67349e7027905 100644 (file)
@@ -25,6 +25,9 @@ struct cxl_mock_ops {
        void (*cxl_endpoint_parse_cdat)(struct cxl_port *port);
        struct cxl_dport *(*devm_cxl_add_dport_by_dev)(struct cxl_port *port,
                                                       struct device *dport_dev);
+       int (*hmat_get_extended_linear_cache_size)(struct resource *backing_res,
+                                                  int nid,
+                                                  resource_size_t *cache_size);
 };
 
 void register_cxl_mock_ops(struct cxl_mock_ops *ops);