|
|
@@ -54,6 +54,7 @@
|
|
|
#define HAVE_EPOLL
|
|
|
#endif
|
|
|
|
|
|
+#include "dynclock.h"
|
|
|
#include "elist.h"
|
|
|
#include "icarus-common.h"
|
|
|
#include "miner.h"
|
|
|
@@ -172,7 +173,7 @@ static void rev(unsigned char *s, size_t l)
|
|
|
#define icarus_open2(devpath, baud, purge) serial_open(devpath, baud, ICARUS_READ_FAULT_DECISECONDS, purge)
|
|
|
#define icarus_open(devpath, baud) icarus_open2(devpath, baud, false)
|
|
|
|
|
|
-static int icarus_gets(unsigned char *buf, int fd, struct timeval *tv_finish, struct thr_info *thr, int read_count)
|
|
|
+int icarus_gets(unsigned char *buf, int fd, struct timeval *tv_finish, struct thr_info *thr, int read_count)
|
|
|
{
|
|
|
ssize_t ret = 0;
|
|
|
int rc = 0;
|
|
|
@@ -374,7 +375,8 @@ static void set_timing_mode(int this_option_offset, struct cgpu_info *icarus)
|
|
|
|
|
|
info->min_data_count = MIN_DATA_COUNT;
|
|
|
|
|
|
- applog(LOG_DEBUG, "Icarus: Init: %d mode=%s read_count=%d Hs=%e",
|
|
|
+ applog(LOG_DEBUG, "%s %u: Init: mode=%s read_count=%d Hs=%e",
|
|
|
+ icarus->api->name,
|
|
|
icarus->device_id, timing_mode_str(info->timing_mode), info->read_count, info->Hs);
|
|
|
}
|
|
|
|
|
|
@@ -593,10 +595,12 @@ bool icarus_detect_custom(const char *devpath, struct device_api *api, struct IC
|
|
|
icarus->threads = 1;
|
|
|
add_cgpu(icarus);
|
|
|
|
|
|
- applog(LOG_INFO, "Found Icarus at %s, mark as %d",
|
|
|
- devpath, icarus->device_id);
|
|
|
+ applog(LOG_INFO, "Found %s %u at %s",
|
|
|
+ icarus->api->name, icarus->device_id,
|
|
|
+ devpath);
|
|
|
|
|
|
- applog(LOG_DEBUG, "Icarus: Init: %d baud=%d work_division=%d fpga_count=%d",
|
|
|
+ applog(LOG_DEBUG, "%s %u: Init: baud=%d work_division=%d fpga_count=%d",
|
|
|
+ icarus->api->name,
|
|
|
icarus->device_id, baud, work_division, fpga_count);
|
|
|
|
|
|
icarus->cgpu_data = info;
|
|
|
@@ -636,14 +640,6 @@ static void icarus_detect()
|
|
|
serial_detect(&icarus_api, icarus_detect_one);
|
|
|
}
|
|
|
|
|
|
-struct icarus_state {
|
|
|
- bool firstrun;
|
|
|
- struct timeval tv_workstart;
|
|
|
- struct timeval tv_workfinish;
|
|
|
- struct work last_work;
|
|
|
- bool changework;
|
|
|
-};
|
|
|
-
|
|
|
static bool icarus_prepare(struct thr_info *thr)
|
|
|
{
|
|
|
struct cgpu_info *icarus = thr->cgpu;
|
|
|
@@ -774,6 +770,19 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
|
|
|
tcflush(fd, TCOFLUSH);
|
|
|
#endif
|
|
|
|
|
|
+ memcpy(&nonce, nonce_bin, sizeof(nonce_bin));
|
|
|
+ nonce = be32toh(nonce);
|
|
|
+
|
|
|
+ // Handle dynamic clocking for "subclass" devices
|
|
|
+ // This runs before sending next job, in case it isn't supported
|
|
|
+ if (info->dclk.freqM && likely(!state->firstrun)) {
|
|
|
+ dclk_gotNonces(&info->dclk);
|
|
|
+ if (nonce && !test_nonce(&state->last_work, nonce, false))
|
|
|
+ dclk_errorCount(&info->dclk, 1.0);
|
|
|
+ dclk_preUpdate(&info->dclk);
|
|
|
+ dclk_updateFreq(&info->dclk, info->dclk_change_clock_func, thr);
|
|
|
+ }
|
|
|
+
|
|
|
gettimeofday(&state->tv_workstart, NULL);
|
|
|
|
|
|
ret = icarus_write(fd, ob_bin, sizeof(ob_bin));
|
|
|
@@ -785,7 +794,8 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
|
|
|
if (opt_debug) {
|
|
|
ob_hex = bin2hex(ob_bin, sizeof(ob_bin));
|
|
|
if (ob_hex) {
|
|
|
- applog(LOG_DEBUG, "Icarus %d sent: %s",
|
|
|
+ applog(LOG_DEBUG, "%s %u sent: %s",
|
|
|
+ icarus->api->name,
|
|
|
icarus->device_id, ob_hex);
|
|
|
free(ob_hex);
|
|
|
}
|
|
|
@@ -803,7 +813,6 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
|
|
|
}
|
|
|
|
|
|
// OK, done starting Icarus's next job... now process the last run's result!
|
|
|
- memcpy((char *)&nonce, nonce_bin, sizeof(nonce_bin));
|
|
|
|
|
|
// aborted before becoming idle, get new work
|
|
|
if (nonce == 0 && lret) {
|
|
|
@@ -819,7 +828,8 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
|
|
|
estimate_hashes = 0xffffffff;
|
|
|
|
|
|
if (opt_debug) {
|
|
|
- applog(LOG_DEBUG, "Icarus %d no nonce = 0x%08llx hashes (%ld.%06lds)",
|
|
|
+ applog(LOG_DEBUG, "%s %u no nonce = 0x%08llx hashes (%ld.%06lds)",
|
|
|
+ icarus->api->name,
|
|
|
icarus->device_id, estimate_hashes,
|
|
|
elapsed.tv_sec, elapsed.tv_usec);
|
|
|
}
|
|
|
@@ -827,8 +837,6 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
|
|
|
return estimate_hashes;
|
|
|
}
|
|
|
|
|
|
- nonce = be32toh(nonce);
|
|
|
-
|
|
|
curr_hw_errors = icarus->hw_errors;
|
|
|
submit_nonce(thr, &state->last_work, nonce);
|
|
|
was_hw_error = (curr_hw_errors > icarus->hw_errors);
|
|
|
@@ -839,7 +847,8 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
|
|
|
hash_count *= info->fpga_count;
|
|
|
|
|
|
if (opt_debug) {
|
|
|
- applog(LOG_DEBUG, "Icarus %d nonce = 0x%08x = 0x%08llx hashes (%ld.%06lds)",
|
|
|
+ applog(LOG_DEBUG, "%s %u nonce = 0x%08x = 0x%08llx hashes (%ld.%06lds)",
|
|
|
+ icarus->api->name,
|
|
|
icarus->device_id, nonce, hash_count, elapsed.tv_sec, elapsed.tv_usec);
|
|
|
}
|
|
|
|
|
|
@@ -961,8 +970,9 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
|
|
|
else if (info->timing_mode == MODE_SHORT)
|
|
|
info->do_icarus_timing = false;
|
|
|
|
|
|
-// applog(LOG_WARNING, "Icarus %d Re-estimate: read_count=%d fullnonce=%fs history count=%d Hs=%e W=%e values=%d hash range=0x%08lx min data count=%u", icarus->device_id, read_count, fullnonce, count, Hs, W, values, hash_count_range, info->min_data_count);
|
|
|
- applog(LOG_WARNING, "Icarus %d Re-estimate: Hs=%e W=%e read_count=%d fullnonce=%.3fs",
|
|
|
+// applog(LOG_WARNING, "%s %u Re-estimate: read_count=%d fullnonce=%fs history count=%d Hs=%e W=%e values=%d hash range=0x%08lx min data count=%u", icarus->api->name, icarus->device_id, read_count, fullnonce, count, Hs, W, values, hash_count_range, info->min_data_count);
|
|
|
+ applog(LOG_WARNING, "%s %u Re-estimate: Hs=%e W=%e read_count=%d fullnonce=%.3fs",
|
|
|
+ icarus->api->name,
|
|
|
icarus->device_id, Hs, W, read_count, fullnonce);
|
|
|
}
|
|
|
info->history_count++;
|