Browse Source

cairnsmore: Detect frequency changing support despite hashing of commands

Luke Dashjr 13 years ago
parent
commit
663b3ee97b
3 changed files with 9 additions and 14 deletions
  1. 7 12
      driver-cairnsmore.c
  2. 1 1
      driver-icarus.c
  3. 1 1
      libblkmaker

+ 7 - 12
driver-cairnsmore.c

@@ -66,7 +66,7 @@ static bool cairnsmore_send_cmd(int fd, uint8_t cmd, uint8_t data)
 		"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
 		"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
 		"vdi\xb7"
 		"vdi\xb7"
 		"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
 		"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-		"BFG0" "\xff\xff\xff\xff" "\0\0\0\0";
+		"BFG0" "\xff\xff\xff\xff" "\x23\0\0\0";
 	pkt[32] = 0xda ^ cmd ^ data;
 	pkt[32] = 0xda ^ cmd ^ data;
 	pkt[33] = data;
 	pkt[33] = data;
 	pkt[34] = cmd;
 	pkt[34] = cmd;
@@ -75,12 +75,7 @@ static bool cairnsmore_send_cmd(int fd, uint8_t cmd, uint8_t data)
 
 
 bool cairnsmore_supports_dynclock(int fd)
 bool cairnsmore_supports_dynclock(int fd)
 {
 {
-	unsigned char pkts[64] =
-		"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-		"\xe6\x3c\0\xb7"  // Set frequency multiplier to 60 (150 Mhz)
-		"\0\0\0\0\0\0\0\0\0\0\0\0" "BFG0"
-		"\x8b\xdb\x05\x1a" "\xff\xff\xff\xff" "\x00\x00\x1e\xfd";
-	if (write(fd, pkts, sizeof(pkts)) != sizeof(pkts))
+	if (!cairnsmore_send_cmd(fd, 0, 1))
 		return false;
 		return false;
 
 
 	uint32_t nonce = 0;
 	uint32_t nonce = 0;
@@ -93,8 +88,8 @@ bool cairnsmore_supports_dynclock(int fd)
 		icarus_gets((unsigned char*)&nonce, fd, &tv_finish, &dummy, 1);
 		icarus_gets((unsigned char*)&nonce, fd, &tv_finish, &dummy, 1);
 	}
 	}
 	switch (nonce) {
 	switch (nonce) {
-		case 0x000b1b5e:  // on big    endian
-		case 0x5e1b0b00:  // on little endian
+		case 0x0023b2ee:  // big    endian
+		case 0xeeb22300:  // little endian
 			// Hashed the command, so it's not supported
 			// Hashed the command, so it's not supported
 			return false;
 			return false;
 		default:
 		default:
@@ -127,6 +122,7 @@ static bool cairnsmore_init(struct thr_info *thr)
 {
 {
 	struct cgpu_info *cm1 = thr->cgpu;
 	struct cgpu_info *cm1 = thr->cgpu;
 	struct ICARUS_INFO *info = cm1->cgpu_data;
 	struct ICARUS_INFO *info = cm1->cgpu_data;
+	struct icarus_state *state = thr->cgpu_data;
 
 
 	if (cairnsmore_supports_dynclock(cm1->device_fd)) {
 	if (cairnsmore_supports_dynclock(cm1->device_fd)) {
 		info->dclk_change_clock_func = cairnsmore_change_clock_func;
 		info->dclk_change_clock_func = cairnsmore_change_clock_func;
@@ -144,10 +140,9 @@ static bool cairnsmore_init(struct thr_info *thr)
 		applog(LOG_WARNING, "%s %u: Frequency scaling not supported",
 		applog(LOG_WARNING, "%s %u: Frequency scaling not supported",
 			cm1->api->name, cm1->device_id
 			cm1->api->name, cm1->device_id
 		);
 		);
-		// Test failures corrupt the hash state, so next scanhash is a firstrun
-		struct icarus_state *state = thr->cgpu_data;
-		state->firstrun = true;
 	}
 	}
+	// Commands corrupt the hash state, so next scanhash is a firstrun
+	state->firstrun = true;
 
 
 	return true;
 	return true;
 }
 }

+ 1 - 1
driver-icarus.c

@@ -774,7 +774,7 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
 	nonce = be32toh(nonce);
 	nonce = be32toh(nonce);
 
 
 	// Handle dynamic clocking for "subclass" devices
 	// Handle dynamic clocking for "subclass" devices
-	// This runs before sending next job, in case it isn't supported
+	// This needs to run before sending next job, since it hashes the command too
 	if (info->dclk.freqM && likely(!state->firstrun)) {
 	if (info->dclk.freqM && likely(!state->firstrun)) {
 		dclk_gotNonces(&info->dclk);
 		dclk_gotNonces(&info->dclk);
 		if (nonce && !test_nonce(&state->last_work, nonce, false))
 		if (nonce && !test_nonce(&state->last_work, nonce, false))

+ 1 - 1
libblkmaker

@@ -1 +1 @@
-Subproject commit 7f153402d6699d6748fc3ac6585c9076375c4b53
+Subproject commit e0b627c6522fdbd7c65f883a2c76e3aa437ce910