minion - add a unique id to each task
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
diff --git a/driver-minion.c b/driver-minion.c
index f6cac56..eca813c 100644
--- a/driver-minion.c
+++ b/driver-minion.c
@@ -416,6 +416,7 @@ typedef struct witem {
#define LIMIT_TITEMS 0
typedef struct titem {
+ uint64_t tid;
uint8_t chip;
bool write;
uint8_t address;
@@ -642,6 +643,8 @@ struct minion_info {
K_STORE *task_list;
K_STORE *treply_list;
+ uint64_t next_tid;
+
// Nonce replies
K_LIST *rfree_list;
K_STORE *rnonce_list;
@@ -1865,6 +1868,7 @@ static void *minion_spi_write(void *userdata)
chip);
K_WLOCK(minioninfo->tfree_list);
task = k_unlink_head(minioninfo->tfree_list);
+ DATAT(task)->tid = ++(minioninfo->next_tid);
DATAT(task)->chip = chip;
DATAT(task)->write = true;
DATAT(task)->address = MINION_SYS_RSTN_CTL;
@@ -2539,6 +2543,7 @@ static void minion_flush_work(struct cgpu_info *minioncgpu)
if (minioninfo->chip[i]) {
// TODO: consider sending it now rather than adding to the task list?
task = k_unlink_head(minioninfo->tfree_list);
+ DATAT(task)->tid = ++(minioninfo->next_tid);
DATAT(task)->chip = i;
DATAT(task)->write = true;
DATAT(task)->address = MINION_SYS_RSTN_CTL;
@@ -2601,6 +2606,7 @@ static void sys_chip_sta(struct cgpu_info *minioncgpu, int chip)
K_WLOCK(minioninfo->tfree_list);
item = k_unlink_head(minioninfo->tfree_list);
+ DATAT(item)->tid = ++(minioninfo->next_tid);
K_WUNLOCK(minioninfo->tfree_list);
DATAT(item)->chip = chip;
@@ -2614,6 +2620,7 @@ static void sys_chip_sta(struct cgpu_info *minioncgpu, int chip)
K_WLOCK(minioninfo->task_list);
k_add_head(minioninfo->task_list, item);
item = k_unlink_head(minioninfo->tfree_list);
+ DATAT(item)->tid = ++(minioninfo->next_tid);
K_WUNLOCK(minioninfo->task_list);
DATAT(item)->chip = chip;
@@ -2633,6 +2640,7 @@ static void sys_chip_sta(struct cgpu_info *minioncgpu, int chip)
// Ena
K_WLOCK(minioninfo->tfree_list);
item = k_unlink_head(minioninfo->tfree_list);
+ DATAT(item)->tid = ++(minioninfo->next_tid);
K_WUNLOCK(minioninfo->tfree_list);
DATAT(item)->chip = chip;
@@ -2647,6 +2655,7 @@ static void sys_chip_sta(struct cgpu_info *minioncgpu, int chip)
k_add_head(minioninfo->task_list, item);
// Act
item = k_unlink_head(minioninfo->tfree_list);
+ DATAT(item)->tid = ++(minioninfo->next_tid);
K_WUNLOCK(minioninfo->task_list);
DATAT(item)->chip = chip;
@@ -2673,6 +2682,7 @@ static void new_work_task(struct cgpu_info *minioncgpu, K_ITEM *witem, int chip,
K_WLOCK(minioninfo->tfree_list);
item = k_unlink_head(minioninfo->tfree_list);
+ DATAT(item)->tid = ++(minioninfo->next_tid);
K_WUNLOCK(minioninfo->tfree_list);
DATAT(item)->chip = chip;
@@ -2853,6 +2863,7 @@ static void minion_do_work(struct cgpu_info *minioncgpu)
// Clear CMD interrupt since we've now sent more
K_WLOCK(minioninfo->tfree_list);
task = k_unlink_head(minioninfo->tfree_list);
+ DATAT(task)->tid = ++(minioninfo->next_tid);
DATAT(task)->chip = 0; // ignored
DATAT(task)->write = true;
DATAT(task)->address = MINION_SYS_INT_CLR;