Merge branch 'master' into stratum
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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
diff --git a/API-README b/API-README
index a1c54c5..7e5fac8 100644
--- a/API-README
+++ b/API-README
@@ -383,7 +383,7 @@ miner.php - an example web page to access the API
Feature Changelog for external applications using the API:
-API V1.19
+API V1.19 (cgminer v2.7.6)
Added API commands:
'debug'
diff --git a/NEWS b/NEWS
index 115bf83..24df568 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,23 @@
+Version 2.7.7 - October 7, 2012
+
+- Fix unused warnings on ming build.
+- Fix sign warning in ocl.c
+- fds need to be zeroed before set in modminer.
+- Put scrypt warning on separate line to avoid 0 being shown on windows as
+bufsize.
+- Display correct pool number when block is found.
+- Prevent corrupt values returned from the opencl code from trying to read
+beyond the end of the buffer by masking the value to a max of 15.
+- Icarus USB write failure is also a comms error
+- api.c DEBUG message has no paramter
+- Icarus catch more USB errors and close/reopen the port
+- API-README update cgminer verison number
+- hashmeter fix stats kh/s on 32bit windows
+
+
Version 2.7.6 - September 24, 2012
+- Reorder libztex header include order to fix missing struct definition.
- Display share difficulty on log with a shortened hash display on submission.
- API stats add some pool getwork difficulty stats
- Ignore any pings pushed to the worker threads if the thread is still paused to
diff --git a/api.c b/api.c
index f81eced..8c358af 100644
--- a/api.c
+++ b/api.c
@@ -523,7 +523,7 @@ struct CODES {
{ SEVERITY_ERR, MSG_INVBOOL, PARAM_NONE, "Invalid parameter should be true or false" },
{ SEVERITY_SUCC, MSG_FOO, PARAM_BOOL, "Failover-Only set to %s" },
{ SEVERITY_SUCC, MSG_MINECOIN,PARAM_NONE, "CGMiner coin" },
- { SEVERITY_SUCC, MSG_DEBUGSET,PARAM_STR, "Debug settings" },
+ { SEVERITY_SUCC, MSG_DEBUGSET,PARAM_NONE, "Debug settings" },
#ifdef HAVE_AN_FPGA
{ SEVERITY_SUCC, MSG_PGAIDENT,PARAM_PGA, "Identify command sent to PGA%d" },
{ SEVERITY_WARN, MSG_PGANOID, PARAM_PGA, "PGA%d does not support identify" },
diff --git a/cgminer.c b/cgminer.c
index a486bac..c08cfe1 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2719,7 +2719,7 @@ static void check_solve(struct work *work)
work->pool->solved++;
found_blocks++;
work->mandatory = true;
- applog(LOG_NOTICE, "Found block for pool %d!", work->pool);
+ applog(LOG_NOTICE, "Found block for pool %d!", work->pool->pool_no);
}
#endif
}
@@ -3946,7 +3946,7 @@ static inline void thread_reportout(struct thr_info *thr)
}
static void hashmeter(int thr_id, struct timeval *diff,
- unsigned long long hashes_done)
+ uint64_t hashes_done)
{
struct timeval temp_tv_end, total_diff;
double secs;
@@ -3974,7 +3974,7 @@ static void hashmeter(int thr_id, struct timeval *diff,
double thread_rolling = 0.0;
int i;
- applog(LOG_DEBUG, "[thread %d: %llu hashes, %.1f khash/sec]",
+ applog(LOG_DEBUG, "[thread %d: %"PRIu64" hashes, %.1f khash/sec]",
thr_id, hashes_done, hashes_done / 1000 / secs);
/* Rolling average for each thread and each device */
diff --git a/configure.ac b/configure.ac
index 55dc2c7..aa0ea0b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
m4_define([v_maj], [2])
m4_define([v_min], [7])
-m4_define([v_mic], [6])
+m4_define([v_mic], [7])
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
m4_define([v_ver], [v_maj.v_min.v_mic])
m4_define([lt_rev], m4_eval(v_maj + v_min))
diff --git a/driver-bitforce.c b/driver-bitforce.c
index ded9e92..606ec2e 100644
--- a/driver-bitforce.c
+++ b/driver-bitforce.c
@@ -410,6 +410,11 @@ static bool bitforce_get_temp(struct cgpu_info *bitforce)
if ((!strncasecmp(pdevbuf, "TEMP", 4)) && (s = strchr(pdevbuf + 4, ':'))) {
float temp = strtof(s + 1, NULL);
+ /* Cope with older software that breaks and reads nonsense
+ * values */
+ if (temp > 100)
+ temp = strtod(s + 1, NULL);
+
if (temp > 0) {
bitforce->temp = temp;
if (unlikely(bitforce->cutofftemp > 0 && temp > bitforce->cutofftemp)) {
diff --git a/driver-icarus.c b/driver-icarus.c
index 2cc2a45..c013b5d 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -225,6 +225,11 @@ 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)
+#define ICA_GETS_ERROR -1
+#define ICA_GETS_OK 0
+#define ICA_GETS_RESTART 1
+#define ICA_GETS_TIMEOUT 2
+
static int icarus_gets(unsigned char *buf, int fd, struct timeval *tv_finish, struct thr_info *thr, int read_count)
{
ssize_t ret = 0;
@@ -235,12 +240,14 @@ static int icarus_gets(unsigned char *buf, int fd, struct timeval *tv_finish, st
// Read reply 1 byte at a time to get earliest tv_finish
while (true) {
ret = read(fd, buf, 1);
+ if (ret < 0)
+ return ICA_GETS_ERROR;
if (first)
gettimeofday(tv_finish, NULL);
if (ret >= read_amount)
- return 0;
+ return ICA_GETS_OK;
if (ret > 0) {
buf += ret;
@@ -256,16 +263,16 @@ static int icarus_gets(unsigned char *buf, int fd, struct timeval *tv_finish, st
"Icarus Read: No data in %.2f seconds",
(float)rc/(float)TIME_FACTOR);
}
- return 1;
+ return ICA_GETS_TIMEOUT;
}
- if (thr->work_restart) {
+ if (thr && thr->work_restart) {
if (opt_debug) {
applog(LOG_DEBUG,
"Icarus Read: Work restart at %.2f seconds",
(float)(rc)/(float)TIME_FACTOR);
}
- return 1;
+ return ICA_GETS_RESTART;
}
}
}
@@ -283,6 +290,13 @@ static int icarus_write(int fd, const void *buf, size_t bufLen)
#define icarus_close(fd) close(fd)
+static void do_icarus_close(struct thr_info *thr)
+{
+ struct cgpu_info *icarus = thr->cgpu;
+ icarus_close(icarus->device_fd);
+ icarus->device_fd = -1;
+}
+
static const char *timing_mode_str(enum timing_mode timing_mode)
{
switch(timing_mode) {
@@ -535,10 +549,7 @@ static bool icarus_detect_one(const char *devpath)
gettimeofday(&tv_start, NULL);
memset(nonce_bin, 0, sizeof(nonce_bin));
- struct thr_info dummy = {
- .work_restart = false,
- };
- icarus_gets(nonce_bin, fd, &tv_finish, &dummy, 1);
+ icarus_gets(nonce_bin, fd, &tv_finish, NULL, 1);
icarus_close(fd);
@@ -565,6 +576,7 @@ static bool icarus_detect_one(const char *devpath)
icarus = calloc(1, sizeof(struct cgpu_info));
icarus->api = &icarus_api;
icarus->device_path = strdup(devpath);
+ icarus->device_fd = -1;
icarus->threads = 1;
add_cgpu(icarus);
icarus_info = realloc(icarus_info, sizeof(struct ICARUS_INFO *) * (total_devices + 1));
@@ -609,6 +621,8 @@ static bool icarus_prepare(struct thr_info *thr)
struct timeval now;
+ icarus->device_fd = -1;
+
int fd = icarus_open(icarus->device_path, icarus_info[icarus->device_id]->baud);
if (unlikely(-1 == fd)) {
applog(LOG_ERR, "Failed to open Icarus on %s",
@@ -655,6 +669,17 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
elapsed.tv_sec = elapsed.tv_usec = 0;
icarus = thr->cgpu;
+ if (icarus->device_fd == -1)
+ if (!icarus_prepare(thr)) {
+ applog(LOG_ERR, "ICA%i: Comms error", icarus->device_id);
+ icarus->device_last_not_well = time(NULL);
+ icarus->device_not_well_reason = REASON_DEV_COMMS_ERROR;
+ icarus->dev_comms_error_count++;
+
+ // fail the device if the reopen attempt fails
+ return -1;
+ }
+
fd = icarus->device_fd;
memset(ob_bin, 0, sizeof(ob_bin));
@@ -666,8 +691,14 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
tcflush(fd, TCOFLUSH);
#endif
ret = icarus_write(fd, ob_bin, sizeof(ob_bin));
- if (ret)
- return -1; /* This should never happen */
+ if (ret) {
+ do_icarus_close(thr);
+ applog(LOG_ERR, "ICA%i: Comms error", icarus->device_id);
+ icarus->device_last_not_well = time(NULL);
+ icarus->device_not_well_reason = REASON_DEV_COMMS_ERROR;
+ icarus->dev_comms_error_count++;
+ return 0; /* This should never happen */
+ }
gettimeofday(&tv_start, NULL);
@@ -684,12 +715,19 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
memset(nonce_bin, 0, sizeof(nonce_bin));
info = icarus_info[icarus->device_id];
ret = icarus_gets(nonce_bin, fd, &tv_finish, thr, info->read_count);
+ if (ret == ICA_GETS_ERROR) {
+ do_icarus_close(thr);
+ applog(LOG_ERR, "ICA%i: Comms error", icarus->device_id);
+ icarus->device_last_not_well = time(NULL);
+ icarus->device_not_well_reason = REASON_DEV_COMMS_ERROR;
+ icarus->dev_comms_error_count++;
+ return 0;
+ }
work->blk.nonce = 0xffffffff;
- memcpy((char *)&nonce, nonce_bin, sizeof(nonce_bin));
// aborted before becoming idle, get new work
- if (nonce == 0 && ret) {
+ if (ret == ICA_GETS_TIMEOUT || ret == ICA_GETS_RESTART) {
timersub(&tv_finish, &tv_start, &elapsed);
// ONLY up to just when it aborted
@@ -711,6 +749,8 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
return estimate_hashes;
}
+ memcpy((char *)&nonce, nonce_bin, sizeof(nonce_bin));
+
#if !defined (__BIG_ENDIAN__) && !defined(MIPSEB)
nonce = swab32(nonce);
#endif
@@ -719,6 +759,10 @@ static int64_t icarus_scanhash(struct thr_info *thr, struct work *work,
submit_nonce(thr, work, nonce);
was_hw_error = (curr_hw_errors > icarus->hw_errors);
+ // Force a USB close/reopen on any hw error
+ if (was_hw_error)
+ do_icarus_close(thr);
+
hash_count = (nonce & info->nonce_mask);
hash_count++;
hash_count *= info->fpga_count;
@@ -864,8 +908,7 @@ static struct api_data *icarus_api_stats(struct cgpu_info *cgpu)
static void icarus_shutdown(struct thr_info *thr)
{
- struct cgpu_info *icarus = thr->cgpu;
- icarus_close(icarus->device_fd);
+ do_icarus_close(thr);
}
struct device_api icarus_api = {
diff --git a/driver-modminer.c b/driver-modminer.c
index d15f2d8..cc8d162 100644
--- a/driver-modminer.c
+++ b/driver-modminer.c
@@ -128,6 +128,7 @@ modminer_detect()
} while(0)
#define status_read(eng) do { \
+FD_ZERO(&fds); \
FD_SET(fd, &fds); \
select(fd+1, &fds, NULL, NULL, NULL); \
if (1 != read(fd, buf, 1)) \
@@ -139,7 +140,7 @@ select(fd+1, &fds, NULL, NULL, NULL); \
static bool
modminer_fpga_upload_bitstream(struct cgpu_info*modminer)
{
-fd_set fds;
+ fd_set fds;
char buf[0x100];
unsigned char *ubuf = (unsigned char*)buf;
unsigned long len;
diff --git a/findnonce.c b/findnonce.c
index 788835d..344c7d1 100644
--- a/findnonce.c
+++ b/findnonce.c
@@ -252,6 +252,9 @@ static void *postcalc_hash(void *userdata)
pthread_detach(pthread_self());
+ /* To prevent corrupt values in FOUND from trying to read beyond the
+ * end of the res[] array */
+ pcd->res[FOUND] &= FOUND;
for (entry = 0; entry < pcd->res[FOUND]; entry++) {
uint32_t nonce = pcd->res[entry];
diff --git a/fpgautils.c b/fpgautils.c
index de9d93e..4c5829a 100644
--- a/fpgautils.c
+++ b/fpgautils.c
@@ -74,7 +74,7 @@ int serial_autodetect_udev(__maybe_unused detectone_func_t detectone, __maybe_un
}
#endif
-int serial_autodetect_devserial(detectone_func_t detectone, const char*prodname)
+int serial_autodetect_devserial(__maybe_unused detectone_func_t detectone, __maybe_unused const char*prodname)
{
#ifndef WIN32
DIR *D;
diff --git a/miner.h b/miner.h
index 0140db2..19e1e53 100644
--- a/miner.h
+++ b/miner.h
@@ -392,8 +392,8 @@ struct cgpu_info {
#ifdef USE_SCRYPT
int opt_lg, lookup_gap;
- int opt_tc, thread_concurrency;
- int shaders;
+ size_t opt_tc, thread_concurrency;
+ size_t shaders;
#endif
struct timeval tv_gpustart;
struct timeval tv_gpumid;
diff --git a/ocl.c b/ocl.c
index 450a2d6..5b56e00 100644
--- a/ocl.c
+++ b/ocl.c
@@ -541,7 +541,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
strcat(binaryfilename, "g");
if (opt_scrypt) {
#ifdef USE_SCRYPT
- sprintf(numbuf, "lg%dtc%d", cgpu->lookup_gap, cgpu->thread_concurrency);
+ sprintf(numbuf, "lg%utc%u", cgpu->lookup_gap, (unsigned int)cgpu->thread_concurrency);
strcat(binaryfilename, numbuf);
#endif
} else {
@@ -614,7 +614,7 @@ build:
#ifdef USE_SCRYPT
if (opt_scrypt)
sprintf(CompilerOptions, "-D LOOKUP_GAP=%d -D CONCURRENT_THREADS=%d -D WORKSIZE=%d",
- cgpu->lookup_gap, cgpu->thread_concurrency, (int)clState->wsize);
+ cgpu->lookup_gap, (unsigned int)cgpu->thread_concurrency, (int)clState->wsize);
else
#endif
{
@@ -810,8 +810,8 @@ built:
/* Use the max alloc value which has been rounded to a power of
* 2 greater >= required amount earlier */
if (bufsize > cgpu->max_alloc) {
- applog(LOG_WARNING, "Maximum buffer memory device %d supports says %u, your scrypt settings come to %u",
- gpu, cgpu->max_alloc, bufsize);
+ applog(LOG_WARNING, "Maximum buffer memory device %d supports says %u", gpu, cgpu->max_alloc);
+ applog(LOG_WARNING, "Your scrypt settings come to %u", bufsize);
} else
bufsize = cgpu->max_alloc;
applog(LOG_DEBUG, "Creating scrypt buffer sized %d", bufsize);