Browse Source

bitfury: Do debug logging of read data before rotation

Luke Dashjr 12 years ago
parent
commit
b8398449fe
1 changed files with 18 additions and 23 deletions
  1. 18 23
      driver-bitfury.c

+ 18 - 23
driver-bitfury.c

@@ -91,13 +91,18 @@ void *bitfury_just_io(struct bitfury_device * const bitfury)
 extern unsigned decnonce(unsigned);
 
 static
-void bitfury_debug_nonce_array(char *sp, const struct bitfury_device * const bitfury, const uint32_t * const newbuf, const int active)
+void bitfury_debug_nonce_array(const struct cgpu_info * const proc, const char *msg, const uint32_t * const inp)
 {
-	const int divide = 0x10 - active;
+	const struct bitfury_device * const bitfury = proc->device_data;
+	const int active = bitfury->active;
+	char s[((1 + 8) * 0x10) + 1];
+	char *sp = s;
 	for (int i = 0; i < 0x10; ++i)
 		sp += sprintf(sp, "%c%08lx",
-		              (divide == i) ? ';' : ' ',
-		              (unsigned long)newbuf[i]);
+		              (active == i) ? '>' : ' ',
+		              (unsigned long)decnonce(inp[i]));
+	applog(LOG_DEBUG, "%"PRIpreprv": %s%s (job=%08lx)",
+	       proc->proc_repr, msg, s, (unsigned long)inp[0x10]);
 }
 
 bool bitfury_init_oldbuf(struct cgpu_info * const proc)
@@ -143,17 +148,12 @@ tryagain:
 	}
 	
 	bitfury->active = differ;
-	for (i = 0; i < 0x10; ++i)
-		oldbuf[i] = decnonce(inp[(bitfury->active + i) % 0x10]);
+	memcpy(&oldbuf[0], &inp[bitfury->active], 4 * (0x10 - bitfury->active));
+	memcpy(&oldbuf[0x10 - bitfury->active], &inp[0], 4 * bitfury->active);
 	bitfury->oldjob = inp[0x10];
 	
 	if (opt_debug)
-	{
-		char s[((1 + 8) * 0x10) + 1];
-		bitfury_debug_nonce_array(s, bitfury, oldbuf, bitfury->active);
-		applog(LOG_DEBUG, "%"PRIpreprv": Init%s (job=%08lx)",
-		       proc->proc_repr, s, (unsigned long)inp[0x10]);
-	}
+		bitfury_debug_nonce_array(proc, "Init", inp);
 	
 	return true;
 }
@@ -453,19 +453,14 @@ void bitfury_do_io(struct thr_info *thr)
 	
 	inp = bitfury_just_io(bitfury);
 	
+	if (opt_debug)
+		bitfury_debug_nonce_array(proc, "Read", inp);
+	
 	// To avoid dealing with wrap-around entirely, we rotate array so previous active uint32_t is at index 0
-	for (i = 0; i < 0x10; ++i)
-		newbuf[i] = decnonce(inp[(bitfury->active + i) % 0x10]);
+	memcpy(&newbuf[0], &inp[bitfury->active], 4 * (0x10 - bitfury->active));
+	memcpy(&newbuf[0x10 - bitfury->active], &inp[0], 4 * bitfury->active);
 	newjob = inp[0x10];
 	
-	if (opt_debug)
-	{
-		char s[((1 + 8) * 0x10) + 1];
-		bitfury_debug_nonce_array(s, bitfury, newbuf, bitfury->active);
-		applog(LOG_DEBUG, "%"PRIpreprv": Read%s (job=%08lx)",
-		       proc->proc_repr, s, (unsigned long)inp[0x10]);
-	}
-	
 	if (newbuf[0xf] != oldbuf[0xf])
 	{
 		inc_hw_errors2(thr, NULL, NULL);
@@ -497,7 +492,7 @@ void bitfury_do_io(struct thr_info *thr)
 	{
 		for (i = 0; i < n; ++i)
 		{
-			nonce = newbuf[i];
+			nonce = decnonce(newbuf[i]);
 			if (fudge_nonce(thr->work, &nonce))
 			{
 				applog(LOG_DEBUG, "%"PRIpreprv": nonce %x = %08lx (work=%p)",