Browse Source

icarus correct device_id and use device_data for icarus_info

nfactor-troky
Kano 12 years ago
parent
commit
350e7f893f
  1. 64
      driver-icarus.c

64
driver-icarus.c

@ -196,9 +196,6 @@ struct ICARUS_INFO {
#define END_CONDITION 0x0000ffff #define END_CONDITION 0x0000ffff
// One for each possible device
static struct ICARUS_INFO **icarus_info;
// Looking for options in --icarus-timing and --icarus-options: // Looking for options in --icarus-timing and --icarus-options:
// //
// Code increments this each time we start to look at a device // Code increments this each time we start to look at a device
@ -224,8 +221,8 @@ static void _transfer(struct cgpu_info *icarus, uint8_t request_type, uint8_t bR
err = usb_transfer_data(icarus, request_type, bRequest, wValue, wIndex, data, siz, cmd); err = usb_transfer_data(icarus, request_type, bRequest, wValue, wIndex, data, siz, cmd);
applog(LOG_DEBUG, "%s%i: %s got err %d", applog(LOG_DEBUG, "%s: cgid %d %s got err %d",
icarus->drv->name, icarus->device_id, icarus->drv->name, icarus->cgminer_id,
usb_cmdname(cmd), err); usb_cmdname(cmd), err);
} }
@ -316,8 +313,8 @@ static void icarus_initialise(struct cgpu_info *icarus, __maybe_unused int baud)
case IDENT_CMR: case IDENT_CMR:
break; break;
default: default:
quit(1, "icarus_intialise() called with invalid %s%i ident=%d", quit(1, "icarus_intialise() called with invalid %s cgid %i ident=%d",
icarus->drv->name, icarus->device_id, icarus->drv->name, icarus->cgminer_id,
icarus->usbdev->ident); icarus->usbdev->ident);
} }
} }
@ -411,7 +408,7 @@ static const char *timing_mode_str(enum timing_mode timing_mode)
static void set_timing_mode(int this_option_offset, struct cgpu_info *icarus) static void set_timing_mode(int this_option_offset, struct cgpu_info *icarus)
{ {
struct ICARUS_INFO *info = icarus_info[icarus->device_id]; struct ICARUS_INFO *info = (struct ICARUS_INFO *)(icarus->device_data);
double Hs; double Hs;
char buf[BUFSIZ+1]; char buf[BUFSIZ+1];
char *ptr, *comma, *eq; char *ptr, *comma, *eq;
@ -508,8 +505,10 @@ static void set_timing_mode(int this_option_offset, struct cgpu_info *icarus)
info->min_data_count = MIN_DATA_COUNT; info->min_data_count = MIN_DATA_COUNT;
applog(LOG_DEBUG, "Icarus: Init: %d mode=%s read_time=%dms Hs=%e", applog(LOG_DEBUG, "%s: cgid %d Init: mode=%s read_time=%dms Hs=%e",
icarus->device_id, timing_mode_str(info->timing_mode), info->read_time, info->Hs); icarus->drv->name, icarus->cgminer_id,
timing_mode_str(info->timing_mode),
info->read_time, info->Hs);
} }
static uint32_t mask(int work_division) static uint32_t mask(int work_division)
@ -730,22 +729,17 @@ retry:
update_usb_stats(icarus); update_usb_stats(icarus);
icarus_info = realloc(icarus_info, sizeof(struct ICARUS_INFO *) * (total_devices + 1)); applog(LOG_INFO, "%s%d: Found at %s",
if (unlikely(!icarus_info)) icarus->drv->name, icarus->device_id, devpath);
quit(1, "Failed to realloc ICARUS_INFO");
applog(LOG_INFO, "Found Icarus at %s, mark as %d", applog(LOG_DEBUG, "%s%d: Init baud=%d work_division=%d fpga_count=%d",
devpath, icarus->device_id); icarus->drv->name, icarus->device_id, baud, work_division, fpga_count);
applog(LOG_DEBUG, "Icarus: Init: %d baud=%d work_division=%d fpga_count=%d", info = (struct ICARUS_INFO *)malloc(sizeof(struct ICARUS_INFO));
icarus->device_id, baud, work_division, fpga_count); if (unlikely(!info))
// Since we are adding a new device on the end it needs to always be allocated
icarus_info[icarus->device_id] = (struct ICARUS_INFO *)malloc(sizeof(struct ICARUS_INFO));
if (unlikely(!(icarus_info[icarus->device_id])))
quit(1, "Failed to malloc ICARUS_INFO"); quit(1, "Failed to malloc ICARUS_INFO");
info = icarus_info[icarus->device_id]; icarus->device_data = (void *)info;
// Initialise everything to zero for a new device // Initialise everything to zero for a new device
memset(info, 0, sizeof(struct ICARUS_INFO)); memset(info, 0, sizeof(struct ICARUS_INFO));
@ -796,10 +790,8 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
__maybe_unused int64_t max_nonce) __maybe_unused int64_t max_nonce)
{ {
struct cgpu_info *icarus = thr->cgpu; struct cgpu_info *icarus = thr->cgpu;
struct ICARUS_INFO *info = (struct ICARUS_INFO *)(icarus->device_data);
int ret, err, amount; int ret, err, amount;
struct ICARUS_INFO *info;
unsigned char ob_bin[64], nonce_bin[ICARUS_READ_SIZE]; unsigned char ob_bin[64], nonce_bin[ICARUS_READ_SIZE];
char *ob_hex; char *ob_hex;
uint32_t nonce; uint32_t nonce;
@ -822,7 +814,6 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
if (icarus->usbinfo.nodev) if (icarus->usbinfo.nodev)
return -1; return -1;
info = icarus_info[icarus->device_id];
elapsed.tv_sec = elapsed.tv_usec = 0; elapsed.tv_sec = elapsed.tv_usec = 0;
memset(ob_bin, 0, sizeof(ob_bin)); memset(ob_bin, 0, sizeof(ob_bin));
@ -842,8 +833,8 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
if (opt_debug) { if (opt_debug) {
ob_hex = bin2hex(ob_bin, sizeof(ob_bin)); ob_hex = bin2hex(ob_bin, sizeof(ob_bin));
applog(LOG_DEBUG, "Icarus %d sent: %s", applog(LOG_DEBUG, "%s%d: sent %s",
icarus->device_id, ob_hex); icarus->drv->name, icarus->device_id, ob_hex);
free(ob_hex); free(ob_hex);
} }
@ -870,8 +861,9 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
estimate_hashes = 0xffffffff; estimate_hashes = 0xffffffff;
if (opt_debug) { if (opt_debug) {
applog(LOG_DEBUG, "Icarus %d no nonce = 0x%08lX hashes (%ld.%06lds)", applog(LOG_DEBUG, "%s%d: no nonce = 0x%08lX hashes (%ld.%06lds)",
icarus->device_id, (long unsigned int)estimate_hashes, icarus->drv->name, icarus->device_id,
(long unsigned int)estimate_hashes,
elapsed.tv_sec, elapsed.tv_usec); elapsed.tv_sec, elapsed.tv_usec);
} }
@ -892,8 +884,9 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
timersub(&tv_finish, &tv_start, &elapsed); timersub(&tv_finish, &tv_start, &elapsed);
if (opt_debug) { if (opt_debug) {
applog(LOG_DEBUG, "Icarus %d nonce = 0x%08x = 0x%08lX hashes (%ld.%06lds)", applog(LOG_DEBUG, "%s%d: nonce = 0x%08x = 0x%08lX hashes (%ld.%06lds)",
icarus->device_id, nonce, (long unsigned int)hash_count, icarus->drv->name, icarus->device_id,
nonce, (long unsigned int)hash_count,
elapsed.tv_sec, elapsed.tv_usec); elapsed.tv_sec, elapsed.tv_usec);
} }
@ -985,9 +978,8 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
else if (info->timing_mode == MODE_SHORT) else if (info->timing_mode == MODE_SHORT)
info->do_icarus_timing = false; info->do_icarus_timing = false;
// applog(LOG_WARNING, "Icarus %d Re-estimate: read_time=%d fullnonce=%fs history count=%d Hs=%e W=%e values=%d hash range=0x%08lx min data count=%u", icarus->device_id, read_time, fullnonce, count, Hs, W, values, hash_count_range, info->min_data_count); applog(LOG_WARNING, "%s%d Re-estimate: Hs=%e W=%e read_time=%dms fullnonce=%.3fs",
applog(LOG_WARNING, "Icarus %d Re-estimate: Hs=%e W=%e read_time=%dms fullnonce=%.3fs", icarus->drv->name, icarus->device_id, Hs, W, read_time, fullnonce);
icarus->device_id, Hs, W, read_time, fullnonce);
} }
info->history_count++; info->history_count++;
cgtime(&tv_history_finish); cgtime(&tv_history_finish);
@ -1002,7 +994,7 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
static struct api_data *icarus_api_stats(struct cgpu_info *cgpu) static struct api_data *icarus_api_stats(struct cgpu_info *cgpu)
{ {
struct api_data *root = NULL; struct api_data *root = NULL;
struct ICARUS_INFO *info = icarus_info[cgpu->device_id]; struct ICARUS_INFO *info = (struct ICARUS_INFO *)(cgpu->device_data);
// Warning, access to these is not locked - but we don't really // Warning, access to these is not locked - but we don't really
// care since hashing performance is way more important than // care since hashing performance is way more important than

Loading…
Cancel
Save