Commit f4d657ee7f1f13d9e6b8ace2217000fd094187f6

Con Kolivas 2011-12-24T07:35:42

Only adjust gpu engine speed in autotune mode if the gpu is currently at the performance level of that being adjusted.

diff --git a/adl.c b/adl.c
index 39aa697..5eacf16 100644
--- a/adl.c
+++ b/adl.c
@@ -815,6 +815,7 @@ void gpu_autotune(int gpu, bool *enable)
 	ga = &cgpu->adl;
 
 	lock_adl();
+	ADL_Overdrive5_CurrentActivity_Get(ga->iAdapterIndex, &ga->lpActivity);
 	temp = __gpu_temp(ga);
 	newpercent = fanpercent = __gpu_fanpercent(ga);
 	unlock_adl();
@@ -864,11 +865,14 @@ void gpu_autotune(int gpu, bool *enable)
 		} else if (temp > ga->overtemp && engine > ga->minspeed) {
 			applog(LOG_WARNING, "Overheat detected, decreasing GPU %d clock speed", gpu);
 			newengine = ga->minspeed;
-		} else if (temp > ga->targettemp + opt_hysteresis && engine > ga->minspeed && fan_optimal) {
+		/* Only try to tune engine speed if the current performance level is at max */
+		} else if ((ga->lpActivity.iCurrentPerformanceLevel == ga->lpOdParameters.iNumberOfPerformanceLevels) &&
+			   (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 (temp < ga->targettemp && engine < ga->maxspeed) {
+		} else if ((ga->lpActivity.iCurrentPerformanceLevel == ga->lpOdParameters.iNumberOfPerformanceLevels) &&
+			   (temp < ga->targettemp && engine < ga->maxspeed)) {
 			if (opt_debug)
 				applog(LOG_DEBUG, "Temperature below target, increasing clock speed");
 			newengine = engine + ga->lpOdParameters.sEngineClock.iStep;