Reset hfa device if no valid hashes are seen for 1 minute from the last work.
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
diff --git a/driver-hashfast.c b/driver-hashfast.c
index 846d26a..a95ef3a 100644
--- a/driver-hashfast.c
+++ b/driver-hashfast.c
@@ -274,6 +274,8 @@ static bool hfa_reset(struct cgpu_info *hashfast, struct hashfast_info *info)
uint8_t hcrc;
bool ret;
+ info->resets++;
+
/* Hash clock rate in Mhz */
info->hash_clock_rate = opt_hfa_hash_clock;
info->group_ntime_roll = opt_hfa_ntime_roll;
@@ -880,6 +882,8 @@ static bool hfa_prepare(struct thr_info *thr)
cgtime(&now);
get_datestamp(hashfast->init, sizeof(hashfast->init), &now);
+ hashfast->last_device_valid_work = time(NULL);
+ info->resets = 0;
return true;
}
@@ -913,6 +917,17 @@ static int64_t hfa_scanwork(struct thr_info *thr)
return -1;
}
+ if (unlikely(last_getwork - hashfast->last_device_valid_work > 60)) {
+ applog(LOG_WARNING, "HFA %d: No valid hashes for over 1 minute, attempting to reset",
+ hashfast->device_id);
+ ret = hfa_reset(hashfast, info);
+ if (unlikely(!ret)) {
+ applog(LOG_ERR, "HFA %d: Failed to reset after hash failure, disabling",
+ hashfast->device_id);
+ return -1;
+ }
+ }
+
if (unlikely(thr->work_restart)) {
restart:
thr->work_restart = false;
@@ -1069,6 +1084,7 @@ static struct api_data *hfa_api_stats(struct cgpu_info *cgpu)
root = api_add_uint64(root, "raw hashcount", &info->raw_hashes, false);
root = api_add_uint64(root, "calc hashcount", &info->calc_hashes, false);
+ root = api_add_int(root, "resets", &info->resets, false);
return root;
}
diff --git a/driver-hashfast.h b/driver-hashfast.h
index 9e634b6..76a8660 100644
--- a/driver-hashfast.h
+++ b/driver-hashfast.h
@@ -98,6 +98,7 @@ struct hashfast_info {
uint64_t calc_hashes;
uint16_t shed_count; // Dynamic copy of #cores device has shed for thermal control
int no_matching_work;
+ int resets;
pthread_t read_thr;
};