Browse Source

* only send one byte on reset
* add support on send 2 bulk taskes at begin

Xiangfu 13 years ago
parent
commit
4c4cba12ee
2 changed files with 26 additions and 6 deletions
  1. 25 6
      driver-avalon.c
  2. 1 0
      driver-avalon.h

+ 25 - 6
driver-avalon.c

@@ -149,6 +149,8 @@ static int avalon_send_task(int fd, const struct avalon_task *at,
 	buf[0] = tt;
 	buf[0] = tt;
 	buf[4] = rev8(buf[4]);
 	buf[4] = rev8(buf[4]);
 #endif
 #endif
+	if (at->reset)
+		nr_len = 1;
 	if (opt_debug) {
 	if (opt_debug) {
 		applog(LOG_DEBUG, "Avalon: Sent(%d):", nr_len);
 		applog(LOG_DEBUG, "Avalon: Sent(%d):", nr_len);
 		hexdump((uint8_t *)buf, nr_len);
 		hexdump((uint8_t *)buf, nr_len);
@@ -602,6 +604,7 @@ static void do_avalon_close(struct thr_info *thr)
 	avalon_free_work(thr, info->bulk0);
 	avalon_free_work(thr, info->bulk0);
 	avalon_free_work(thr, info->bulk1);
 	avalon_free_work(thr, info->bulk1);
 	avalon_free_work(thr, info->bulk2);
 	avalon_free_work(thr, info->bulk2);
+	avalon_free_work(thr, info->bulk3);
 }
 }
 
 
 static int64_t avalon_scanhash(struct thr_info *thr, struct work **work,
 static int64_t avalon_scanhash(struct thr_info *thr, struct work **work,
@@ -613,12 +616,13 @@ static int64_t avalon_scanhash(struct thr_info *thr, struct work **work,
 	struct avalon_info *info;
 	struct avalon_info *info;
 	struct avalon_task at;
 	struct avalon_task at;
 	struct avalon_result ar;
 	struct avalon_result ar;
-	int i, work_i0, work_i1, work_i2;
+	int i, work_i0, work_i1, work_i2, work_i3;
 	int avalon_get_work_count;
 	int avalon_get_work_count;
 
 
 	struct timeval tv_start, tv_finish, elapsed;
 	struct timeval tv_start, tv_finish, elapsed;
 	uint32_t nonce;
 	uint32_t nonce;
 	int64_t hash_count;
 	int64_t hash_count;
+	static int first_try = 0;
 
 
 	avalon = thr->cgpu;
 	avalon = thr->cgpu;
 	info = avalon_info[avalon->device_id];
 	info = avalon_info[avalon->device_id];
@@ -640,9 +644,10 @@ static int64_t avalon_scanhash(struct thr_info *thr, struct work **work,
 	for (i = 0; i < avalon_get_work_count; i++) {
 	for (i = 0; i < avalon_get_work_count; i++) {
 		info->bulk0[i] = info->bulk1[i];
 		info->bulk0[i] = info->bulk1[i];
 		info->bulk1[i] = info->bulk2[i];
 		info->bulk1[i] = info->bulk2[i];
-		info->bulk2[i] = work[i];
+		info->bulk2[i] = info->bulk3[i];
+		info->bulk3[i] = work[i];
 		applog(LOG_DEBUG, "Avalon: bulk0/1/2 buffer [%d]: %p, %p, %p",
 		applog(LOG_DEBUG, "Avalon: bulk0/1/2 buffer [%d]: %p, %p, %p",
-		       i, info->bulk0[i], info->bulk1[i], info->bulk2[i]);
+		       i, info->bulk0[i], info->bulk1[i], info->bulk2[i], info->bulk3[i]);
 	}
 	}
 
 
 	i = 0;
 	i = 0;
@@ -651,18 +656,25 @@ static int64_t avalon_scanhash(struct thr_info *thr, struct work **work,
 		avalon_create_task(&at, work[i]);
 		avalon_create_task(&at, work[i]);
 		ret = avalon_send_task(fd, &at, thr);
 		ret = avalon_send_task(fd, &at, thr);
 		if (unlikely(ret == AVA_SEND_ERROR ||
 		if (unlikely(ret == AVA_SEND_ERROR ||
-		    (ret == AVA_SEND_BUFFER_EMPTY &&
-		     (i + 1 == avalon_get_work_count)))) {
+			     (ret == AVA_SEND_BUFFER_EMPTY &&
+			      (i + 1 == avalon_get_work_count) &&
+			      first_try))) {
 			avalon_free_work(thr, info->bulk0);
 			avalon_free_work(thr, info->bulk0);
 			avalon_free_work(thr, info->bulk1);
 			avalon_free_work(thr, info->bulk1);
 			avalon_free_work(thr, info->bulk2);
 			avalon_free_work(thr, info->bulk2);
+			avalon_free_work(thr, info->bulk3);
 			do_avalon_close(thr);
 			do_avalon_close(thr);
 			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);
+			first_try = 0;
 			sleep(1);
 			sleep(1);
 			return 0;	/* This should never happen */
 			return 0;	/* This should never happen */
 		}
 		}
+		if (ret == AVA_SEND_BUFFER_EMPTY && (i + 1 == avalon_get_work_count)) {
+			first_try = 1;
+			return 0xffffffff;
+		}
 
 
 		work[i]->blk.nonce = 0xffffffff;
 		work[i]->blk.nonce = 0xffffffff;
 
 
@@ -671,6 +683,8 @@ static int64_t avalon_scanhash(struct thr_info *thr, struct work **work,
 
 
 		i++;
 		i++;
 	}
 	}
+	if (unlikely(first_try))
+		first_try = 0;
 
 
 	elapsed.tv_sec = elapsed.tv_usec = 0;
 	elapsed.tv_sec = elapsed.tv_usec = 0;
 	gettimeofday(&tv_start, NULL);
 	gettimeofday(&tv_start, NULL);
@@ -690,6 +704,7 @@ static int64_t avalon_scanhash(struct thr_info *thr, struct work **work,
 			avalon_free_work(thr, info->bulk0);
 			avalon_free_work(thr, info->bulk0);
 			avalon_free_work(thr, info->bulk1);
 			avalon_free_work(thr, info->bulk1);
 			avalon_free_work(thr, info->bulk2);
 			avalon_free_work(thr, info->bulk2);
+			avalon_free_work(thr, info->bulk3);
 			do_avalon_close(thr);
 			do_avalon_close(thr);
 			applog(LOG_ERR,
 			applog(LOG_ERR,
 			       "AVA%i: Comms error(read)", avalon->device_id);
 			       "AVA%i: Comms error(read)", avalon->device_id);
@@ -706,6 +721,7 @@ static int64_t avalon_scanhash(struct thr_info *thr, struct work **work,
 			avalon_free_work(thr, info->bulk0);
 			avalon_free_work(thr, info->bulk0);
 			avalon_free_work(thr, info->bulk1);
 			avalon_free_work(thr, info->bulk1);
 			avalon_free_work(thr, info->bulk2);
 			avalon_free_work(thr, info->bulk2);
+			avalon_free_work(thr, info->bulk3);
 			continue;
 			continue;
 		}
 		}
 		avalon->temp = (ar.temp0 + ar.temp1 + ar.temp2) / 3;
 		avalon->temp = (ar.temp0 + ar.temp1 + ar.temp2) / 3;
@@ -727,7 +743,8 @@ static int64_t avalon_scanhash(struct thr_info *thr, struct work **work,
 		work_i0 = avalon_decode_nonce(thr, info->bulk0, &ar, &nonce);
 		work_i0 = avalon_decode_nonce(thr, info->bulk0, &ar, &nonce);
 		work_i1 = avalon_decode_nonce(thr, info->bulk1, &ar, &nonce);
 		work_i1 = avalon_decode_nonce(thr, info->bulk1, &ar, &nonce);
 		work_i2 = avalon_decode_nonce(thr, info->bulk2, &ar, &nonce);
 		work_i2 = avalon_decode_nonce(thr, info->bulk2, &ar, &nonce);
-		if ((work_i0 < 0) && (work_i1 < 0) && (work_i2 < 0)) {
+		work_i3 = avalon_decode_nonce(thr, info->bulk3, &ar, &nonce);
+		if ((work_i0 < 0) && (work_i1 < 0) && (work_i2 < 0) && (work_i3 < 0)) {
 			if (opt_debug) {
 			if (opt_debug) {
 				timersub(&tv_finish, &tv_start, &elapsed);
 				timersub(&tv_finish, &tv_start, &elapsed);
 				applog(LOG_DEBUG,"Avalon: no matching work: %d"
 				applog(LOG_DEBUG,"Avalon: no matching work: %d"
@@ -743,6 +760,8 @@ static int64_t avalon_scanhash(struct thr_info *thr, struct work **work,
 			submit_nonce(thr, info->bulk1[work_i1], nonce);
 			submit_nonce(thr, info->bulk1[work_i1], nonce);
 		if (work_i2 >= 0)
 		if (work_i2 >= 0)
 			submit_nonce(thr, info->bulk2[work_i2], nonce);
 			submit_nonce(thr, info->bulk2[work_i2], nonce);
+		if (work_i3 >= 0)
+			submit_nonce(thr, info->bulk3[work_i3], nonce);
 
 
 		hash_count += nonce;
 		hash_count += nonce;
 
 

+ 1 - 0
driver-avalon.h

@@ -85,6 +85,7 @@ struct avalon_info {
 	struct work *bulk0[AVALON_DEFAULT_MINER_NUM];
 	struct work *bulk0[AVALON_DEFAULT_MINER_NUM];
 	struct work *bulk1[AVALON_DEFAULT_MINER_NUM];
 	struct work *bulk1[AVALON_DEFAULT_MINER_NUM];
 	struct work *bulk2[AVALON_DEFAULT_MINER_NUM];
 	struct work *bulk2[AVALON_DEFAULT_MINER_NUM];
+	struct work *bulk3[AVALON_DEFAULT_MINER_NUM];
 };
 };
 
 
 #define AVALON_WRITE_SIZE (sizeof(struct avalon_task))
 #define AVALON_WRITE_SIZE (sizeof(struct avalon_task))