Idle avalon after reset.
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
diff --git a/driver-avalon.c b/driver-avalon.c
index 0a63eb3..758be6c 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -455,6 +455,33 @@ static void get_options(int this_option_offset, int *baud, int *miner_count,
}
}
+static void wait_avalon_ready(int fd)
+{
+ while (avalon_buffer_full(fd) == AVA_BUFFER_FULL) {
+ nmsleep(40);
+ }
+}
+
+static void avalon_idle(struct cgpu_info *avalon, struct avalon_info *info,
+ int fd)
+{
+ int i;
+
+ info->idle = true;
+ wait_avalon_ready(fd);
+ applog(LOG_WARNING, "AVA%i: Idling %d miners", avalon->device_id,
+ info->miner_count);
+ /* Send idle to all miners */
+ for (i = 0; i < info->miner_count; i++) {
+ struct avalon_task at;
+
+ avalon_init_task(&at, 0, 0, info->fan_pwm, info->timeout,
+ info->asic_count, info->miner_count, 1, 1,
+ info->frequency);
+ avalon_send_task(fd, &at, avalon);
+ }
+}
+
static bool avalon_detect_one(const char *devpath)
{
struct avalon_info *info;
@@ -521,6 +548,7 @@ static bool avalon_detect_one(const char *devpath)
* avalon_close(fd);
* return false; */
}
+ avalon_idle(avalon, info, fd);
return true;
}
@@ -651,6 +679,7 @@ static void *avalon_get_results(void *userdata)
applog(LOG_ERR, "AVA%d: %d invalid consecutive results, resetting",
avalon->device_id, -avalon->results);
avalon_reset(avalon, fd);
+ avalon_idle(avalon, info, fd);
avalon->results = 0;
}
@@ -695,13 +724,6 @@ static void avalon_rotate_array(struct cgpu_info *avalon)
avalon->work_array = 0;
}
-static void wait_avalon_ready(int fd)
-{
- while (avalon_buffer_full(fd) == AVA_BUFFER_FULL) {
- nmsleep(40);
- }
-}
-
static void *avalon_send_tasks(void *userdata)
{
struct cgpu_info *avalon = (struct cgpu_info *)userdata;
@@ -751,6 +773,7 @@ static void *avalon_send_tasks(void *userdata)
avalon->device_id);
dev_error(avalon, REASON_DEV_COMMS_ERROR);
avalon_reset(avalon, fd);
+ avalon_idle(avalon, info, fd);
}
}
avalon_rotate_array(avalon);
@@ -778,7 +801,6 @@ 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);
@@ -828,23 +850,12 @@ static void do_avalon_close(struct thr_info *thr)
{
struct cgpu_info *avalon = thr->cgpu;
struct avalon_info *info = avalon->device_data;
- int i, fd = avalon->device_fd;
+ int fd = avalon->device_fd;
pthread_cancel(info->read_thr);
pthread_cancel(info->write_thr);
avalon_reset(avalon, fd);
- wait_avalon_ready(fd);
- applog(LOG_WARNING, "AVA%i: Idling %d miners", avalon->device_id,
- info->miner_count);
- /* Send idle to all miners */
- for (i = 0; i < info->miner_count; i++) {
- struct avalon_task at;
-
- avalon_init_task(&at, 0, 0, info->fan_pwm, info->timeout,
- info->asic_count, info->miner_count, 1, 1,
- info->frequency);
- avalon_send_task(fd, &at, avalon);
- }
+ avalon_idle(avalon, info, fd);
avalon_free_work(thr);
avalon_close(fd);
avalon->device_fd = -1;