Blame SOURCES/powertop-2.9-cstates-rewrite-fix.patch

60eb6b
From f3f350f138912dc89abb37676f7e65fc6057ec53 Mon Sep 17 00:00:00 2001
60eb6b
From: Gautam Paranjape <gautam.paranjape@intel.com>
60eb6b
Date: Fri, 21 Jul 2017 07:02:13 -0700
60eb6b
Subject: [PATCH] Some c-states exposed by the intel_idle driver are assigned
60eb6b
 the same line_level, which means that the most recent one assigned can
60eb6b
 overwrite another c-state. For example, the C1-SKL c-state is overwritten by
60eb6b
 the C1E-SKL c-state because both have a "1" in the name and are assigned the
60eb6b
 same line level. To fix this, check if a "sub c-state" (ex. C1E-SKL) is being
60eb6b
 inserted. If so, check the vector of c-states if a c-state with similar name
60eb6b
 (ex. C1-SKL) exists, and increment the line level.
60eb6b
60eb6b
Signed-off-by: Gautam Paranjape <gautam.paranjape@intel.com>
60eb6b
---
60eb6b
 src/cpu/abstract_cpu.cpp | 11 +++++++++++
60eb6b
 1 file changed, 11 insertions(+)
60eb6b
60eb6b
diff --git a/src/cpu/abstract_cpu.cpp b/src/cpu/abstract_cpu.cpp
60eb6b
index bc32336..c59721c 100644
60eb6b
--- a/src/cpu/abstract_cpu.cpp
60eb6b
+++ b/src/cpu/abstract_cpu.cpp
60eb6b
@@ -218,6 +218,17 @@ void abstract_cpu::insert_cstate(const char *linux_name, const char *human_name,
60eb6b
 		}
60eb6b
 		if (*c >= '0' && *c <='9') {
60eb6b
 			state->line_level = strtoull(c, NULL, 10);
60eb6b
+			if(*(c+1) != '-'){
60eb6b
+				int greater_line_level = strtoull(c, NULL, 10);
60eb6b
+				for(unsigned int pos = 0; pos < cstates.size(); pos++){
60eb6b
+					if(*c == cstates[pos]->human_name[1]){
60eb6b
+						if(*(c+1) != cstates[pos]->human_name[2]){
60eb6b
+							greater_line_level = max(greater_line_level, cstates[pos]->line_level);
60eb6b
+							state->line_level = greater_line_level + 1;
60eb6b
+						}
60eb6b
+					}
60eb6b
+				}
60eb6b
+			}
60eb6b
 			break;
60eb6b
 		}
60eb6b
 		c++;
60eb6b
-- 
60eb6b
2.14.3
60eb6b