Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
[firefly-linux-kernel-4.4.55.git] / drivers / thermal / intel_powerclamp.c
index d833c8f5b465d4a96e5ee0d34de8758e1035169e..a084325f13861cc12de7824d9a251ccb58cdb282 100644 (file)
@@ -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;
@@ -498,7 +507,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;
        }