浏览代码

intel_powerclamp: Fix cstate counter detection.

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

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Yuxuan Shui 11 年之前
父节点
当前提交
7734e3ac89
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 10 1
      drivers/thermal/intel_powerclamp.c

+ 10 - 1
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)
 static u64 pkg_state_counter(void)
 {
 {
 	u64 val;
 	u64 val;
@@ -500,7 +509,7 @@ static int start_power_clamp(void)
 	struct task_struct *thread;
 	struct task_struct *thread;
 
 
 	/* check if pkg cstate counter is completely 0, abort in this case */
 	/* 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");
 		pr_err("pkg cstate counter not functional, abort\n");
 		return -EINVAL;
 		return -EINVAL;
 	}
 	}