Commit f164446282cc651df7ad35a3589e13e1151fce55

Con Kolivas 2013-05-27T01:32:31

Lock qlock mutex during reset from read thread in avalon to prevent more work being sent till the reset is over.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/driver-avalon.c b/driver-avalon.c
index b81161b..0ca3206 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -691,9 +691,13 @@ static void *avalon_get_results(void *userdata)
 		if (unlikely(avalon->results <= -info->miner_count)) {
 			applog(LOG_ERR, "AVA%d: %d invalid consecutive results, resetting",
 			       avalon->device_id, -avalon->results);
+
+			/* Lock to prevent more work being sent during reset */
+			mutex_lock(&info->qlock);
 			avalon_reset(avalon, fd);
 			avalon_idle(avalon, info, fd);
 			avalon->results = 0;
+			mutex_unlock(&info->qlock);
 		}
 
 		if (unlikely(offset + rsize >= AVALON_READBUF_SIZE)) {