Browse Source

Discard any reads obtained from the avalon get results thread during a reset.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
abfaf36112
  1. 41
      driver-avalon.c
  2. 1
      driver-avalon.h

41
driver-avalon.c

@ -668,6 +668,25 @@ static void avalon_parse_results(struct cgpu_info *avalon, struct avalon_info *i
memmove(buf, buf + spare, *offset); memmove(buf, buf + spare, *offset);
} }
static void __avalon_running_reset(struct cgpu_info *avalon,
struct avalon_info *info, int fd)
{
info->reset = true;
avalon_reset(avalon, fd, false);
avalon_idle(avalon, info, fd);
avalon->results = 0;
info->reset = false;
}
static void avalon_running_reset(struct cgpu_info *avalon,
struct avalon_info *info, int fd)
{
/* Lock to prevent more work being sent during reset */
mutex_lock(&info->qlock);
__avalon_running_reset(avalon, info, fd);
mutex_unlock(&info->qlock);
}
static void *avalon_get_results(void *userdata) static void *avalon_get_results(void *userdata)
{ {
struct cgpu_info *avalon = (struct cgpu_info *)userdata; struct cgpu_info *avalon = (struct cgpu_info *)userdata;
@ -698,13 +717,7 @@ static void *avalon_get_results(void *userdata)
if (unlikely(avalon->results <= -info->miner_count)) { if (unlikely(avalon->results <= -info->miner_count)) {
applog(LOG_ERR, "AVA%d: %d invalid consecutive results, resetting", applog(LOG_ERR, "AVA%d: %d invalid consecutive results, resetting",
avalon->device_id, -avalon->results); avalon->device_id, -avalon->results);
avalon_running_reset(avalon, info, fd);
/* Lock to prevent more work being sent during reset */
mutex_lock(&info->qlock);
avalon_reset(avalon, fd, false);
avalon_idle(avalon, info, fd);
avalon->results = 0;
mutex_unlock(&info->qlock);
} }
if (unlikely(offset + rsize >= AVALON_READBUF_SIZE)) { if (unlikely(offset + rsize >= AVALON_READBUF_SIZE)) {
@ -735,6 +748,12 @@ static void *avalon_get_results(void *userdata)
hexdump((uint8_t *)buf, ret); hexdump((uint8_t *)buf, ret);
} }
/* During a reset, goes on reading but discards anything */
if (unlikely(info->reset)) {
offset = 0;
continue;
}
memcpy(&readbuf[offset], buf, ret); memcpy(&readbuf[offset], buf, ret);
offset += ret; offset += ret;
} }
@ -777,8 +796,7 @@ static void *avalon_send_tasks(void *userdata)
"AVA%i: Buffer full before all work queued", "AVA%i: Buffer full before all work queued",
avalon->device_id); avalon->device_id);
dev_error(avalon, REASON_DEV_COMMS_ERROR); dev_error(avalon, REASON_DEV_COMMS_ERROR);
avalon_reset(avalon, fd, false); __avalon_running_reset(avalon, info, fd);
avalon_idle(avalon, info, fd);
break; break;
} }
@ -799,8 +817,7 @@ static void *avalon_send_tasks(void *userdata)
applog(LOG_ERR, "AVA%i: Comms error(buffer)", applog(LOG_ERR, "AVA%i: Comms error(buffer)",
avalon->device_id); avalon->device_id);
dev_error(avalon, REASON_DEV_COMMS_ERROR); dev_error(avalon, REASON_DEV_COMMS_ERROR);
avalon_reset(avalon, fd, false); __avalon_running_reset(avalon, info, fd);
avalon_idle(avalon, info, fd);
break; break;
} }
} }
@ -883,7 +900,7 @@ static void do_avalon_close(struct thr_info *thr)
pthread_cancel(info->read_thr); pthread_cancel(info->read_thr);
pthread_cancel(info->write_thr); pthread_cancel(info->write_thr);
avalon_reset(avalon, fd, false); __avalon_running_reset(avalon, info, fd);
avalon_idle(avalon, info, fd); avalon_idle(avalon, info, fd);
avalon_free_work(thr); avalon_free_work(thr);
avalon_close(fd); avalon_close(fd);

1
driver-avalon.h

@ -109,6 +109,7 @@ struct avalon_info {
int nonces; int nonces;
bool idle; bool idle;
bool reset;
}; };
#define AVALON_WRITE_SIZE (sizeof(struct avalon_task)) #define AVALON_WRITE_SIZE (sizeof(struct avalon_task))

Loading…
Cancel
Save