All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Renninger <trenn@suse.de>
To: rjw@rjwysocki.net
Cc: linux-pm@vger.kernel.org, Thomas Renninger <trenn@suse.de>
Subject: [PATCH 6/9] cpupower: If root, try to load msr driver on x86 if /dev/cpu/0/msr is not avail
Date: Tue, 13 May 2014 12:41:43 +0200	[thread overview]
Message-ID: <1399977706-50854-7-git-send-email-trenn@suse.de> (raw)
In-Reply-To: <1399977706-50854-1-git-send-email-trenn@suse.de>

Signed-off-by: Thomas Renninger <trenn@suse.de>
---
 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;
-- 
1.7.6.1


  parent reply	other threads:[~2014-05-13 10:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13 10:41 Latest cpupower enhancements and fixes Thomas Renninger
2014-05-13 10:41 ` [PATCH 1/9] cpupower: Rename cpufrequtils -> cpupower, and libcpufreq -> libcpupower Thomas Renninger
2014-05-13 10:41 ` [PATCH 2/9] cpupower: Remove dead link to homepage, and update the targets built Thomas Renninger
2014-05-13 10:41 ` [PATCH 3/9] cpupower: Remove all manpages on make uninstall Thomas Renninger
2014-05-13 10:41 ` [PATCH 4/9] cpupower: Introduce idle state disable-by-latency and enable-all Thomas Renninger
2014-05-13 10:41 ` [PATCH 5/9] cpupower: Install recently added cpupower-idle-{set,info} manpages Thomas Renninger
2014-05-13 10:41 ` Thomas Renninger [this message]
2014-05-13 10:41 ` [PATCH 7/9] cpupower: cpupower info -b should return 0 on success, not the perf bias value Thomas Renninger
2014-05-13 10:41 ` [PATCH 8/9] cpupower: Remove mc and smt power aware scheduler info/settings Thomas Renninger
2014-05-13 10:41 ` [PATCH 9/9] cpupower, add option to display frequencies and latencies without rounding off values Thomas Renninger
2014-05-16 22:57 ` Latest cpupower enhancements and fixes Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399977706-50854-7-git-send-email-trenn@suse.de \
    --to=trenn@suse.de \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.