Skip to content

Commit 68f4a85

Browse files
committed
cxl/test: Add support for acpi extended linear cache
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>
1 parent 4b1c046 commit 68f4a85

4 files changed

Lines changed: 45 additions & 0 deletions

File tree

tools/testing/cxl/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ ldflags-y += --wrap=cxl_rcd_component_reg_phys
1111
ldflags-y += --wrap=cxl_endpoint_parse_cdat
1212
ldflags-y += --wrap=cxl_dport_init_ras_reporting
1313
ldflags-y += --wrap=devm_cxl_endpoint_decoders_setup
14+
ldflags-y += --wrap=hmat_get_extended_linear_cache_size
1415

1516
DRIVERS := ../../../drivers
1617
CXL_SRC := $(DRIVERS)/cxl

tools/testing/cxl/test/cxl.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,25 @@ mock_acpi_evaluate_integer(acpi_handle handle, acpi_string pathname,
612612
return AE_OK;
613613
}
614614

615+
static int
616+
mock_hmat_get_extended_linear_cache_size(struct resource *backing_res,
617+
int nid, resource_size_t *cache_size)
618+
{
619+
struct acpi_cedt_cfmws *window = mock_cfmws[0];
620+
struct resource cfmws0_res =
621+
DEFINE_RES_MEM(window->base_hpa, window->window_size);
622+
623+
if (!extended_linear_cache ||
624+
!resource_contains(&cfmws0_res, backing_res)) {
625+
return hmat_get_extended_linear_cache_size(backing_res,
626+
nid, cache_size);
627+
}
628+
629+
*cache_size = mock_auto_region_size;
630+
631+
return 0;
632+
}
633+
615634
static struct pci_bus mock_pci_bus[NR_BRIDGES];
616635
static struct acpi_pci_root mock_pci_root[ARRAY_SIZE(mock_pci_bus)] = {
617636
[0] = {
@@ -1140,6 +1159,8 @@ static struct cxl_mock_ops cxl_mock_ops = {
11401159
.devm_cxl_port_enumerate_dports = mock_cxl_port_enumerate_dports,
11411160
.cxl_endpoint_parse_cdat = mock_cxl_endpoint_parse_cdat,
11421161
.devm_cxl_add_dport_by_dev = mock_cxl_add_dport_by_dev,
1162+
.hmat_get_extended_linear_cache_size =
1163+
mock_hmat_get_extended_linear_cache_size,
11431164
.list = LIST_HEAD_INIT(cxl_mock_ops.list),
11441165
};
11451166

tools/testing/cxl/test/mock.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,26 @@ acpi_status __wrap_acpi_evaluate_integer(acpi_handle handle,
111111
}
112112
EXPORT_SYMBOL(__wrap_acpi_evaluate_integer);
113113

114+
int __wrap_hmat_get_extended_linear_cache_size(struct resource *backing_res,
115+
int nid,
116+
resource_size_t *cache_size)
117+
{
118+
int index, rc;
119+
struct cxl_mock_ops *ops = get_cxl_mock_ops(&index);
120+
121+
if (ops)
122+
rc = ops->hmat_get_extended_linear_cache_size(backing_res, nid,
123+
cache_size);
124+
else
125+
rc = hmat_get_extended_linear_cache_size(backing_res, nid,
126+
cache_size);
127+
128+
put_cxl_mock_ops(index);
129+
130+
return rc;
131+
}
132+
EXPORT_SYMBOL_GPL(__wrap_hmat_get_extended_linear_cache_size);
133+
114134
struct acpi_pci_root *__wrap_acpi_pci_find_root(acpi_handle handle)
115135
{
116136
int index;

tools/testing/cxl/test/mock.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ struct cxl_mock_ops {
2525
void (*cxl_endpoint_parse_cdat)(struct cxl_port *port);
2626
struct cxl_dport *(*devm_cxl_add_dport_by_dev)(struct cxl_port *port,
2727
struct device *dport_dev);
28+
int (*hmat_get_extended_linear_cache_size)(struct resource *backing_res,
29+
int nid,
30+
resource_size_t *cache_size);
2831
};
2932

3033
void register_cxl_mock_ops(struct cxl_mock_ops *ops);

0 commit comments

Comments
 (0)