Browse Source

Trying harder to get 1.15y working

nfactor-troky
nelisky 13 years ago
parent
commit
0080aea432
  1. 16
      driver-ztex.c
  2. 8
      libztex.c

16
driver-ztex.c

@ -41,6 +41,7 @@ static void ztex_selectFpga(struct libztex_device* ztex)
if (ztex->root->numberOfFpgas > 1) { if (ztex->root->numberOfFpgas > 1) {
if (ztex->root->selectedFpga != ztex->fpgaNum) if (ztex->root->selectedFpga != ztex->fpgaNum)
mutex_lock(&ztex->root->mutex); mutex_lock(&ztex->root->mutex);
applog(LOG_DEBUG, "%s:%d: locked", ztex->repr, ztex->fpgaNum);
libztex_selectFpga(ztex); libztex_selectFpga(ztex);
} }
} }
@ -50,6 +51,7 @@ static void ztex_releaseFpga(struct libztex_device* ztex)
if (ztex->root->numberOfFpgas > 1) { if (ztex->root->numberOfFpgas > 1) {
ztex->root->selectedFpga = -1; ztex->root->selectedFpga = -1;
mutex_unlock(&ztex->root->mutex); mutex_unlock(&ztex->root->mutex);
applog(LOG_DEBUG, "%s:%d: unlocked", ztex->repr, ztex->fpgaNum);
} }
} }
@ -127,7 +129,7 @@ static bool ztex_updateFreq(struct libztex_device* ztex)
if (bestM != ztex->freqM) { if (bestM != ztex->freqM) {
ztex_selectFpga(ztex); ztex_selectFpga(ztex);
libztex_setFreq(ztex, bestM); libztex_setFreq(ztex->root, bestM);
ztex_releaseFpga(ztex); ztex_releaseFpga(ztex);
} }
@ -136,7 +138,7 @@ static bool ztex_updateFreq(struct libztex_device* ztex)
maxM++; maxM++;
if ((bestM < (1.0 - LIBZTEX_OVERHEATTHRESHOLD) * maxM) && bestM < maxM - 1) { if ((bestM < (1.0 - LIBZTEX_OVERHEATTHRESHOLD) * maxM) && bestM < maxM - 1) {
ztex_selectFpga(ztex); ztex_selectFpga(ztex);
libztex_resetFpga(ztex); libztex_resetFpga(ztex->root);
ztex_releaseFpga(ztex); ztex_releaseFpga(ztex);
applog(LOG_ERR, "%s: frequency drop of %.1f%% detect. This may be caused by overheating. FPGA is shut down to prevent damage.", applog(LOG_ERR, "%s: frequency drop of %.1f%% detect. This may be caused by overheating. FPGA is shut down to prevent damage.",
ztex->repr, (1.0 - 1.0 * bestM / maxM) * 100); ztex->repr, (1.0 - 1.0 * bestM / maxM) * 100);
@ -204,12 +206,12 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
memcpy(sendbuf + 12, work->midstate, 32); memcpy(sendbuf + 12, work->midstate, 32);
ztex_selectFpga(ztex); ztex_selectFpga(ztex);
i = libztex_sendHashData(ztex, sendbuf); i = libztex_sendHashData(ztex->root, sendbuf);
if (i < 0) { if (i < 0) {
// Something wrong happened in send // Something wrong happened in send
applog(LOG_ERR, "%s: Failed to send hash data with err %d, retrying", ztex->repr, i); applog(LOG_ERR, "%s: Failed to send hash data with err %d, retrying", ztex->repr, i);
usleep(500000); usleep(500000);
i = libztex_sendHashData(ztex, sendbuf); i = libztex_sendHashData(ztex->root, sendbuf);
if (i < 0) { if (i < 0) {
// And there's nothing we can do about it // And there's nothing we can do about it
ztex_disable(thr); ztex_disable(thr);
@ -247,12 +249,12 @@ static uint64_t ztex_scanhash(struct thr_info *thr, struct work *work,
break; break;
} }
ztex_selectFpga(ztex); ztex_selectFpga(ztex);
i = libztex_readHashData(ztex, &hdata[0]); i = libztex_readHashData(ztex->root, &hdata[0]);
if (i < 0) { if (i < 0) {
// Something wrong happened in read // Something wrong happened in read
applog(LOG_ERR, "%s: Failed to read hash data with err %d, retrying", ztex->repr, i); applog(LOG_ERR, "%s: Failed to read hash data with err %d, retrying", ztex->repr, i);
usleep(500000); usleep(500000);
i = libztex_readHashData(ztex, &hdata[0]); i = libztex_readHashData(ztex->root, &hdata[0]);
if (i < 0) { if (i < 0) {
// And there's nothing we can do about it // And there's nothing we can do about it
ztex_disable(thr); ztex_disable(thr);
@ -361,7 +363,7 @@ static bool ztex_prepare(struct thr_info *thr)
get_datestamp(cgpu->init, &now); get_datestamp(cgpu->init, &now);
ztex_selectFpga(ztex); ztex_selectFpga(ztex);
if (libztex_configureFpga(ztex) != 0) if (libztex_configureFpga(ztex->root) != 0)
return false; return false;
ztex_releaseFpga(ztex); ztex_releaseFpga(ztex);
ztex->freqM = -1; ztex->freqM = -1;

8
libztex.c

@ -351,19 +351,19 @@ int libztex_numberOfFpgas(struct libztex_device *ztex) {
} }
int libztex_selectFpga(struct libztex_device *ztex) { int libztex_selectFpga(struct libztex_device *ztex) {
int cnt, fpgacnt = libztex_numberOfFpgas(ztex); int cnt, fpgacnt = libztex_numberOfFpgas(ztex->root);
int number = ztex->fpgaNum; int number = ztex->fpgaNum;
if (number < 0 || number >= fpgacnt) { if (number < 0 || number >= fpgacnt) {
applog(LOG_WARNING, "%s: Trying to select wrong fpga (%d in %d)", ztex->repr, number, fpgacnt); applog(LOG_WARNING, "%s: Trying to select wrong fpga (%d in %d)", ztex->repr, number, fpgacnt);
return 1; return 1;
} }
if (ztex->selectedFpga != number && libztex_checkCapability(ztex, CAPABILITY_MULTI_FPGA)) { if (ztex->root->selectedFpga != number && libztex_checkCapability(ztex->root, CAPABILITY_MULTI_FPGA)) {
cnt = libusb_control_transfer(ztex->hndl, 0x40, 0x51, number, 0, NULL, 0, 500); cnt = libusb_control_transfer(ztex->root->hndl, 0x40, 0x51, number, 0, NULL, 0, 500);
if (unlikely(cnt < 0)) { if (unlikely(cnt < 0)) {
applog(LOG_ERR, "Ztex check device: Failed to set fpga with err %d", cnt); applog(LOG_ERR, "Ztex check device: Failed to set fpga with err %d", cnt);
return cnt; return cnt;
} }
ztex->selectedFpga = number; ztex->root->selectedFpga = number;
} }
return 0; return 0;
} }

Loading…
Cancel
Save