Browse Source

Bugfix: bitforce: parallelized: Properly handle parallelized protocol with only 1 chip

Luke Dashjr 12 years ago
parent
commit
e0b07d8f54
1 changed files with 12 additions and 9 deletions
  1. 12 9
      driver-bitforce.c

+ 12 - 9
driver-bitforce.c

@@ -155,7 +155,7 @@ static bool bitforce_detect_one(const char *devpath)
 	char pdevbuf[0x100];
 	char pdevbuf[0x100];
 	size_t pdevbuf_len;
 	size_t pdevbuf_len;
 	char *s;
 	char *s;
-	int procs = 1, parallel = 1;
+	int procs = 1, parallel = -1;
 	struct bitforce_init_data *initdata;
 	struct bitforce_init_data *initdata;
 
 
 	applog(LOG_DEBUG, "BFL: Attempting to open %s", devpath);
 	applog(LOG_DEBUG, "BFL: Attempting to open %s", devpath);
@@ -210,11 +210,12 @@ static bool bitforce_detect_one(const char *devpath)
 	}
 	}
 	initdata->parallels = malloc(sizeof(initdata->parallels[0]) * procs);
 	initdata->parallels = malloc(sizeof(initdata->parallels[0]) * procs);
 	initdata->parallels[0] = parallel;
 	initdata->parallels[0] = parallel;
+	parallel = abs(parallel);
 	for (int proc = 1; proc < procs; ++proc)
 	for (int proc = 1; proc < procs; ++proc)
 	{
 	{
 		applog(LOG_DEBUG, "Slave board %d:", proc);
 		applog(LOG_DEBUG, "Slave board %d:", proc);
-		initdata->parallels[proc] = 1;
-		bitforce_cmd1(fdDev, 0, pdevbuf, sizeof(pdevbuf), "ZCX");
+		initdata->parallels[proc] = -1;
+		bitforce_cmd1(fdDev, proc, pdevbuf, sizeof(pdevbuf), "ZCX");
 		for (int i = 0; (!pdevbuf[0]) && i < 4; ++i)
 		for (int i = 0; (!pdevbuf[0]) && i < 4; ++i)
 			BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 			BFgets(pdevbuf, sizeof(pdevbuf), fdDev);
 		for ( ;
 		for ( ;
@@ -231,14 +232,14 @@ static bool bitforce_detect_one(const char *devpath)
 			if (!strncasecmp(pdevbuf, "CHIP PARALLELIZATION: YES @", 27))
 			if (!strncasecmp(pdevbuf, "CHIP PARALLELIZATION: YES @", 27))
 				initdata->parallels[proc] = atoi(&pdevbuf[27]);
 				initdata->parallels[proc] = atoi(&pdevbuf[27]);
 		}
 		}
-		parallel += initdata->parallels[proc];
+		parallel += abs(initdata->parallels[proc]);
 	}
 	}
 	BFclose(fdDev);
 	BFclose(fdDev);
 	
 	
-	if (unlikely(procs < parallel && !initdata->sc))
+	if (unlikely((procs != 1 || parallel != 1) && !initdata->sc))
 	{
 	{
-		// Only bitforce_queue supports parallelization, so force SC mode and hope for the best
-		applog(LOG_WARNING, "Chip parallelization detected with non-SC device; this is not supported!");
+		// Only bitforce_queue supports parallelization and XLINK, so force SC mode and hope for the best
+		applog(LOG_WARNING, "SC features detected with non-SC device; this is not supported!");
 		initdata->sc = true;
 		initdata->sc = true;
 	}
 	}
 	
 	
@@ -286,6 +287,7 @@ struct bitforce_data {
 	int queued;
 	int queued;
 	int queued_max;
 	int queued_max;
 	int parallel;
 	int parallel;
+	bool parallel_protocol;
 	bool already_have_results;
 	bool already_have_results;
 	bool just_flushed;
 	bool just_flushed;
 	int ready_to_queue;
 	int ready_to_queue;
@@ -1249,7 +1251,8 @@ static bool bitforce_thread_init(struct thr_info *thr)
 			.proto = BFP_RANGE,
 			.proto = BFP_RANGE,
 			.sc = sc,
 			.sc = sc,
 			.sleep_ms_default = BITFORCE_SLEEP_MS,
 			.sleep_ms_default = BITFORCE_SLEEP_MS,
-			.parallel = initdata->parallels[boardno],
+			.parallel = abs(initdata->parallels[boardno]),
+			.parallel_protocol = (initdata->parallels[boardno] != -1),
 		};
 		};
 		thr->cgpu_data = procdata = malloc(sizeof(*procdata));
 		thr->cgpu_data = procdata = malloc(sizeof(*procdata));
 		*procdata = (struct bitforce_proc_data){
 		*procdata = (struct bitforce_proc_data){
@@ -1577,7 +1580,7 @@ bool bitforce_queue_do_results(struct thr_info *thr)
 		
 		
 		end = &buf[89];
 		end = &buf[89];
 		chip_cgpu = bitforce;
 		chip_cgpu = bitforce;
-		if (data->parallel > 1)
+		if (data->parallel_protocol)
 		{
 		{
 			chipno = strtol(&end[1], &end, 16);
 			chipno = strtol(&end[1], &end, 16);
 			if (chipno >= data->parallel)
 			if (chipno >= data->parallel)