|
@@ -92,6 +92,7 @@ struct bitforce_data {
|
|
|
bool is_open;
|
|
bool is_open;
|
|
|
struct lowl_pci_handle *lph;
|
|
struct lowl_pci_handle *lph;
|
|
|
uint8_t lasttag;
|
|
uint8_t lasttag;
|
|
|
|
|
+ uint8_t lasttag_read;
|
|
|
bytes_t getsbuf;
|
|
bytes_t getsbuf;
|
|
|
int xlink_id;
|
|
int xlink_id;
|
|
|
unsigned char next_work_ob[70]; // Data aligned for 32-bit access
|
|
unsigned char next_work_ob[70]; // Data aligned for 32-bit access
|
|
@@ -219,6 +220,8 @@ bool bitforce_pci_open(struct cgpu_info * const dev)
|
|
|
if (!devdata->lph)
|
|
if (!devdata->lph)
|
|
|
return false;
|
|
return false;
|
|
|
devdata->lasttag = (lowl_pci_get_word(devdata->lph, 2, 2) >> 16) & 0xff;
|
|
devdata->lasttag = (lowl_pci_get_word(devdata->lph, 2, 2) >> 16) & 0xff;
|
|
|
|
|
+ devdata->lasttag_read = 0;
|
|
|
|
|
+ bytes_reset(&devdata->getsbuf);
|
|
|
devdata->is_open = true;
|
|
devdata->is_open = true;
|
|
|
return devdata->is_open;
|
|
return devdata->is_open;
|
|
|
}
|
|
}
|
|
@@ -242,8 +245,14 @@ void _bitforce_pci_read(struct cgpu_info * const dev)
|
|
|
uint32_t resp;
|
|
uint32_t resp;
|
|
|
bytes_t *b = &devdata->getsbuf;
|
|
bytes_t *b = &devdata->getsbuf;
|
|
|
|
|
|
|
|
- if (!bytes_len(&devdata->getsbuf))
|
|
|
|
|
|
|
+ if (devdata->lasttag != devdata->lasttag_read)
|
|
|
{
|
|
{
|
|
|
|
|
+ if (unlikely(bytes_len(b)))
|
|
|
|
|
+ {
|
|
|
|
|
+ applog(LOG_WARNING, "%s: %ld bytes remaining in read buffer at new command", dev->dev_repr, (long)bytes_len(&devdata->getsbuf));
|
|
|
|
|
+ bytes_reset(b);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
while (((resp = lowl_pci_get_word(devdata->lph, 2, 2)) & 0xff0000) != looking_for)
|
|
while (((resp = lowl_pci_get_word(devdata->lph, 2, 2)) & 0xff0000) != looking_for)
|
|
|
cgsleep_ms(1);
|
|
cgsleep_ms(1);
|
|
|
|
|
|
|
@@ -254,6 +263,8 @@ void _bitforce_pci_read(struct cgpu_info * const dev)
|
|
|
void * const buf = bytes_preappend(b, resp + LOWL_PCI_GET_DATA_PADDING);
|
|
void * const buf = bytes_preappend(b, resp + LOWL_PCI_GET_DATA_PADDING);
|
|
|
if (lowl_pci_read_data(devdata->lph, buf, resp, 1, 0))
|
|
if (lowl_pci_read_data(devdata->lph, buf, resp, 1, 0))
|
|
|
bytes_postappend(b, resp);
|
|
bytes_postappend(b, resp);
|
|
|
|
|
+
|
|
|
|
|
+ devdata->lasttag_read = devdata->lasttag;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -349,7 +360,12 @@ ssize_t bitforce_read(struct cgpu_info * const proc, void * const buf, const siz
|
|
|
ssize_t rv;
|
|
ssize_t rv;
|
|
|
|
|
|
|
|
if (likely(devdata->is_open))
|
|
if (likely(devdata->is_open))
|
|
|
- rv = devdata->lowlif->read(buf, bufLen, dev);
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ if (bufLen == 0)
|
|
|
|
|
+ rv = 0;
|
|
|
|
|
+ else
|
|
|
|
|
+ rv = devdata->lowlif->read(buf, bufLen, dev);
|
|
|
|
|
+ }
|
|
|
else
|
|
else
|
|
|
rv = -1;
|
|
rv = -1;
|
|
|
|
|
|
|
@@ -1635,7 +1651,7 @@ static bool bitforce_thread_init(struct thr_info *thr)
|
|
|
bitforce->sleep_ms = BITFORCE_SLEEP_MS;
|
|
bitforce->sleep_ms = BITFORCE_SLEEP_MS;
|
|
|
bitforce->device_data = data = malloc(sizeof(*data));
|
|
bitforce->device_data = data = malloc(sizeof(*data));
|
|
|
*data = (struct bitforce_data){
|
|
*data = (struct bitforce_data){
|
|
|
- .lowlif = &bfllif_vcom,
|
|
|
|
|
|
|
+ .lowlif = initdata->lowlif,
|
|
|
.xlink_id = xlink_id,
|
|
.xlink_id = xlink_id,
|
|
|
.next_work_ob = ">>>>>>>>|---------- MidState ----------||-DataTail-||Nonces|>>>>>>>>",
|
|
.next_work_ob = ">>>>>>>>|---------- MidState ----------||-DataTail-||Nonces|>>>>>>>>",
|
|
|
.proto = BFP_RANGE,
|
|
.proto = BFP_RANGE,
|