linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yuxuan Shui <yshuiv7@gmail.com>
To: linux-pm@vger.kernel.org
Cc: arjan@linux.intel.com, jacob.jun.pan@linux.intel.com,
	Yuxuan Shui <yshuiv7@gmail.com>
Subject: [PATCH] intel_powerclamp: Fix cstate counter detection.
Date: Mon, 18 Nov 2013 15:06:35 +0800	[thread overview]
Message-ID: <1384758395-5074-1-git-send-email-yshuiv7@gmail.com> (raw)

Having all zero cstate count doesn't necesserily mean the cstate
counter is no functional.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
---
 drivers/thermal/intel_powerclamp.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/intel_powerclamp.c b/drivers/thermal/intel_powerclamp.c
index b40b37c..e302769 100644
--- a/drivers/thermal/intel_powerclamp.c
+++ b/drivers/thermal/intel_powerclamp.c
@@ -206,6 +206,15 @@ static void find_target_mwait(void)
 
 }
 
+static bool has_pkg_state_counter(void)
+{
+	u64 tmp;
+	return !rdmsrl_safe(MSR_PKG_C2_RESIDENCY, &tmp) ||
+	       !rdmsrl_safe(MSR_PKG_C3_RESIDENCY, &tmp) ||
+	       !rdmsrl_safe(MSR_PKG_C6_RESIDENCY, &tmp) ||
+	       !rdmsrl_safe(MSR_PKG_C7_RESIDENCY, &tmp);
+}
+
 static u64 pkg_state_counter(void)
 {
 	u64 val;
@@ -500,7 +509,7 @@ static int start_power_clamp(void)
 	struct task_struct *thread;
 
 	/* check if pkg cstate counter is completely 0, abort in this case */
-	if (!pkg_state_counter()) {
+	if (!has_pkg_state_counter()) {
 		pr_err("pkg cstate counter not functional, abort\n");
 		return -EINVAL;
 	}
-- 
1.8.4.2


             reply	other threads:[~2013-11-18  7:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-18  7:06 Yuxuan Shui [this message]
2013-11-18 16:22 ` [PATCH] intel_powerclamp: Fix cstate counter detection Arjan van de Ven
2013-11-19  5:44   ` Yuxuan Shui
     [not found]   ` <CAGqt0zw2wEM_4SqMA8tqzABe0M1-ZXxM6X3rh4OezfnS9-eXJg@mail.gmail.com>
     [not found]     ` <528B74C9.3010902@linux.intel.com>
2013-11-19 18:09       ` Yuxuan Shui
2013-11-19 18:38         ` Jacob Pan
2014-01-02  3:03           ` Zhang Rui
2014-01-02 20:41             ` jacob pan

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=1384758395-5074-1-git-send-email-yshuiv7@gmail.com \
    --to=yshuiv7@gmail.com \
    --cc=arjan@linux.intel.com \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=linux-pm@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).