diff options
author | Thomas Renninger <trenn@suse.de> | 2014-05-13 12:41:43 +0200 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2014-05-17 00:36:36 +0200 |
commit | 8a19cb586708361058e089b7c23b6f3eb33af6c6 (patch) | |
tree | a59cffe15d0efb00a4b1ce7fe73dfcc9fb1f3a79 /tools | |
parent | 84baab91772b5aeec9040cb33de6a46738b1aba8 (diff) | |
download | op-kernel-dev-8a19cb586708361058e089b7c23b6f3eb33af6c6.zip op-kernel-dev-8a19cb586708361058e089b7c23b6f3eb33af6c6.tar.gz |
cpupower: If root, try to load msr driver on x86 if /dev/cpu/0/msr is not available
Signed-off-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/power/cpupower/utils/cpupower.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/power/cpupower/utils/cpupower.c b/tools/power/cpupower/utils/cpupower.c index 7efc570..7cdcf88 100644 --- a/tools/power/cpupower/utils/cpupower.c +++ b/tools/power/cpupower/utils/cpupower.c @@ -12,6 +12,9 @@ #include <string.h> #include <unistd.h> #include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/utsname.h> #include "builtin.h" #include "helpers/helpers.h" @@ -169,6 +172,8 @@ int main(int argc, const char *argv[]) { const char *cmd; unsigned int i, ret; + struct stat statbuf; + struct utsname uts; cpus_chosen = bitmask_alloc(sysconf(_SC_NPROCESSORS_CONF)); @@ -195,6 +200,15 @@ int main(int argc, const char *argv[]) get_cpu_info(0, &cpupower_cpu_info); run_as_root = !getuid(); + if (run_as_root) { + ret = uname(&uts); + if (!ret && !strcmp(uts.machine, "x86_64") && + stat("/dev/cpu/0/msr", &statbuf) != 0) { + if (system("modprobe msr") == -1) + fprintf(stderr, _("MSR access not available.\n")); + } + } + for (i = 0; i < ARRAY_SIZE(commands); i++) { struct cmd_struct *p = commands + i; |