modminer: Temperature sensor improvements Display the temperature of each of the (up to) 4 FPGAs
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
diff --git a/cgminer.c b/cgminer.c
index 7ad478a..19ceea1 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -4318,7 +4318,7 @@ static void *watchdog_thread(void __maybe_unused *userdata)
#ifdef HAVE_OPENCL
for (i = 0; i < total_devices; ++i) {
struct cgpu_info *cgpu = devices[i];
- struct thr_info *thr = cgpu->thread;
+ struct thr_info *thr = cgpu->thr[0];
enum dev_enable *denable;
int gpu;
@@ -5200,6 +5200,8 @@ begin_bench:
k = 0;
for (i = 0; i < total_devices; ++i) {
struct cgpu_info *cgpu = devices[i];
+ cgpu->thr = malloc(sizeof(*cgpu->thr) * (cgpu->threads+1));
+ cgpu->thr[cgpu->threads] = NULL;
for (j = 0; j < cgpu->threads; ++j, ++k) {
thr = &thr_info[k];
@@ -5227,7 +5229,7 @@ begin_bench:
if (unlikely(thr_info_create(thr, NULL, miner_thread, thr)))
quit(1, "thread %d create failed", thr->id);
- cgpu->thread = thr;
+ cgpu->thr[j] = thr;
}
}
diff --git a/driver-modminer.c b/driver-modminer.c
index 617b237..a08a439 100644
--- a/driver-modminer.c
+++ b/driver-modminer.c
@@ -106,17 +106,6 @@ modminer_detect()
serial_detect_auto("modminer", modminer_detect_one, modminer_detect_auto);
}
-static void
-get_modminer_statline_before(char *buf, struct cgpu_info *modminer)
-{
- float gt = modminer->temp;
- if (gt > 0)
- tailsprintf(buf, "%5.1fC ", gt);
- else
- tailsprintf(buf, " ", gt);
- tailsprintf(buf, " | ");
-}
-
#define bailout(...) return _bailout(-1, modminer, __VA_ARGS__);
#define bailout2(...) return _bailout(fd, modminer, __VA_ARGS__);
@@ -255,6 +244,8 @@ struct modminer_fpga_state {
int no_nonce_counter;
int good_share_counter;
time_t last_cutoff_reduced;
+
+ unsigned char temp;
};
static bool
@@ -346,6 +337,39 @@ modminer_fpga_init(struct thr_info *thr)
return true;
}
+static void
+get_modminer_statline_before(char *buf, struct cgpu_info *modminer)
+{
+ char info[18] = " | ";
+ int tc = modminer->threads;
+ bool havetemp = false;
+ int i;
+
+ if (tc > 4)
+ tc = 4;
+
+ for (i = tc - 1; i >= 0; --i) {
+ struct thr_info*thr = modminer->thr[i];
+ struct modminer_fpga_state *state = thr->cgpu_data;
+ unsigned char temp = state->temp;
+
+ info[i*3+2] = '/';
+ if (temp) {
+ havetemp = true;
+ if (temp > 9)
+ info[i*3+0] = 0x30 + (temp / 10);
+ info[i*3+1] = 0x30 + (temp % 10);
+ }
+ }
+ if (havetemp) {
+ info[tc*3-1] = ' ';
+ info[tc*3] = 'C';
+ strcat(buf, info);
+ }
+ else
+ strcat(buf, " | ");
+}
+
static bool
modminer_prepare_next_work(struct modminer_fpga_state*state, struct work*work)
{
@@ -401,7 +425,9 @@ modminer_process_results(struct thr_info*thr)
mutex_lock(&modminer->device_mutex);
if (2 == write(fd, cmd, 2) && read(fd, &temperature, 1) == 1)
{
- modminer->temp = (float)temperature;
+ state->temp = temperature;
+ if (!fpgaid)
+ modminer->temp = (float)temperature;
if (temperature > modminer->cutofftemp - 2) {
if (temperature > modminer->cutofftemp) {
applog(LOG_WARNING, "%s %u.%u: Hit thermal cutoff limit, disabling device!", modminer->api->name, modminer->device_id, fpgaid);
diff --git a/miner.h b/miner.h
index b6479c1..31f68db 100644
--- a/miner.h
+++ b/miner.h
@@ -327,7 +327,7 @@ struct cgpu_info {
struct timeval last_message_tv;
int threads;
- struct thr_info *thread;
+ struct thr_info **thr;
unsigned int max_hashes;