1515
1616static int interleave_arithmetic ;
1717
18+ #define FAKE_QTG_ID 42
19+
1820#define NR_CXL_HOST_BRIDGES 2
1921#define NR_CXL_SINGLE_HOST 1
2022#define NR_CXL_RCH 1
@@ -209,7 +211,7 @@ static struct {
209211 .granularity = 4 ,
210212 .restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
211213 ACPI_CEDT_CFMWS_RESTRICT_VOLATILE ,
212- .qtg_id = 0 ,
214+ .qtg_id = FAKE_QTG_ID ,
213215 .window_size = SZ_256M * 4UL ,
214216 },
215217 .target = { 0 },
@@ -224,7 +226,7 @@ static struct {
224226 .granularity = 4 ,
225227 .restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
226228 ACPI_CEDT_CFMWS_RESTRICT_VOLATILE ,
227- .qtg_id = 1 ,
229+ .qtg_id = FAKE_QTG_ID ,
228230 .window_size = SZ_256M * 8UL ,
229231 },
230232 .target = { 0 , 1 , },
@@ -239,7 +241,7 @@ static struct {
239241 .granularity = 4 ,
240242 .restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
241243 ACPI_CEDT_CFMWS_RESTRICT_PMEM ,
242- .qtg_id = 2 ,
244+ .qtg_id = FAKE_QTG_ID ,
243245 .window_size = SZ_256M * 4UL ,
244246 },
245247 .target = { 0 },
@@ -254,7 +256,7 @@ static struct {
254256 .granularity = 4 ,
255257 .restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
256258 ACPI_CEDT_CFMWS_RESTRICT_PMEM ,
257- .qtg_id = 3 ,
259+ .qtg_id = FAKE_QTG_ID ,
258260 .window_size = SZ_256M * 8UL ,
259261 },
260262 .target = { 0 , 1 , },
@@ -269,7 +271,7 @@ static struct {
269271 .granularity = 4 ,
270272 .restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
271273 ACPI_CEDT_CFMWS_RESTRICT_PMEM ,
272- .qtg_id = 4 ,
274+ .qtg_id = FAKE_QTG_ID ,
273275 .window_size = SZ_256M * 4UL ,
274276 },
275277 .target = { 2 },
@@ -284,7 +286,7 @@ static struct {
284286 .granularity = 4 ,
285287 .restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
286288 ACPI_CEDT_CFMWS_RESTRICT_VOLATILE ,
287- .qtg_id = 5 ,
289+ .qtg_id = FAKE_QTG_ID ,
288290 .window_size = SZ_256M ,
289291 },
290292 .target = { 3 },
@@ -301,7 +303,7 @@ static struct {
301303 .granularity = 4 ,
302304 .restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
303305 ACPI_CEDT_CFMWS_RESTRICT_PMEM ,
304- .qtg_id = 0 ,
306+ .qtg_id = FAKE_QTG_ID ,
305307 .window_size = SZ_256M * 8UL ,
306308 },
307309 .target = { 0 , },
@@ -317,7 +319,7 @@ static struct {
317319 .granularity = 0 ,
318320 .restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
319321 ACPI_CEDT_CFMWS_RESTRICT_PMEM ,
320- .qtg_id = 1 ,
322+ .qtg_id = FAKE_QTG_ID ,
321323 .window_size = SZ_256M * 8UL ,
322324 },
323325 .target = { 0 , 1 , },
@@ -333,7 +335,7 @@ static struct {
333335 .granularity = 0 ,
334336 .restrictions = ACPI_CEDT_CFMWS_RESTRICT_TYPE3 |
335337 ACPI_CEDT_CFMWS_RESTRICT_PMEM ,
336- .qtg_id = 0 ,
338+ .qtg_id = FAKE_QTG_ID ,
337339 .window_size = SZ_256M * 16UL ,
338340 },
339341 .target = { 0 , 1 , 0 , 1 , },
@@ -976,6 +978,48 @@ static int mock_cxl_port_enumerate_dports(struct cxl_port *port)
976978 return 0 ;
977979}
978980
981+ /*
982+ * Faking the cxl_dpa_perf for the memdev when appropriate.
983+ */
984+ static void dpa_perf_setup (struct cxl_port * endpoint , struct range * range ,
985+ struct cxl_dpa_perf * dpa_perf )
986+ {
987+ dpa_perf -> qos_class = FAKE_QTG_ID ;
988+ dpa_perf -> dpa_range = * range ;
989+ dpa_perf -> coord .read_latency = 500 ;
990+ dpa_perf -> coord .write_latency = 500 ;
991+ dpa_perf -> coord .read_bandwidth = 1000 ;
992+ dpa_perf -> coord .write_bandwidth = 1000 ;
993+ }
994+
995+ static void mock_cxl_endpoint_parse_cdat (struct cxl_port * port )
996+ {
997+ struct cxl_root * cxl_root __free (put_cxl_root ) =
998+ find_cxl_root (port );
999+ struct cxl_memdev * cxlmd = to_cxl_memdev (port -> uport_dev );
1000+ struct cxl_dev_state * cxlds = cxlmd -> cxlds ;
1001+ struct cxl_memdev_state * mds = to_cxl_memdev_state (cxlds );
1002+ struct range pmem_range = {
1003+ .start = cxlds -> pmem_res .start ,
1004+ .end = cxlds -> pmem_res .end ,
1005+ };
1006+ struct range ram_range = {
1007+ .start = cxlds -> ram_res .start ,
1008+ .end = cxlds -> ram_res .end ,
1009+ };
1010+
1011+ if (!cxl_root )
1012+ return ;
1013+
1014+ if (range_len (& ram_range ))
1015+ dpa_perf_setup (port , & ram_range , & mds -> ram_perf );
1016+
1017+ if (range_len (& pmem_range ))
1018+ dpa_perf_setup (port , & pmem_range , & mds -> pmem_perf );
1019+
1020+ cxl_memdev_update_perf (cxlmd );
1021+ }
1022+
9791023static struct cxl_mock_ops cxl_mock_ops = {
9801024 .is_mock_adev = is_mock_adev ,
9811025 .is_mock_bridge = is_mock_bridge ,
@@ -989,6 +1033,7 @@ static struct cxl_mock_ops cxl_mock_ops = {
9891033 .devm_cxl_setup_hdm = mock_cxl_setup_hdm ,
9901034 .devm_cxl_add_passthrough_decoder = mock_cxl_add_passthrough_decoder ,
9911035 .devm_cxl_enumerate_decoders = mock_cxl_enumerate_decoders ,
1036+ .cxl_endpoint_parse_cdat = mock_cxl_endpoint_parse_cdat ,
9921037 .list = LIST_HEAD_INIT (cxl_mock_ops .list ),
9931038};
9941039
0 commit comments