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

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