Check last temperature we reached and don't change fan speed if it's already correcting.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
diff --git a/adl.c b/adl.c
index 2877448..3f27d99 100644
--- a/adl.c
+++ b/adl.c
@@ -79,6 +79,7 @@ static int iNumberAdapters;
static LPAdapterInfo lpInfo = NULL;
static int set_fanspeed(int gpu, int iFanSpeed);
+static float __gpu_temp(struct gpu_adl *ga);
static inline void lock_adl(void)
{
@@ -326,10 +327,11 @@ void init_adl(int nDevs)
ga->autoengine = true;
ga->managed = true;
}
+ ga->lasttemp = __gpu_temp(ga);
}
}
-static inline float __gpu_temp(struct gpu_adl *ga)
+static float __gpu_temp(struct gpu_adl *ga)
{
if (ADL_Overdrive5_Temperature_Get(ga->iAdapterIndex, 0, &ga->lpTemperature) != ADL_OK)
return -1;
@@ -828,7 +830,7 @@ void gpu_autotune(int gpu, bool *enable)
if (temp > ga->overtemp && fanpercent < iMax) {
applog(LOG_WARNING, "Overheat detected on GPU %d, increasing fan to 100%", gpu);
newpercent = iMax;
- } else if (temp > ga->targettemp && fanpercent < top) {
+ } else if (temp > ga->targettemp && fanpercent < top && temp >= ga->lasttemp) {
if (opt_debug)
applog(LOG_DEBUG, "Temperature over target, increasing fanspeed");
if (temp > ga->targettemp + opt_hysteresis)
@@ -837,7 +839,7 @@ void gpu_autotune(int gpu, bool *enable)
newpercent = ga->targetfan + 5;
if (newpercent > top)
newpercent = top;
- } else if (fanpercent > bot && temp < ga->targettemp - opt_hysteresis) {
+ } else if (fanpercent > bot && temp < ga->targettemp - opt_hysteresis && temp <= ga->lasttemp) {
if (opt_debug)
applog(LOG_DEBUG, "Temperature %d degrees below target, decreasing fanspeed", opt_hysteresis);
newpercent = ga->targetfan - 1;
@@ -882,6 +884,7 @@ void gpu_autotune(int gpu, bool *enable)
set_engineclock(gpu, newengine);
}
}
+ ga->lasttemp = temp;
}
void set_defaultfan(int gpu)
diff --git a/miner.h b/miner.h
index 3c9d376..5fa8331 100644
--- a/miner.h
+++ b/miner.h
@@ -179,6 +179,7 @@ struct gpu_adl {
bool autoengine;
bool managed; /* Were the values ever changed on this card */
+ int lasttemp;
int targetfan;
int targettemp;
int overtemp;