mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Merge pull request #447 from kanoi/master
Missing DEVLOCKs and fix applog GPU problems
This commit is contained in:
commit
4280537a1f
2
adl.c
2
adl.c
@ -1343,7 +1343,7 @@ updated:
|
||||
wlogprint("Failed to modify engine clock speed\n");
|
||||
} else if (!strncasecmp(&input, "f", 1)) {
|
||||
get_fanrange(gpu, &imin, &imax);
|
||||
wlogprint("Enter fan percentage (%d - %d %)", imin, imax);
|
||||
wlogprint("Enter fan percentage (%d - %d %%)", imin, imax);
|
||||
val = curses_int("");
|
||||
if (val < imin || val > imax) {
|
||||
wlogprint("Value is outside safe range, are you sure?\n");
|
||||
|
31
api.c
31
api.c
@ -126,7 +126,6 @@ char *WSAErrorMsg(void) {
|
||||
#endif
|
||||
|
||||
static const char *UNAVAILABLE = " - API will not be available";
|
||||
static const char *INVAPIGROUPS = "Invalid --api-groups parameter";
|
||||
|
||||
static const char *BLANK = "";
|
||||
static const char *COMMA = ",";
|
||||
@ -3587,30 +3586,21 @@ static void setup_groups()
|
||||
colon = strchr(ptr, ':');
|
||||
if (colon)
|
||||
*colon = '\0';
|
||||
applog(LOG_WARNING, "API invalid group name '%s'", ptr);
|
||||
quit(1, INVAPIGROUPS);
|
||||
quit(1, "API invalid group name '%s'", ptr);
|
||||
}
|
||||
|
||||
group = GROUP(*ptr);
|
||||
if (!VALIDGROUP(group)) {
|
||||
applog(LOG_WARNING, "API invalid group name '%c'", *ptr);
|
||||
quit(1, INVAPIGROUPS);
|
||||
}
|
||||
if (!VALIDGROUP(group))
|
||||
quit(1, "API invalid group name '%c'", *ptr);
|
||||
|
||||
if (group == PRIVGROUP) {
|
||||
applog(LOG_WARNING, "API group name can't be '%c'", PRIVGROUP);
|
||||
quit(1, INVAPIGROUPS);
|
||||
}
|
||||
if (group == PRIVGROUP)
|
||||
quit(1, "API group name can't be '%c'", PRIVGROUP);
|
||||
|
||||
if (group == NOPRIVGROUP) {
|
||||
applog(LOG_WARNING, "API group name can't be '%c'", NOPRIVGROUP);
|
||||
quit(1, INVAPIGROUPS);
|
||||
}
|
||||
if (group == NOPRIVGROUP)
|
||||
quit(1, "API group name can't be '%c'", NOPRIVGROUP);
|
||||
|
||||
if (apigroups[GROUPOFFSET(group)].commands != NULL) {
|
||||
applog(LOG_WARNING, "API duplicate group name '%c'", *ptr);
|
||||
quit(1, INVAPIGROUPS);
|
||||
}
|
||||
if (apigroups[GROUPOFFSET(group)].commands != NULL)
|
||||
quit(1, "API duplicate group name '%c'", *ptr);
|
||||
|
||||
ptr += 2;
|
||||
|
||||
@ -3644,8 +3634,7 @@ static void setup_groups()
|
||||
*cmd = '\0';
|
||||
}
|
||||
} else {
|
||||
applog(LOG_WARNING, "API unknown command '%s' in group '%c'", ptr, group);
|
||||
quit(1, INVAPIGROUPS);
|
||||
quit(1, "API unknown command '%s' in group '%c'", ptr, group);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -685,7 +685,7 @@ retry:
|
||||
if (powertune != -1)
|
||||
tailsprintf(logline, "P: %d%%", powertune);
|
||||
tailsprintf(logline, "\n");
|
||||
wlog(logline);
|
||||
_wlog(logline);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
109
usbutils.c
109
usbutils.c
@ -2542,16 +2542,14 @@ out_unlock:
|
||||
return err;
|
||||
}
|
||||
|
||||
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, __maybe_unused 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, __maybe_unused enum usb_cmds cmd)
|
||||
{
|
||||
struct cg_usb_device *usbdev;
|
||||
#if DO_USB_STATS
|
||||
struct timeval tv_start, tv_finish;
|
||||
#endif
|
||||
uint32_t *buf = NULL;
|
||||
int err, i, bufsiz, pstate;
|
||||
|
||||
DEVLOCK(cgpu, pstate);
|
||||
int err, i, bufsiz;
|
||||
|
||||
USBDEBUG("USB debug: _usb_transfer(%s (nodev=%s),type=%"PRIu8",req=%"PRIu8",value=%"PRIu16",index=%"PRIu16",siz=%d,timeout=%u,cmd=%s)", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), request_type, bRequest, wValue, wIndex, siz, timeout, usb_cmdname(cmd));
|
||||
|
||||
@ -2559,7 +2557,7 @@ int _usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRequest
|
||||
USB_REJECT(cgpu, MODE_CTRL_WRITE);
|
||||
|
||||
err = LIBUSB_ERROR_NO_DEVICE;
|
||||
goto out_unlock;
|
||||
goto out_;
|
||||
}
|
||||
usbdev = cgpu->usbdev;
|
||||
|
||||
@ -2591,13 +2589,23 @@ int _usb_transfer(struct cgpu_info *cgpu, uint8_t request_type, uint8_t bRequest
|
||||
|
||||
IOERR_CHECK(cgpu, err);
|
||||
|
||||
if (buf)
|
||||
free(buf);
|
||||
free(buf);
|
||||
|
||||
if (NOCONTROLDEV(err))
|
||||
release_cgpu(cgpu);
|
||||
|
||||
out_unlock:
|
||||
out_:
|
||||
return err;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
DEVLOCK(cgpu, pstate);
|
||||
|
||||
err = __usb_transfer(cgpu, request_type, bRequest, wValue, wIndex, data, siz, timeout, cmd);
|
||||
|
||||
DEVUNLOCK(cgpu, pstate);
|
||||
|
||||
return err;
|
||||
@ -2677,23 +2685,30 @@ int usb_ftdi_cts(struct cgpu_info *cgpu)
|
||||
|
||||
int usb_ftdi_set_latency(struct cgpu_info *cgpu)
|
||||
{
|
||||
int err;
|
||||
int err = 0;
|
||||
int pstate;
|
||||
|
||||
if (cgpu->usbdev->usb_type != USB_TYPE_FTDI) {
|
||||
applog(LOG_ERR, "%s: cgid %d latency request on non-FTDI device",
|
||||
cgpu->drv->name, cgpu->cgminer_id);
|
||||
return LIBUSB_ERROR_NOT_SUPPORTED;
|
||||
DEVLOCK(cgpu, pstate);
|
||||
|
||||
if (cgpu->usbdev) {
|
||||
if (cgpu->usbdev->usb_type != USB_TYPE_FTDI) {
|
||||
applog(LOG_ERR, "%s: cgid %d latency request on non-FTDI device",
|
||||
cgpu->drv->name, cgpu->cgminer_id);
|
||||
err = LIBUSB_ERROR_NOT_SUPPORTED;
|
||||
} else if (cgpu->usbdev->found->latency == LATENCY_UNUSED) {
|
||||
applog(LOG_ERR, "%s: cgid %d invalid latency (UNUSED)",
|
||||
cgpu->drv->name, cgpu->cgminer_id);
|
||||
err = LIBUSB_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if (!err)
|
||||
err = __usb_transfer(cgpu, FTDI_TYPE_OUT, FTDI_REQUEST_LATENCY,
|
||||
cgpu->usbdev->found->latency,
|
||||
cgpu->usbdev->found->interface,
|
||||
NULL, 0, DEVTIMEOUT, C_LATENCY);
|
||||
}
|
||||
|
||||
if (cgpu->usbdev->found->latency == LATENCY_UNUSED) {
|
||||
applog(LOG_ERR, "%s: cgid %d invalid latency (UNUSED)",
|
||||
cgpu->drv->name, cgpu->cgminer_id);
|
||||
return LIBUSB_ERROR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
err = usb_transfer_data(cgpu, FTDI_TYPE_OUT, FTDI_REQUEST_LATENCY,
|
||||
cgpu->usbdev->found->latency,
|
||||
cgpu->usbdev->found->interface, NULL, 0, C_LATENCY);
|
||||
DEVUNLOCK(cgpu, pstate);
|
||||
|
||||
applog(LOG_DEBUG, "%s: cgid %d %s got err %d",
|
||||
cgpu->drv->name, cgpu->cgminer_id,
|
||||
@ -2704,9 +2719,13 @@ int usb_ftdi_set_latency(struct cgpu_info *cgpu)
|
||||
|
||||
void usb_buffer_enable(struct cgpu_info *cgpu)
|
||||
{
|
||||
struct cg_usb_device *cgusb = cgpu->usbdev;
|
||||
struct cg_usb_device *cgusb;
|
||||
int pstate;
|
||||
|
||||
if (!cgusb->buffer) {
|
||||
DEVLOCK(cgpu, pstate);
|
||||
|
||||
cgusb = cgpu->usbdev;
|
||||
if (cgusb && !cgusb->buffer) {
|
||||
cgusb->bufamt = 0;
|
||||
cgusb->buffer = malloc(USB_MAX_READ+1);
|
||||
if (!cgusb->buffer)
|
||||
@ -2714,40 +2733,66 @@ void usb_buffer_enable(struct cgpu_info *cgpu)
|
||||
cgpu->drv->name, cgpu->device_id);
|
||||
cgusb->bufsiz = USB_MAX_READ;
|
||||
}
|
||||
|
||||
DEVUNLOCK(cgpu, pstate);
|
||||
}
|
||||
|
||||
void usb_buffer_disable(struct cgpu_info *cgpu)
|
||||
{
|
||||
struct cg_usb_device *cgusb = cgpu->usbdev;
|
||||
struct cg_usb_device *cgusb;
|
||||
int pstate;
|
||||
|
||||
if (cgusb->buffer) {
|
||||
DEVLOCK(cgpu, pstate);
|
||||
|
||||
cgusb = cgpu->usbdev;
|
||||
if (cgusb && cgusb->buffer) {
|
||||
cgusb->bufamt = 0;
|
||||
cgusb->bufsiz = 0;
|
||||
free(cgusb->buffer);
|
||||
cgusb->buffer = NULL;
|
||||
}
|
||||
|
||||
DEVUNLOCK(cgpu, pstate);
|
||||
}
|
||||
|
||||
void usb_buffer_clear(struct cgpu_info *cgpu)
|
||||
{
|
||||
struct cg_usb_device *cgusb = cgpu->usbdev;
|
||||
int pstate;
|
||||
|
||||
cgusb->bufamt = 0;
|
||||
DEVLOCK(cgpu, pstate);
|
||||
|
||||
if (cgpu->usbdev)
|
||||
cgpu->usbdev->bufamt = 0;
|
||||
|
||||
DEVUNLOCK(cgpu, pstate);
|
||||
}
|
||||
|
||||
uint32_t usb_buffer_size(struct cgpu_info *cgpu)
|
||||
{
|
||||
struct cg_usb_device *cgusb = cgpu->usbdev;
|
||||
uint32_t ret = 0;
|
||||
int pstate;
|
||||
|
||||
return cgusb->bufamt;
|
||||
DEVLOCK(cgpu, pstate);
|
||||
|
||||
if (cgpu->usbdev)
|
||||
ret = cgpu->usbdev->bufamt;
|
||||
|
||||
DEVUNLOCK(cgpu, pstate);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Need to set all devices with matching usbdev
|
||||
void usb_set_dev_start(struct cgpu_info *cgpu)
|
||||
{
|
||||
struct cg_usb_device *cgusb = cgpu->usbdev;
|
||||
struct cg_usb_device *cgusb;
|
||||
struct cgpu_info *cgpu2;
|
||||
struct timeval now;
|
||||
int pstate;
|
||||
|
||||
DEVLOCK(cgpu, pstate);
|
||||
|
||||
cgusb = cgpu->usbdev;
|
||||
|
||||
// If the device wasn't dropped
|
||||
if (cgusb != NULL) {
|
||||
@ -2761,6 +2806,8 @@ void usb_set_dev_start(struct cgpu_info *cgpu)
|
||||
copy_time(&(cgpu2->dev_start_tv), &now);
|
||||
}
|
||||
}
|
||||
|
||||
DEVUNLOCK(cgpu, pstate);
|
||||
}
|
||||
|
||||
void usb_cleanup()
|
||||
|
Loading…
Reference in New Issue
Block a user