Added idle mode Idle is only set by pgadisable, so GPU/CPU is unaffected. For Icarus/Ztex, in scanhash the thread is immediately set disabled then returns.
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
diff --git a/api.c b/api.c
index b644149..3e6501a 100644
--- a/api.c
+++ b/api.c
@@ -167,6 +167,7 @@ static const char *SICK = "Sick";
static const char *NOSTART = "NoStart";
static const char *DISABLED = "Disabled";
static const char *ALIVE = "Alive";
+static const char *IDLE = "Idle";
static const char *REJECTING = "Rejecting";
static const char *UNKNOWN = "Unknown";
#define _DYNAMIC "D"
@@ -879,7 +880,7 @@ static void pgastatus(int pga, bool isjson)
cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
- if (cgpu->deven != DEV_DISABLED)
+ if (cgpu->deven == DEV_ENABLED)
enabled = (char *)YES;
else
enabled = (char *)NO;
@@ -890,6 +891,8 @@ static void pgastatus(int pga, bool isjson)
status = (char *)SICK;
else if (cgpu->status == LIFE_NOSTART)
status = (char *)NOSTART;
+ else if (cgpu->deven == DEV_IDLE)
+ status = (char *)IDLE;
else
status = (char *)ALIVE;
@@ -1092,7 +1095,7 @@ static void pgaenable(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
struct cgpu_info *cgpu = devices[dev];
- if (cgpu->deven != DEV_DISABLED) {
+ if (cgpu->deven == DEV_ENABLED) {
strcpy(io_buffer, message(MSG_PGALRENA, id, NULL, isjson));
return;
}
@@ -1143,12 +1146,12 @@ static void pgadisable(__maybe_unused SOCKETTYPE c, char *param, bool isjson)
struct cgpu_info *cgpu = devices[dev];
- if (cgpu->deven == DEV_DISABLED) {
+ if (cgpu->deven != DEV_ENABLED) {
strcpy(io_buffer, message(MSG_PGALRDIS, id, NULL, isjson));
return;
}
- cgpu->deven = DEV_DISABLED;
+ cgpu->deven = DEV_IDLE;
strcpy(io_buffer, message(MSG_PGADIS, id, NULL, isjson));
}
diff --git a/cgminer.c b/cgminer.c
index a9f8445..ad1259e 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2643,22 +2643,15 @@ void remove_pool(struct pool *pool)
void write_config(FILE *fcfg)
{
- int i = 0;
- int j = 0;
+ int i;
- /* Write pool values in priority order */
+ /* Write pool values */
fputs("{\n\"pools\" : [", fcfg);
- while((j < total_pools) && (i < total_pools)) {
- if(pools[i]->prio == j) {
- fprintf(fcfg, "%s\n\t{\n\t\t\"url\" : \"%s\",", i > 0 ? "," : "", pools[i]->rpc_url);
- fprintf(fcfg, "\n\t\t\"user\" : \"%s\",", pools[i]->rpc_user);
- fprintf(fcfg, "\n\t\t\"pass\" : \"%s\"\n\t}", pools[i]->rpc_pass);
- j++;
- i=0;
- }
- else
- i++;
- }
+ for(i = 0; i < total_pools; i++) {
+ fprintf(fcfg, "%s\n\t{\n\t\t\"url\" : \"%s\",", i > 0 ? "," : "", pools[i]->rpc_url);
+ fprintf(fcfg, "\n\t\t\"user\" : \"%s\",", pools[i]->rpc_user);
+ fprintf(fcfg, "\n\t\t\"pass\" : \"%s\"\n\t}", pools[i]->rpc_pass);
+ }
fputs("\n]\n", fcfg);
if (nDevs) {
@@ -3925,7 +3918,7 @@ void *miner_thread(void *userdata)
tv_lastupdate = tv_end;
}
- if (unlikely(mythr->pause || cgpu->deven != DEV_ENABLED)) {
+ if (unlikely(mythr->pause || cgpu->deven == DEV_DISABLED || cgpu->deven == DEV_RECOVER)) {
applog(LOG_WARNING, "Thread %d being disabled", thr_id);
disabled:
mythr->rolling = mythr->cgpu->rolling = 0;
diff --git a/driver-icarus.c b/driver-icarus.c
index 75ab5e3..630b66b 100644
--- a/driver-icarus.c
+++ b/driver-icarus.c
@@ -566,6 +566,12 @@ static uint64_t icarus_scanhash(struct thr_info *thr, struct work *work,
uint32_t values;
uint64_t hash_count_range;
+ /* Device developer can make use of idle state, until then, disable and return */
+ if (thr->cgpu->deven == DEV_IDLE) {
+ thr->cgpu->deven = DEV_DISABLED;
+ return 1;
+ }
+
elapsed.tv_sec = elapsed.tv_usec = 0;
icarus = thr->cgpu;
diff --git a/driver-ztex.c b/driver-ztex.c
index c881cd7..91f7a7b 100644
--- a/driver-ztex.c
+++ b/driver-ztex.c
@@ -199,6 +199,12 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
bool overflow, found, rv;
struct libztex_hash_data hdata[GOLDEN_BACKLOG];
+ /* Device developer can make use of idle state, until then, disable and return */
+ if (thr->cgpu->deven == DEV_IDLE) {
+ thr->cgpu->deven = DEV_DISABLED;
+ return 1;
+ }
+
ztex = thr->cgpu->device_ztex;
memcpy(sendbuf, work->data + 64, 12);
diff --git a/miner.h b/miner.h
index ec9d725..f5f7122 100644
--- a/miner.h
+++ b/miner.h
@@ -250,6 +250,7 @@ enum dev_enable {
DEV_ENABLED,
DEV_DISABLED,
DEV_RECOVER,
+ DEV_IDLE,
};
enum cl_kernels {