Skip to content

Commit 1f81c5e

Browse files
committed
tools/power turbostat: Fix missing SYS_LPI counter on some Chromebooks
Some Chromebook BIOS' do not export an ACPI LPIT, which is how Linux finds the residency counter for CPU and SYSTEM low power states, that is exports in /sys/devices/system/cpu/cpuidle/*residency_us When these sysfs attributes are missing, check the debugfs attrubte from the pmc_core driver, which accesses the same counter value. Signed-off-by: Len Brown <[email protected]>
1 parent f670840 commit 1f81c5e

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

tools/power/x86/turbostat/turbostat.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ int *irqs_per_cpu; /* indexed by cpu_num */
304304

305305
void setup_all_buffers(void);
306306

307+
char *sys_lpi_file;
308+
char *sys_lpi_file_sysfs = "/sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us";
309+
char *sys_lpi_file_debugfs = "/sys/kernel/debug/pmc_core/slp_s0_residency_usec";
310+
307311
int cpu_is_not_present(int cpu)
308312
{
309313
return !CPU_ISSET_S(cpu, cpu_present_setsize, cpu_present_set);
@@ -2916,8 +2920,6 @@ int snapshot_gfx_mhz(void)
29162920
*
29172921
* record snapshot of
29182922
* /sys/devices/system/cpu/cpuidle/low_power_idle_cpu_residency_us
2919-
*
2920-
* return 1 if config change requires a restart, else return 0
29212923
*/
29222924
int snapshot_cpu_lpi_us(void)
29232925
{
@@ -2941,17 +2943,14 @@ int snapshot_cpu_lpi_us(void)
29412943
/*
29422944
* snapshot_sys_lpi()
29432945
*
2944-
* record snapshot of
2945-
* /sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us
2946-
*
2947-
* return 1 if config change requires a restart, else return 0
2946+
* record snapshot of sys_lpi_file
29482947
*/
29492948
int snapshot_sys_lpi_us(void)
29502949
{
29512950
FILE *fp;
29522951
int retval;
29532952

2954-
fp = fopen_or_die("/sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us", "r");
2953+
fp = fopen_or_die(sys_lpi_file, "r");
29552954

29562955
retval = fscanf(fp, "%lld", &cpuidle_cur_sys_lpi_us);
29572956
if (retval != 1) {
@@ -4946,10 +4945,16 @@ void process_cpuid()
49464945
else
49474946
BIC_NOT_PRESENT(BIC_CPU_LPI);
49484947

4949-
if (!access("/sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us", R_OK))
4948+
if (!access(sys_lpi_file_sysfs, R_OK)) {
4949+
sys_lpi_file = sys_lpi_file_sysfs;
49504950
BIC_PRESENT(BIC_SYS_LPI);
4951-
else
4951+
} else if (!access(sys_lpi_file_debugfs, R_OK)) {
4952+
sys_lpi_file = sys_lpi_file_debugfs;
4953+
BIC_PRESENT(BIC_SYS_LPI);
4954+
} else {
4955+
sys_lpi_file_sysfs = NULL;
49524956
BIC_NOT_PRESENT(BIC_SYS_LPI);
4957+
}
49534958

49544959
if (!quiet)
49554960
decode_misc_feature_control();

0 commit comments

Comments
 (0)