Revert "Only get bitforce temperature at a time when we have not requested any other responses to minimise risk of interleaved responses." This reverts commit e29d2d92c9aa730c642c8df55c2a96901dce5450. As P. Shep points out, this breaks re-enabling of a disabled device.
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 80 81 82 83 84 85 86 87 88
diff --git a/driver-bitforce.c b/driver-bitforce.c
index adcd691..bf7c039 100644
--- a/driver-bitforce.c
+++ b/driver-bitforce.c
@@ -338,19 +338,19 @@ void bitforce_init(struct cgpu_info *bitforce)
mutex_unlock(&bitforce->device_mutex);
}
-static void bitforce_get_temp(struct cgpu_info *bitforce)
+static bool bitforce_get_temp(struct cgpu_info *bitforce)
{
int fdDev = bitforce->device_fd;
char pdevbuf[0x100];
char *s;
if (!fdDev)
- return;
+ return false;
/* It is not critical getting temperature so don't get stuck if we
* can't grab the mutex here */
if (mutex_trylock(&bitforce->device_mutex))
- return;
+ return false;
BFwrite(fdDev, "ZLX", 3);
BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
@@ -359,7 +359,7 @@ static void bitforce_get_temp(struct cgpu_info *bitforce)
if (unlikely(!pdevbuf[0])) {
applog(LOG_ERR, "BFL%i: Error: Get temp returned empty string/timed out", bitforce->device_id);
bitforce->hw_errors++;
- return;
+ return false;
}
if ((!strncasecmp(pdevbuf, "TEMP", 4)) && (s = strchr(pdevbuf + 4, ':'))) {
@@ -384,7 +384,10 @@ static void bitforce_get_temp(struct cgpu_info *bitforce)
/* Count throttling episodes as hardware errors */
bitforce->hw_errors++;
bitforce_clear_buffer(bitforce);
+ return false;;
}
+
+ return true;
}
static bool bitforce_send_work(struct thr_info *thr, struct work *work)
@@ -600,11 +603,6 @@ static int64_t bitforce_scanhash(struct thr_info *thr, struct work *work, int64_
send_ret = bitforce_send_work(thr, work);
- /* A convenient time to ask for the temperature without risk of
- * interleaved responses */
- if (send_ret && !work->blk.nonce)
- bitforce_get_temp(bitforce);
-
if (!bitforce->nonce_range) {
/* Initially wait 2/3 of the average cycle time so we can request more
work before full scan is up */
@@ -615,7 +613,7 @@ static int64_t bitforce_scanhash(struct thr_info *thr, struct work *work, int64_
bitforce->wait_ms = sleep_time;
queue_request(thr, false);
- /* Now wait the final 1/3rd; no bitforce should be finished by now */
+ /* Now wait athe final 1/3rd; no bitforce should be finished by now */
sleep_time = bitforce->sleep_ms - sleep_time;
if (!restart_wait(sleep_time))
return 0;
@@ -647,6 +645,11 @@ static int64_t bitforce_scanhash(struct thr_info *thr, struct work *work, int64_
return ret;
}
+static bool bitforce_get_stats(struct cgpu_info *bitforce)
+{
+ return bitforce_get_temp(bitforce);
+}
+
static bool bitforce_thread_init(struct thr_info *thr)
{
struct cgpu_info *bitforce = thr->cgpu;
@@ -682,6 +685,7 @@ struct device_api bitforce_api = {
.get_api_stats = bitforce_api_stats,
.reinit_device = bitforce_init,
.get_statline_before = get_bitforce_statline_before,
+ .get_stats = bitforce_get_stats,
.thread_prepare = bitforce_thread_prepare,
.thread_init = bitforce_thread_init,
.scanhash = bitforce_scanhash,