Keep track of intended engine clock speed and only adjust up if it's higher than the last intended speed. This avoids setting the clock speed to one relative to a lower profile one by mistake.
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
diff --git a/adl.c b/adl.c
index 7858b99..6f0b501 100644
--- a/adl.c
+++ b/adl.c
@@ -743,6 +743,10 @@ int set_engineclock(int gpu, int iEngineClock)
iEngineClock *= 100;
ga = &gpus[gpu].adl;
+ /* Keep track of intended engine clock in case the device changes
+ * profile and drops while idle, not taking the new engine clock */
+ ga->lastengine = iEngineClock;
+
lev = ga->lpOdParameters.iNumberOfPerformanceLevels - 1;
lpOdPerformanceLevels = alloca(sizeof(ADLODPerformanceLevels) + (lev * sizeof(ADLODPerformanceLevel)));
lpOdPerformanceLevels->iSize = sizeof(ADLODPerformanceLevels) + sizeof(ADLODPerformanceLevel) * lev;
@@ -1073,7 +1077,12 @@ void gpu_autotune(int gpu, bool *enable)
newengine = ga->maxspeed;
else if (newengine < ga->minspeed)
newengine = ga->minspeed;
- if (newengine != engine) {
+
+ /* Adjust engine clock speed if it's lower, or if it's higher
+ * but higher than the last intended value as well as the
+ * current speed, to avoid setting the engine clock speed to
+ * a speed relateive to a lower profile during idle periods. */
+ if (newengine < engine || (newengine > engine && newengine > ga->lastengine)) {
newengine /= 100;
applog(LOG_INFO, "Setting GPU %d engine clock to %d", gpu, newengine);
set_engineclock(gpu, newengine);
diff --git a/miner.h b/miner.h
index 7550ec7..8e05696 100644
--- a/miner.h
+++ b/miner.h
@@ -169,6 +169,7 @@ struct gpu_adl {
bool autoengine;
bool managed; /* Were the values ever changed on this card */
+ int lastengine;
int lasttemp;
int targetfan;
int targettemp;