Browse Source

Check for a timeout in avalon_scanhash and post to the write sem if we receive one.

Con Kolivas 12 years ago
parent
commit
a011fe5182
1 changed files with 7 additions and 1 deletions
  1. 7 1
      driver-avalon.c

+ 7 - 1
driver-avalon.c

@@ -1200,6 +1200,7 @@ static int64_t avalon_scanhash(struct thr_info *thr)
 	struct timeval now, then, tdiff;
 	int64_t hash_count, us_timeout;
 	struct timespec abstime;
+	int ret;
 
 	/* Half nonce range */
 	us_timeout = 0x80000000ll / info->asic_count / info->frequency;
@@ -1213,9 +1214,14 @@ static int64_t avalon_scanhash(struct thr_info *thr)
 	/* Wait until avalon_send_tasks signals us that it has completed
 	 * sending its work or a full nonce range timeout has occurred */
 	mutex_lock(&info->qlock);
-	pthread_cond_timedwait(&info->qcond, &info->qlock, &abstime);
+	ret = pthread_cond_timedwait(&info->qcond, &info->qlock, &abstime);
 	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);
 	hash_count = 0xffffffffull * (uint64_t)info->nonces;
 	avalon->results += info->nonces + info->idle;