Implement the main scanloop for bxf, trying to prevent it from ntime rolling work if the work protocol does not allow 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 71 72 73 74 75 76 77 78
diff --git a/driver-bitfury.c b/driver-bitfury.c
index 8e73b00..4a12f2f 100644
--- a/driver-bitfury.c
+++ b/driver-bitfury.c
@@ -514,6 +514,44 @@ out:
return ret;
}
+static int64_t bxf_scan(struct cgpu_info *bitfury, struct bitfury_info *info)
+{
+ struct work *work, *tmp;
+ int64_t ret;
+ int work_id;
+
+ /* If we're using work that can't be ntime rolled, send new work every
+ * loop through bxf_scan. The device will not abort it instantly unless
+ * the prevhash has changed. This is a problem with getwork work since
+ * it may be impossible to prevent it working on ntime rolled work. */
+ if (!info->can_roll) {
+ bxf_update_work(bitfury, info);
+ cgsleep_ms(500);
+ } else
+ cgsleep_ms(3000);
+
+ mutex_lock(&info->lock);
+ ret = (int64_t)info->nonces * 0xffffffff;
+ info->nonces = 0;
+ work_id = info->work_id;
+ mutex_unlock(&info->lock);
+
+ /* Keep no more than the last 5 work items in the hashlist */
+ wr_lock(&bitfury->qlock);
+ HASH_ITER(hh, bitfury->queued_work, work, tmp) {
+ if (work->subid + 5 < work_id)
+ __work_completed(bitfury, work);
+ }
+ wr_unlock(&bitfury->qlock);
+
+ if (unlikely(bitfury->usbinfo.nodev)) {
+ applog(LOG_WARNING, "%s %d: Device disappeared, disabling thread",
+ bitfury->drv->name, bitfury->device_id);
+ ret = -1;
+ }
+ return ret;
+}
+
static int64_t bitfury_scanwork(struct thr_info *thr)
{
struct cgpu_info *bitfury = thr->cgpu;
@@ -524,6 +562,8 @@ static int64_t bitfury_scanwork(struct thr_info *thr)
return bf1_scan(thr, bitfury, info);
break;
case IDENT_BXF:
+ return bxf_scan(bitfury, info);
+ break;
default:
return 0;
}
@@ -553,6 +593,7 @@ static void bxf_update_work(struct cgpu_info *bitfury, struct bitfury_info *info
mutex_lock(&info->lock);
work->subid = ++info->work_id;
+ info->can_roll = !!work->drv_rolllimit;
mutex_unlock(&info->lock);
bxf_send_work(bitfury, work);
diff --git a/driver-bitfury.h b/driver-bitfury.h
index 2438e28..f9b8733 100644
--- a/driver-bitfury.h
+++ b/driver-bitfury.h
@@ -34,6 +34,7 @@ struct bitfury_info {
double temperature;
int work_id; // Current work->subid
int no_matching_work;
+ bool can_roll;
};
#endif /* BITFURY_H */