|
@@ -1172,6 +1172,7 @@ static int numpgas()
|
|
|
int count = 0;
|
|
int count = 0;
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
|
|
|
+ mutex_lock(&devices_lock);
|
|
|
for (i = 0; i < total_devices; i++) {
|
|
for (i = 0; i < total_devices; i++) {
|
|
|
#ifdef HAVE_OPENCL
|
|
#ifdef HAVE_OPENCL
|
|
|
if (devices[i]->api == &opencl_api)
|
|
if (devices[i]->api == &opencl_api)
|
|
@@ -1183,6 +1184,7 @@ static int numpgas()
|
|
|
#endif
|
|
#endif
|
|
|
++count;
|
|
++count;
|
|
|
}
|
|
}
|
|
|
|
|
+ mutex_unlock(&devices_lock);
|
|
|
return count;
|
|
return count;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1191,6 +1193,7 @@ static int pgadevice(int pgaid)
|
|
|
int count = 0;
|
|
int count = 0;
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
|
|
|
|
+ mutex_lock(&devices_lock);
|
|
|
for (i = 0; i < total_devices; i++) {
|
|
for (i = 0; i < total_devices; i++) {
|
|
|
#ifdef HAVE_OPENCL
|
|
#ifdef HAVE_OPENCL
|
|
|
if (devices[i]->api == &opencl_api)
|
|
if (devices[i]->api == &opencl_api)
|
|
@@ -1201,9 +1204,12 @@ static int pgadevice(int pgaid)
|
|
|
continue;
|
|
continue;
|
|
|
#endif
|
|
#endif
|
|
|
++count;
|
|
++count;
|
|
|
- if (count == (pgaid + 1))
|
|
|
|
|
|
|
+ if (count == (pgaid + 1)) {
|
|
|
|
|
+ mutex_unlock(&devices_lock);
|
|
|
return i;
|
|
return i;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ mutex_unlock(&devices_lock);
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
#endif
|
|
#endif
|
|
@@ -1477,12 +1483,14 @@ static void devdetail_an(struct io_data *io_data, struct cgpu_info *cgpu, bool i
|
|
|
|
|
|
|
|
cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
|
|
cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
|
|
|
|
|
|
|
|
|
|
+ mutex_lock(&devices_lock);
|
|
|
for (i = 0; i < total_devices; ++i) {
|
|
for (i = 0; i < total_devices; ++i) {
|
|
|
if (devices[i] == cgpu)
|
|
if (devices[i] == cgpu)
|
|
|
break;
|
|
break;
|
|
|
if (cgpu->devtype == devices[i]->devtype)
|
|
if (cgpu->devtype == devices[i]->devtype)
|
|
|
++n;
|
|
++n;
|
|
|
}
|
|
}
|
|
|
|
|
+ mutex_unlock(&devices_lock);
|
|
|
|
|
|
|
|
root = api_add_int(root, (char*)cgpu->devtype, &n, true);
|
|
root = api_add_int(root, (char*)cgpu->devtype, &n, true);
|
|
|
root = api_add_device_identifier(root, cgpu);
|
|
root = api_add_device_identifier(root, cgpu);
|
|
@@ -1509,12 +1517,14 @@ static void devstatus_an(struct io_data *io_data, struct cgpu_info *cgpu, bool i
|
|
|
|
|
|
|
|
cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
|
|
cgpu->utility = cgpu->accepted / ( total_secs ? total_secs : 1 ) * 60;
|
|
|
|
|
|
|
|
|
|
+ mutex_lock(&devices_lock);
|
|
|
for (i = 0; i < total_devices; ++i) {
|
|
for (i = 0; i < total_devices; ++i) {
|
|
|
if (devices[i] == cgpu)
|
|
if (devices[i] == cgpu)
|
|
|
break;
|
|
break;
|
|
|
if (cgpu->devtype == devices[i]->devtype)
|
|
if (cgpu->devtype == devices[i]->devtype)
|
|
|
++n;
|
|
++n;
|
|
|
}
|
|
}
|
|
|
|
|
+ mutex_unlock(&devices_lock);
|
|
|
|
|
|
|
|
root = api_add_int(root, (char*)cgpu->devtype, &n, true);
|
|
root = api_add_int(root, (char*)cgpu->devtype, &n, true);
|
|
|
root = api_add_device_identifier(root, cgpu);
|
|
root = api_add_device_identifier(root, cgpu);
|
|
@@ -1563,7 +1573,7 @@ static void pgastatus(struct io_data *io_data, int pga, bool isjson, bool precom
|
|
|
int dev = pgadevice(pga);
|
|
int dev = pgadevice(pga);
|
|
|
if (dev < 0) // Should never happen
|
|
if (dev < 0) // Should never happen
|
|
|
return;
|
|
return;
|
|
|
- devstatus_an(io_data, devices[dev], isjson, precom);
|
|
|
|
|
|
|
+ devstatus_an(io_data, get_proc_by_id(dev), isjson, precom);
|
|
|
}
|
|
}
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
@@ -1593,7 +1603,7 @@ devinfo_internal(void (*func)(struct io_data *, struct cgpu_info*, bool, bool),
|
|
|
io_open = io_add(io_data, COMSTR JSON_DEVS);
|
|
io_open = io_add(io_data, COMSTR JSON_DEVS);
|
|
|
|
|
|
|
|
for (i = 0; i < total_devices; ++i) {
|
|
for (i = 0; i < total_devices; ++i) {
|
|
|
- func(io_data, devices[i], isjson, isjson && i > 0);
|
|
|
|
|
|
|
+ func(io_data, get_proc_by_id(i), isjson, isjson && i > 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (isjson && io_open)
|
|
if (isjson && io_open)
|
|
@@ -1680,6 +1690,7 @@ static void pgadev(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *p
|
|
|
|
|
|
|
|
static void pgaenable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
|
|
static void pgaenable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
|
|
|
{
|
|
{
|
|
|
|
|
+ struct cgpu_info *cgpu;
|
|
|
int numpga = numpgas();
|
|
int numpga = numpgas();
|
|
|
int id;
|
|
int id;
|
|
|
|
|
|
|
@@ -1705,7 +1716,7 @@ static void pgaenable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- struct cgpu_info *cgpu = devices[dev];
|
|
|
|
|
|
|
+ cgpu = get_proc_by_id(dev);
|
|
|
|
|
|
|
|
applog(LOG_DEBUG, "API: request to pgaenable pgaid %d device %d %s",
|
|
applog(LOG_DEBUG, "API: request to pgaenable pgaid %d device %d %s",
|
|
|
id, dev, cgpu->proc_repr_ns);
|
|
id, dev, cgpu->proc_repr_ns);
|
|
@@ -1729,6 +1740,7 @@ static void pgaenable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char
|
|
|
|
|
|
|
|
static void pgadisable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
|
|
static void pgadisable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
|
|
|
{
|
|
{
|
|
|
|
|
+ struct cgpu_info *cgpu;
|
|
|
int numpga = numpgas();
|
|
int numpga = numpgas();
|
|
|
int id;
|
|
int id;
|
|
|
|
|
|
|
@@ -1754,7 +1766,7 @@ static void pgadisable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, cha
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- struct cgpu_info *cgpu = devices[dev];
|
|
|
|
|
|
|
+ cgpu = get_proc_by_id(dev);
|
|
|
|
|
|
|
|
applog(LOG_DEBUG, "API: request to pgadisable pgaid %d device %d %s",
|
|
applog(LOG_DEBUG, "API: request to pgadisable pgaid %d device %d %s",
|
|
|
id, dev, cgpu->proc_repr_ns);
|
|
id, dev, cgpu->proc_repr_ns);
|
|
@@ -1771,6 +1783,8 @@ static void pgadisable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, cha
|
|
|
|
|
|
|
|
static void pgaidentify(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
|
|
static void pgaidentify(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
|
|
|
{
|
|
{
|
|
|
|
|
+ struct cgpu_info *cgpu;
|
|
|
|
|
+ const struct device_api *api;
|
|
|
int numpga = numpgas();
|
|
int numpga = numpgas();
|
|
|
int id;
|
|
int id;
|
|
|
|
|
|
|
@@ -1796,8 +1810,8 @@ static void pgaidentify(struct io_data *io_data, __maybe_unused SOCKETTYPE c, ch
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- struct cgpu_info *cgpu = devices[dev];
|
|
|
|
|
- const struct device_api *api = cgpu->api;
|
|
|
|
|
|
|
+ cgpu = get_proc_by_id(dev);
|
|
|
|
|
+ api = cgpu->api;
|
|
|
|
|
|
|
|
if (api->identify_device && api->identify_device(cgpu))
|
|
if (api->identify_device && api->identify_device(cgpu))
|
|
|
message(io_data, MSG_PGAIDENT, id, NULL, isjson);
|
|
message(io_data, MSG_PGAIDENT, id, NULL, isjson);
|
|
@@ -2666,7 +2680,7 @@ static void notify(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe
|
|
|
io_open = io_add(io_data, COMSTR JSON_NOTIFY);
|
|
io_open = io_add(io_data, COMSTR JSON_NOTIFY);
|
|
|
|
|
|
|
|
for (i = 0; i < total_devices; i++)
|
|
for (i = 0; i < total_devices; i++)
|
|
|
- notifystatus(io_data, i, devices[i], isjson, group);
|
|
|
|
|
|
|
+ notifystatus(io_data, i, get_proc_by_id(i), isjson, group);
|
|
|
|
|
|
|
|
if (isjson && io_open)
|
|
if (isjson && io_open)
|
|
|
io_close(io_data);
|
|
io_close(io_data);
|
|
@@ -2691,7 +2705,7 @@ static void devdetails(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
|
|
|
io_open = io_add(io_data, COMSTR JSON_DEVDETAILS);
|
|
io_open = io_add(io_data, COMSTR JSON_DEVDETAILS);
|
|
|
|
|
|
|
|
for (i = 0; i < total_devices; i++) {
|
|
for (i = 0; i < total_devices; i++) {
|
|
|
- cgpu = devices[i];
|
|
|
|
|
|
|
+ cgpu = get_proc_by_id(i);
|
|
|
|
|
|
|
|
root = api_add_int(root, "DEVDETAILS", &i, false);
|
|
root = api_add_int(root, "DEVDETAILS", &i, false);
|
|
|
root = api_add_device_identifier(root, cgpu);
|
|
root = api_add_device_identifier(root, cgpu);
|
|
@@ -2787,6 +2801,7 @@ static int itemstats(struct io_data *io_data, int i, char *id, struct cgminer_st
|
|
|
|
|
|
|
|
static void minerstats(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
|
|
static void minerstats(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
|
|
|
{
|
|
{
|
|
|
|
|
+ struct cgpu_info *cgpu;
|
|
|
bool io_open = false;
|
|
bool io_open = false;
|
|
|
struct api_data *extra;
|
|
struct api_data *extra;
|
|
|
char id[20];
|
|
char id[20];
|
|
@@ -2799,7 +2814,7 @@ static void minerstats(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
|
|
|
|
|
|
|
|
i = 0;
|
|
i = 0;
|
|
|
for (j = 0; j < total_devices; j++) {
|
|
for (j = 0; j < total_devices; j++) {
|
|
|
- struct cgpu_info *cgpu = devices[j];
|
|
|
|
|
|
|
+ cgpu = get_proc_by_id(j);
|
|
|
|
|
|
|
|
if (cgpu && cgpu->api) {
|
|
if (cgpu && cgpu->api) {
|
|
|
if (cgpu->api->get_api_stats)
|
|
if (cgpu->api->get_api_stats)
|
|
@@ -3006,6 +3021,8 @@ static void setconfig(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char
|
|
|
#ifdef HAVE_AN_FPGA
|
|
#ifdef HAVE_AN_FPGA
|
|
|
static void pgaset(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
|
|
static void pgaset(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe_unused char *param, bool isjson, __maybe_unused char group)
|
|
|
{
|
|
{
|
|
|
|
|
+ struct cgpu_info *cgpu;
|
|
|
|
|
+ const struct device_api *api;
|
|
|
char buf[TMPBUFSIZ];
|
|
char buf[TMPBUFSIZ];
|
|
|
int numpga = numpgas();
|
|
int numpga = numpgas();
|
|
|
|
|
|
|
@@ -3039,8 +3056,8 @@ static void pgaset(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __maybe
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- struct cgpu_info *cgpu = devices[dev];
|
|
|
|
|
- const struct device_api *api = cgpu->api;
|
|
|
|
|
|
|
+ cgpu = get_proc_by_id(dev);
|
|
|
|
|
+ api = cgpu->api;
|
|
|
|
|
|
|
|
char *set = strchr(opt, ',');
|
|
char *set = strchr(opt, ',');
|
|
|
if (set)
|
|
if (set)
|