|
|
@@ -31,9 +31,20 @@ struct modminer_fpga_state {
|
|
|
char next_work_cmd[46];
|
|
|
|
|
|
unsigned char clock;
|
|
|
+ unsigned char max_clock;
|
|
|
+ // Number of iterations since we last got a nonce
|
|
|
int no_nonce_counter;
|
|
|
+ // Number of nonces didn't meet pdiff 1, ever
|
|
|
int bad_share_counter;
|
|
|
+ // Number of nonces did meet pdiff 1, ever
|
|
|
int good_share_counter;
|
|
|
+ // Number of nonces didn't meet pdiff 1, since last clock change
|
|
|
+ int bad_nonce_counter;
|
|
|
+ // Number of nonces total, since last clock change
|
|
|
+ int nonce_counter;
|
|
|
+ // Number of good nonces, since last clock change OR bad nonce
|
|
|
+ int good_nonce_counter;
|
|
|
+ // Time the clock was last reduced due to temperature
|
|
|
time_t last_cutoff_reduced;
|
|
|
|
|
|
unsigned char temp;
|
|
|
@@ -301,7 +312,7 @@ modminer_fpga_prepare(struct thr_info *thr)
|
|
|
}
|
|
|
|
|
|
static bool
|
|
|
-modminer_reduce_clock(struct thr_info*thr, bool needlock)
|
|
|
+modminer_change_clock(struct thr_info*thr, bool needlock)
|
|
|
{
|
|
|
struct cgpu_info*modminer = thr->cgpu;
|
|
|
struct modminer_fpga_state *state = thr->cgpu_data;
|
|
|
@@ -309,12 +320,9 @@ modminer_reduce_clock(struct thr_info*thr, bool needlock)
|
|
|
int fd;
|
|
|
unsigned char cmd[6], buf[1];
|
|
|
|
|
|
- if (state->clock <= 100)
|
|
|
- return false;
|
|
|
-
|
|
|
cmd[0] = '\x06'; // set clock speed
|
|
|
cmd[1] = fpgaid;
|
|
|
- cmd[2] = state->clock -= 2;
|
|
|
+ cmd[2] = state->clock;
|
|
|
cmd[3] = cmd[4] = cmd[5] = '\0';
|
|
|
|
|
|
if (needlock)
|
|
|
@@ -327,9 +335,38 @@ modminer_reduce_clock(struct thr_info*thr, bool needlock)
|
|
|
if (needlock)
|
|
|
mutex_unlock(&modminer->device_mutex);
|
|
|
|
|
|
+ state->bad_nonce_counter = state->nonce_counter = 0;
|
|
|
+ state->good_nonce_counter = 0;
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+static bool
|
|
|
+modminer_reduce_clock(struct thr_info*thr, bool needlock)
|
|
|
+{
|
|
|
+ struct modminer_fpga_state *state = thr->cgpu_data;
|
|
|
+
|
|
|
+ if (state->clock <= 100)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ state->clock -= 2;
|
|
|
+
|
|
|
+ return modminer_change_clock(thr, needlock);
|
|
|
+}
|
|
|
+
|
|
|
+static bool
|
|
|
+modminer_increase_clock(struct thr_info*thr, bool needlock)
|
|
|
+{
|
|
|
+ struct modminer_fpga_state *state = thr->cgpu_data;
|
|
|
+
|
|
|
+ if (state->clock >= state->max_clock)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ state->clock += 2;
|
|
|
+
|
|
|
+ return modminer_change_clock(thr, needlock);
|
|
|
+}
|
|
|
+
|
|
|
static bool
|
|
|
modminer_fpga_init(struct thr_info *thr)
|
|
|
{
|
|
|
@@ -364,9 +401,10 @@ modminer_fpga_init(struct thr_info *thr)
|
|
|
applog(LOG_DEBUG, "%s %u.%u: FPGA is already programmed :)", modminer->api->name, modminer->device_id, fpgaid);
|
|
|
state->pdone = 101;
|
|
|
|
|
|
+ state->max_clock = 210;
|
|
|
state->clock = 212; // Will be reduced to 210 by modminer_reduce_clock
|
|
|
- modminer_reduce_clock(thr, false);
|
|
|
- applog(LOG_WARNING, "%s %u.%u: Setting clock speed to %u", modminer->api->name, modminer->device_id, fpgaid, state->clock);
|
|
|
+ if (modminer_reduce_clock(thr, false))
|
|
|
+ applog(LOG_WARNING, "%s %u.%u: Setting clock speed to %u", modminer->api->name, modminer->device_id, fpgaid, state->clock);
|
|
|
|
|
|
mutex_unlock(&modminer->device_mutex);
|
|
|
|
|
|
@@ -431,8 +469,13 @@ get_modminer_api_extra_device_status(struct cgpu_info*modminer)
|
|
|
if (state->temp)
|
|
|
json_object_set(o, "Temperature", json_integer(state->temp));
|
|
|
json_object_set(o, "Frequency", json_real((double)state->clock * 1000000.));
|
|
|
+ json_object_set(o, "Max Frequency", json_real((double)state->max_clock * 1000000.));
|
|
|
+ json_object_set(o, "_No Nonce Counter", json_integer(state->no_nonce_counter));
|
|
|
json_object_set(o, "Hardware Errors", json_integer(state->bad_share_counter));
|
|
|
json_object_set(o, "Valid Nonces", json_integer(state->good_share_counter));
|
|
|
+ json_object_set(o, "_Bad Nonce Counter", json_integer(state->bad_nonce_counter));
|
|
|
+ json_object_set(o, "_Nonce Counter", json_integer(state->nonce_counter));
|
|
|
+ json_object_set(o, "_Good Nonce Counter", json_integer(state->good_nonce_counter));
|
|
|
|
|
|
root = api_add_json(root, k[i], o, false);
|
|
|
json_decref(o);
|
|
|
@@ -518,8 +561,8 @@ modminer_process_results(struct thr_info*thr)
|
|
|
time_t now = time(NULL);
|
|
|
if (state->last_cutoff_reduced != now) {
|
|
|
state->last_cutoff_reduced = now;
|
|
|
- modminer_reduce_clock(thr, false);
|
|
|
- applog(LOG_WARNING, "%s %u.%u: Drop clock speed to %u (temp: %d)", modminer->api->name, modminer->device_id, fpgaid, state->clock, temperature);
|
|
|
+ if (modminer_reduce_clock(thr, false))
|
|
|
+ applog(LOG_WARNING, "%s %u.%u: Drop clock speed to %u (temp: %d)", modminer->api->name, modminer->device_id, fpgaid, state->clock, temperature);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -535,36 +578,47 @@ 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;
|
|
|
+ ++state->nonce_counter;
|
|
|
bad = !test_nonce(work, nonce, false);
|
|
|
if (!bad)
|
|
|
{
|
|
|
++state->good_share_counter;
|
|
|
submit_nonce(thr, work, nonce);
|
|
|
+ ++state->good_nonce_counter;
|
|
|
+ if (state->good_nonce_counter >= 100 && ((!state->temp) || state->temp < modminer->cutofftemp - 2)) {
|
|
|
+ if (modminer_increase_clock(thr, true))
|
|
|
+ applog(LOG_NOTICE, "%s %u.%u: Raise clock speed to %u", modminer->api->name, modminer->device_id, fpgaid, state->clock);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
if (unlikely((!state->good_share_counter) && nonce == 0xffffff00))
|
|
|
{
|
|
|
// Firmware returns 0xffffff00 immediately if we set clockspeed too high; but it's not a hw error and shouldn't affect future downclocking
|
|
|
- modminer_reduce_clock(thr, true);
|
|
|
- applog(LOG_WARNING, "%s %u.%u: Drop clock speed to %u (init)", modminer->api->name, modminer->device_id, fpgaid, state->clock);
|
|
|
+ if (modminer_reduce_clock(thr, true)) {
|
|
|
+ applog(LOG_WARNING, "%s %u.%u: Drop clock speed to %u (init)", modminer->api->name, modminer->device_id, fpgaid, state->clock);
|
|
|
+ state->max_clock = state->clock;
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
++hw_errors;
|
|
|
++modminer->hw_errors;
|
|
|
++state->bad_share_counter;
|
|
|
- if (state->bad_share_counter * 100 > 1000 + state->bad_share_counter + state->good_share_counter)
|
|
|
+ ++state->bad_nonce_counter;
|
|
|
+ state->good_nonce_counter = 0;
|
|
|
+ if (state->bad_nonce_counter * 50 > 500 + state->nonce_counter)
|
|
|
{
|
|
|
- // Only reduce clocks if hardware errors are more than ~1% of results
|
|
|
- modminer_reduce_clock(thr, true);
|
|
|
- applog(LOG_WARNING, "%s %u.%u: Drop clock speed to %u (%d%% hw err)", modminer->api->name, modminer->device_id, fpgaid, state->clock, state->bad_share_counter * 100 / (state->bad_share_counter + state->good_share_counter));
|
|
|
+ // Only reduce clocks if hardware errors are more than ~2% of results
|
|
|
+ int pchwe = state->bad_nonce_counter * 100 / state->nonce_counter;
|
|
|
+ if (modminer_reduce_clock(thr, true))
|
|
|
+ applog(LOG_WARNING, "%s %u.%u: Drop clock speed to %u (%d%% hw err)", modminer->api->name, modminer->device_id, fpgaid, state->clock, pchwe);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
if (++state->no_nonce_counter > 0x20000) {
|
|
|
state->no_nonce_counter = 0;
|
|
|
- modminer_reduce_clock(thr, true);
|
|
|
- applog(LOG_WARNING, "%s %u.%u: Drop clock speed to %u (no nonces)", modminer->api->name, modminer->device_id, fpgaid, state->clock);
|
|
|
+ if (modminer_reduce_clock(thr, true))
|
|
|
+ applog(LOG_WARNING, "%s %u.%u: Drop clock speed to %u (no nonces)", modminer->api->name, modminer->device_id, fpgaid, state->clock);
|
|
|
}
|
|
|
if (work_restart(thr) || !--iter)
|
|
|
break;
|