Browse Source

bitfury: Remove old (unused) driver code

Luke Dashjr 12 years ago
parent
commit
e7ddc09263
5 changed files with 2 additions and 498 deletions
  1. 0 219
      driver-bitfury.c
  2. 0 2
      driver-bitfury.h
  3. 0 5
      driver-metabank.c
  4. 0 244
      libbitfury.c
  5. 2 28
      libbitfury.h

+ 0 - 219
driver-bitfury.c

@@ -37,14 +37,8 @@
 #include "util.h"
 #include "spidevc.h"
 
-#define GOLDEN_BACKLOG 5
-#define LINE_LEN 2048
-
 struct device_drv bitfury_drv;
 
-int calc_stat(time_t * stat_ts, time_t stat, struct timeval now);
-double shares_to_ghashes(int shares, int seconds);
-
 static
 int bitfury_autodetect()
 {
@@ -206,219 +200,6 @@ bool bitfury_init(struct thr_info *thr)
 	return true;
 }
 
-static
-bool bitfury_queue_full(struct cgpu_info *cgpu)
-{
-	struct cgpu_info *proc;
-	struct bitfury_device *bitfury;
-	
-	for (proc = cgpu; proc; proc = proc->next_proc)
-	{
-		bitfury = proc->device_data;
-		
-		if (bitfury->work)
-			continue;
-		
-		bitfury->work = get_queued(cgpu);
-		if (!bitfury->work)
-			return false;
-		
-		work_to_payload(&bitfury->payload, bitfury->work);
-	}
-	
-	return true;
-}
-
-int64_t bitfury_scanHash(struct thr_info *thr)
-{
-	struct cgpu_info * const cgpu = thr->cgpu;
-	struct bitfury_device * const sds = cgpu->device_data;
-	struct cgpu_info *proc;
-	struct thr_info *pthr;
-	struct bitfury_device *bitfury;
-	struct timeval now;
-	char line[LINE_LEN];
-	int short_stat = 10;
-	int long_stat = 1800;
-	int i;
-
-	if (!bitfury_queue_full(cgpu))
-		return 0;
-	
-	for (proc = cgpu; proc; proc = proc->next_proc)
-	{
-		const int chip = proc->proc_id;
-		pthr = proc->thr[0];
-		bitfury = proc->device_data;
-		
-		bitfury->job_switched = 0;
-		payload_to_atrvec(bitfury->atrvec, &bitfury->payload);
-		libbitfury_sendHashData1(chip, bitfury, pthr);
-	}
-
-	cgsleep_ms(5);
-
-	cgtime(&now);
-	for (proc = cgpu; proc; proc = proc->next_proc)
-	{
-		pthr = proc->thr[0];
-		bitfury = proc->device_data;
-		
-		if (bitfury->job_switched) {
-			int i,j;
-			unsigned int * const res = bitfury->results;
-			struct work * const work = bitfury->work;
-			struct work * const owork = bitfury->owork;
-			struct work * const o2work = bitfury->o2work;
-			i = bitfury->results_n;
-			for (j = i - 1; j >= 0; j--) {
-				if (owork) {
-					submit_nonce(pthr, owork, bswap_32(res[j]));
-					bitfury->stat_ts[bitfury->stat_counter++] =
-						now.tv_sec;
-					if (bitfury->stat_counter == BITFURY_STAT_N) {
-						bitfury->stat_counter = 0;
-					}
-				}
-				if (o2work) {
-					// TEST
-					//submit_nonce(pthr, owork, bswap_32(res[j]));
-				}
-			}
-			bitfury->results_n = 0;
-			bitfury->job_switched = 0;
-			if (bitfury->old_nonce && o2work) {
-					submit_nonce(pthr, o2work, bswap_32(bitfury->old_nonce));
-					i++;
-			}
-			if (bitfury->future_nonce) {
-					submit_nonce(pthr, work, bswap_32(bitfury->future_nonce));
-					i++;
-			}
-
-			if (o2work)
-				work_completed(cgpu, o2work);
-
-			bitfury->o2work = bitfury->owork;
-			bitfury->owork = bitfury->work;
-			bitfury->work = NULL;
-			hashes_done2(pthr, 0xbd000000, NULL);
-		}
-	}
-
-	if (now.tv_sec - sds->short_out_t > short_stat) {
-		int shares_first = 0, shares_last = 0, shares_total = 0;
-		char stat_lines[32][LINE_LEN] = {{0}};
-		int len, k;
-		double gh[32][8] = {{0}};
-		double ghsum = 0, gh1h = 0, gh2h = 0;
-		unsigned strange_counter = 0;
-
-		for (proc = cgpu; proc; proc = proc->next_proc)
-		{
-			const int chip = proc->proc_id;
-			bitfury = proc->device_data;
-			
-			int shares_found = calc_stat(bitfury->stat_ts, short_stat, now);
-			double ghash;
-			len = strlen(stat_lines[bitfury->slot]);
-			ghash = shares_to_ghashes(shares_found, short_stat);
-			gh[bitfury->slot][chip & 0x07] = ghash;
-			snprintf(stat_lines[bitfury->slot] + len, LINE_LEN - len, "%.1f-%3.0f ", ghash, bitfury->mhz);
-
-			if(sds->short_out_t && ghash < 0.5) {
-				applog(LOG_WARNING, "Chip_id %d FREQ CHANGE", chip);
-				send_freq(bitfury->spi, bitfury->slot, bitfury->fasync, bitfury->osc6_bits - 1);
-				cgsleep_ms(1);
-				send_freq(bitfury->spi, bitfury->slot, bitfury->fasync, bitfury->osc6_bits);
-			}
-			shares_total += shares_found;
-			shares_first += chip < 4 ? shares_found : 0;
-			shares_last += chip > 3 ? shares_found : 0;
-			strange_counter += bitfury->strange_counter;
-			bitfury->strange_counter = 0;
-		}
-		sprintf(line, "vvvvwww SHORT stat %ds: wwwvvvv", short_stat);
-		applog(LOG_WARNING, "%s", line);
-		sprintf(line, "stranges: %u", strange_counter);
-		applog(LOG_WARNING, "%s", line);
-		for(i = 0; i < 32; i++)
-			if(strlen(stat_lines[i])) {
-				len = strlen(stat_lines[i]);
-				ghsum = 0;
-				gh1h = 0;
-				gh2h = 0;
-				for(k = 0; k < 4; k++) {
-					gh1h += gh[i][k];
-					gh2h += gh[i][k+4];
-					ghsum += gh[i][k] + gh[i][k+4];
-				}
-				snprintf(stat_lines[i] + len, LINE_LEN - len, "- %2.1f + %2.1f = %2.1f slot %i ", gh1h, gh2h, ghsum, i);
-				applog(LOG_WARNING, "%s", stat_lines[i]);
-			}
-		sds->short_out_t = now.tv_sec;
-	}
-
-	if (now.tv_sec - sds->long_out_t > long_stat) {
-		int shares_first = 0, shares_last = 0, shares_total = 0;
-		char stat_lines[32][LINE_LEN] = {{0}};
-		int len, k;
-		double gh[32][8] = {{0}};
-		double ghsum = 0, gh1h = 0, gh2h = 0;
-
-		for (proc = cgpu; proc; proc = proc->next_proc)
-		{
-			const int chip = proc->proc_id;
-			bitfury = proc->device_data;
-			
-			int shares_found = calc_stat(bitfury->stat_ts, long_stat, now);
-			double ghash;
-			len = strlen(stat_lines[bitfury->slot]);
-			ghash = shares_to_ghashes(shares_found, long_stat);
-			gh[bitfury->slot][chip & 0x07] = ghash;
-			snprintf(stat_lines[bitfury->slot] + len, LINE_LEN - len, "%.1f-%3.0f ", ghash, bitfury->mhz);
-
-			shares_total += shares_found;
-			shares_first += chip < 4 ? shares_found : 0;
-			shares_last += chip > 3 ? shares_found : 0;
-		}
-		sprintf(line, "!!!_________ LONG stat %ds: ___________!!!", long_stat);
-		applog(LOG_WARNING, "%s", line);
-		for(i = 0; i < 32; i++)
-			if(strlen(stat_lines[i])) {
-				len = strlen(stat_lines[i]);
-				ghsum = 0;
-				gh1h = 0;
-				gh2h = 0;
-				for(k = 0; k < 4; k++) {
-					gh1h += gh[i][k];
-					gh2h += gh[i][k+4];
-					ghsum += gh[i][k] + gh[i][k+4];
-				}
-				snprintf(stat_lines[i] + len, LINE_LEN - len, "- %2.1f + %2.1f = %2.1f slot %i ", gh1h, gh2h, ghsum, i);
-				applog(LOG_WARNING, "%s", stat_lines[i]);
-			}
-		sds->long_out_t = now.tv_sec;
-	}
-
-	return 0;
-}
-
-double shares_to_ghashes(int shares, int seconds) {
-	return (double)shares / (double)seconds * 4.84387;  //orig: 4.77628
-}
-
-int calc_stat(time_t * stat_ts, time_t stat, struct timeval now) {
-	int j;
-	int shares_found = 0;
-	for(j = 0; j < BITFURY_STAT_N; j++) {
-		if (now.tv_sec - stat_ts[j] < stat) {
-			shares_found++;
-		}
-	}
-	return shares_found;
-}
-
 void bitfury_shutdown(struct thr_info *thr) {
 	struct cgpu_info *cgpu = thr->cgpu, *proc;
 	struct bitfury_device *bitfury;

+ 0 - 2
driver-bitfury.h

@@ -13,8 +13,6 @@ extern bool bitfury_init_chip(struct cgpu_info *);
 extern void bitfury_init_freq_stat(struct freq_stat *, int osc6_min, int osc6_max);
 extern void bitfury_clean_freq_stat(struct freq_stat *);
 
-extern int64_t bitfury_scanHash(struct thr_info *);
-
 extern bool bitfury_job_prepare(struct thr_info *, struct work *, uint64_t max_nonce);
 extern void bitfury_noop_job_start(struct thr_info *);
 extern void bitfury_do_io(struct thr_info *);

+ 0 - 5
driver-metabank.c

@@ -228,11 +228,6 @@ struct device_drv metabank_drv = {
 	.drv_detect = metabank_detect,
 	.thread_init = metabank_init,
 	
-#if 0
-	.minerloop = hash_queued_work,
-	.thread_prepare = bitfury_prepare,
-	.scanwork = bitfury_scanHash,
-#endif
 	.minerloop = minerloop_async,
 	.job_prepare = bitfury_job_prepare,
 	.job_start = bitfury_noop_job_start,

+ 0 - 244
libbitfury.c

@@ -60,10 +60,6 @@ const int8_t counters[16] = { 64, 64,
 	SECOND_BASE, SECOND_BASE+4, SECOND_BASE+2, SECOND_BASE+2+16, SECOND_BASE, SECOND_BASE+1,
 	(FIRST_BASE)%65,  (FIRST_BASE+1)%65,  (FIRST_BASE+3)%65, (FIRST_BASE+3+16)%65, (FIRST_BASE+4)%65, (FIRST_BASE+4+4)%65, (FIRST_BASE+3+3)%65, (FIRST_BASE+3+1+3)%65};
 
-//char counters[16] = { 64, 64,
-//	SECOND_BASE, SECOND_BASE+4, SECOND_BASE+2, SECOND_BASE+2+16, SECOND_BASE, SECOND_BASE+1,
-//	(FIRST_BASE)%65,  (FIRST_BASE+1)%65,  (FIRST_BASE+3)%65, (FIRST_BASE+3+16)%65, (FIRST_BASE+4)%65, (FIRST_BASE+4+4)%65, (FIRST_BASE+3+3)%65, (FIRST_BASE+3+1+3)%65};
-
 /* Oscillator setup variants (maybe more), values inside of chip ANDed to not allow by programming errors work it at higher speeds  */
 /* WARNING! no chip temperature control limits, etc. It may self-fry and make fried chips with great ease :-) So if trying to overclock */
 /* Do not place chip near flammable objects, provide adequate power protection and better wear eye protection ! */
@@ -193,17 +189,6 @@ int get_counter(unsigned int *newbuf, unsigned int *oldbuf) {
 	return 0;
 }
 
-int get_diff(unsigned int *newbuf, unsigned int *oldbuf) {
-		int j;
-		unsigned counter = 0;
-		for(j = 0; j < 16; j++) {
-				if (newbuf[j] != oldbuf[j]) {
-						counter++;
-				}
-		}
-		return counter;
-}
-
 int detect_chip(struct spi_port *port, int chip_n) {
 	/* Test vectors to calculate (using address-translated loads) */
 	unsigned atrvec[] = {
@@ -385,232 +370,3 @@ void payload_to_atrvec(uint32_t *atrvec, struct bitfury_payload *p)
 	memcpy(atrvec, p, 20*4);
 	ms3_compute(atrvec);
 }
-
-void libbitfury_sendHashData1(int chip_id, struct bitfury_device *d, struct thr_info *thr)
-{
-	struct spi_port *port = d->spi;
-	unsigned *newbuf = d->newbuf;
-	unsigned *oldbuf = d->oldbuf;
-	struct bitfury_payload *p = &(d->payload);
-	struct bitfury_payload *op = &(d->opayload);
-	struct bitfury_payload *o2p = &(d->o2payload);
-	struct timeval d_time;
-	struct timeval time;
-	int smart = 0;
-	int chip = d->fasync;
-	int buf_diff;
-
-	timer_set_now(&time);
-
-	if (!d->second_run) {
-		d->predict2 = d->predict1 = time;
-		d->counter1 = d->counter2 = 0;
-		d->req2_done = 0;
-	};
-
-	timersub(&time, &d->predict1, &d_time);
-	if (d_time.tv_sec < 0 && (d->req2_done || !smart)) {
-		d->otimer1 = d->timer1;
-		d->timer1 = time;
-		d->ocounter1 = d->counter1;
-		/* Programming next value */
-		spi_clear_buf(port);
-		spi_emit_break(port);
-		spi_emit_fasync(port, chip);
-		spi_emit_data(port, 0x3000, &d->atrvec[0], 19*4);
-		if (smart) {
-			config_reg(port, 3, 0);
-		}
-		timer_set_now(&time);
-		timersub(&time, &d->predict1, &d_time);
-		spi_txrx(port);
-		memcpy(newbuf, spi_getrxbuf(port)+4 + chip, 17*4);
-		d->counter1 = get_counter(newbuf, oldbuf);
-		buf_diff = get_diff(newbuf, oldbuf);
-		if (buf_diff > 4 || (d->counter1 > 0 && d->counter1 < 0x00400000 / 2)) {
-			if (buf_diff > 4) {
-#ifdef BITFURY_SENDHASHDATA_DEBUG
-				applog(LOG_DEBUG, "AAA        chip_id: %d, buf_diff: %d, counter: %08x", chip_id, buf_diff, d->counter1);
-#endif
-				payload_to_atrvec(&d->atrvec[0], p);
-				spi_clear_buf(port);
-				spi_emit_break(port);
-				spi_emit_fasync(port, chip);
-				spi_emit_data(port, 0x3000, &d->atrvec[0], 19*4);
-				timer_set_now(&time);
-				timersub(&time, &d->predict1, &d_time);
-				spi_txrx(port);
-				memcpy(newbuf, spi_getrxbuf(port)+4 + chip, 17*4);
-				buf_diff = get_diff(newbuf, oldbuf);
-				d->counter1 = get_counter(newbuf, oldbuf);
-#ifdef BITFURY_SENDHASHDATA_DEBUG
-				applog(LOG_DEBUG, "AAA _222__ chip_id: %d, buf_diff: %d, counter: %08x", chip_id, buf_diff, d->counter1);
-#endif
-			}
-		}
-
-		d->job_switched = newbuf[16] != oldbuf[16];
-
-		int i;
-		int results_num = 0;
-		int found = 0;
-		unsigned * results = d->results;
-
-		d->old_nonce = 0;
-		d->future_nonce = 0;
-		for (i = 0; i < 16; i++) {
-			if (oldbuf[i] != newbuf[i] && op && o2p) {
-				uint32_t pn;  // possible nonce
-				if ((newbuf[i] & 0xFF) == 0xE0)
-					continue;
-				pn = bitfury_decnonce(newbuf[i]);
-				if (bitfury_fudge_nonce(op->midstate, op->m7, op->ntime, op->nbits, &pn))
-				{
-					int k;
-					int dup = 0;
-					for (k = 0; k < results_num; k++) {
-						if (results[k] == bswap_32(pn))
-							dup = 1;
-					}
-					if (!dup) {
-						results[results_num++] = bswap_32(pn);
-						found++;
-					}
-				}
-				else
-				if (bitfury_fudge_nonce(o2p->midstate, o2p->m7, o2p->ntime, o2p->nbits, &pn))
-				{
-					d->old_nonce = bswap_32(pn);
-					found++;
-				}
-				else
-				if (bitfury_fudge_nonce(p->midstate, p->m7, p->ntime, p->nbits, &pn))
-				{
-					d->future_nonce = bswap_32(pn);
-					found++;
-				}
-				if (!found) {
-					inc_hw_errors2(thr, NULL, &pn);
-					d->strange_counter++;
-				}
-			}
-		}
-		d->results_n = results_num;
-
-		if (smart) {
-			timersub(&d->timer2, &d->timer1, &d_time);
-		} else {
-			timersub(&d->otimer1, &d->timer1, &d_time);
-		}
-		d->counter1 = get_counter(newbuf, oldbuf);
-		if (d->counter2 || !smart) {
-			int shift;
-			int cycles;
-			int req1_cycles;
-			long long unsigned int period;
-			double ns;
-			unsigned full_cycles, half_cycles;
-			double full_delay, half_delay;
-			long long unsigned delta;
-			struct timeval t_delta;
-			double mhz;
-#ifdef BITFURY_SENDHASHDATA_DEBUG
-			int ccase;
-#endif
-
-			shift = 800000;
-			if (smart) {
-				cycles = d->counter1 < d->counter2 ? 0x00400000 - d->counter2 + d->counter1 : d->counter1 - d->counter2; // + 0x003FFFFF;
-			} else {
-				if (d->counter1 > (0x00400000 - shift * 2) && d->ocounter1 > (0x00400000 - shift)) {
-					cycles = 0x00400000 - d->ocounter1 + d->counter1; // + 0x003FFFFF;
-#ifdef BITFURY_SENDHASHDATA_DEBUG
-					ccase = 1;
-#endif
-				} else {
-					cycles = d->counter1 > d->ocounter1 ? d->counter1 - d->ocounter1 : 0x00400000 - d->ocounter1 + d->counter1;
-#ifdef BITFURY_SENDHASHDATA_DEBUG
-					ccase = 2;
-#endif
-				}
-			}
-			req1_cycles = 0x003FFFFF - d->counter1;
-			period = timeval_to_us(&d_time) * 1000ULL;
-			ns = (double)period / (double)(cycles);
-			mhz = 1.0 / ns * 65.0 * 1000.0;
-
-#ifdef BITFURY_SENDHASHDATA_DEBUG
-			if (d->counter1 > 0 && d->counter1 < 0x001FFFFF) {
-				applog(LOG_DEBUG, "//AAA chip_id %2d: %llu ms, req1_cycles: %08u,  counter1: %08d, ocounter1: %08d, counter2: %08d, cycles: %08d, ns: %.2f, mhz: %.2f ", chip_id, period / 1000000ULL, req1_cycles, d->counter1, d->ocounter1, d->counter2, cycles, ns, mhz);
-			}
-#endif
-			if (ns > 2000.0 || ns < 20) {
-#ifdef BITFURY_SENDHASHDATA_DEBUG
-				applog(LOG_DEBUG, "AAA %d!Stupid ns chip_id %2d: %llu ms, req1_cycles: %08u,  counter1: %08d, ocounter1: %08d, counter2: %08d, cycles: %08d, ns: %.2f, mhz: %.2f ", ccase, chip_id, period / 1000000ULL, req1_cycles, d->counter1, d->ocounter1, d->counter2, cycles, ns, mhz);
-#endif
-				ns = 200.0;
-			} else {
-				d->ns = ns;
-				d->mhz = mhz;
-			}
-
-			if (smart) {
-				half_cycles = req1_cycles + shift;
-				full_cycles = 0x003FFFFF - 2 * shift;
-			} else {
-				half_cycles = 0;
-				full_cycles = req1_cycles > shift ? req1_cycles - shift : req1_cycles + 0x00400000 - shift;
-			}
-			half_delay = (double)half_cycles * ns * (1 +0.92);
-			full_delay = (double)full_cycles * ns;
-			delta = (long long unsigned)(full_delay + half_delay);
-			t_delta = TIMEVAL_USECS(delta / 1000ULL);
-			timeradd(&time, &t_delta, &d->predict1);
-
-			if (smart) {
-				half_cycles = req1_cycles + shift;
-				full_cycles = 0;
-			} else {
-				full_cycles = req1_cycles + shift;
-			}
-			half_delay = (double)half_cycles * ns * (1 + 0.92);
-			full_delay = (double)full_cycles * ns;
-			delta = (long long unsigned)(full_delay + half_delay);
-
-			t_delta = TIMEVAL_USECS(delta / 1000ULL);
-			timeradd(&time, &t_delta, &d->predict2);
-			d->req2_done = 0; d->req1_done = 0;
-		}
-
-		if (d->job_switched) {
-			memcpy(o2p, op, sizeof(struct bitfury_payload));
-			memcpy(op, p, sizeof(struct bitfury_payload));
-			memcpy(oldbuf, newbuf, 17 * 4);
-		}
-	}
-
-	timer_set_now(&time);
-	timersub(&time, &d->predict2, &d_time);
-	if (d_time.tv_sec < 0 && !d->req2_done) {
-		if(smart) {
-			d->otimer2 = d->timer2;
-			d->timer2 = time;
-			spi_clear_buf(port);
-			spi_emit_break(port);
-			spi_emit_fasync(port, chip);
-			spi_emit_data(port, 0x3000, &d->atrvec[0], 19*4);
-			if (smart) {
-				config_reg(port, 3, 1);
-			}
-			spi_txrx(port);
-			memcpy(newbuf, spi_getrxbuf(port)+4 + chip, 17*4);
-			d->counter2 = get_counter(newbuf, oldbuf);
-
-			d->req2_done = 1;
-		} else {
-			d->req2_done = 1;
-		}
-	}
-	
-	d->second_run = true;
-}

+ 2 - 28
libbitfury.h

@@ -7,6 +7,8 @@
 #include "miner.h"
 #include "spidevc.h"
 
+struct work;
+
 #define BITFURY_STAT_N 1024
 
 struct bitfury_payload {
@@ -36,50 +38,22 @@ struct bitfury_device {
 	unsigned oldbuf[17];
 	bool oldjob;
 	int active;
-	struct work * work;
-	struct work * owork;
-	struct work * o2work;
-	int job_switched;
 	uint32_t atrvec[20];
 	struct bitfury_payload payload;
-	struct bitfury_payload opayload;
-	struct bitfury_payload o2payload;
 	struct freq_stat chip_stat;
-	unsigned int results[16];
-	int results_n;
-	time_t stat_ts[BITFURY_STAT_N];
-	unsigned int stat_counter;
-	unsigned int future_nonce;
-	unsigned int old_nonce;
 	struct timeval timer1;
-	struct timeval timer2;
-	struct timeval otimer1;
-	struct timeval otimer2;
-	struct timeval predict1;
-	struct timeval predict2;
 	struct timeval tv_stat;
 	unsigned int counter1, counter2;
-	unsigned int ocounter1, ocounter2;
-	int rate; //per msec
-	int osc_slow;
-	int osc_fast;
-	int req1_done, req2_done;
 	double mhz;
-	double ns;
 	unsigned slot;
 	unsigned fasync;
 	unsigned strange_counter;
-	bool second_run;
 	bool force_reinit;
 	int desync_counter;
 	int sample_hwe;
 	int sample_tot;
-	
-	time_t short_out_t;
-	time_t long_out_t;
 };
 
-extern void libbitfury_sendHashData1(int chip_id, struct bitfury_device *, struct thr_info *);
 void work_to_payload(struct bitfury_payload *p, struct work *w);
 extern void payload_to_atrvec(uint32_t *atrvec, struct bitfury_payload *);
 extern void send_reinit(struct spi_port *, int slot, int chip_n, int n);