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

8
libztex.c

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

Loading…
Cancel
Save