Use a re-entrant value to store what fanspeed we're trying to set in case the card doesn't support small changes. Force it to a multiple of 10% if it fails on trying to speed up the fan.
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
diff --git a/adl.c b/adl.c
index 9a73fd2..e3f6187 100644
--- a/adl.c
+++ b/adl.c
@@ -797,6 +797,9 @@ static int set_fanspeed(int gpu, int iFanSpeed)
lock_adl();
if (ADL_Overdrive5_FanSpeed_Get(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue) != ADL_OK)
goto out;
+ /* Store what fanspeed we're actually aiming for for re-entrant changes
+ * in case this device does not support fine setting changes */
+ ga->targetfan = iFanSpeed;
ga->lpFanSpeedValue.iFlags = ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED;
if ((ga->lpFanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_RPM_WRITE) &&
!(ga->lpFanSpeedInfo.iFlags & ADL_DL_FANCTRL_SUPPORTS_PERCENT_WRITE)) {
@@ -868,15 +871,15 @@ void gpu_autotune(int gpu, bool *enable)
if (opt_debug)
applog(LOG_DEBUG, "Temperature over target, increasing fanspeed");
if (temp > ga->targettemp + opt_hysteresis)
- newpercent = fanpercent + 10;
+ newpercent = ga->targetfan + 10;
else
- newpercent = fanpercent + 5;
+ newpercent = ga->targetfan + 5;
if (newpercent > top)
newpercent = top;
} else if (fanpercent > bot && temp < ga->targettemp - opt_hysteresis) {
if (opt_debug)
applog(LOG_DEBUG, "Temperature %d degrees below target, decreasing fanspeed", opt_hysteresis);
- newpercent = fanpercent - 1;
+ newpercent = ga->targetfan - 1;
}
if (newpercent > 100)
@@ -887,6 +890,15 @@ void gpu_autotune(int gpu, bool *enable)
fan_optimal = false;
applog(LOG_INFO, "Setting GPU %d fan percentage to %d", gpu, newpercent);
set_fanspeed(gpu, newpercent);
+ if (newpercent > fanpercent) {
+ int changefan = gpu_fanspeed(gpu);
+
+ if (changefan < newpercent) {
+ newpercent += 10;
+ newpercent -= newpercent % 10;
+ set_fanspeed(gpu, newpercent);
+ }
+ }
}
}
diff --git a/miner.h b/miner.h
index 0567139..ce2a6b6 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 targetfan;
int targettemp;
int overtemp;
int cutofftemp;