Browse Source

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.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
c0c5c060bd
  1. 47
      driver-avalon.c
  2. 4
      driver-avalon.h

47
driver-avalon.c

@ -328,7 +328,7 @@ static int avalon_reset(struct cgpu_info *avalon, bool initial)
return 0; 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) int *asic_count, int *timeout, int *frequency)
{ {
char err_buf[BUFSIZ+1]; 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'; 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)) if (!(*buf))
return; return false;
colon = strchr(buf, ':'); colon = strchr(buf, ':');
if (colon) 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) 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 avalon_info *info;
struct cgpu_info *avalon; struct cgpu_info *avalon;
char devpath[20]; char devpath[20];
bool configured;
int ret; int ret;
avalon = calloc(1, sizeof(struct cgpu_info)); 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->drv = &avalon_drv;
avalon->threads = AVALON_MINER_THREADS; avalon->threads = AVALON_MINER_THREADS;
get_options(this_option_offset, &baud, &miner_count, &asic_count, configured = get_options(this_option_offset, &baud, &miner_count,
&timeout, &frequency); &asic_count, &timeout, &frequency);
if (!usb_init(avalon, dev, found)) if (!usb_init(avalon, dev, found))
return false; return false;
@ -594,10 +590,6 @@ static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found
avalon_initialise(avalon); 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); avalon->device_path = strdup(devpath);
add_cgpu(avalon); 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"); quit(1, "Failed to malloc avalon_info data");
info = avalon->device_data; info = avalon->device_data;
if (configured) {
info->baud = baud; info->baud = baud;
info->miner_count = miner_count; info->miner_count = miner_count;
info->asic_count = asic_count; info->asic_count = asic_count;
info->timeout = timeout; 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->fan_pwm = AVALON_DEFAULT_FAN_MIN_PWM;
info->temp_max = 0; 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_history_index = 0;
info->temp_sum = 0; info->temp_sum = 0;
info->temp_old = 0; info->temp_old = 0;
info->frequency = frequency;
ret = avalon_reset(avalon, true); ret = avalon_reset(avalon, true);
if (ret) { if (ret && !configured) {
/* FIXME: usb_uninit(avalon);
* avalon_close(fd); return false;
* return false; */
} }
avalon_idle(avalon, info); 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; return true;
} }
@ -823,8 +828,8 @@ static void *avalon_send_tasks(void *userdata)
start_count = avalon->work_array * avalon_get_work_count; start_count = avalon->work_array * avalon_get_work_count;
end_count = start_count + avalon_get_work_count; end_count = start_count + avalon_get_work_count;
for (i = start_count, j = 0; i < end_count; i++, j++) { for (i = start_count, j = 0; i < end_count; i++, j++) {
if (unlikely(avalon_buffer_full(avalon))) { if (avalon_buffer_full(avalon)) {
applog(LOG_WARNING, applog(LOG_INFO,
"AVA%i: Buffer full after only %d of %d work queued", "AVA%i: Buffer full after only %d of %d work queued",
avalon->device_id, j, avalon_get_work_count); avalon->device_id, j, avalon_get_work_count);
break; break;

4
driver-avalon.h

@ -25,8 +25,8 @@
#define AVALON_DEFAULT_FAN_MAX_PWM 0xA0 /* 100% */ #define AVALON_DEFAULT_FAN_MAX_PWM 0xA0 /* 100% */
#define AVALON_DEFAULT_FAN_MIN_PWM 0x20 /* 20% */ #define AVALON_DEFAULT_FAN_MIN_PWM 0x20 /* 20% */
#define AVALON_DEFAULT_TIMEOUT 0x32 #define AVALON_DEFAULT_TIMEOUT 0x2D
#define AVALON_DEFAULT_FREQUENCY 256 #define AVALON_DEFAULT_FREQUENCY 282
#define AVALON_DEFAULT_MINER_NUM 0x20 #define AVALON_DEFAULT_MINER_NUM 0x20
#define AVALON_DEFAULT_ASIC_NUM 0xA #define AVALON_DEFAULT_ASIC_NUM 0xA

Loading…
Cancel
Save