Browse Source

bitfury: Reset chips if more than 8 hw errors are found in a 0x40 result sample period

Luke Dashjr 12 years ago
parent
commit
8490a55ac0
2 changed files with 16 additions and 0 deletions
  1. 14 0
      driver-bitfury.c
  2. 2 0
      libbitfury.h

+ 14 - 0
driver-bitfury.c

@@ -527,7 +527,21 @@ void bitfury_do_io(struct thr_info *thr)
 				submit_nonce(thr, thr->prev_work, nonce);
 				submit_nonce(thr, thr->prev_work, nonce);
 			}
 			}
 			else
 			else
+			{
 				inc_hw_errors(thr, thr->work, nonce);
 				inc_hw_errors(thr, thr->work, nonce);
+				++bitfury->sample_hwe;
+			}
+			if (++bitfury->sample_tot >= 0x40)
+			{
+				if (bitfury->sample_hwe >= 8)
+				{
+					applog(LOG_WARNING, "%"PRIpreprv": %d of the last %d results were bad, reinitialising",
+					       proc->proc_repr, bitfury->sample_hwe, bitfury->sample_tot);
+					send_reinit(bitfury->spi, bitfury->slot, bitfury->fasync, bitfury->osc6_bits);
+					bitfury_init_oldbuf(proc);
+				}
+				bitfury->sample_tot = bitfury->sample_hwe = 0;
+			}
 		}
 		}
 		bitfury->active = (bitfury->active + n) % 0x10;
 		bitfury->active = (bitfury->active + n) % 0x10;
 	}
 	}

+ 2 - 0
libbitfury.h

@@ -55,6 +55,8 @@ struct bitfury_device {
 	unsigned strange_counter;
 	unsigned strange_counter;
 	bool second_run;
 	bool second_run;
 	int desync_counter;
 	int desync_counter;
+	int sample_hwe;
+	int sample_tot;
 	
 	
 	time_t short_out_t;
 	time_t short_out_t;
 	time_t long_out_t;
 	time_t long_out_t;