Browse Source

fixes for 300 MHz, fix K1 parts list

nfactor-troky
bkkcoins 11 years ago committed by Con Kolivas
parent
commit
5ae1502b68
  1. 146
      cgminer/driver-klondike.c

146
cgminer/driver-klondike.c

@ -142,68 +142,70 @@ static char *SendCmdGetReply(struct cgpu_info *klncgpu, char Cmd, int device, in
} }
return NULL; return NULL;
} }
static bool klondike_get_cfgs(struct cgpu_info *klncgpu)
static bool klondike_init(struct cgpu_info *klncgpu)
{ {
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
int dev; int slaves, dev;
if (klncgpu->usbinfo.nodev || klninfo->status == NULL) char *reply = SendCmdGetReply(klncgpu, 'S', 0, 0, NULL);
if(reply == NULL)
return false; return false;
for(dev = 0; dev <= klninfo->status->slavecount; dev++) { slaves = ((WORKSTATUS *)(reply+2))->slavecount;
char *reply = SendCmdGetReply(klncgpu, 'C', dev, 1, ""); if(klninfo->status == NULL) {
if(reply != NULL) applog(LOG_DEBUG, "Klondike initializing data");
// alloc space for status, devinfo and cfg for master and slaves
klninfo->status = calloc(slaves+1, sizeof(WORKSTATUS));
if (unlikely(!klninfo->status))
quit(1, "Failed to calloc status array in klondke_get_stats");
klninfo->devinfo = calloc(slaves+1, sizeof(DEVINFO));
if (unlikely(!klninfo->devinfo))
quit(1, "Failed to calloc devinfo array in klondke_get_stats");
klninfo->cfg = calloc(slaves+1, sizeof(WORKCFG));
if (unlikely(!klninfo->cfg))
quit(1, "Failed to calloc cfg array in klondke_get_stats");
}
// where does saved user cfg info come from?
// todo: set user cfg to devices
for(dev = 0; dev <= slaves; dev++) {
char *reply = SendCmdGetReply(klncgpu, 'C', dev, 2, "\0");
if(reply != NULL) {
klninfo->cfg[dev] = *(WORKCFG *)(reply+2); klninfo->cfg[dev] = *(WORKCFG *)(reply+2);
applog(LOG_DEBUG, "Klondike config (%d: Clk: %d)", dev, klninfo->cfg[dev].hashclock);
}
} }
SendCmdGetReply(klncgpu, 'E', 0, 1, "1");
return true; return true;
} }
static bool klondike_get_stats(struct cgpu_info *klncgpu) static bool klondike_get_stats(struct cgpu_info *klncgpu)
{ {
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
bool allok = false;
int slaves, dev; int slaves, dev;
if (klncgpu->usbinfo.nodev) if (klncgpu->usbinfo.nodev || klninfo->status == NULL)
return false; return false;
char *reply = SendCmdGetReply(klncgpu, 'S', 0, 0, NULL); applog(LOG_DEBUG, "Klondike getting status");
if(reply != NULL) { slaves = klninfo->status[0].slavecount;
// todo: detect slavecount change and realloc space // loop thru devices and get status for each
slaves = ((WORKSTATUS *)(reply+2))->slavecount; wr_lock(&(klninfo->stat_lock));
if(klninfo->status == NULL) { for(dev = 0; dev <= slaves; dev++) {
applog(LOG_DEBUG, "Klondike initializing status data"); char *reply = SendCmdGetReply(klncgpu, 'S', dev, 0, NULL);
// alloc space for status, devinfo and cfg for master and slaves if(reply != NULL)
klninfo->status = calloc(slaves+1, sizeof(WORKSTATUS)); klninfo->status[dev] = *(WORKSTATUS *)(reply+2);
if (unlikely(!klninfo->status)) }
quit(1, "Failed to calloc status array in klondke_get_stats"); wr_unlock(&(klninfo->stat_lock));
klninfo->devinfo = calloc(slaves+1, sizeof(DEVINFO));
if (unlikely(!klninfo->devinfo))
quit(1, "Failed to calloc devinfo array in klondke_get_stats");
klninfo->cfg = calloc(slaves+1, sizeof(WORKCFG));
if (unlikely(!klninfo->cfg))
quit(1, "Failed to calloc cfg array in klondke_get_stats");
// where does saved user cfg info come from?
// todo: set user cfg to devices
}
applog(LOG_DEBUG, "Klondike updating status");
// device 0 is master and must exist // todo: detect slavecount change and realloc space
wr_lock(&(klninfo->stat_lock));
klninfo->status[0] = *(WORKSTATUS *)(reply+2);
// loop thru slaves and get status for each return true;
for(dev = 1; dev <= slaves; dev++) {
char *reply = SendCmdGetReply(klncgpu, 'S', dev, 0, NULL);
if(reply != NULL)
klninfo->status[dev] = *(WORKSTATUS *)(reply+2);
}
wr_unlock(&(klninfo->stat_lock));
allok = true;
}
return allok;
} }
static bool klondike_detect_one(struct libusb_device *dev, struct usb_find_devices *found) static bool klondike_detect_one(struct libusb_device *dev, struct usb_find_devices *found)
@ -252,7 +254,7 @@ static bool klondike_detect_one(struct libusb_device *dev, struct usb_find_devic
break; break;
applog(LOG_DEBUG, "Klondike cgpu added"); applog(LOG_DEBUG, "Klondike cgpu added");
return true; return true;
} }
} }
usb_uninit(klncgpu); usb_uninit(klncgpu);
} }
@ -276,6 +278,7 @@ static void klondike_check_nonce(struct cgpu_info *klncgpu, WORKRESULT *result)
struct work *work, *tmp; struct work *work, *tmp;
applog(LOG_DEBUG, "Klondike FOUND NONCE (%02x:%08x)", result->workid, result->nonce); applog(LOG_DEBUG, "Klondike FOUND NONCE (%02x:%08x)", result->workid, result->nonce);
HASH_ITER(hh, klncgpu->queued_work, work, tmp) { HASH_ITER(hh, klncgpu->queued_work, work, tmp) {
if (work->queued && (work->subid == (result->device*256 + result->workid))) { if (work->queued && (work->subid == (result->device*256 + result->workid))) {
@ -290,7 +293,7 @@ static void klondike_check_nonce(struct cgpu_info *klncgpu, WORKRESULT *result)
} }
} }
applog(LOG_ERR, "%s%i:%d failed to find nonce work (%02x:%08x) - can't be processed - ignored", applog(LOG_ERR, "%s%i:%d unknown work (%02x:%08x) - can't be processed - ignored",
klncgpu->drv->name, klncgpu->device_id, result->device, result->workid, result->nonce); klncgpu->drv->name, klncgpu->device_id, result->device, result->workid, result->nonce);
//inc_hw_errors(klncgpu->thr[0]); //inc_hw_errors(klncgpu->thr[0]);
} }
@ -330,33 +333,11 @@ static void *klondike_get_replies(void *userdata)
return NULL; return NULL;
} }
static bool klondike_thread_prepare(struct thr_info *thr)
{
struct cgpu_info *klncgpu = thr->cgpu;
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
struct timeval now;
if (thr_info_create(&(klninfo->replies_thr), NULL, klondike_get_replies, (void *)klncgpu)) {
applog(LOG_ERR, "%s%i: thread create failed", klncgpu->drv->name, klncgpu->device_id);
return false;
}
pthread_detach(klninfo->replies_thr.pth);
// init status data structures
nmsleep(500);
klondike_get_stats(klncgpu);
return true;
}
static void klondike_flush_work(struct cgpu_info *klncgpu) static void klondike_flush_work(struct cgpu_info *klncgpu)
{ {
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
int dev; int dev;
if(klninfo->status == NULL)
return;
applog(LOG_DEBUG, "Klondike flushing work work"); applog(LOG_DEBUG, "Klondike flushing work work");
for (dev = 0; dev <= klninfo->status->slavecount; dev++) { for (dev = 0; dev <= klninfo->status->slavecount; dev++) {
char *reply = SendCmdGetReply(klncgpu, 'A', dev, 0, NULL); char *reply = SendCmdGetReply(klncgpu, 'A', dev, 0, NULL);
@ -368,6 +349,24 @@ static void klondike_flush_work(struct cgpu_info *klncgpu)
} }
} }
static bool klondike_thread_prepare(struct thr_info *thr)
{
struct cgpu_info *klncgpu = thr->cgpu;
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
struct timeval now;
if (thr_info_create(&(klninfo->replies_thr), NULL, klondike_get_replies, (void *)klncgpu)) {
applog(LOG_ERR, "%s%i: thread create failed", klncgpu->drv->name, klncgpu->device_id);
return false;
}
pthread_detach(klninfo->replies_thr.pth);
// let the listening get started
nmsleep(100);
return klondike_init(klncgpu);
}
static bool klondike_thread_init(struct thr_info *thr) static bool klondike_thread_init(struct thr_info *thr)
{ {
struct cgpu_info *klncgpu = thr->cgpu; struct cgpu_info *klncgpu = thr->cgpu;
@ -386,6 +385,9 @@ static void klondike_shutdown(struct thr_info *thr)
struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data); struct klondike_info *klninfo = (struct klondike_info *)(klncgpu->device_data);
klondike_flush_work(klncgpu); klondike_flush_work(klncgpu);
SendCmdGetReply(klncgpu, 'E', 0, 1, "0");
klninfo->shutdown = true; klninfo->shutdown = true;
} }
@ -396,8 +398,8 @@ static void klondike_thread_enable(struct thr_info *thr)
if (klncgpu->usbinfo.nodev) if (klncgpu->usbinfo.nodev)
return; return;
klondike_flush_work(klncgpu); SendCmdGetReply(klncgpu, 'E', 0, 1, "0");
klondike_get_cfgs(klncgpu);
} }
static bool klondike_send_work(struct cgpu_info *klncgpu, int dev, struct work *work) static bool klondike_send_work(struct cgpu_info *klncgpu, int dev, struct work *work)
@ -492,11 +494,14 @@ static void get_klondike_statline_before(char *buf, struct cgpu_info *klncgpu)
uint8_t temp = 0xFF; uint8_t temp = 0xFF;
int dev; int dev;
if(klninfo->status == NULL)
return;
rd_lock(&(klninfo->stat_lock)); rd_lock(&(klninfo->stat_lock));
for (dev = 0; dev <= klninfo->status->slavecount; dev++) { for (dev = 0; dev <= klninfo->status->slavecount; dev++) {
if (klninfo->status[dev].temp < temp) if (klninfo->status[dev].temp < temp)
temp = klninfo->status[dev].temp; temp = klninfo->status[dev].temp;
} }
rd_unlock(&(klninfo->stat_lock)); rd_unlock(&(klninfo->stat_lock));
tailsprintf(buf, " %3.0fC 1.2V | ", convertKlnTemp(temp)); tailsprintf(buf, " %3.0fC 1.2V | ", convertKlnTemp(temp));
@ -509,6 +514,9 @@ static struct api_data *klondike_api_stats(struct cgpu_info *klncgpu)
char buf[32]; char buf[32];
int dev; int dev;
if(klninfo->status == NULL)
return NULL;
rd_lock(&(klninfo->stat_lock)); rd_lock(&(klninfo->stat_lock));
for (dev = 0; dev <= klninfo->status->slavecount; dev++) { for (dev = 0; dev <= klninfo->status->slavecount; dev++) {

Loading…
Cancel
Save