Avoid calling applog from within hfa statline before to avoid a deadlock.
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
diff --git a/driver-hashfast.c b/driver-hashfast.c
index f58da8e..e28a3eb 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -890,12 +890,20 @@ static bool hfa_prepare(struct thr_info *thr)
}
/* Figure out how many jobs to send. */
-static int hfa_jobs(struct hashfast_info *info)
+static int hfa_jobs(struct cgpu_info *hashfast, struct hashfast_info *info)
{
int ret = 0;
- if (unlikely(info->overheat))
+ if (unlikely(info->overheat)) {
+ /* Acknowledge and notify of new condition.*/
+ if (info->overheat < 0) {
+ applog(LOG_WARNING, "HFA %d: Hit overheat temp, throttling!",
+ hashfast->device_id);
+ /* Value of 1 means acknowledged overheat */
+ info->overheat = 1;
+ }
goto out;
+ }
mutex_lock(&info->lock);
ret = info->usb_init_base.inflight_target - HF_SEQUENCE_DISTANCE(info->hash_sequence_head, info->device_sequence_tail);
@@ -947,7 +955,7 @@ restart:
}
}
- jobs = hfa_jobs(info);
+ jobs = hfa_jobs(hashfast, info);
/* Wait on restart_wait for up to 0.5 seconds or submit jobs as soon as
* they're required. */
@@ -955,7 +963,7 @@ restart:
ret = restart_wait(thr, 100);
if (unlikely(!ret))
goto restart;
- jobs = hfa_jobs(info);
+ jobs = hfa_jobs(hashfast, info);
}
if (jobs) {
@@ -1122,13 +1130,11 @@ static void hfa_statline_before(char *buf, size_t bufsiz, struct cgpu_info *hash
tailsprintf(buf, bufsiz, " max%3.0fC %3.2fV | ", max_temp, max_volt);
if (unlikely(max_temp >= opt_hfa_overheat)) {
- if (!info->overheat) {
- applog(LOG_WARNING, "HFA %d: Hit throttle temp of %.1f, throttling!",
- hashfast->device_id, max_temp);
- info->overheat = true;
- }
+ /* -1 means new overheat condition */
+ if (!info->overheat)
+ info->overheat = -1;
} else if (unlikely(info->overheat))
- info->overheat = false;
+ info->overheat = 0;
}
static void hfa_init(struct cgpu_info __maybe_unused *hashfast)
diff --git a/driver-hashfast.h b/driver-hashfast.h
index 9766b60..595c30b 100644
--- a/driver-hashfast.h
+++ b/driver-hashfast.h
@@ -100,7 +100,7 @@ struct hashfast_info {
uint16_t shed_count; // Dynamic copy of #cores device has shed for thermal control
int no_matching_work;
int resets;
- bool overheat;
+ int overheat;
pthread_t read_thr;
};