@@ -205,6 +205,7 @@ struct msr_counter bic[] = {
205
205
{ 0x0 , "SysWatt" , NULL , 0 , 0 , 0 , NULL , 0 },
206
206
{ 0x0 , "Sys_J" , NULL , 0 , 0 , 0 , NULL , 0 },
207
207
{ 0x0 , "NMI" , NULL , 0 , 0 , 0 , NULL , 0 },
208
+ { 0x0 , "CPU%c1e" , NULL , 0 , 0 , 0 , NULL , 0 },
208
209
};
209
210
210
211
#define MAX_BIC (sizeof(bic) / sizeof(struct msr_counter))
@@ -270,6 +271,7 @@ struct msr_counter bic[] = {
270
271
#define BIC_SysWatt (1ULL << 59)
271
272
#define BIC_Sys_J (1ULL << 60)
272
273
#define BIC_NMI (1ULL << 61)
274
+ #define BIC_CPU_c1e (1ULL << 62)
273
275
274
276
#define BIC_TOPOLOGY (BIC_Package | BIC_Node | BIC_CoreCnt | BIC_PkgCnt | BIC_Core | BIC_CPU | BIC_Die)
275
277
#define BIC_THERMAL_PWR (BIC_CoreTmp | BIC_PkgTmp | BIC_PkgWatt | BIC_CorWatt | BIC_GFXWatt | BIC_RAMWatt | BIC_PKG__ | BIC_RAM__ | BIC_SysWatt)
@@ -1538,6 +1540,14 @@ static struct msr_counter_arch_info msr_counter_arch_infos[] = {
1538
1540
#define PMT_MTL_DC6_GUID 0x1a067102
1539
1541
#define PMT_MTL_DC6_SEQ 0
1540
1542
1543
+ #define PMT_COUNTER_CWF_MC1E_OFFSET_BASE 20936
1544
+ #define PMT_COUNTER_CWF_MC1E_OFFSET_INCREMENT 24
1545
+ #define PMT_COUNTER_CWF_MC1E_NUM_MODULES_PER_FILE 12
1546
+ #define PMT_COUNTER_CWF_CPUS_PER_MODULE 4
1547
+ #define PMT_COUNTER_CWF_MC1E_LSB 0
1548
+ #define PMT_COUNTER_CWF_MC1E_MSB 63
1549
+ #define PMT_CWF_MC1E_GUID 0x14421519
1550
+
1541
1551
unsigned long long tcore_clock_freq_hz = 800000000 ;
1542
1552
1543
1553
#define PMT_COUNTER_NAME_SIZE_BYTES 16
@@ -9367,11 +9377,69 @@ int pmt_add_counter(unsigned int guid, unsigned int seq, const char *name, enum
9367
9377
9368
9378
void pmt_init (void )
9369
9379
{
9380
+ int cpu_num ;
9381
+ unsigned long seq , offset , mod_num ;
9382
+
9370
9383
if (BIC_IS_ENABLED (BIC_Diec6 )) {
9371
9384
pmt_add_counter (PMT_MTL_DC6_GUID , PMT_MTL_DC6_SEQ , "Die%c6" , PMT_TYPE_XTAL_TIME ,
9372
9385
PMT_COUNTER_MTL_DC6_LSB , PMT_COUNTER_MTL_DC6_MSB , PMT_COUNTER_MTL_DC6_OFFSET ,
9373
9386
SCOPE_PACKAGE , FORMAT_DELTA , 0 , PMT_OPEN_TRY );
9374
9387
}
9388
+
9389
+ if (BIC_IS_ENABLED (BIC_CPU_c1e )) {
9390
+ seq = 0 ;
9391
+ offset = PMT_COUNTER_CWF_MC1E_OFFSET_BASE ;
9392
+ mod_num = 0 ; /* Relative module number for current PMT file. */
9393
+
9394
+ /* Open the counter for each CPU. */
9395
+ for (cpu_num = 0 ; cpu_num < topo .max_cpu_num ;) {
9396
+
9397
+ if (cpu_is_not_allowed (cpu_num ))
9398
+ goto next_loop_iter ;
9399
+
9400
+ /*
9401
+ * Set the scope to CPU, even though CWF report the counter per module.
9402
+ * CPUs inside the same module will read from the same location, instead of reporting zeros.
9403
+ *
9404
+ * CWF with newer firmware might require a PMT_TYPE_XTAL_TIME intead of PMT_TYPE_TCORE_CLOCK.
9405
+ */
9406
+ pmt_add_counter (PMT_CWF_MC1E_GUID , seq , "CPU%c1e" , PMT_TYPE_TCORE_CLOCK ,
9407
+ PMT_COUNTER_CWF_MC1E_LSB , PMT_COUNTER_CWF_MC1E_MSB , offset , SCOPE_CPU ,
9408
+ FORMAT_DELTA , cpu_num , PMT_OPEN_TRY );
9409
+
9410
+ /*
9411
+ * Rather complex logic for each time we go to the next loop iteration,
9412
+ * so keep it as a label.
9413
+ */
9414
+ next_loop_iter :
9415
+ /*
9416
+ * Advance the cpu number and check if we should also advance offset to
9417
+ * the next counter inside the PMT file.
9418
+ *
9419
+ * On Clearwater Forest platform, the counter is reported per module,
9420
+ * so open the same counter for all of the CPUs inside the module.
9421
+ * That way, reported table show the correct value for all of the CPUs inside the module,
9422
+ * instead of zeros.
9423
+ */
9424
+ ++ cpu_num ;
9425
+ if (cpu_num % PMT_COUNTER_CWF_CPUS_PER_MODULE == 0 ) {
9426
+ offset += PMT_COUNTER_CWF_MC1E_OFFSET_INCREMENT ;
9427
+ ++ mod_num ;
9428
+ }
9429
+
9430
+ /*
9431
+ * There are PMT_COUNTER_CWF_MC1E_NUM_MODULES_PER_FILE in each PMT file.
9432
+ *
9433
+ * If that number is reached, seq must be incremented to advance to the next file in a sequence.
9434
+ * Offset inside that file and a module counter has to be reset.
9435
+ */
9436
+ if (mod_num == PMT_COUNTER_CWF_MC1E_NUM_MODULES_PER_FILE ) {
9437
+ ++ seq ;
9438
+ offset = PMT_COUNTER_CWF_MC1E_OFFSET_BASE ;
9439
+ mod_num = 0 ;
9440
+ }
9441
+ }
9442
+ }
9375
9443
}
9376
9444
9377
9445
void turbostat_init ()
0 commit comments