small fixes and cleanup
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
diff --git a/todo_ztex.txt b/todo_ztex.txt
index 79fc208..8bc8548 100644
--- a/todo_ztex.txt
+++ b/todo_ztex.txt
@@ -3,3 +3,4 @@
- read actual bitstream
- HS fpga config
- allow configuring LIBZTEX_OVERHEATTHRESHOLD
+- hotplug support?
diff --git a/ztex.c b/ztex.c
index 452d3c2..02b6075 100644
--- a/ztex.c
+++ b/ztex.c
@@ -74,7 +74,6 @@ static bool ztex_updateFreq (struct libztex_device* ztex)
maxM = 0;
while (maxM<ztex->freqMDefault && ztex->maxErrorRate[maxM+1]<LIBZTEX_MAXMAXERRORRATE)
maxM++;
- //applog(LOG_WARNING, "maxM:%d freqMaxM:%d errorWeight:%f maxErrorRate:%f maxMax:%f", maxM, ztex->freqMaxM, ztex->errorWeight[maxM], ztex->maxErrorRate[maxM+1], LIBZTEX_MAXMAXERRORRATE);
while (maxM<ztex->freqMaxM && ztex->errorWeight[maxM]>150 && ztex->maxErrorRate[maxM+1]<LIBZTEX_MAXMAXERRORRATE)
maxM++;
@@ -88,9 +87,6 @@ static bool ztex_updateFreq (struct libztex_device* ztex)
}
}
- //applog(LOG_WARNING, "maxM:%d bestM:%d bestR:%f freqM:%d", maxM, bestM, bestR, ztex->freqM);
-
-
if (bestM != ztex->freqM) {
libztex_setFreq(ztex, bestM);
}
@@ -132,7 +128,7 @@ static bool ztex_checkNonce (struct libztex_device *ztex,
if (swab32(hash2_32[7]) != ((hdata->hash7 + 0x5be0cd19) & 0xFFFFFFFF)) {
ztex->errorCount[ztex->freqM] += 1.0/ztex->numNonces;
- applog(LOG_ERR, "%s: checkNonce failed for %0.8X", ztex->repr, hdata->nonce);
+ applog(LOG_DEBUG, "%s: checkNonce failed for %0.8X", ztex->repr, hdata->nonce);
return false;
}
return true;
@@ -162,9 +158,16 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
lastnonce[i] = 0;
}
overflow = false;
+
while (!(overflow || work_restart[thr->id].restart)) {
usleep(250000);
+ if (work_restart[thr->id].restart) {
+ break;
+ }
libztex_readHashData(ztex, &hdata[0]);
+ if (work_restart[thr->id].restart) {
+ break;
+ }
ztex->errorCount[ztex->freqM] *= 0.995;
ztex->errorWeight[ztex->freqM] = ztex->errorWeight[ztex->freqM] * 0.995 + 1.0;
@@ -179,6 +182,7 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
lastnonce[i] = nonce;
}
if (!ztex_checkNonce(ztex, work, &hdata[i])) {
+ thr->cgpu->hw_errors++;
continue;
}
nonce = hdata[i].goldenNonce;
@@ -208,17 +212,20 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
}
}
- ztex->errorRate[ztex->freqM] = ztex->errorCount[ztex->freqM] / ztex->errorWeight[ztex->freqM] * (ztex->errorWeight[ztex->freqM]<100 ? ztex->errorWeight[ztex->freqM]*0.01 : 1.0);
- if (ztex->errorRate[ztex->freqM] > ztex->maxErrorRate[ztex->freqM]) {
- ztex->maxErrorRate[ztex->freqM] = ztex->errorRate[ztex->freqM];
- }
- if (!ztex_updateFreq(ztex)) {
- // Something really serious happened, so mark this thread as dead!
- thr->cgpu->status = LIFE_DEAD;
- }
- applog(LOG_WARNING, "freqM:%d errorRate:%0.3f errorCount:%d", ztex->freqM, ztex->errorRate[ztex->freqM], ztex->errorCount[ztex->freqM]);
- applog(LOG_DEBUG, "exit %0.8X", noncecnt);
+ ztex->errorRate[ztex->freqM] = ztex->errorCount[ztex->freqM] / ztex->errorWeight[ztex->freqM] * (ztex->errorWeight[ztex->freqM]<100 ? ztex->errorWeight[ztex->freqM]*0.01 : 1.0);
+ if (ztex->errorRate[ztex->freqM] > ztex->maxErrorRate[ztex->freqM]) {
+ ztex->maxErrorRate[ztex->freqM] = ztex->errorRate[ztex->freqM];
+ }
+
+ if (!ztex_updateFreq(ztex)) {
+ // Something really serious happened, so mark this thread as dead!
+ thr->cgpu->status = LIFE_DEAD;
+ }
+ applog(LOG_DEBUG, "exit %1.8X", noncecnt);
+
+ work->blk.nonce = 0xffffffff;
+
return noncecnt;
}
@@ -235,6 +242,7 @@ static bool ztex_prepare(struct thr_info *thr)
}
ztex->device->freqM = -1;
ztex_updateFreq(ztex->device);
+
return true;
}