Commit 400cb21d8baaec229f69af545d288b868b4ffe8e

Con Kolivas 2011-12-24T08:06:53

Off by one error in performance level.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/adl.c b/adl.c
index 5eacf16..6f973ff 100644
--- a/adl.c
+++ b/adl.c
@@ -866,12 +866,12 @@ void gpu_autotune(int gpu, bool *enable)
 			applog(LOG_WARNING, "Overheat detected, decreasing GPU %d clock speed", gpu);
 			newengine = ga->minspeed;
 		/* Only try to tune engine speed if the current performance level is at max */
-		} else if ((ga->lpActivity.iCurrentPerformanceLevel == ga->lpOdParameters.iNumberOfPerformanceLevels) &&
+		} else if ((ga->lpActivity.iCurrentPerformanceLevel == ga->lpOdParameters.iNumberOfPerformanceLevels - 1) &&
 			   (temp > ga->targettemp + opt_hysteresis && engine > ga->minspeed && fan_optimal)) {
 			if (opt_debug)
 				applog(LOG_DEBUG, "Temperature %d degrees over target, decreasing clock speed", opt_hysteresis);
 			newengine = engine - ga->lpOdParameters.sEngineClock.iStep;
-		} else if ((ga->lpActivity.iCurrentPerformanceLevel == ga->lpOdParameters.iNumberOfPerformanceLevels) &&
+		} else if ((ga->lpActivity.iCurrentPerformanceLevel == ga->lpOdParameters.iNumberOfPerformanceLevels - 1) &&
 			   (temp < ga->targettemp && engine < ga->maxspeed)) {
 			if (opt_debug)
 				applog(LOG_DEBUG, "Temperature below target, increasing clock speed");