ants1 - move local cgpu variables to info structure
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
diff --git a/driver-bitmain.c b/driver-bitmain.c
index eb51703..8eb013e 100644
--- a/driver-bitmain.c
+++ b/driver-bitmain.c
@@ -982,9 +982,9 @@ static void bitmain_parse_results(struct cgpu_info *bitmain, struct bitmain_info
memmove(buf, buf + spare, *offset);
}
-static void bitmain_running_reset(struct cgpu_info *bitmain, struct bitmain_info *info)
+static void bitmain_running_reset(struct bitmain_info *info)
{
- bitmain->results = 0;
+ info->results = 0;
info->reset = false;
}
@@ -1020,7 +1020,7 @@ static void *bitmain_get_results(void *userdata)
}
if (unlikely(info->reset)) {
- bitmain_running_reset(bitmain, info);
+ bitmain_running_reset(info);
/* Discard anything in the buffer */
offset = 0;
}
@@ -1075,12 +1075,6 @@ static bool bitmain_prepare(struct thr_info *thr)
struct cgpu_info *bitmain = thr->cgpu;
struct bitmain_info *info = bitmain->device_data;
- free(bitmain->works);
- bitmain->works = calloc(BITMAIN_MAX_WORK_NUM * sizeof(struct work *),
- BITMAIN_ARRAY_SIZE);
- if (!bitmain->works)
- quit(1, "Failed to calloc bitmain works in bitmain_prepare");
-
info->thr = thr;
mutex_init(&info->lock);
mutex_init(&info->qlock);
@@ -1370,7 +1364,7 @@ static void do_bitmain_close(struct thr_info *thr)
struct bitmain_info *info = bitmain->device_data;
pthread_join(info->read_thr, NULL);
- bitmain_running_reset(bitmain, info);
+ bitmain_running_reset(info);
info->no_matching_work = 0;
@@ -1417,14 +1411,14 @@ static bool bitmain_fill(struct cgpu_info *bitmain)
goto out_unlock;
}
- if (bitmain->queued >= BITMAIN_MAX_WORK_QUEUE_NUM)
+ if (info->queued >= BITMAIN_MAX_WORK_QUEUE_NUM)
ret = true;
else
ret = false;
while (info->fifo_space > 0) {
neednum = info->fifo_space<8?info->fifo_space:8;
- queuednum = bitmain->queued;
+ queuednum = info->queued;
applog(LOG_DEBUG, "BTM: Work task queued(%d) fifo space(%d) needsend(%d)",
queuednum, info->fifo_space, neednum);
while (queuednum < neednum) {
@@ -1448,7 +1442,7 @@ static bool bitmain_fill(struct cgpu_info *bitmain)
usework->devflag = true;
}
- subid = bitmain->queued++;
+ subid = info->queued++;
usework->subid = subid;
witem = k_unlink_tail(info->work_list);
if (DATAW(witem)->work) {
@@ -1474,10 +1468,10 @@ static bool bitmain_fill(struct cgpu_info *bitmain)
}
sendnum = queuednum < neednum ? queuednum : neednum;
sendlen = bitmain_set_txtask(info, sendbuf, &(info->last_work_block), &sentcount);
- bitmain->queued -= sendnum;
+ info->queued -= sendnum;
info->send_full_space += sendnum;
- if (bitmain->queued < 0)
- bitmain->queued = 0;
+ if (info->queued < 0)
+ info->queued = 0;
applog(LOG_DEBUG, "BTM: Send work %d", sentcount);
if (sendlen > 0) {
@@ -1573,17 +1567,17 @@ static int64_t bitmain_scanhash(struct thr_info *thr)
mutex_lock(&info->qlock);
hash_count = 0xffffffffull * (uint64_t)info->nonces;
- bitmain->results += info->nonces + info->idle;
- if (bitmain->results > chain_num)
- bitmain->results = chain_num;
+ info->results += info->nonces + info->idle;
+ if (info->results > chain_num)
+ info->results = chain_num;
if (!info->reset)
- bitmain->results--;
+ info->results--;
info->nonces = info->idle = 0;
mutex_unlock(&info->qlock);
/* Check for nothing but consecutive bad results or consistently less
* results than we should be getting and reset the FPGA if necessary */
- //if (bitmain->results < -chain_num && !info->reset) {
+ //if (info->results < -chain_num && !info->reset) {
// applog(LOG_ERR, "BTM%d: Result return rate low, resetting!",
// bitmain->device_id);
// info->reset = true;
@@ -1605,9 +1599,9 @@ static void bitmain_flush_work(struct cgpu_info *bitmain)
//int i = 0;
mutex_lock(&info->qlock);
- applog(LOG_ERR, "bitmain_flush_work queued=%d", bitmain->queued);
+ applog(LOG_ERR, "bitmain_flush_work queued=%d", info->queued);
/* Will overwrite any work queued */
- bitmain->queued = 0;
+ info->queued = 0;
//pthread_cond_signal(&info->qcond);
mutex_unlock(&info->qlock);
}
diff --git a/driver-bitmain.h b/driver-bitmain.h
index 537433a..ac2b68c 100644
--- a/driver-bitmain.h
+++ b/driver-bitmain.h
@@ -166,6 +166,9 @@ struct bitmain_rxnonce_data {
} __attribute__((packed, aligned(4)));
struct bitmain_info {
+ int queued;
+ int results;
+
int baud;
int chain_num;
int asic_num;
@@ -249,7 +252,6 @@ typedef struct witem {
#define DATAW(_item) ((WITEM *)(_item->data))
#define BITMAIN_READ_SIZE 12
-#define BITMAIN_ARRAY_SIZE 2048
#define BTM_GETS_ERROR -1
#define BTM_GETS_OK 0
diff --git a/miner.h b/miner.h
index e130d78..664e8e8 100644
--- a/miner.h
+++ b/miner.h
@@ -431,7 +431,7 @@ struct cgpu_info {
struct cg_usb_info usbinfo;
bool blacklisted;
#endif
-#if defined(USE_AVALON) || defined(USE_AVALON2) || defined(USE_ANT_S1)
+#if defined(USE_AVALON) || defined(USE_AVALON2)
struct work **works;
int work_array;
int queued;