Browse Source

Bugfix: Cleanup handling of complete device/driver failure

Conflicts:
	deviceapi.c
	miner.c
Luke Dashjr 12 years ago
parent
commit
1f9d08d1c9
4 changed files with 29 additions and 6 deletions
  1. 11 2
      deviceapi.c
  2. 2 0
      driver-modminer.c
  3. 15 4
      miner.c
  4. 1 0
      miner.h

+ 11 - 2
deviceapi.c

@@ -570,11 +570,20 @@ void *miner_thread(void *userdata)
 	else
 		minerloop_scanhash(mythr);
 
-out:
+out: ;
+	struct cgpu_info *proc = cgpu;
+	do
+	{
+		proc->status = LIFE_DEAD2;
+	}
+	while ( (proc = proc->next_proc) && !proc->threads);
+	mythr->getwork = 0;
+	PTH(mythr) = false;
+	nmsleep(1000);
+	
 	if (api->thread_shutdown)
 		api->thread_shutdown(mythr);
 
-	thread_reportin(mythr);
 	applog(LOG_ERR, "Thread %d failure, exiting", thr_id);
 	notifier_destroy(mythr->notifier);
 

+ 2 - 0
driver-modminer.c

@@ -800,6 +800,8 @@ modminer_scanhash(struct thr_info*thr, struct work*work, int64_t __maybe_unused
 static void
 modminer_fpga_shutdown(struct thr_info *thr)
 {
+	for (struct cgpu_info *proc = thr->cgpu->device; proc; proc = proc->next_proc)
+		proc->status = LIFE_DEAD2;
 	free(thr->cgpu_data);
 }
 

+ 15 - 4
miner.c

@@ -2118,6 +2118,17 @@ double stats_elapsed(struct cgminer_stats *stats)
 	return elapsed;
 }
 
+bool drv_ready(struct cgpu_info *cgpu)
+{
+	switch (cgpu->status) {
+		case LIFE_INIT:
+		case LIFE_DEAD2:
+			return false;
+		default:
+			return true;
+	}
+}
+
 /* Convert a uint64_t value into a truncated string for displaying with its
  * associated suitable for Mega, Giga etc. Buf array needs to be long enough */
 static void suffix_string(uint64_t val, char *buf, int sigdigits)
@@ -2327,7 +2338,7 @@ static void get_statline2(char *buf, struct cgpu_info *cgpu, bool for_curses)
 		return;
 	}
 	
-	if (api->get_dev_statline_before || api->get_statline_before)
+	if ((api->get_dev_statline_before || api->get_statline_before) && likely(drv_ready(cgpu)))
 	{
 		if (api->get_dev_statline_before && api->get_statline_before)
 			statline_func = opt_show_procs ? api->get_statline_before : api->get_dev_statline_before;
@@ -2357,7 +2368,7 @@ static void get_statline2(char *buf, struct cgpu_info *cgpu, bool for_curses)
 					if (proc->deven == DEV_RECOVER)
 						cHrStatsI = 3;
 				case 3:
-					if (proc->status == LIFE_SICK || proc->status == LIFE_DEAD)
+					if (proc->status == LIFE_SICK || proc->status == LIFE_DEAD || proc->status == LIFE_DEAD2)
 					{
 						cHrStatsI = 1;
 						all_off = false;
@@ -2368,7 +2379,7 @@ static void get_statline2(char *buf, struct cgpu_info *cgpu, bool for_curses)
 				case 1:
 					break;
 			}
-			if (likely(proc->status != LIFE_DEAD))
+			if (likely(proc->status != LIFE_DEAD && proc->status != LIFE_DEAD2))
 				all_dead = false;
 			if (opt_show_procs)
 				break;
@@ -7471,7 +7482,7 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 			char *dev_str = cgpu->proc_repr;
 			int gpu;
 
-			if (cgpu->api->get_stats && likely(cgpu->status != LIFE_INIT))
+			if (cgpu->api->get_stats && likely(drv_ready(cgpu)))
 			  cgpu->api->get_stats(cgpu);
 
 			gpu = cgpu->device_id;

+ 1 - 0
miner.h

@@ -215,6 +215,7 @@ enum alive {
 	LIFE_INIT,
 	LIFE_WAIT,
 	LIFE_INIT2,  // Still initializing, but safe to call functions
+	LIFE_DEAD2,  // Totally dead, NOT safe to call functions
 };