Merge pull request #252 from pshep/master More timing changes
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
diff --git a/driver-bitforce.c b/driver-bitforce.c
index cf2d6ca..27494c4 100644
--- a/driver-bitforce.c
+++ b/driver-bitforce.c
@@ -21,7 +21,8 @@
#include "miner.h"
#define BITFORCE_SLEEP_MS 3000
-#define BITFORCE_TIMEOUT_MS 10000
+#define BITFORCE_TIMEOUT_MS 7000
+#define BITFORCE_LONG_TIMEOUT_MS 15000
#define BITFORCE_CHECK_INTERVAL_MS 10
#define WORK_CHECK_INTERVAL_MS 50
#define MAX_START_DELAY_US 100000
@@ -196,6 +197,7 @@ void bitforce_init(struct cgpu_info *bitforce)
}
bitforce->device_fd = fdDev;
+ bitforce->sleep_ms = BITFORCE_SLEEP_MS;
mutex_unlock(&bitforce->device_mutex);
}
@@ -301,7 +303,7 @@ static uint64_t bitforce_get_result(struct thr_info *thr, struct work *work)
if (!fdDev)
return 0;
- while (bitforce->wait_ms < BITFORCE_TIMEOUT_MS) {
+ while (bitforce->wait_ms < BITFORCE_LONG_TIMEOUT_MS) {
if (unlikely(work_restart[thr->id].restart))
return 1;
mutex_lock(&bitforce->device_mutex);
@@ -317,20 +319,21 @@ static uint64_t bitforce_get_result(struct thr_info *thr, struct work *work)
}
if (bitforce->wait_ms >= BITFORCE_TIMEOUT_MS) {
- applog(LOG_ERR, "BFL%i: took longer than 10s", bitforce->device_id);
+ applog(LOG_ERR, "BFL%i: took longer than %dms", bitforce->device_id, BITFORCE_TIMEOUT_MS);
bitforce->device_last_not_well = time(NULL);
bitforce->device_not_well_reason = REASON_DEV_OVER_HEAT;
bitforce->dev_over_heat_count++;
- return 1;
+ if (!pdevbuf[0]) /* Only return if we got nothing after timeout - there still may be results */
+ return 1;
} else if (pdevbuf[0] == 'N') {/* Hashing complete (NONCE-FOUND or NO-NONCE) */
/* Simple timing adjustment */
delay_time_ms = bitforce->sleep_ms;
if (bitforce->wait_ms > (bitforce->sleep_ms + BITFORCE_CHECK_INTERVAL_MS))
bitforce->sleep_ms += (unsigned int) ((double) (bitforce->wait_ms - bitforce->sleep_ms) / 1.6);
else if (bitforce->wait_ms == bitforce->sleep_ms)
- bitforce->sleep_ms -= BITFORCE_CHECK_INTERVAL_MS;
+ bitforce->sleep_ms -= WORK_CHECK_INTERVAL_MS;
if (delay_time_ms != bitforce->sleep_ms)
- applog(LOG_DEBUG, "BFL%i: Wait time changed to: %d. Waited: %d", bitforce->device_id, bitforce->sleep_ms, bitforce->wait_ms);
+ applog(LOG_DEBUG, "BFL%i: Wait time changed to: %d", bitforce->device_id, bitforce->sleep_ms, bitforce->wait_ms);
}
applog(LOG_DEBUG, "BFL%i: waited %dms until %s", bitforce->device_id, bitforce->wait_ms, pdevbuf);
@@ -439,10 +442,24 @@ static bool bitforce_thread_init(struct thr_info *thr)
return true;
}
+static struct api_data *bitforce_api_stats(struct cgpu_info *cgpu)
+{
+ struct api_data *root = NULL;
+
+ // Warning, access to these is not locked - but we don't really
+ // care since hashing performance is way more important than
+ // locking access to displaying API debug 'stats'
+ // If locking becomes an issue for any of them, use copy_data=true also
+ root = api_add_int(root, "Sleep Time", &(cgpu->sleep_ms), false);
+
+ return root;
+}
+
struct device_api bitforce_api = {
.dname = "bitforce",
.name = "BFL",
.api_detect = bitforce_detect,
+ .get_api_stats = bitforce_api_stats,
.reinit_device = bitforce_init,
.get_statline_before = get_bitforce_statline_before,
.get_stats = bitforce_get_stats,