Provide some defaults for avalon if none are specified and do not try to claim the device if it fails to reset with them and no options are specified.
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 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
diff --git a/driver-avalon.c b/driver-avalon.c
index c0f217a..a064b75 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -328,7 +328,7 @@ static int avalon_reset(struct cgpu_info *avalon, bool initial)
return 0;
}
-static void get_options(int this_option_offset, int *baud, int *miner_count,
+static bool get_options(int this_option_offset, int *baud, int *miner_count,
int *asic_count, int *timeout, int *frequency)
{
char err_buf[BUFSIZ+1];
@@ -360,14 +360,8 @@ static void get_options(int this_option_offset, int *baud, int *miner_count,
buf[max] = '\0';
}
- *baud = AVALON_IO_SPEED;
- *miner_count = AVALON_DEFAULT_MINER_NUM - 8;
- *asic_count = AVALON_DEFAULT_ASIC_NUM;
- *timeout = AVALON_DEFAULT_TIMEOUT;
- *frequency = AVALON_DEFAULT_FREQUENCY;
-
if (!(*buf))
- return;
+ return false;
colon = strchr(buf, ':');
if (colon)
@@ -462,6 +456,7 @@ static void get_options(int this_option_offset, int *baud, int *miner_count,
}
}
}
+ return true;
}
static void avalon_idle(struct cgpu_info *avalon, struct avalon_info *info)
@@ -569,6 +564,7 @@ static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found
struct avalon_info *info;
struct cgpu_info *avalon;
char devpath[20];
+ bool configured;
int ret;
avalon = calloc(1, sizeof(struct cgpu_info));
@@ -577,8 +573,8 @@ static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found
avalon->drv = &avalon_drv;
avalon->threads = AVALON_MINER_THREADS;
- get_options(this_option_offset, &baud, &miner_count, &asic_count,
- &timeout, &frequency);
+ configured = get_options(this_option_offset, &baud, &miner_count,
+ &asic_count, &timeout, &frequency);
if (!usb_init(avalon, dev, found))
return false;
@@ -594,10 +590,6 @@ static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found
avalon_initialise(avalon);
- applog(LOG_DEBUG, "Avalon Detected: %s "
- "(miner_count=%d asic_count=%d timeout=%d frequency=%d)",
- devpath, miner_count, asic_count, timeout, frequency);
-
avalon->device_path = strdup(devpath);
add_cgpu(avalon);
@@ -606,10 +598,19 @@ static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found
quit(1, "Failed to malloc avalon_info data");
info = avalon->device_data;
- info->baud = baud;
- info->miner_count = miner_count;
- info->asic_count = asic_count;
- info->timeout = timeout;
+ if (configured) {
+ info->baud = baud;
+ info->miner_count = miner_count;
+ info->asic_count = asic_count;
+ info->timeout = timeout;
+ info->frequency = frequency;
+ } else {
+ info->baud = AVALON_IO_SPEED;
+ info->miner_count = AVALON_DEFAULT_MINER_NUM;
+ info->asic_count = AVALON_DEFAULT_ASIC_NUM;
+ info->timeout = AVALON_DEFAULT_TIMEOUT;
+ info->frequency = AVALON_DEFAULT_FREQUENCY;
+ }
info->fan_pwm = AVALON_DEFAULT_FAN_MIN_PWM;
info->temp_max = 0;
@@ -621,16 +622,20 @@ static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found
info->temp_history_index = 0;
info->temp_sum = 0;
info->temp_old = 0;
- info->frequency = frequency;
ret = avalon_reset(avalon, true);
- if (ret) {
- /* FIXME:
- * avalon_close(fd);
- * return false; */
+ if (ret && !configured) {
+ usb_uninit(avalon);
+ return false;
}
+
avalon_idle(avalon, info);
+ applog(LOG_DEBUG, "Avalon Detected: %s "
+ "(miner_count=%d asic_count=%d timeout=%d frequency=%d)",
+ devpath, info->miner_count, info->asic_count, info->timeout,
+ info->frequency);
+
return true;
}
@@ -823,8 +828,8 @@ static void *avalon_send_tasks(void *userdata)
start_count = avalon->work_array * avalon_get_work_count;
end_count = start_count + avalon_get_work_count;
for (i = start_count, j = 0; i < end_count; i++, j++) {
- if (unlikely(avalon_buffer_full(avalon))) {
- applog(LOG_WARNING,
+ if (avalon_buffer_full(avalon)) {
+ applog(LOG_INFO,
"AVA%i: Buffer full after only %d of %d work queued",
avalon->device_id, j, avalon_get_work_count);
break;
diff --git a/driver-avalon.h b/driver-avalon.h
index d4a6286..323a946 100644
--- a/driver-avalon.h
+++ b/driver-avalon.h
@@ -25,8 +25,8 @@
#define AVALON_DEFAULT_FAN_MAX_PWM 0xA0 /* 100% */
#define AVALON_DEFAULT_FAN_MIN_PWM 0x20 /* 20% */
-#define AVALON_DEFAULT_TIMEOUT 0x32
-#define AVALON_DEFAULT_FREQUENCY 256
+#define AVALON_DEFAULT_TIMEOUT 0x2D
+#define AVALON_DEFAULT_FREQUENCY 282
#define AVALON_DEFAULT_MINER_NUM 0x20
#define AVALON_DEFAULT_ASIC_NUM 0xA