bab - stop stale work accumulating
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
diff --git a/driver-bab.c b/driver-bab.c
index ebcaa35..68c5d01 100644
--- a/driver-bab.c
+++ b/driver-bab.c
@@ -350,6 +350,7 @@ struct bab_info {
uint32_t chip_spis[BAB_MAXCHIPS+1];
int reply_wait;
+ uint64_t reply_waits;
cgsem_t scan_work;
cgsem_t spi_work;
@@ -959,16 +960,28 @@ static void bab_put(struct bab_info *babinfo, K_ITEM *sitem)
static bool bab_get(__maybe_unused struct cgpu_info *babcgpu, struct bab_info *babinfo, struct timeval *when)
{
K_ITEM *item;
+ bool delayed;
int i;
- cgsem_mswait(&(babinfo->spi_reply), babinfo->reply_wait);
+ item = NULL;
+ delayed = false;
+ while (item == NULL) {
+ cgsem_mswait(&(babinfo->spi_reply), babinfo->reply_wait);
- K_WLOCK(babinfo->spi_sent);
- item = k_unlink_tail(babinfo->spi_sent);
- K_WUNLOCK(babinfo->spi_sent);
+ K_WLOCK(babinfo->spi_sent);
+ item = k_unlink_tail(babinfo->spi_sent);
+ K_WUNLOCK(babinfo->spi_sent);
- if (!item)
- return false;
+ if (!item) {
+ if (!delayed) {
+ applog(LOG_WARNING, "%s%d: Delay getting work reply ...",
+ babcgpu->drv->name,
+ babcgpu->device_id);
+ delayed = true;
+ babinfo->reply_waits++;
+ }
+ }
+ }
for (i = 0; i < babinfo->chips; i++) {
if (babinfo->chip_conf[i] & 0x7f) {
@@ -2723,6 +2736,9 @@ static struct api_data *bab_api_stats(struct cgpu_info *babcgpu)
root = api_add_double(root, "Send Min", &(babinfo->send_min), true);
root = api_add_double(root, "Send Max", &(babinfo->send_max), true);
+ root = api_add_int(root, "Reply Wait", &(babinfo->reply_wait), true);
+ root = api_add_uint64(root, "Reply Waits", &(babinfo->reply_waits), true);
+
i = (int)(babinfo->max_speed);
root = api_add_int(root, bab_options[0], &i, true);
i = (int)(babinfo->def_speed);