Browse Source

Pass the lasttemp from the device we're using to adjust fanspeed in twin devices.

nfactor-troky
Con Kolivas 13 years ago
parent
commit
d48faf3998
  1. 22
      adl.c

22
adl.c

@ -978,7 +978,7 @@ static int set_powertune(int gpu, int iPercentage)
return ret; return ret;
} }
static void fan_autotune(int gpu, int temp, int fanpercent, bool __maybe_unused *fan_optimal) static void fan_autotune(int gpu, int temp, int fanpercent, int lasttemp, bool __maybe_unused *fan_optimal)
{ {
struct cgpu_info *cgpu = &gpus[gpu]; struct cgpu_info *cgpu = &gpus[gpu];
struct gpu_adl *ga = &cgpu->adl; struct gpu_adl *ga = &cgpu->adl;
@ -991,7 +991,7 @@ static void fan_autotune(int gpu, int temp, int fanpercent, bool __maybe_unused
if (temp > ga->overtemp && fanpercent < iMax) { if (temp > ga->overtemp && fanpercent < iMax) {
applog(LOG_WARNING, "Overheat detected on GPU %d, increasing fan to 100%", gpu); applog(LOG_WARNING, "Overheat detected on GPU %d, increasing fan to 100%", gpu);
newpercent = iMax; newpercent = iMax;
} else if (temp > ga->targettemp && fanpercent < top && temp >= ga->lasttemp) { } else if (temp > ga->targettemp && fanpercent < top && temp >= lasttemp) {
applog(LOG_DEBUG, "Temperature over target, increasing fanspeed"); applog(LOG_DEBUG, "Temperature over target, increasing fanspeed");
if (temp > ga->targettemp + opt_hysteresis) if (temp > ga->targettemp + opt_hysteresis)
newpercent = ga->targetfan + 10; newpercent = ga->targetfan + 10;
@ -999,16 +999,16 @@ static void fan_autotune(int gpu, int temp, int fanpercent, bool __maybe_unused
newpercent = ga->targetfan + 5; newpercent = ga->targetfan + 5;
if (newpercent > top) if (newpercent > top)
newpercent = top; newpercent = top;
} else if (fanpercent > bot && temp < ga->targettemp - opt_hysteresis && temp <= ga->lasttemp) { } else if (fanpercent > bot && temp < ga->targettemp - opt_hysteresis && temp <= lasttemp) {
applog(LOG_DEBUG, "Temperature %d degrees below target, decreasing fanspeed", opt_hysteresis); applog(LOG_DEBUG, "Temperature %d degrees below target, decreasing fanspeed", opt_hysteresis);
newpercent = ga->targetfan - 1; newpercent = ga->targetfan - 1;
} else { } else {
/* We're in the optimal range, make minor adjustments if the /* We're in the optimal range, make minor adjustments if the
* temp is still drifting */ * temp is still drifting */
if (fanpercent > bot && temp < ga->lasttemp && ga->lasttemp < ga->targettemp) { if (fanpercent > bot && temp < lasttemp && lasttemp < ga->targettemp) {
applog(LOG_DEBUG, "Temperature dropping while in target range, decreasing fanspeed"); applog(LOG_DEBUG, "Temperature dropping while in target range, decreasing fanspeed");
newpercent = ga->targetfan - 1; newpercent = ga->targetfan - 1;
} else if (fanpercent < top && temp > ga->lasttemp && temp > ga->targettemp - opt_hysteresis) { } else if (fanpercent < top && temp > lasttemp && temp > ga->targettemp - opt_hysteresis) {
applog(LOG_DEBUG, "Temperature rising while in target range, increasing fanspeed"); applog(LOG_DEBUG, "Temperature rising while in target range, increasing fanspeed");
newpercent = ga->targetfan + 1; newpercent = ga->targetfan + 1;
} }
@ -1047,21 +1047,25 @@ void gpu_autotune(int gpu, enum dev_enable *denable)
if (temp && fanpercent >= 0 && ga->autofan) { if (temp && fanpercent >= 0 && ga->autofan) {
if (!ga->twin) if (!ga->twin)
fan_autotune(gpu, temp, fanpercent, &fan_optimal); fan_autotune(gpu, temp, fanpercent, ga->lasttemp, &fan_optimal);
else if (ga->autofan && (ga->has_fanspeed || !ga->twin->autofan)) { else if (ga->autofan && (ga->has_fanspeed || !ga->twin->autofan)) {
/* On linked GPUs, we autotune the fan only once, based /* On linked GPUs, we autotune the fan only once, based
* on the highest temperature from either GPUs */ * on the highest temperature from either GPUs */
int hightemp, fan_gpu; int hightemp, fan_gpu;
int lasttemp;
if (twintemp > temp) if (twintemp > temp) {
lasttemp = ga->twin->lasttemp;
hightemp = twintemp; hightemp = twintemp;
else } else {
lasttemp = ga->lasttemp;
hightemp = temp; hightemp = temp;
}
if (ga->has_fanspeed) if (ga->has_fanspeed)
fan_gpu = gpu; fan_gpu = gpu;
else else
fan_gpu = ga->twin->gpu; fan_gpu = ga->twin->gpu;
fan_autotune(fan_gpu, hightemp, fanpercent, &fan_optimal); fan_autotune(fan_gpu, hightemp, fanpercent, lasttemp, &fan_optimal);
} }
} }

Loading…
Cancel
Save