HW: error counter auto for all devices - ztex code not fixed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
diff --git a/cgminer.c b/cgminer.c
index d124dc7..69976f3 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4141,7 +4141,7 @@ err_out:
return false;
}
-bool hashtest(const struct work *work)
+static bool hashtest(struct thr_info *thr, const struct work *work)
{
uint32_t *data32 = (uint32_t *)(work->data);
unsigned char swap[128];
@@ -4162,11 +4162,22 @@ bool hashtest(const struct work *work)
memcpy((void*)work->hash, hash2, 32);
- return fulltest(work->hash, work->target);
+ if (hash2_32[7] != 0) {
+ applog(LOG_WARNING, "%s%d: invalid nonce - HW error",
+ thr->cgpu->api->name, thr->cgpu->device_id);
+ hw_errors++;
+ thr->cgpu->hw_errors++;
+ return true;
+ }
+
+ bool test = fulltest(work->hash, work->target);
+ if (!test)
+ applog(LOG_INFO, "Share below target");
+ return test;
}
-bool test_nonce(struct work *work, uint32_t nonce)
+static bool test_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
{
if (opt_scrypt) {
uint32_t *work_nonce = (uint32_t *)(work->data + 64 + 12);
@@ -4180,7 +4191,7 @@ bool test_nonce(struct work *work, uint32_t nonce)
work->data[64 + 12 + 2] = (nonce >> 16) & 0xff;
work->data[64 + 12 + 3] = (nonce >> 24) & 0xff;
- return hashtest(work);
+ return hashtest(thr, work);
}
bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
@@ -4191,10 +4202,9 @@ bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce)
/* Do one last check before attempting to submit the work */
/* Side effect: sets work->data for us */
- if (!test_nonce(work, nonce)) {
- applog(LOG_INFO, "Share below target");
+ if (!test_nonce(thr, work, nonce))
return true;
- }
+
return submit_work_sync(thr, work);
}
diff --git a/driver-modminer.c b/driver-modminer.c
index 040100d..750f9ec 100644
--- a/driver-modminer.c
+++ b/driver-modminer.c
@@ -405,6 +405,7 @@ modminer_process_results(struct thr_info*thr)
uint32_t nonce;
long iter;
bool bad;
+ int curr_hw_errors;
cmd[0] = '\x0a';
cmd[1] = fpgaid;
@@ -441,12 +442,10 @@ modminer_process_results(struct thr_info*thr)
mutex_unlock(&modminer->device_mutex);
if (memcmp(&nonce, "\xff\xff\xff\xff", 4)) {
state->no_nonce_counter = 0;
- bad = !test_nonce(work, nonce);
- if (!bad)
- submit_nonce(thr, work, nonce);
- else {
- ++hw_errors;
- if (++modminer->hw_errors * 100 > 1000 + state->good_share_counter)
+ curr_hw_errors = modminer->hw_errors;
+ submit_nonce(thr, work, nonce);
+ if (modminer->hw_errors > curr_hw_errors) {
+ if (modminer->hw_errors * 100 > 1000 + state->good_share_counter)
// Only reduce clocks if hardware errors are more than ~1% of results
modminer_reduce_clock(thr, true);
}
diff --git a/findnonce.c b/findnonce.c
index d557f17..788835d 100644
--- a/findnonce.c
+++ b/findnonce.c
@@ -131,6 +131,8 @@ void precalc_hash(dev_blk_ctx *blk, uint32_t *state, uint32_t *data)
blk->sevenA = blk->ctx_h + SHA256_K[7];
}
+#if 0 // not used any more
+
#define P(t) (W[(t)&0xF] = W[(t-16)&0xF] + (rotate(W[(t-15)&0xF], 25) ^ rotate(W[(t-15)&0xF], 14) ^ (W[(t-15)&0xF] >> 3)) + W[(t-7)&0xF] + (rotate(W[(t-2)&0xF], 15) ^ rotate(W[(t-2)&0xF], 13) ^ (W[(t-2)&0xF] >> 10)))
#define IR(u) \
@@ -167,6 +169,8 @@ void precalc_hash(dev_blk_ctx *blk, uint32_t *state, uint32_t *data)
R(E, F, G, H, A, B, C, D, P(u+4), SHA256_K[u+4]); \
R(D, E, F, G, H, A, B, C, P(u+5), SHA256_K[u+5])
+#endif
+
struct pc_data {
struct thr_info *thr;
struct work *work;
@@ -175,6 +179,8 @@ struct pc_data {
int found;
};
+#if 0 // not used any more
+
static void send_sha_nonce(struct pc_data *pcd, cl_uint nonce)
{
dev_blk_ctx *blk = &pcd->work->blk;
@@ -222,6 +228,8 @@ static void send_sha_nonce(struct pc_data *pcd, cl_uint nonce)
}
}
+#endif
+
static void send_scrypt_nonce(struct pc_data *pcd, uint32_t nonce)
{
struct thr_info *thr = pcd->thr;
@@ -238,6 +246,8 @@ static void send_scrypt_nonce(struct pc_data *pcd, uint32_t nonce)
static void *postcalc_hash(void *userdata)
{
struct pc_data *pcd = (struct pc_data *)userdata;
+ struct thr_info *thr = pcd->thr;
+ struct work *work = pcd->work;
unsigned int entry = 0;
pthread_detach(pthread_self());
@@ -248,8 +258,10 @@ static void *postcalc_hash(void *userdata)
applog(LOG_DEBUG, "OCL NONCE %u found in slot %d", nonce, entry);
if (opt_scrypt)
send_scrypt_nonce(pcd, nonce);
- else
- send_sha_nonce(pcd, nonce);
+ else {
+ if (unlikely(submit_nonce(thr, work, nonce) == false))
+ applog(LOG_ERR, "Failed to submit work, exiting");
+ }
}
free(pcd);
diff --git a/miner.h b/miner.h
index 6ac8d93..4771176 100644
--- a/miner.h
+++ b/miner.h
@@ -844,7 +844,6 @@ struct modminer_fpga_state {
#endif
extern void get_datestamp(char *, struct timeval *);
-extern bool test_nonce(struct work *work, uint32_t nonce);
bool submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
extern void tailsprintf(char *f, const char *fmt, ...);
extern void wlogprint(const char *f, ...);