@@ -251,11 +251,8 @@ char *output_buffer, *outp;
251
251
unsigned int do_dts ;
252
252
unsigned int do_ptm ;
253
253
unsigned int do_ipc ;
254
- unsigned long long gfx_cur_rc6_ms ;
255
254
unsigned long long cpuidle_cur_cpu_lpi_us ;
256
255
unsigned long long cpuidle_cur_sys_lpi_us ;
257
- unsigned int gfx_cur_mhz ;
258
- unsigned int gfx_act_mhz ;
259
256
unsigned int tj_max ;
260
257
unsigned int tj_max_override ;
261
258
double rapl_power_units , rapl_time_units ;
@@ -285,6 +282,9 @@ enum gfx_sysfs_idx {
285
282
286
283
struct gfx_sysfs_info {
287
284
const char * path ;
285
+ FILE * fp ;
286
+ unsigned int val ;
287
+ unsigned long long val_ull ;
288
288
};
289
289
290
290
static struct gfx_sysfs_info gfx_info [GFX_MAX ];
@@ -3573,17 +3573,17 @@ int get_counters(struct thread_data *t, struct core_data *c, struct pkg_data *p)
3573
3573
}
3574
3574
3575
3575
if (DO_BIC (BIC_GFX_rc6 ))
3576
- p -> gfx_rc6_ms = gfx_cur_rc6_ms ;
3576
+ p -> gfx_rc6_ms = gfx_info [ GFX_rc6 ]. val_ull ;
3577
3577
3578
3578
/* n.b. assume die0 uncore frequency applies to whole package */
3579
3579
if (DO_BIC (BIC_UNCORE_MHZ ))
3580
3580
p -> uncore_mhz = get_uncore_mhz (p -> package_id , 0 );
3581
3581
3582
3582
if (DO_BIC (BIC_GFXMHz ))
3583
- p -> gfx_mhz = gfx_cur_mhz ;
3583
+ p -> gfx_mhz = gfx_info [ GFX_MHz ]. val ;
3584
3584
3585
3585
if (DO_BIC (BIC_GFXACTMHz ))
3586
- p -> gfx_act_mhz = gfx_act_mhz ;
3586
+ p -> gfx_act_mhz = gfx_info [ GFX_ACTMHz ]. val ;
3587
3587
3588
3588
for (i = 0 , mp = sys .pp ; mp ; i ++ , mp = mp -> next ) {
3589
3589
if (get_mp (cpu , mp , & p -> counter [i ]))
@@ -4621,81 +4621,40 @@ int snapshot_proc_interrupts(void)
4621
4621
}
4622
4622
4623
4623
/*
4624
- * snapshot_gfx_rc6_ms ()
4624
+ * snapshot_graphics ()
4625
4625
*
4626
- * record snapshot of
4627
- * /sys/class/drm/card0/power/rc6_residency_ms
4626
+ * record snapshot of specified graphics sysfs knob
4628
4627
*
4629
4628
* return 1 if config change requires a restart, else return 0
4630
4629
*/
4631
- int snapshot_gfx_rc6_ms ( void )
4630
+ int snapshot_graphics ( int idx )
4632
4631
{
4633
4632
FILE * fp ;
4634
4633
int retval ;
4635
4634
4636
- fp = fopen_or_die (gfx_info [GFX_rc6 ].path , "r" );
4637
-
4638
- retval = fscanf (fp , "%lld" , & gfx_cur_rc6_ms );
4639
- if (retval != 1 )
4640
- err (1 , "GFX rc6" );
4641
-
4642
- fclose (fp );
4643
-
4644
- return 0 ;
4645
- }
4646
-
4647
- /*
4648
- * snapshot_gfx_mhz()
4649
- *
4650
- * fall back to /sys/class/graphics/fb0/device/drm/card0/gt_cur_freq_mhz
4651
- * when /sys/class/drm/card0/gt_cur_freq_mhz is not available.
4652
- *
4653
- * return 1 if config change requires a restart, else return 0
4654
- */
4655
- int snapshot_gfx_mhz (void )
4656
- {
4657
- static FILE * fp ;
4658
- int retval ;
4659
-
4660
- if (fp == NULL ) {
4661
- fp = fopen_or_die (gfx_info [GFX_MHz ].path , "r" );
4662
- } else {
4663
- rewind (fp );
4664
- fflush (fp );
4665
- }
4666
-
4667
- retval = fscanf (fp , "%d" , & gfx_cur_mhz );
4668
- if (retval != 1 )
4669
- err (1 , "GFX MHz" );
4670
-
4671
- return 0 ;
4672
- }
4673
-
4674
- /*
4675
- * snapshot_gfx_cur_mhz()
4676
- *
4677
- * fall back to /sys/class/graphics/fb0/device/drm/card0/gt_act_freq_mhz
4678
- * when /sys/class/drm/card0/gt_act_freq_mhz is not available.
4679
- *
4680
- * return 1 if config change requires a restart, else return 0
4681
- */
4682
- int snapshot_gfx_act_mhz (void )
4683
- {
4684
- static FILE * fp ;
4685
- int retval ;
4686
-
4687
- if (fp == NULL ) {
4688
- fp = fopen_or_die (gfx_info [GFX_ACTMHz ].path , "r" );
4689
- } else {
4690
- rewind (fp );
4691
- fflush (fp );
4635
+ switch (idx ) {
4636
+ case GFX_rc6 :
4637
+ fp = fopen_or_die (gfx_info [idx ].path , "r" );
4638
+ retval = fscanf (fp , "%lld" , & gfx_info [idx ].val_ull );
4639
+ if (retval != 1 )
4640
+ err (1 , "rc6" );
4641
+ fclose (fp );
4642
+ return 0 ;
4643
+ case GFX_MHz :
4644
+ case GFX_ACTMHz :
4645
+ if (gfx_info [idx ].fp == NULL ) {
4646
+ gfx_info [idx ].fp = fopen_or_die (gfx_info [idx ].path , "r" );
4647
+ } else {
4648
+ rewind (gfx_info [idx ].fp );
4649
+ fflush (gfx_info [idx ].fp );
4650
+ }
4651
+ retval = fscanf (gfx_info [idx ].fp , "%d" , & gfx_info [idx ].val );
4652
+ if (retval != 1 )
4653
+ err (1 , "MHz" );
4654
+ return 0 ;
4655
+ default :
4656
+ return - EINVAL ;
4692
4657
}
4693
-
4694
- retval = fscanf (fp , "%d" , & gfx_act_mhz );
4695
- if (retval != 1 )
4696
- err (1 , "GFX ACT MHz" );
4697
-
4698
- return 0 ;
4699
4658
}
4700
4659
4701
4660
/*
@@ -4760,13 +4719,13 @@ int snapshot_proc_sysfs_files(void)
4760
4719
return 1 ;
4761
4720
4762
4721
if (DO_BIC (BIC_GFX_rc6 ))
4763
- snapshot_gfx_rc6_ms ( );
4722
+ snapshot_graphics ( GFX_rc6 );
4764
4723
4765
4724
if (DO_BIC (BIC_GFXMHz ))
4766
- snapshot_gfx_mhz ( );
4725
+ snapshot_graphics ( GFX_MHz );
4767
4726
4768
4727
if (DO_BIC (BIC_GFXACTMHz ))
4769
- snapshot_gfx_act_mhz ( );
4728
+ snapshot_graphics ( GFX_ACTMHz );
4770
4729
4771
4730
if (DO_BIC (BIC_CPU_LPI ))
4772
4731
snapshot_cpu_lpi_us ();
0 commit comments