mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-14 16:58:05 +00:00
Use a write lock when performing any USB control transfers to prevent concurrent transfers.
This commit is contained in:
parent
c069028648
commit
84de52c1c6
22
usbutils.c
22
usbutils.c
@ -2812,21 +2812,22 @@ out_:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We use the write devlock for control transfers since some control transfers
|
||||||
|
* are rare but may be changing settings within the device causing problems
|
||||||
|
* if concurrent transfers are happening. Using the write lock serialises
|
||||||
|
* any transfers. */
|
||||||
int _usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint32_t *data, int siz, unsigned int timeout, enum usb_cmds cmd)
|
int _usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRequest, uint16_t wValue, uint16_t wIndex, uint32_t *data, int siz, unsigned int timeout, enum usb_cmds cmd)
|
||||||
{
|
{
|
||||||
int pstate, err;
|
int pstate, err;
|
||||||
|
|
||||||
DEVRLOCK(cgpu, pstate);
|
DEVWLOCK(cgpu, pstate);
|
||||||
|
|
||||||
err = __usb_transfer(cgpu, request_type, bRequest, wValue, wIndex, data, siz, timeout, cmd);
|
err = __usb_transfer(cgpu, request_type, bRequest, wValue, wIndex, data, siz, timeout, cmd);
|
||||||
|
|
||||||
if (NOCONTROLDEV(err)) {
|
if (NOCONTROLDEV(err))
|
||||||
cg_ruwlock(&cgpu->usbinfo.devlock);
|
|
||||||
release_cgpu(cgpu);
|
release_cgpu(cgpu);
|
||||||
cg_dwlock(&cgpu->usbinfo.devlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
DEVRUNLOCK(cgpu, pstate);
|
DEVWUNLOCK(cgpu, pstate);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -2840,7 +2841,7 @@ int _usb_transfer_read(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRe
|
|||||||
unsigned char tbuf[64];
|
unsigned char tbuf[64];
|
||||||
int err, pstate;
|
int err, pstate;
|
||||||
|
|
||||||
DEVRLOCK(cgpu, pstate);
|
DEVWLOCK(cgpu, pstate);
|
||||||
|
|
||||||
USBDEBUG("USB debug: _usb_transfer_read(%s (nodev=%s),type=%"PRIu8",req=%"PRIu8",value=%"PRIu16",index=%"PRIu16",bufsiz=%d,timeout=%u,cmd=%s)", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), request_type, bRequest, wValue, wIndex, bufsiz, timeout, usb_cmdname(cmd));
|
USBDEBUG("USB debug: _usb_transfer_read(%s (nodev=%s),type=%"PRIu8",req=%"PRIu8",value=%"PRIu16",index=%"PRIu16",bufsiz=%d,timeout=%u,cmd=%s)", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), request_type, bRequest, wValue, wIndex, bufsiz, timeout, usb_cmdname(cmd));
|
||||||
|
|
||||||
@ -2896,13 +2897,10 @@ int _usb_transfer_read(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRe
|
|||||||
err, libusb_error_name(err));
|
err, libusb_error_name(err));
|
||||||
}
|
}
|
||||||
out_noerrmsg:
|
out_noerrmsg:
|
||||||
if (NOCONTROLDEV(err)) {
|
if (NOCONTROLDEV(err))
|
||||||
cg_ruwlock(&cgpu->usbinfo.devlock);
|
|
||||||
release_cgpu(cgpu);
|
release_cgpu(cgpu);
|
||||||
cg_dwlock(&cgpu->usbinfo.devlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
DEVRUNLOCK(cgpu, pstate);
|
DEVWUNLOCK(cgpu, pstate);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user