Browse Source

The write thread in avalon is only ever actually woken up by timeout so remove the write semaphore and use a simple sleep poll.

nfactor-troky
Con Kolivas 11 years ago
parent
commit
dd9233f78b
  1. 22
      driver-avalon.c
  2. 1
      driver-avalon.h

22
driver-avalon.c

@ -702,11 +702,9 @@ static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found
if (!add_cgpu(avalon)) if (!add_cgpu(avalon))
goto unshin; goto unshin;
cgsem_init(&info->write_sem);
ret = avalon_reset(avalon, true); ret = avalon_reset(avalon, true);
if (ret && !configured) if (ret && !configured)
goto unshinsem; goto unshin;
update_usb_stats(avalon); update_usb_stats(avalon);
@ -730,10 +728,6 @@ static bool avalon_detect_one(libusb_device *dev, struct usb_find_devices *found
return true; return true;
unshinsem:
cgsem_destroy(&info->write_sem);
unshin: unshin:
usb_uninit(avalon); usb_uninit(avalon);
@ -976,7 +970,7 @@ static void *avalon_send_tasks(void *userdata)
bool idled = false; bool idled = false;
while (avalon_buffer_full(avalon)) while (avalon_buffer_full(avalon))
cgsem_wait(&info->write_sem); nmsleep(40);
if (opt_avalon_auto && info->auto_queued >= AVALON_AUTO_CYCLE) { if (opt_avalon_auto && info->auto_queued >= AVALON_AUTO_CYCLE) {
mutex_lock(&info->lock); mutex_lock(&info->lock);
@ -1014,7 +1008,7 @@ static void *avalon_send_tasks(void *userdata)
break; break;
else { else {
while (avalon_buffer_full(avalon)) while (avalon_buffer_full(avalon))
cgsem_wait(&info->write_sem); nmsleep(40);
} }
} }
@ -1100,8 +1094,6 @@ static void do_avalon_close(struct thr_info *thr)
avalon_running_reset(avalon, info); avalon_running_reset(avalon, info);
info->no_matching_work = 0; info->no_matching_work = 0;
cgsem_destroy(&info->write_sem);
} }
static inline void record_temp_fan(struct avalon_info *info, struct avalon_result *ar, float *temp_avg) static inline void record_temp_fan(struct avalon_info *info, struct avalon_result *ar, float *temp_avg)
@ -1284,7 +1276,6 @@ static int64_t avalon_scanhash(struct thr_info *thr)
struct timeval now, then, tdiff; struct timeval now, then, tdiff;
int64_t hash_count, us_timeout; int64_t hash_count, us_timeout;
struct timespec abstime; struct timespec abstime;
int ret;
/* Half nonce range */ /* Half nonce range */
us_timeout = 0x80000000ll / info->asic_count / info->frequency; us_timeout = 0x80000000ll / info->asic_count / info->frequency;
@ -1298,14 +1289,9 @@ static int64_t avalon_scanhash(struct thr_info *thr)
/* Wait until avalon_send_tasks signals us that it has completed /* Wait until avalon_send_tasks signals us that it has completed
* sending its work or a full nonce range timeout has occurred */ * sending its work or a full nonce range timeout has occurred */
mutex_lock(&info->qlock); mutex_lock(&info->qlock);
ret = pthread_cond_timedwait(&info->qcond, &info->qlock, &abstime); pthread_cond_timedwait(&info->qcond, &info->qlock, &abstime);
mutex_unlock(&info->qlock); mutex_unlock(&info->qlock);
/* If we timed out, avalon_send_tasks may be stuck waiting on the
* write_sem, so force it to check for avalon_buffer_full itself. */
if (ret)
cgsem_post(&info->write_sem);
mutex_lock(&info->lock); mutex_lock(&info->lock);
hash_count = 0xffffffffull * (uint64_t)info->nonces; hash_count = 0xffffffffull * (uint64_t)info->nonces;
avalon->results += info->nonces + info->idle; avalon->results += info->nonces + info->idle;

1
driver-avalon.h

@ -132,7 +132,6 @@ struct avalon_info {
pthread_mutex_t lock; pthread_mutex_t lock;
pthread_mutex_t qlock; pthread_mutex_t qlock;
pthread_cond_t qcond; pthread_cond_t qcond;
cgsem_t write_sem;
int nonces; int nonces;
int auto_queued; int auto_queued;

Loading…
Cancel
Save