1414struct dsmas_entry {
1515 struct range dpa_range ;
1616 u8 handle ;
17- struct access_coordinate coord ;
17+ struct access_coordinate coord [ ACCESS_COORDINATE_MAX ] ;
1818
1919 int entries ;
2020 int qos_class ;
@@ -88,8 +88,8 @@ static int cdat_dsmas_handler(union acpi_subtable_headers *header, void *arg,
8888 return 0 ;
8989}
9090
91- static void cxl_access_coordinate_set (struct access_coordinate * coord ,
92- int access , unsigned int val )
91+ static void __cxl_access_coordinate_set (struct access_coordinate * coord ,
92+ int access , unsigned int val )
9393{
9494 switch (access ) {
9595 case ACPI_HMAT_ACCESS_LATENCY :
@@ -115,6 +115,13 @@ static void cxl_access_coordinate_set(struct access_coordinate *coord,
115115 }
116116}
117117
118+ static void cxl_access_coordinate_set (struct access_coordinate * coord ,
119+ int access , unsigned int val )
120+ {
121+ for (int i = 0 ; i < ACCESS_COORDINATE_MAX ; i ++ )
122+ __cxl_access_coordinate_set (& coord [i ], access , val );
123+ }
124+
118125static int cdat_dslbis_handler (union acpi_subtable_headers * header , void * arg ,
119126 const unsigned long end )
120127{
@@ -156,7 +163,7 @@ static int cdat_dslbis_handler(union acpi_subtable_headers *header, void *arg,
156163 val = cdat_normalize (le16_to_cpu (le_val ), le64_to_cpu (le_base ),
157164 dslbis -> data_type );
158165
159- cxl_access_coordinate_set (& dent -> coord , dslbis -> data_type , val );
166+ cxl_access_coordinate_set (dent -> coord , dslbis -> data_type , val );
160167
161168 return 0 ;
162169}
@@ -190,13 +197,13 @@ static int cxl_cdat_endpoint_process(struct cxl_port *port,
190197static int cxl_port_perf_data_calculate (struct cxl_port * port ,
191198 struct xarray * dsmas_xa )
192199{
193- struct access_coordinate ep_c ;
200+ struct access_coordinate ep_c [ ACCESS_COORDINATE_MAX ] ;
194201 struct dsmas_entry * dent ;
195202 int valid_entries = 0 ;
196203 unsigned long index ;
197204 int rc ;
198205
199- rc = cxl_endpoint_get_perf_coordinates (port , & ep_c );
206+ rc = cxl_endpoint_get_perf_coordinates (port , ep_c );
200207 if (rc ) {
201208 dev_dbg (& port -> dev , "Failed to retrieve ep perf coordinates.\n" );
202209 return rc ;
@@ -213,10 +220,11 @@ static int cxl_port_perf_data_calculate(struct cxl_port *port,
213220 xa_for_each (dsmas_xa , index , dent ) {
214221 int qos_class ;
215222
216- cxl_coordinates_combine (& dent -> coord , & dent -> coord , & ep_c );
223+ cxl_coordinates_combine (dent -> coord , dent -> coord , ep_c );
217224 dent -> entries = 1 ;
218- rc = cxl_root -> ops -> qos_class (cxl_root , & dent -> coord , 1 ,
219- & qos_class );
225+ rc = cxl_root -> ops -> qos_class (cxl_root ,
226+ & dent -> coord [ACCESS_COORDINATE_CPU ],
227+ 1 , & qos_class );
220228 if (rc != 1 )
221229 continue ;
222230
@@ -233,14 +241,17 @@ static int cxl_port_perf_data_calculate(struct cxl_port *port,
233241static void update_perf_entry (struct device * dev , struct dsmas_entry * dent ,
234242 struct cxl_dpa_perf * dpa_perf )
235243{
244+ for (int i = 0 ; i < ACCESS_COORDINATE_MAX ; i ++ )
245+ dpa_perf -> coord [i ] = dent -> coord [i ];
236246 dpa_perf -> dpa_range = dent -> dpa_range ;
237- dpa_perf -> coord = dent -> coord ;
238247 dpa_perf -> qos_class = dent -> qos_class ;
239248 dev_dbg (dev ,
240249 "DSMAS: dpa: %#llx qos: %d read_bw: %d write_bw %d read_lat: %d write_lat: %d\n" ,
241250 dent -> dpa_range .start , dpa_perf -> qos_class ,
242- dent -> coord .read_bandwidth , dent -> coord .write_bandwidth ,
243- dent -> coord .read_latency , dent -> coord .write_latency );
251+ dent -> coord [ACCESS_COORDINATE_CPU ].read_bandwidth ,
252+ dent -> coord [ACCESS_COORDINATE_CPU ].write_bandwidth ,
253+ dent -> coord [ACCESS_COORDINATE_CPU ].read_latency ,
254+ dent -> coord [ACCESS_COORDINATE_CPU ].write_latency );
244255}
245256
246257static void cxl_memdev_set_qos_class (struct cxl_dev_state * cxlds ,
@@ -477,10 +488,11 @@ static int cdat_sslbis_handler(union acpi_subtable_headers *header, void *arg,
477488
478489 xa_for_each (& port -> dports , index , dport ) {
479490 if (dsp_id == ACPI_CDAT_SSLBIS_ANY_PORT ||
480- dsp_id == dport -> port_id )
481- cxl_access_coordinate_set (& dport -> sw_coord ,
491+ dsp_id == dport -> port_id ) {
492+ cxl_access_coordinate_set (dport -> coord ,
482493 sslbis -> data_type ,
483494 val );
495+ }
484496 }
485497 }
486498
@@ -502,6 +514,21 @@ void cxl_switch_parse_cdat(struct cxl_port *port)
502514}
503515EXPORT_SYMBOL_NS_GPL (cxl_switch_parse_cdat , CXL );
504516
517+ static void __cxl_coordinates_combine (struct access_coordinate * out ,
518+ struct access_coordinate * c1 ,
519+ struct access_coordinate * c2 )
520+ {
521+ if (c1 -> write_bandwidth && c2 -> write_bandwidth )
522+ out -> write_bandwidth = min (c1 -> write_bandwidth ,
523+ c2 -> write_bandwidth );
524+ out -> write_latency = c1 -> write_latency + c2 -> write_latency ;
525+
526+ if (c1 -> read_bandwidth && c2 -> read_bandwidth )
527+ out -> read_bandwidth = min (c1 -> read_bandwidth ,
528+ c2 -> read_bandwidth );
529+ out -> read_latency = c1 -> read_latency + c2 -> read_latency ;
530+ }
531+
505532/**
506533 * cxl_coordinates_combine - Combine the two input coordinates
507534 *
@@ -513,15 +540,8 @@ void cxl_coordinates_combine(struct access_coordinate *out,
513540 struct access_coordinate * c1 ,
514541 struct access_coordinate * c2 )
515542{
516- if (c1 -> write_bandwidth && c2 -> write_bandwidth )
517- out -> write_bandwidth = min (c1 -> write_bandwidth ,
518- c2 -> write_bandwidth );
519- out -> write_latency = c1 -> write_latency + c2 -> write_latency ;
520-
521- if (c1 -> read_bandwidth && c2 -> read_bandwidth )
522- out -> read_bandwidth = min (c1 -> read_bandwidth ,
523- c2 -> read_bandwidth );
524- out -> read_latency = c1 -> read_latency + c2 -> read_latency ;
543+ for (int i = 0 ; i < ACCESS_COORDINATE_MAX ; i ++ )
544+ __cxl_coordinates_combine (& out [i ], & c1 [i ], & c2 [i ]);
525545}
526546
527547MODULE_IMPORT_NS (CXL );
@@ -558,12 +578,12 @@ void cxl_region_perf_data_calculate(struct cxl_region *cxlr,
558578 /* Get total bandwidth and the worst latency for the cxl region */
559579 cxlr -> coord [i ].read_latency = max_t (unsigned int ,
560580 cxlr -> coord [i ].read_latency ,
561- perf -> coord .read_latency );
581+ perf -> coord [ i ] .read_latency );
562582 cxlr -> coord [i ].write_latency = max_t (unsigned int ,
563583 cxlr -> coord [i ].write_latency ,
564- perf -> coord .write_latency );
565- cxlr -> coord [i ].read_bandwidth += perf -> coord .read_bandwidth ;
566- cxlr -> coord [i ].write_bandwidth += perf -> coord .write_bandwidth ;
584+ perf -> coord [ i ] .write_latency );
585+ cxlr -> coord [i ].read_bandwidth += perf -> coord [ i ] .read_bandwidth ;
586+ cxlr -> coord [i ].write_bandwidth += perf -> coord [ i ] .write_bandwidth ;
567587 }
568588}
569589
0 commit comments