Browse Source

gridseed: Bugfix: Revert earlier changes to scanhash based on feedback

Nate Woolls 11 years ago
parent
commit
7b2613ec3a
3 changed files with 23 additions and 35 deletions
  1. 7 32
      driver-gridseed.c
  2. 15 2
      gc3355.c
  3. 1 1
      gc3355.h

+ 7 - 32
driver-gridseed.c

@@ -19,9 +19,7 @@
 #include "gc3355.h"
 
 #define GRIDSEED_DEFAULT_FREQUENCY  600
-
-// 60Kh/s at 700MHz in ms
-#define GRIDSEED_HASH_SPEED			0.08571428571429
+#define GRIDSEED_HASH_SPEED			0.0851128926	// in ms
 
 BFG_REGISTER_DRIVER(gridseed_drv)
 
@@ -230,48 +228,25 @@ static
 int64_t gridseed_scanhash(struct thr_info *thr, struct work *work, int64_t __maybe_unused max_nonce)
 {
 	struct cgpu_info *device = thr->cgpu;
-	struct gc3355_info *info = device->device_data;
-	struct timeval tv_nonce_range, tv_hashes_done;
-
-	// total hashrate of this device:
-	uint32_t hashes_per_sec = GRIDSEED_HASH_SPEED * (double)(1000 * info->freq * info->chips);
-	// amount of time it takes this device to scan a nonce range:
-	uint32_t nonce_range_sec = 0xffffffff / hashes_per_sec;
-	// timer to break out of scanning should we scan an entire nonce range
-	timer_set_delay_from_now(&tv_nonce_range, nonce_range_sec * 1000000);
-
-	// timer to estimate hashes every 10s for runs of no shares
-	const uint32_t hashes_delay = 10 * 1000000;
-	timer_set_delay_from_now(&tv_hashes_done, hashes_delay);
 
 	unsigned char buf[GC3355_READ_SIZE];
 	int read = 0;
 	int fd = device->device_fd;
 
-	while (!thr->work_restart &&											// true when new work is available (miner.c)
-		   (read = gc3355_read(fd, (char *)buf, GC3355_READ_SIZE)) >= 0 &&	// only check for failure - allow 0 bytes
-		   !timer_passed(&tv_nonce_range, NULL))							// true when we've had time to scan a range
+	while (!thr->work_restart && (read = gc3355_read(fd, (char *)buf, GC3355_READ_SIZE)) > 0)
 	{
-		if (timer_passed(&tv_hashes_done, NULL))
-		{
-			gridseed_hashes_done(thr);
-			timer_set_delay_from_now(&tv_hashes_done, hashes_delay);
-		}
-
-		if (read == 0)
-			continue;
-		else if ((buf[0] == 0x55) && (buf[1] == 0x20))
+		if ((buf[0] == 0x55) && (buf[1] == 0x20))
 		{
+			// LTC result
 			gridseed_submit_nonce(thr, buf, work);
-			gridseed_hashes_done(thr);
-			timer_set_delay_from_now(&tv_hashes_done, hashes_delay);
 		}
 		else
+		{
 			applog(LOG_ERR, "%"PRIpreprv": Unrecognized response", device->proc_repr);
+			break;
+		}
 	}
 
-	// estimate remaining hashes for elapsed time
-	// e.g. work_restart ~hashes_delay after tv_hashes_done
 	gridseed_hashes_done(thr);
 
 	return 0;

+ 15 - 2
gc3355.c

@@ -388,9 +388,22 @@ void gc3355_log_protocol(int fd, const char *buf, size_t size, const char *prefi
 	       GC3355_CHIP_NAME, fd, prefix, (unsigned long)size, hex);
 }
 
-ssize_t gc3355_read(int fd, char *buf, size_t size)
+int gc3355_read(int fd, char *buf, size_t size)
 {
-	size_t read = serial_read(fd, buf, size);
+	size_t read;
+	int tries = 20;
+	
+	while (tries > 0)
+	{
+		read = serial_read(fd, buf, size);
+		if (read > 0)
+			break;
+		
+		tries--;
+	}
+	
+	if (unlikely(tries == 0))
+		return -1;
 	
 	if ((read > 0) && opt_dev_protocol)
 		gc3355_log_protocol(fd, buf, read, "RECV");

+ 1 - 1
gc3355.h

@@ -41,7 +41,7 @@ struct gc3355_info
 #define gc3355_open(path)  serial_open(path, 115200, 1, true)
 #define gc3355_close(fd)  serial_close(fd)
 
-extern ssize_t gc3355_read(int fd, char *buf, size_t size);
+extern int gc3355_read(int fd, char *buf, size_t size);
 extern ssize_t gc3355_write(int fd, const void * const buf, const size_t size);
 
 extern void gc3355_init_miner(int fd, int pll_freq);