Browse Source

Bugfix: bitfury: Fix processor disable/enable for all bitfury-based devices

Luke Dashjr 12 years ago
parent
commit
20b866851b
7 changed files with 78 additions and 28 deletions
  1. 2 25
      driver-bfsb.c
  2. 32 1
      driver-bitfury.c
  3. 2 0
      driver-bitfury.h
  4. 3 0
      driver-hashbuster.c
  5. 16 2
      driver-littlefury.c
  6. 3 0
      driver-metabank.c
  7. 20 0
      driver-nanofury.c

+ 2 - 25
driver-bfsb.c

@@ -158,29 +158,6 @@ bool bfsb_init(struct thr_info *thr)
 	return true;
 	return true;
 }
 }
 
 
-static
-void bfsb_disable(struct thr_info * const thr)
-{
-	struct cgpu_info * const proc = thr->cgpu;
-	struct bitfury_device * const bitfury = proc->device_data;
-	
-	applog(LOG_DEBUG, "%"PRIpreprv": Shutting down chip (disable)", proc->proc_repr);
-	bitfury_send_shutdown(bitfury->spi, bitfury->slot, bitfury->fasync);
-}
-
-static
-void bfsb_enable(struct thr_info * const thr)
-{
-	struct cgpu_info * const proc = thr->cgpu;
-	struct bitfury_device * const bitfury = proc->device_data;
-	
-	applog(LOG_DEBUG, "%"PRIpreprv": Reinitialising chip (enable)", proc->proc_repr);
-	bitfury_send_reinit(bitfury->spi, bitfury->slot, bitfury->fasync, bitfury->osc6_bits);
-	bitfury_init_chip(proc);
-}
-
-extern void bitfury_shutdown(struct thr_info *);
-
 static void bfsb_shutdown(struct thr_info *thr)
 static void bfsb_shutdown(struct thr_info *thr)
 {
 {
 	bitfury_shutdown(thr);
 	bitfury_shutdown(thr);
@@ -210,8 +187,8 @@ struct device_drv bfsb_drv = {
 	.get_api_extra_device_detail = bfsb_api_device_detail,
 	.get_api_extra_device_detail = bfsb_api_device_detail,
 	.get_api_extra_device_status = bitfury_api_device_status,
 	.get_api_extra_device_status = bitfury_api_device_status,
 	.set_device = bitfury_set_device,
 	.set_device = bitfury_set_device,
-	.thread_disable = bfsb_disable,
-	.thread_enable = bfsb_enable,
+	.thread_disable = bitfury_disable,
+	.thread_enable = bitfury_enable,
 	.thread_shutdown = bfsb_shutdown,
 	.thread_shutdown = bfsb_shutdown,
 	
 	
 #ifdef HAVE_CURSES
 #ifdef HAVE_CURSES

+ 32 - 1
driver-bitfury.c

@@ -200,6 +200,30 @@ bool bitfury_init(struct thr_info *thr)
 	return true;
 	return true;
 }
 }
 
 
+void bitfury_disable(struct thr_info * const thr)
+{
+	struct cgpu_info * const proc = thr->cgpu;
+	struct bitfury_device * const bitfury = proc->device_data;
+	
+	applog(LOG_DEBUG, "%"PRIpreprv": Shutting down chip (disable)", proc->proc_repr);
+	bitfury_send_shutdown(bitfury->spi, bitfury->slot, bitfury->fasync);
+}
+
+void bitfury_enable(struct thr_info * const thr)
+{
+	struct cgpu_info * const proc = thr->cgpu;
+	struct bitfury_device * const bitfury = proc->device_data;
+	struct cgpu_info * const dev = proc->device;
+	struct thr_info * const master_thr = dev->thr[0];
+	
+	applog(LOG_DEBUG, "%"PRIpreprv": Reinitialising chip (enable)", proc->proc_repr);
+	bitfury_send_reinit(bitfury->spi, bitfury->slot, bitfury->fasync, bitfury->osc6_bits);
+	bitfury_init_chip(proc);
+	
+	if (!timer_isset(&master_thr->tv_poll))
+		timer_set_now(&master_thr->tv_poll);
+}
+
 void bitfury_shutdown(struct thr_info *thr) {
 void bitfury_shutdown(struct thr_info *thr) {
 	struct cgpu_info *cgpu = thr->cgpu, *proc;
 	struct cgpu_info *cgpu = thr->cgpu, *proc;
 	struct bitfury_device *bitfury;
 	struct bitfury_device *bitfury;
@@ -359,7 +383,7 @@ void bitfury_do_io(struct thr_info * const master_thr)
 		
 		
 		should_be_running = (proc->deven == DEV_ENABLED && !thr->pause);
 		should_be_running = (proc->deven == DEV_ENABLED && !thr->pause);
 		
 		
-		if (should_be_running)
+		if (should_be_running || thr->_job_transition_in_progress)
 		{
 		{
 			if (spi != bitfury->spi)
 			if (spi != bitfury->spi)
 			{
 			{
@@ -380,6 +404,11 @@ void bitfury_do_io(struct thr_info * const master_thr)
 		if (thr->work /* is currently running */ && thr->busy_state != TBS_STARTING_JOB)
 		if (thr->work /* is currently running */ && thr->busy_state != TBS_STARTING_JOB)
 			;//FIXME: shutdown chip
 			;//FIXME: shutdown chip
 	}
 	}
+	if (!spi)
+	{
+		timer_unset(&master_thr->tv_poll);
+		return;
+	}
 	timer_set_now(&tv_now);
 	timer_set_now(&tv_now);
 	spi_txrx(spi);
 	spi_txrx(spi);
 	
 	
@@ -718,6 +747,8 @@ struct device_drv bitfury_drv = {
 	.drv_detect = bitfury_detect,
 	.drv_detect = bitfury_detect,
 	
 	
 	.thread_init = bitfury_init,
 	.thread_init = bitfury_init,
+	.thread_disable = bitfury_disable,
+	.thread_enable = bitfury_enable,
 	.thread_shutdown = bitfury_shutdown,
 	.thread_shutdown = bitfury_shutdown,
 	
 	
 	.minerloop = minerloop_async,
 	.minerloop = minerloop_async,

+ 2 - 0
driver-bitfury.h

@@ -24,6 +24,8 @@ extern void bitfury_tui_wlogprint_choices(struct cgpu_info *);
 extern const char *bitfury_tui_handle_choice(struct cgpu_info *, int input);
 extern const char *bitfury_tui_handle_choice(struct cgpu_info *, int input);
 extern void bitfury_wlogprint_status(struct cgpu_info *);
 extern void bitfury_wlogprint_status(struct cgpu_info *);
 
 
+extern void bitfury_disable(struct thr_info *);
+extern void bitfury_enable(struct thr_info *);
 extern void bitfury_shutdown(struct thr_info *);
 extern void bitfury_shutdown(struct thr_info *);
 
 
 #endif
 #endif

+ 3 - 0
driver-hashbuster.c

@@ -294,6 +294,9 @@ struct device_drv hashbuster_drv = {
 	.drv_detect = hashbuster_detect,
 	.drv_detect = hashbuster_detect,
 	
 	
 	.thread_init = hashbuster_init,
 	.thread_init = hashbuster_init,
+	.thread_disable = bitfury_disable,
+	.thread_enable = bitfury_enable,
+	.thread_shutdown = bitfury_shutdown,
 	
 	
 	.minerloop = minerloop_async,
 	.minerloop = minerloop_async,
 	.job_prepare = bitfury_job_prepare,
 	.job_prepare = bitfury_job_prepare,

+ 16 - 2
driver-littlefury.c

@@ -358,10 +358,9 @@ static
 void littlefury_disable(struct thr_info * const thr)
 void littlefury_disable(struct thr_info * const thr)
 {
 {
 	struct cgpu_info *proc = thr->cgpu;
 	struct cgpu_info *proc = thr->cgpu;
-	struct bitfury_device * const bitfury = proc->device_data;
 	struct cgpu_info * const dev = proc->device;
 	struct cgpu_info * const dev = proc->device;
 	
 	
-	bitfury_send_shutdown(bitfury->spi, 0, bitfury->fasync);
+	bitfury_disable(thr);
 	
 	
 	// If all chips disabled, kill power and close device
 	// If all chips disabled, kill power and close device
 	bool any_running = false;
 	bool any_running = false;
@@ -379,9 +378,21 @@ void littlefury_disable(struct thr_info * const thr)
 			applog(LOG_WARNING, "%s: Unable to power off chip(s)", dev->dev_repr);
 			applog(LOG_WARNING, "%s: Unable to power off chip(s)", dev->dev_repr);
 		serial_close(dev->device_fd);
 		serial_close(dev->device_fd);
 		dev->device_fd = -1;
 		dev->device_fd = -1;
+		timer_unset(&dev->thr[0]->tv_poll);
 	}
 	}
 }
 }
 
 
+static
+void littlefury_enable(struct thr_info * const thr)
+{
+	struct cgpu_info *proc = thr->cgpu;
+	struct cgpu_info * const dev = proc->device;
+	struct thr_info * const master_thr = dev->thr[0];
+	
+	if (!timer_isset(&master_thr->tv_poll))
+		timer_set_now(&master_thr->tv_poll);
+}
+
 static void littlefury_shutdown(struct thr_info *thr)
 static void littlefury_shutdown(struct thr_info *thr)
 {
 {
 	struct cgpu_info * const cgpu = thr->cgpu;
 	struct cgpu_info * const cgpu = thr->cgpu;
@@ -437,6 +448,8 @@ void littlefury_poll(struct thr_info * const master_thr)
 		
 		
 		for (proc = dev; proc; proc = proc->next_proc)
 		for (proc = dev; proc; proc = proc->next_proc)
 		{
 		{
+			if (proc->deven != DEV_ENABLED || proc->thr[0]->pause)
+				continue;
 			struct bitfury_device * const bitfury = proc->device_data;
 			struct bitfury_device * const bitfury = proc->device_data;
 			bitfury_send_reinit(bitfury->spi, bitfury->slot, bitfury->fasync, bitfury->osc6_bits);
 			bitfury_send_reinit(bitfury->spi, bitfury->slot, bitfury->fasync, bitfury->osc6_bits);
 			bitfury_init_chip(proc);
 			bitfury_init_chip(proc);
@@ -459,6 +472,7 @@ struct device_drv littlefury_drv = {
 	
 	
 	.thread_init = littlefury_thread_init,
 	.thread_init = littlefury_thread_init,
 	.thread_disable = littlefury_disable,
 	.thread_disable = littlefury_disable,
+	.thread_enable = littlefury_enable,
 	.reinit_device = littlefury_reinit,
 	.reinit_device = littlefury_reinit,
 	.thread_shutdown = littlefury_shutdown,
 	.thread_shutdown = littlefury_shutdown,
 	
 	

+ 3 - 0
driver-metabank.c

@@ -226,7 +226,10 @@ struct device_drv metabank_drv = {
 	.dname = "metabank",
 	.dname = "metabank",
 	.name = "MBF",
 	.name = "MBF",
 	.drv_detect = metabank_detect,
 	.drv_detect = metabank_detect,
+	
 	.thread_init = metabank_init,
 	.thread_init = metabank_init,
+	.thread_enable = bitfury_enable,
+	.thread_disable = bitfury_disable,
 	
 	
 	.minerloop = minerloop_async,
 	.minerloop = minerloop_async,
 	.job_prepare = bitfury_job_prepare,
 	.job_prepare = bitfury_job_prepare,

+ 20 - 0
driver-nanofury.c

@@ -283,6 +283,24 @@ bool nanofury_init(struct thr_info * const thr)
 	return true;
 	return true;
 }
 }
 
 
+static
+void nanofury_disable(struct thr_info * const thr)
+{
+	struct mcp2210_device * const mcp = thr->cgpu_data;
+	
+	bitfury_disable(thr);
+	nanofury_device_off(mcp);
+}
+
+static
+void nanofury_enable(struct thr_info * const thr)
+{
+	struct mcp2210_device * const mcp = thr->cgpu_data;
+	
+	nanofury_checkport(mcp);
+	bitfury_enable(thr);
+}
+
 static
 static
 void nanofury_shutdown(struct thr_info * const thr)
 void nanofury_shutdown(struct thr_info * const thr)
 {
 {
@@ -297,6 +315,8 @@ struct device_drv nanofury_drv = {
 	.drv_detect = nanofury_detect,
 	.drv_detect = nanofury_detect,
 	
 	
 	.thread_init = nanofury_init,
 	.thread_init = nanofury_init,
+	.thread_disable = nanofury_disable,
+	.thread_enable = nanofury_enable,
 	.thread_shutdown = nanofury_shutdown,
 	.thread_shutdown = nanofury_shutdown,
 	
 	
 	.minerloop = minerloop_async,
 	.minerloop = minerloop_async,