Move avalon read thread start till after conditional wait, store idle status in avalon_info and use it to determine whether an error is appropriate or not.
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
diff --git a/driver-avalon.c b/driver-avalon.c
index a51e33f..9525186 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -546,6 +546,9 @@ static void avalon_update_temps(struct cgpu_info *avalon, struct avalon_info *in
static void avalon_inc_nvw(struct avalon_info *info, struct thr_info *thr)
{
+ if (unlikely(info->idle))
+ return;
+
applog(LOG_WARNING, "%s%d: No valid work - HW error",
thr->cgpu->drv->name, thr->cgpu->device_id);
@@ -681,7 +684,6 @@ static void *avalon_send_tasks(void *userdata)
const int avalon_get_work_count = info->miner_count;
int fd = avalon->device_fd;
char threadname[24];
- bool idle = false;
pthread_detach(pthread_self());
@@ -709,7 +711,7 @@ static void *avalon_send_tasks(void *userdata)
}
if (likely(j < avalon->queued)) {
- idle = false;
+ info->idle = false;
avalon_init_task(&at, 0, 0, info->fan_pwm,
info->timeout, info->asic_count,
info->miner_count, 1, 0, info->frequency);
@@ -731,8 +733,8 @@ static void *avalon_send_tasks(void *userdata)
pthread_cond_signal(&info->qcond);
mutex_unlock(&info->qlock);
- if (unlikely(idled && !idle)) {
- idle = true;
+ if (unlikely(idled && !info->idle)) {
+ info->idle = true;
applog(LOG_WARNING, "AVA%i: Idled %d miners",
avalon->device_id, idled);
}
@@ -753,6 +755,7 @@ static bool avalon_prepare(struct thr_info *thr)
if (!avalon->works)
quit(1, "Failed to calloc avalon works in avalon_prepare");
+ info->idle = true;
info->thr = thr;
mutex_init(&info->lock);
mutex_init(&info->qlock);
@@ -762,13 +765,13 @@ static bool avalon_prepare(struct thr_info *thr)
if (pthread_create(&info->write_thr, NULL, avalon_send_tasks, (void *)avalon))
quit(1, "Failed to create avalon write_thr");
- if (pthread_create(&info->read_thr, NULL, avalon_get_results, (void *)avalon))
- quit(1, "Failed to create avalon read_thr");
-
mutex_lock(&info->qlock);
pthread_cond_wait(&info->qcond, &info->qlock);
mutex_unlock(&info->qlock);
+ if (pthread_create(&info->read_thr, NULL, avalon_get_results, (void *)avalon))
+ quit(1, "Failed to create avalon read_thr");
+
avalon_init(avalon);
cgtime(&now);
diff --git a/driver-avalon.h b/driver-avalon.h
index ba22ae1..2260e39 100644
--- a/driver-avalon.h
+++ b/driver-avalon.h
@@ -107,6 +107,8 @@ struct avalon_info {
pthread_mutex_t qlock;
pthread_cond_t qcond;
int nonces;
+
+ bool idle;
};
#define AVALON_WRITE_SIZE (sizeof(struct avalon_task))