Only reset values on exiting if we've ever modified them.
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
diff --git a/adl.c b/adl.c
index a73dba4..2605956 100644
--- a/adl.c
+++ b/adl.c
@@ -318,6 +318,12 @@ void init_adl(int nDevs)
ADL_Overdrive5_PowerControl_Get(ga->iAdapterIndex, &ga->iPercentage, &dummy);
}
+ /* Flag if the values of this GPU were ever modified to tell us
+ * we need to reset the values upon exiting */
+ if (gpus[gpu].gpu_engine || gpus[gpu].gpu_memclock || gpus[gpu].gpu_vddc ||
+ gpus[gpu].gpu_fan || gpus[gpu].gpu_powertune)
+ ga->managed = true;
+
/* Set some default temperatures for autotune when enabled */
ga->targettemp = opt_targettemp;
ga->overtemp = opt_overheattemp;
@@ -616,6 +622,7 @@ static int set_engineclock(int gpu, int iEngineClock)
ga->minspeed = ga->iEngineClock;
ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock;
ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc;
+ ga->managed = true;
ret = 0;
out:
unlock_adl();
@@ -677,6 +684,7 @@ static int set_memoryclock(int gpu, int iMemoryClock)
ga->iEngineClock = lpOdPerformanceLevels->aLevels[lev].iEngineClock;
ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock;
ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc;
+ ga->managed = true;
ret = 0;
out:
unlock_adl();
@@ -749,6 +757,7 @@ static int set_vddc(int gpu, float fVddc)
ga->iEngineClock = lpOdPerformanceLevels->aLevels[lev].iEngineClock;
ga->iMemoryClock = lpOdPerformanceLevels->aLevels[lev].iMemoryClock;
ga->iVddc = lpOdPerformanceLevels->aLevels[lev].iVddc;
+ ga->managed = true;
ret = 0;
out:
unlock_adl();
@@ -796,6 +805,7 @@ static int set_fanspeed(int gpu, int iFanSpeed)
ga->lpFanSpeedValue.iFanSpeed = iFanSpeed;
if (ADL_Overdrive5_FanSpeed_Set(ga->iAdapterIndex, 0, &ga->lpFanSpeedValue) != ADL_OK)
goto out;
+ ga->managed = true;
ret = 0;
out:
unlock_adl();
@@ -822,6 +832,7 @@ static int set_powertune(int gpu, int iPercentage)
goto out;
}
ADL_Overdrive5_PowerControl_Get(ga->iAdapterIndex, &ga->iPercentage, &dummy);
+ ga->managed = true;
ret = 0;
out:
unlock_adl();
@@ -1079,7 +1090,8 @@ void clear_adl(nDevs)
/* Try to reset values to their defaults */
for (i = 0; i < nDevs; i++) {
ga = &gpus[i].adl;
- if (!gpus[i].has_adl)
+ /* Only reset the values if we've changed them at any time */
+ if (!gpus[i].has_adl || !ga->managed)
continue;
ADL_Adapter_Speed_Set(ga->iAdapterIndex, ga->lpCurrent);
ADL_Overdrive5_ODPerformanceLevels_Set(ga->iAdapterIndex, ga->DefPerfLev);
diff --git a/miner.h b/miner.h
index a1d99f0..2dc1d16 100644
--- a/miner.h
+++ b/miner.h
@@ -176,6 +176,7 @@ struct gpu_adl {
bool autofan;
bool autoengine;
+ bool managed; /* Were the values ever changed on this card */
int targettemp;
int overtemp;