Attempt to re-initialise ADL should a device that previously reported fanspeed stops reporting it.
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
diff --git a/adl.c b/adl.c
index 13dd06b..04e4868 100644
--- a/adl.c
+++ b/adl.c
@@ -639,6 +639,8 @@ static inline int __gpu_fanspeed(struct gpu_adl *ga)
return ga->lpFanSpeedValue.iFanSpeed;
}
+static void reinit_adl(void);
+
int gpu_fanspeed(int gpu)
{
struct gpu_adl *ga;
@@ -667,6 +669,8 @@ static int __gpu_fanpercent(struct gpu_adl *ga)
return ga->lpFanSpeedValue.iFanSpeed;
}
+
+
int gpu_fanpercent(int gpu)
{
struct gpu_adl *ga;
@@ -679,6 +683,11 @@ int gpu_fanpercent(int gpu)
lock_adl();
ret = __gpu_fanpercent(ga);
unlock_adl();
+ if (unlikely(ga->has_fanspeed && ret == -1)) {
+ applog(LOG_WARNING, "GPU %d stopped reporting fanspeed", gpu);
+ applog(LOG_WARNING, "Will attempt to re-initialise ADL");
+ reinit_adl();
+ }
return ret;
}
@@ -1359,7 +1368,7 @@ void clear_adl(int nDevs)
free_adl();
}
-void reinit_adl(void)
+static void reinit_adl(void)
{
bool ret;
lock_adl();
@@ -1368,7 +1377,8 @@ void reinit_adl(void)
if (!ret) {
adl_active = false;
applog(LOG_WARNING, "Attempt to re-initialise ADL has failed, disabling");
- }
+ } else
+ applog(LOG_WARNING, "ADL re-initialisation complete");
unlock_adl();
}
#endif /* HAVE_ADL */
diff --git a/adl.h b/adl.h
index 363741c..f48c420 100644
--- a/adl.h
+++ b/adl.h
@@ -19,12 +19,10 @@ bool gpu_stats(int gpu, float *temp, int *engineclock, int *memclock, float *vdd
void change_gpusettings(int gpu);
void gpu_autotune(int gpu, enum dev_enable *denable);
void clear_adl(int nDevs);
-void reinit_adl(void);
#else /* HAVE_ADL */
#define adl_active (0)
static inline void init_adl(int nDevs) {}
static inline void change_gpusettings(int gpu) { }
static inline void clear_adl(int nDevs) {}
-static inline void reinit_adl(void) {}
#endif
#endif