mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-22 20:44:19 +00:00
prevent nonces when not state W
This commit is contained in:
parent
fe8bb058a4
commit
63d8dbd3b6
@ -42,6 +42,7 @@
|
|||||||
#define REPLY_BUFSIZE 16 // reply + 1 byte to mark used
|
#define REPLY_BUFSIZE 16 // reply + 1 byte to mark used
|
||||||
#define MAX_REPLY_COUNT 32 // more unhandled replies than this will result in data loss
|
#define MAX_REPLY_COUNT 32 // more unhandled replies than this will result in data loss
|
||||||
#define REPLY_WAIT_TIME 100 // poll interval for a cmd waiting it's reply
|
#define REPLY_WAIT_TIME 100 // poll interval for a cmd waiting it's reply
|
||||||
|
#define CMD_REPLY_RETRIES 8 // how many retries for cmds
|
||||||
#define MAX_WORK_COUNT 4 // for now, must be binary multiple and match firmware
|
#define MAX_WORK_COUNT 4 // for now, must be binary multiple and match firmware
|
||||||
#define TACH_FACTOR 87890 // fan rpm divisor
|
#define TACH_FACTOR 87890 // fan rpm divisor
|
||||||
|
|
||||||
@ -124,7 +125,7 @@ static char *SendCmdGetReply(struct cgpu_info *klncgpu, char Cmd, int device, in
|
|||||||
{
|
{
|
||||||
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
|
||||||
char outbuf[64];
|
char outbuf[64];
|
||||||
int retries = 10;
|
int retries = CMD_REPLY_RETRIES;
|
||||||
int chkreply = klninfo->nextreply;
|
int chkreply = klninfo->nextreply;
|
||||||
int sent, err;
|
int sent, err;
|
||||||
|
|
||||||
@ -138,7 +139,7 @@ static char *SendCmdGetReply(struct cgpu_info *klncgpu, char Cmd, int device, in
|
|||||||
if (err < 0 || sent != 2+datalen) {
|
if (err < 0 || sent != 2+datalen) {
|
||||||
applog(LOG_ERR, "%s (%s) Cmd:%c Dev:%d, write failed (%d:%d)", klncgpu->drv->dname, klncgpu->device_path, Cmd, device, sent, err);
|
applog(LOG_ERR, "%s (%s) Cmd:%c Dev:%d, write failed (%d:%d)", klncgpu->drv->dname, klncgpu->device_path, Cmd, device, sent, err);
|
||||||
}
|
}
|
||||||
while(retries-- > 0) {
|
while(retries-- > 0 && klninfo->shutdown == false) {
|
||||||
nmsleep(REPLY_WAIT_TIME);
|
nmsleep(REPLY_WAIT_TIME);
|
||||||
while(*(klninfo->replies + chkreply*REPLY_BUFSIZE) != Cmd || *(klninfo->replies + chkreply*REPLY_BUFSIZE + 2) != device) {
|
while(*(klninfo->replies + chkreply*REPLY_BUFSIZE) != Cmd || *(klninfo->replies + chkreply*REPLY_BUFSIZE + 2) != device) {
|
||||||
if(++chkreply == MAX_REPLY_COUNT)
|
if(++chkreply == MAX_REPLY_COUNT)
|
||||||
@ -244,7 +245,6 @@ static bool klondike_detect_one(struct libusb_device *dev, struct usb_find_devic
|
|||||||
klninfo = calloc(1, sizeof(*klninfo));
|
klninfo = calloc(1, sizeof(*klninfo));
|
||||||
if (unlikely(!klninfo))
|
if (unlikely(!klninfo))
|
||||||
quit(1, "Failed to calloc klninfo in klondke_detect_one");
|
quit(1, "Failed to calloc klninfo in klondke_detect_one");
|
||||||
// TODO: fix ... everywhere ...
|
|
||||||
klncgpu->device_data = (FILE *)klninfo;
|
klncgpu->device_data = (FILE *)klninfo;
|
||||||
|
|
||||||
klninfo->replies = calloc(MAX_REPLY_COUNT, REPLY_BUFSIZE);
|
klninfo->replies = calloc(MAX_REPLY_COUNT, REPLY_BUFSIZE);
|
||||||
@ -283,6 +283,7 @@ static bool klondike_detect_one(struct libusb_device *dev, struct usb_find_devic
|
|||||||
}
|
}
|
||||||
usb_uninit(klncgpu);
|
usb_uninit(klncgpu);
|
||||||
}
|
}
|
||||||
|
free(klninfo->replies);
|
||||||
free(klncgpu);
|
free(klncgpu);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -363,7 +364,7 @@ static void klondike_flush_work(struct cgpu_info *klncgpu)
|
|||||||
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
|
||||||
int dev;
|
int dev;
|
||||||
|
|
||||||
applog(LOG_DEBUG, "Klondike flushing work work");
|
applog(LOG_DEBUG, "Klondike flushing work");
|
||||||
for (dev = 0; dev <= klninfo->status->slavecount; dev++) {
|
for (dev = 0; dev <= klninfo->status->slavecount; dev++) {
|
||||||
char *reply = SendCmdGetReply(klncgpu, 'A', dev, 0, NULL);
|
char *reply = SendCmdGetReply(klncgpu, 'A', dev, 0, NULL);
|
||||||
if(reply != NULL) {
|
if(reply != NULL) {
|
||||||
@ -408,12 +409,13 @@ static void klondike_shutdown(struct thr_info *thr)
|
|||||||
{
|
{
|
||||||
struct cgpu_info *klncgpu = thr->cgpu;
|
struct cgpu_info *klncgpu = thr->cgpu;
|
||||||
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
|
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
|
||||||
|
int dev;
|
||||||
//SendCmdGetReply(klncgpu, 'E', 0, 1, "0");
|
|
||||||
|
|
||||||
klondike_flush_work(klncgpu);
|
applog(LOG_DEBUG, "Klondike shutting down work");
|
||||||
|
for (dev = 0; dev <= klninfo->status->slavecount; dev++) {
|
||||||
klninfo->shutdown = true;
|
SendCmdGetReply(klncgpu, 'E', dev, 1, "0");
|
||||||
|
}
|
||||||
|
klncgpu->shutdown = klninfo->shutdown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void klondike_thread_enable(struct thr_info *thr)
|
static void klondike_thread_enable(struct thr_info *thr)
|
||||||
@ -423,7 +425,7 @@ static void klondike_thread_enable(struct thr_info *thr)
|
|||||||
if (klncgpu->usbinfo.nodev)
|
if (klncgpu->usbinfo.nodev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SendCmdGetReply(klncgpu, 'E', 0, 1, "0");
|
//SendCmdGetReply(klncgpu, 'E', 0, 1, "0");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,7 +509,7 @@ static int64_t klondike_scanwork(struct thr_info *thr)
|
|||||||
klninfo->devinfo[dev].lasthashcount = klninfo->status[dev].hashcount;
|
klninfo->devinfo[dev].lasthashcount = klninfo->status[dev].hashcount;
|
||||||
newhashcount += (newhashdev << 32) / klninfo->status[dev].maxcount;
|
newhashcount += (newhashdev << 32) / klninfo->status[dev].maxcount;
|
||||||
|
|
||||||
// check stats for critical conditions
|
// todo: check stats for critical conditions
|
||||||
|
|
||||||
}
|
}
|
||||||
rd_unlock(&(klninfo->stat_lock));
|
rd_unlock(&(klninfo->stat_lock));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user