Commit 64ecfa53a9fa3109a137d52cc7251c30b2576ebe

Con Kolivas 2013-04-08T11:32:24

Revert "Use only 2 queued work arrays in avalon." This reverts commit 0ea9d68d6786473b641bc377651b908aeeab06a2. This was leading to failure to find work items on block changes.

diff --git a/driver-avalon.c b/driver-avalon.c
index 4596cde..7bb8dc8 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -670,7 +670,7 @@ static bool avalon_prepare(struct thr_info *thr)
 	struct timeval now;
 
 	free(avalon->works);
-	avalon->works = calloc(info->miner_count * sizeof(struct work *), 2);
+	avalon->works = calloc(info->miner_count * sizeof(struct work *), 4);
 	if (!avalon->works)
 		quit(1, "Failed to calloc avalon works in avalon_prepare");
 	if (avalon->device_fd == -1)
@@ -697,7 +697,7 @@ static void avalon_free_work(struct thr_info *thr)
 	works = avalon->works;
 	info = avalon_infos[avalon->device_id];
 
-	for (i = 0; i < info->miner_count * 2; i++) {
+	for (i = 0; i < info->miner_count * 4; i++) {
 		if (works[i]) {
 			work_completed(avalon, works[i]);
 			works[i] = NULL;
@@ -717,7 +717,8 @@ static void avalon_free_work_array(struct thr_info *thr)
 		return;
 	works = avalon->works;
 	mc = avalon_infos[avalon->device_id]->miner_count;
-	avalon->work_array ^= 1;
+	if (++avalon->work_array > 3)
+		avalon->work_array = 0;
 
 	for (i = avalon->work_array * mc, j = 0; j < mc; i++, j++) {
 		if (likely(works[i])) {