mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-23 13:04:29 +00:00
usbutils allow a short wait for resources to be released
This commit is contained in:
parent
5869539e67
commit
3f4b717ac2
31
usbutils.c
31
usbutils.c
@ -2368,12 +2368,14 @@ int _usb_transfer_read(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRe
|
|||||||
void usb_cleanup()
|
void usb_cleanup()
|
||||||
{
|
{
|
||||||
struct cgpu_info *cgpu;
|
struct cgpu_info *cgpu;
|
||||||
|
int count;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
hotplug_time = 0;
|
hotplug_time = 0;
|
||||||
|
|
||||||
nmsleep(10);
|
nmsleep(10);
|
||||||
|
|
||||||
|
count = 0;
|
||||||
for (i = 0; i < total_devices; i++) {
|
for (i = 0; i < total_devices; i++) {
|
||||||
cgpu = devices[i];
|
cgpu = devices[i];
|
||||||
switch (cgpu->drv->drv_id) {
|
switch (cgpu->drv->drv_id) {
|
||||||
@ -2383,11 +2385,40 @@ void usb_cleanup()
|
|||||||
case DRIVER_ICARUS:
|
case DRIVER_ICARUS:
|
||||||
case DRIVER_AVALON:
|
case DRIVER_AVALON:
|
||||||
release_cgpu(cgpu);
|
release_cgpu(cgpu);
|
||||||
|
count++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Must attempt to wait for the resource thread to release coz
|
||||||
|
* during a restart it won't automatically release them in linux
|
||||||
|
*/
|
||||||
|
if (count) {
|
||||||
|
struct timeval start, now;
|
||||||
|
|
||||||
|
cgtime(&start);
|
||||||
|
while (42) {
|
||||||
|
nmsleep(50);
|
||||||
|
|
||||||
|
mutex_lock(&cgusbres_lock);
|
||||||
|
|
||||||
|
if (!res_work_head)
|
||||||
|
break;
|
||||||
|
|
||||||
|
cgtime(&now);
|
||||||
|
if (tdiff(&now, &start) > 0.366) {
|
||||||
|
applog(LOG_WARNING,
|
||||||
|
"usb_cleanup gave up waiting for resource thread");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mutex_unlock(&cgusbres_lock);
|
||||||
|
}
|
||||||
|
mutex_unlock(&cgusbres_lock);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void usb_initialise()
|
void usb_initialise()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user