Browse Source

Merge commit '67be00e' into update_avalon_20130524

Luke Dashjr 13 years ago
parent
commit
d55ce05f79
2 changed files with 40 additions and 9 deletions
  1. 39 9
      driver-avalon.c
  2. 1 0
      miner.h

+ 39 - 9
driver-avalon.c

@@ -640,7 +640,7 @@ static bool avalon_prepare(struct thr_info *thr)
 	struct avalon_info *info = avalon_infos[avalon->device_id];
 	struct avalon_info *info = avalon_infos[avalon->device_id];
 	struct timeval now;
 	struct timeval now;
 
 
-	avalon->works = calloc(info->miner_count * sizeof(struct work *), 1);
+	avalon->works = calloc(info->miner_count * sizeof(struct work *), 4);
 	if (!avalon->works)
 	if (!avalon->works)
 		quit(1, "Failed to calloc avalon works in avalon_prepare");
 		quit(1, "Failed to calloc avalon works in avalon_prepare");
 	__avalon_init(avalon);
 	__avalon_init(avalon);
@@ -664,7 +664,31 @@ static void avalon_free_work(struct thr_info *thr)
 	works = avalon->works;
 	works = avalon->works;
 	info = avalon_infos[avalon->device_id];
 	info = avalon_infos[avalon->device_id];
 
 
-	for (i = 0; i < info->miner_count; i++) {
+	for (i = 0; i < info->miner_count * 4; i++) {
+		if (works[i]) {
+			work_completed(avalon, works[i]);
+			works[i] = NULL;
+		}
+	}
+}
+
+static void avalon_free_work_array(struct thr_info *thr)
+{
+	struct cgpu_info *avalon;
+	struct work **works;
+	int i, j, mc, wa;
+
+	avalon = thr->cgpu;
+	avalon->queued = 0;
+	if (unlikely(!avalon->works))
+		return;
+	works = avalon->works;
+	mc = avalon_infos[avalon->device_id]->miner_count;
+	wa = avalon->work_array + 1;
+	if (wa > 3)
+		wa = 0;
+
+	for (i = wa * mc, j = 0; j < mc; i++, j++) {
 		if (likely(works[i])) {
 		if (likely(works[i])) {
 			work_completed(avalon, works[i]);
 			work_completed(avalon, works[i]);
 			works[i] = NULL;
 			works[i] = NULL;
@@ -753,13 +777,14 @@ static inline void adjust_fan(struct avalon_info *info)
 static bool avalon_fill(struct cgpu_info *avalon)
 static bool avalon_fill(struct cgpu_info *avalon)
 {
 {
 	struct work *work = get_queued(avalon);
 	struct work *work = get_queued(avalon);
+	int mc = avalon_infos[avalon->device_id]->miner_count;
 
 
 	if (unlikely(!work))
 	if (unlikely(!work))
 		return false;
 		return false;
-	if (avalon->queued == avalon_infos[avalon->device_id]->miner_count)
+	if (avalon->queued >= mc)
 		return true;
 		return true;
-	avalon->works[avalon->queued++] = work;
-	if (avalon->queued == avalon_infos[avalon->device_id]->miner_count)
+	avalon->works[avalon->work_array * mc + avalon->queued++] = work;
+	if (avalon->queued >= mc)
 		return true;
 		return true;
 	return false;
 	return false;
 }
 }
@@ -775,6 +800,7 @@ static int64_t avalon_scanhash(struct thr_info *thr)
 	struct avalon_result ar;
 	struct avalon_result ar;
 	int i;
 	int i;
 	int avalon_get_work_count;
 	int avalon_get_work_count;
+	int start_count, end_count;
 
 
 	struct timeval tv_start, tv_finish, elapsed;
 	struct timeval tv_start, tv_finish, elapsed;
 	uint32_t nonce;
 	uint32_t nonce;
@@ -801,7 +827,9 @@ static int64_t avalon_scanhash(struct thr_info *thr)
 	tcflush(fd, TCOFLUSH);
 	tcflush(fd, TCOFLUSH);
 #endif
 #endif
 
 
-	i = 0;
+	start_count = avalon->work_array * avalon_get_work_count;
+	end_count = start_count + avalon_get_work_count;
+	i = start_count;
 	while (true) {
 	while (true) {
 		avalon_init_task(&at, 0, 0, info->fan_pwm,
 		avalon_init_task(&at, 0, 0, info->fan_pwm,
 				 info->timeout, info->asic_count,
 				 info->timeout, info->asic_count,
@@ -810,7 +838,7 @@ static int64_t avalon_scanhash(struct thr_info *thr)
 		ret = avalon_send_task(fd, &at, avalon);
 		ret = avalon_send_task(fd, &at, avalon);
 		if (unlikely(ret == AVA_SEND_ERROR ||
 		if (unlikely(ret == AVA_SEND_ERROR ||
 			     (ret == AVA_SEND_BUFFER_EMPTY &&
 			     (ret == AVA_SEND_BUFFER_EMPTY &&
-			      (i + 1 == avalon_get_work_count) &&
+			      (i + 1 == end_count) &&
 			      first_try))) {
 			      first_try))) {
 			do_avalon_close(thr);
 			do_avalon_close(thr);
 			applog(LOG_ERR, "AVA%i: Comms error(buffer)",
 			applog(LOG_ERR, "AVA%i: Comms error(buffer)",
@@ -821,7 +849,7 @@ static int64_t avalon_scanhash(struct thr_info *thr)
 			avalon_init(avalon);
 			avalon_init(avalon);
 			return 0;	/* This should never happen */
 			return 0;	/* This should never happen */
 		}
 		}
-		if (ret == AVA_SEND_BUFFER_EMPTY && (i + 1 == avalon_get_work_count)) {
+		if (ret == AVA_SEND_BUFFER_EMPTY && (i + 1 == end_count)) {
 			first_try = 1;
 			first_try = 1;
 			return 0xffffffff;
 			return 0xffffffff;
 		}
 		}
@@ -903,7 +931,9 @@ static int64_t avalon_scanhash(struct thr_info *thr)
 		return 0;
 		return 0;
 	}
 	}
 
 
-	avalon_free_work(thr);
+	avalon_free_work_array(thr);
+	if (++avalon->work_array > 3)
+		avalon->work_array = 0;
 
 
 	record_temp_fan(info, &ar, &(avalon->temp));
 	record_temp_fan(info, &ar, &(avalon->temp));
 	applog(LOG_INFO,
 	applog(LOG_INFO,

+ 1 - 0
miner.h

@@ -435,6 +435,7 @@ struct cgpu_info {
 	};
 	};
 #ifdef USE_AVALON
 #ifdef USE_AVALON
 	struct work **works;
 	struct work **works;
+	int work_array;
 	int queued;
 	int queued;
 #endif
 #endif
 #ifdef USE_BITFORCE
 #ifdef USE_BITFORCE