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

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