Skip to content

Commit 90a2fe2

Browse files
committed
tools/power x86_energy_perf_policy: Simplify Android MSR probe
no functional change Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 2ff4b59 commit 90a2fe2

1 file changed

Lines changed: 11 additions & 27 deletions

File tree

tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ unsigned int bdx_highest_ratio;
9595
#define PATH_TO_CPU "/sys/devices/system/cpu/"
9696
#define SYSFS_PATH_MAX 255
9797

98-
/* keep Default as a linux path */
9998
static int use_android_msr_path;
10099

101100
/*
@@ -681,29 +680,6 @@ void err_on_hypervisor(void)
681680
"not supported on this virtual machine");
682681
}
683682

684-
static void probe_msr_path_format(void)
685-
{
686-
struct stat sb;
687-
char test_path[32];
688-
689-
/* Test standard Linux path */
690-
sprintf(test_path, "/dev/cpu/%d/msr", base_cpu);
691-
if (stat(test_path, &sb) == 0) {
692-
use_android_msr_path = 0;
693-
return;
694-
}
695-
696-
/* Test Android-style path */
697-
sprintf(test_path, "/dev/msr%d", base_cpu);
698-
if (stat(test_path, &sb) == 0) {
699-
use_android_msr_path = 1;
700-
return;
701-
}
702-
703-
/* If neither exists, keep the default Linux format */
704-
use_android_msr_path = 0;
705-
}
706-
707683
int get_msr(int cpu, int offset, unsigned long long *msr)
708684
{
709685
int retval;
@@ -1450,12 +1426,23 @@ void set_base_cpu(void)
14501426
err(-ENODEV, "No valid cpus found");
14511427
}
14521428

1429+
static void probe_android_msr_path(void)
1430+
{
1431+
struct stat sb;
1432+
char test_path[32];
1433+
1434+
sprintf(test_path, "/dev/msr%d", base_cpu);
1435+
if (stat(test_path, &sb) == 0)
1436+
use_android_msr_path = 1;
1437+
}
14531438

14541439
void probe_dev_msr(void)
14551440
{
14561441
struct stat sb;
14571442
char pathname[32];
14581443

1444+
probe_android_msr_path();
1445+
14591446
sprintf(pathname, use_android_msr_path ? "/dev/msr%d" : "/dev/cpu/%d/msr", base_cpu);
14601447
if (stat(pathname, &sb)) {
14611448
if (system("/sbin/modprobe msr > /dev/null 2>&1")) {
@@ -1582,9 +1569,6 @@ int main(int argc, char **argv)
15821569
{
15831570
set_base_cpu();
15841571

1585-
/* probe MSR path */
1586-
probe_msr_path_format();
1587-
15881572
probe_dev_msr();
15891573
init_data_structures();
15901574

0 commit comments

Comments
 (0)