Browse Source

titan: Do clean flush ("purge") on init

Vitalii Demianets 11 years ago
parent
commit
2b6103dab8
2 changed files with 23 additions and 6 deletions
  1. 11 2
      driver-titan.c
  2. 12 4
      titan-asic.c

+ 11 - 2
driver-titan.c

@@ -201,8 +201,7 @@ static int knc_titan_detect_auto(void)
 	char devpath[256];
 	int found = 0, i;
 
-	for (i = first; i <= last; ++i)
-	{
+	for (i = first; i <= last; ++i) {
 		sprintf(devpath, "%d", i);
 		if (knc_titan_detect_one(devpath))
 			++found;
@@ -216,6 +215,13 @@ static void knc_titan_detect(void)
 	generic_detect(&knc_titan_drv, knc_titan_detect_one, knc_titan_detect_auto, GDF_REQUIRE_DNAME | GDF_DEFAULT_NOAUTO);
 }
 
+static void knc_titan_clean_flush(const char *repr, struct spi_port * const spi, int die)
+{
+	struct titan_report report;
+	bool unused;
+	knc_titan_set_work(repr, spi, &report, die, 0xFFFF, 0, NULL, true, &unused);
+}
+
 static bool knc_titan_init(struct thr_info * const thr)
 {
 	const int max_cores = KNC_TITAN_CORES_PER_ASIC;
@@ -266,6 +272,9 @@ static bool knc_titan_init(struct thr_info * const thr)
 			++total_cores;
 			applog(LOG_DEBUG, "%s Allocated core %d:%d:%d", proc->device->dev_repr, asic, die, (i - core_base));
 
+			if (0 == knccore->coreno)
+				knc_titan_clean_flush(proc->device->dev_repr, knc->spi, knccore->dieno);
+
 			proc = proc->next_proc;
 			if ((!proc) || proc->device == proc)
 				break;

+ 12 - 4
titan-asic.c

@@ -229,10 +229,18 @@ bool knc_titan_set_work(const char *repr, struct spi_port * const spi, struct ti
 	uint32_t *src, *dst;
 	uint32_t errors;
 
-	src = (uint32_t *)work->data;
-	dst = (uint32_t *)(&set_work_cmd_aligned[3 + 5]);
-	for (i = 0; i < (BLOCK_HEADER_BYTES_WITHOUT_NONCE / 4); ++i)
-		dst[i] = htobe32(src[i]);
+	if (NULL != work) {
+		src = (uint32_t *)work->data;
+		dst = (uint32_t *)(&set_work_cmd_aligned[3 + 5]);
+		for (i = 0; i < (BLOCK_HEADER_BYTES_WITHOUT_NONCE / 4); ++i)
+			dst[i] = htobe32(src[i]);
+	} else {
+		/* Empty work is allowed only for the "purge" (slot = 0) operation */
+		if (0 != slot) {
+			applog(LOG_ERR, "%s[%d:%d] knc_titan_set_work: Invalid work", repr, die, core);
+			return false;
+		}
+	}
 
 	rxbuf = spi_transfer(spi, &set_work_cmd_aligned[3], send_size, transfer_size, 2 + KNC_TITAN_NONCES_PER_REPORT * 5, &errors, work_accepted);
 	if (NULL == rxbuf) {