Browse Source

Add LIFE_INIT2 status (safe to call functions, but not mining yet) for devices that want to report initialization status in their statline

Conflicts:
	driver-bitforce.c
	driver-ztex.c

Conflicts:
	driver-avalon.c
	driver-bitforce.c
	driver-modminer.c
	driver-x6500.c
Luke Dashjr 12 years ago
parent
commit
7d6644c5fd
8 changed files with 14 additions and 4 deletions
  1. 1 0
      api.c
  2. 2 0
      driver-bitforce.c
  3. 2 0
      driver-icarus.c
  4. 3 1
      driver-modminer.c
  5. 3 2
      driver-x6500.c
  6. 1 0
      driver-ztex.c
  7. 1 1
      miner.c
  8. 1 0
      miner.h

+ 1 - 0
api.c

@@ -1452,6 +1452,7 @@ static const char *status2str(enum alive status)
 		case LIFE_NOSTART:
 			return NOSTART;
 		case LIFE_INIT:
+		case LIFE_INIT2:
 			return INIT;
 		case LIFE_WAIT:
 			return WAIT;

+ 2 - 0
driver-bitforce.c

@@ -154,6 +154,8 @@ static bool bitforce_thread_prepare(struct thr_info *thr)
 	gettimeofday(&now, NULL);
 	get_datestamp(bitforce->init, &now);
 
+	bitforce->status = LIFE_INIT2;
+	
 	return true;
 }
 

+ 2 - 0
driver-icarus.c

@@ -699,6 +699,8 @@ static bool icarus_prepare(struct thr_info *thr)
 	}
 #endif
 
+	icarus->status = LIFE_INIT2;
+	
 	return true;
 }
 

+ 3 - 1
driver-modminer.c

@@ -297,6 +297,8 @@ modminer_fpga_prepare(struct thr_info *thr)
 	dclk_prepare(&state->dclk);
 	state->next_work_cmd[0] = MODMINER_SEND_WORK;
 	state->next_work_cmd[1] = thr->device_thread;  // FPGA id
+	
+	modminer->status = LIFE_INIT2;
 
 	return true;
 }
@@ -410,7 +412,7 @@ modminer_fpga_init(struct thr_info *thr)
 		applog(LOG_ERR, "%s %u.%u: FPGA not programmed", modminer->api->name, modminer->device_id, fpgaid);
 		if (!modminer_fpga_upload_bitstream(modminer))
 			return false;
-	} else if (opt_force_dev_init && modminer->status == LIFE_INIT) {
+	} else if (opt_force_dev_init && modminer->status == LIFE_INIT2) {
 		applog(LOG_DEBUG, "%s %u.%u: FPGA is already programmed, but --force-dev-init is set",
 		       modminer->api->name, modminer->device_id, fpgaid);
 		if (!modminer_fpga_upload_bitstream(modminer))

+ 3 - 2
driver-x6500.c

@@ -216,7 +216,7 @@ x6500_fpga_upload_bitstream(struct cgpu_info *x6500, struct jtag_port *jp1)
 
 	applog(LOG_WARNING, "%s %u: Programming %s...",
 	       x6500->api->name, x6500->device_id, x6500->device_path);
-	x6500->status = LIFE_INIT;
+	x6500->status = LIFE_INIT2;
 	
 	// "Magic" jtag_port configured to access both FPGAs concurrently
 	struct jtag_port jpt = {
@@ -349,6 +349,7 @@ static bool x6500_fpga_init(struct thr_info *thr)
 	jp->a = x6500->cgpu_data;
 	x6500_jtag_set(jp, pinoffset);
 	thr->cgpu_data = fpga;
+	x6500->status = LIFE_INIT2;
 	
 	mutex_lock(&x6500->device_mutex);
 	if (!jtag_reset(jp)) {
@@ -382,7 +383,7 @@ static bool x6500_fpga_init(struct thr_info *thr)
 		       x6500->api->name, x6500->device_id, fpgaid);
 		if (!x6500_fpga_upload_bitstream(x6500, jp))
 			return false;
-	} else if (opt_force_dev_init && x6500->status == LIFE_INIT) {
+	} else if (opt_force_dev_init && x6500->status == LIFE_INIT2) {
 		applog(LOG_DEBUG, "%s %u.%u: FPGA is already programmed, but --force-dev-init is set",
 		       x6500->api->name, x6500->device_id, fpgaid);
 		if (!x6500_fpga_upload_bitstream(x6500, jp))

+ 1 - 0
driver-ztex.c

@@ -371,6 +371,7 @@ static bool ztex_prepare(struct thr_info *thr)
 	libztex_setFreq(ztex, ztex->dclk.freqMDefault);
 	ztex_releaseFpga(ztex);
 	applog(LOG_DEBUG, "%s: prepare", ztex->repr);
+	cgpu->status = LIFE_INIT2;
 	return true;
 }
 

+ 1 - 1
miner.c

@@ -7304,7 +7304,7 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 				continue;
 #endif
 			if (cgpu->status != LIFE_WELL && (now.tv_sec - thr->last.tv_sec < WATCHDOG_SICK_TIME)) {
-				if (cgpu->status != LIFE_INIT)
+				if (likely(cgpu->status != LIFE_INIT && cgpu->status != LIFE_INIT2))
 				applog(LOG_ERR, "%s: Recovered, declaring WELL!", dev_str);
 				cgpu->status = LIFE_WELL;
 				cgpu->device_last_well = time(NULL);

+ 1 - 0
miner.h

@@ -216,6 +216,7 @@ enum alive {
 	LIFE_NOSTART,
 	LIFE_INIT,
 	LIFE_WAIT,
+	LIFE_INIT2,  // Still initializing, but safe to call functions
 };