@@ -20,6 +20,36 @@ struct dsmas_entry {
20
20
int qos_class ;
21
21
};
22
22
23
+ static u32 cdat_normalize (u16 entry , u64 base , u8 type )
24
+ {
25
+ u32 value ;
26
+
27
+ /*
28
+ * Check for invalid and overflow values
29
+ */
30
+ if (entry == 0xffff || !entry )
31
+ return 0 ;
32
+ else if (base > (UINT_MAX / (entry )))
33
+ return 0 ;
34
+
35
+ /*
36
+ * CDAT fields follow the format of HMAT fields. See table 5 Device
37
+ * Scoped Latency and Bandwidth Information Structure in Coherent Device
38
+ * Attribute Table (CDAT) Specification v1.01.
39
+ */
40
+ value = entry * base ;
41
+ switch (type ) {
42
+ case ACPI_HMAT_ACCESS_LATENCY :
43
+ case ACPI_HMAT_READ_LATENCY :
44
+ case ACPI_HMAT_WRITE_LATENCY :
45
+ value = DIV_ROUND_UP (value , 1000 );
46
+ break ;
47
+ default :
48
+ break ;
49
+ }
50
+ return value ;
51
+ }
52
+
23
53
static int cdat_dsmas_handler (union acpi_subtable_headers * header , void * arg ,
24
54
const unsigned long end )
25
55
{
@@ -97,7 +127,6 @@ static int cdat_dslbis_handler(union acpi_subtable_headers *header, void *arg,
97
127
__le16 le_val ;
98
128
u64 val ;
99
129
u16 len ;
100
- int rc ;
101
130
102
131
len = le16_to_cpu ((__force __le16 )hdr -> length );
103
132
if (len != size || (unsigned long )hdr + len > end ) {
@@ -124,10 +153,8 @@ static int cdat_dslbis_handler(union acpi_subtable_headers *header, void *arg,
124
153
125
154
le_base = (__force __le64 )dslbis -> entry_base_unit ;
126
155
le_val = (__force __le16 )dslbis -> entry [0 ];
127
- rc = check_mul_overflow (le64_to_cpu (le_base ),
128
- le16_to_cpu (le_val ), & val );
129
- if (rc )
130
- pr_warn ("DSLBIS value overflowed.\n" );
156
+ val = cdat_normalize (le16_to_cpu (le_val ), le64_to_cpu (le_base ),
157
+ dslbis -> data_type );
131
158
132
159
cxl_access_coordinate_set (& dent -> coord , dslbis -> data_type , val );
133
160
@@ -164,7 +191,6 @@ static int cxl_port_perf_data_calculate(struct cxl_port *port,
164
191
struct xarray * dsmas_xa )
165
192
{
166
193
struct access_coordinate ep_c ;
167
- struct access_coordinate coord [ACCESS_COORDINATE_MAX ];
168
194
struct dsmas_entry * dent ;
169
195
int valid_entries = 0 ;
170
196
unsigned long index ;
@@ -176,12 +202,6 @@ static int cxl_port_perf_data_calculate(struct cxl_port *port,
176
202
return rc ;
177
203
}
178
204
179
- rc = cxl_hb_get_perf_coordinates (port , coord );
180
- if (rc ) {
181
- dev_dbg (& port -> dev , "Failed to retrieve hb perf coordinates.\n" );
182
- return rc ;
183
- }
184
-
185
205
struct cxl_root * cxl_root __free (put_cxl_root ) = find_cxl_root (port );
186
206
187
207
if (!cxl_root )
@@ -194,18 +214,9 @@ static int cxl_port_perf_data_calculate(struct cxl_port *port,
194
214
int qos_class ;
195
215
196
216
cxl_coordinates_combine (& dent -> coord , & dent -> coord , & ep_c );
197
- /*
198
- * Keeping the host bridge coordinates separate from the dsmas
199
- * coordinates in order to allow calculation of access class
200
- * 0 and 1 for region later.
201
- */
202
- cxl_coordinates_combine (& coord [ACCESS_COORDINATE_CPU ],
203
- & coord [ACCESS_COORDINATE_CPU ],
204
- & dent -> coord );
205
217
dent -> entries = 1 ;
206
- rc = cxl_root -> ops -> qos_class (cxl_root ,
207
- & coord [ACCESS_COORDINATE_CPU ],
208
- 1 , & qos_class );
218
+ rc = cxl_root -> ops -> qos_class (cxl_root , & dent -> coord , 1 ,
219
+ & qos_class );
209
220
if (rc != 1 )
210
221
continue ;
211
222
@@ -461,10 +472,8 @@ static int cdat_sslbis_handler(union acpi_subtable_headers *header, void *arg,
461
472
462
473
le_base = (__force __le64 )tbl -> sslbis_header .entry_base_unit ;
463
474
le_val = (__force __le16 )tbl -> entries [i ].latency_or_bandwidth ;
464
-
465
- if (check_mul_overflow (le64_to_cpu (le_base ),
466
- le16_to_cpu (le_val ), & val ))
467
- dev_warn (dev , "SSLBIS value overflowed!\n" );
475
+ val = cdat_normalize (le16_to_cpu (le_val ), le64_to_cpu (le_base ),
476
+ sslbis -> data_type );
468
477
469
478
xa_for_each (& port -> dports , index , dport ) {
470
479
if (dsp_id == ACPI_CDAT_SSLBIS_ANY_PORT ||
@@ -521,17 +530,13 @@ void cxl_region_perf_data_calculate(struct cxl_region *cxlr,
521
530
struct cxl_endpoint_decoder * cxled )
522
531
{
523
532
struct cxl_memdev * cxlmd = cxled_to_memdev (cxled );
524
- struct cxl_port * port = cxlmd -> endpoint ;
525
533
struct cxl_dev_state * cxlds = cxlmd -> cxlds ;
526
534
struct cxl_memdev_state * mds = to_cxl_memdev_state (cxlds );
527
- struct access_coordinate hb_coord [ACCESS_COORDINATE_MAX ];
528
- struct access_coordinate coord ;
529
535
struct range dpa = {
530
536
.start = cxled -> dpa_res -> start ,
531
537
.end = cxled -> dpa_res -> end ,
532
538
};
533
539
struct cxl_dpa_perf * perf ;
534
- int rc ;
535
540
536
541
switch (cxlr -> mode ) {
537
542
case CXL_DECODER_RAM :
@@ -549,35 +554,16 @@ void cxl_region_perf_data_calculate(struct cxl_region *cxlr,
549
554
if (!range_contains (& perf -> dpa_range , & dpa ))
550
555
return ;
551
556
552
- rc = cxl_hb_get_perf_coordinates (port , hb_coord );
553
- if (rc ) {
554
- dev_dbg (& port -> dev , "Failed to retrieve hb perf coordinates.\n" );
555
- return ;
556
- }
557
-
558
557
for (int i = 0 ; i < ACCESS_COORDINATE_MAX ; i ++ ) {
559
- /* Pickup the host bridge coords */
560
- cxl_coordinates_combine (& coord , & hb_coord [i ], & perf -> coord );
561
-
562
558
/* Get total bandwidth and the worst latency for the cxl region */
563
559
cxlr -> coord [i ].read_latency = max_t (unsigned int ,
564
560
cxlr -> coord [i ].read_latency ,
565
- coord .read_latency );
561
+ perf -> coord .read_latency );
566
562
cxlr -> coord [i ].write_latency = max_t (unsigned int ,
567
563
cxlr -> coord [i ].write_latency ,
568
- coord .write_latency );
569
- cxlr -> coord [i ].read_bandwidth += coord .read_bandwidth ;
570
- cxlr -> coord [i ].write_bandwidth += coord .write_bandwidth ;
571
-
572
- /*
573
- * Convert latency to nanosec from picosec to be consistent
574
- * with the resulting latency coordinates computed by the
575
- * HMAT_REPORTING code.
576
- */
577
- cxlr -> coord [i ].read_latency =
578
- DIV_ROUND_UP (cxlr -> coord [i ].read_latency , 1000 );
579
- cxlr -> coord [i ].write_latency =
580
- DIV_ROUND_UP (cxlr -> coord [i ].write_latency , 1000 );
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 ;
581
567
}
582
568
}
583
569
0 commit comments