Browse Source

nvml: separated vendor id to string function

for the day nvidia will fix their nvmlDeviceGetPciInfo api..
master
Tanguy Pruvot 10 years ago
parent
commit
7981e83db7
  1. 74
      nvml.cpp
  2. 1
      x11/x11.cu

74
nvml.cpp

@ -232,7 +232,7 @@ nvml_handle * nvml_create()
nvmlh->nvml_pci_domain_id[i] = pciinfo.domain; nvmlh->nvml_pci_domain_id[i] = pciinfo.domain;
nvmlh->nvml_pci_bus_id[i] = pciinfo.bus; nvmlh->nvml_pci_bus_id[i] = pciinfo.bus;
nvmlh->nvml_pci_device_id[i] = pciinfo.device; nvmlh->nvml_pci_device_id[i] = pciinfo.device;
nvmlh->nvml_pci_subsys_id[i] = pciinfo.pci_device_id; nvmlh->nvml_pci_subsys_id[i] = pciinfo.pci_device_id; /* pci_subsystem_id broken (0xccccccccc) */
nvmlh->app_clocks[i] = NVML_FEATURE_UNKNOWN; nvmlh->app_clocks[i] = NVML_FEATURE_UNKNOWN;
if (nvmlh->nvmlDeviceSetAPIRestriction) { if (nvmlh->nvmlDeviceSetAPIRestriction) {
@ -779,7 +779,7 @@ int nvapi_init()
NvAPI_ShortString str; NvAPI_ShortString str;
ret = NvAPI_SYS_GetDriverAndBranchVersion(&udv, str); ret = NvAPI_SYS_GetDriverAndBranchVersion(&udv, str);
if (ret == NVAPI_OK) { if (ret == NVAPI_OK) {
sprintf(driver_version,"%d.%d", udv/100, udv % 100); sprintf(driver_version,"%d.%02d", udv / 100, udv % 100);
} }
return 0; return 0;
@ -888,17 +888,12 @@ unsigned int gpu_power(struct cgpu_info *gpu)
return mw; return mw;
} }
#ifdef HAVE_PCIDEV static int translate_vendor_id(uint16_t vid, char *vendorname)
extern "C" {
#include <errno.h>
#include <pci/pci.h>
}
static int linux_gpu_vendor(uint8_t pci_bus_id, char* vendorname, uint16_t &pid)
{ {
uint16_t subvendor = 0; bool identified = false;
struct pci_access *pci;
struct pci_dev *dev; if (!vendorname)
uint16_t subdevice; return -EINVAL;
struct VENDORS { struct VENDORS {
const uint16_t vid; const uint16_t vid;
@ -906,13 +901,36 @@ static int linux_gpu_vendor(uint8_t pci_bus_id, char* vendorname, uint16_t &pid)
} vendors[] = { } vendors[] = {
{ 0x1043, "ASUS" }, { 0x1043, "ASUS" },
{ 0x10B0, "Gainward" }, { 0x10B0, "Gainward" },
{ 0x10DE, "NVIDIA" }, // { 0x10DE, "NVIDIA" },
{ 0x1458, "Gigabyte" }, { 0x1458, "Gigabyte" },
{ 0x1462, "MSI" }, { 0x1462, "MSI" },
{ 0x3842, "EVGA" }, { 0x3842, "EVGA" },
{ 0, "" } { 0, "" }
}; };
for(int v=0; v < ARRAY_SIZE(vendors); v++) {
if (vid == vendors[v].vid) {
strcpy(vendorname, vendors[v].name);
return vid;
}
}
if (!identified && opt_debug)
applog(LOG_DEBUG, "nvml: Unknown vendor %04x\n", vid);
return 0;
}
#ifdef HAVE_PCIDEV
extern "C" {
#include <errno.h>
#include <pci/pci.h>
}
static int linux_gpu_vendor(uint8_t pci_bus_id, char* vendorname, uint16_t &pid)
{
uint16_t subvendor = 0;
struct pci_access *pci;
struct pci_dev *dev;
uint16_t subdevice;
if (!vendorname) if (!vendorname)
return -EINVAL; return -EINVAL;
@ -925,24 +943,16 @@ static int linux_gpu_vendor(uint8_t pci_bus_id, char* vendorname, uint16_t &pid)
for(dev = pci->devices; dev; dev = dev->next) for(dev = pci->devices; dev; dev = dev->next)
{ {
if (dev->device_class == PCI_CLASS_DISPLAY_VGA && dev->bus == pci_bus_id) if (dev->bus == pci_bus_id && dev->vendor_id == 0x10DE)
{ {
bool identified = false; if (!(dev->known_fields & PCI_FILL_CLASS))
pci_fill_info(dev, PCI_FILL_CLASS);
if (dev->device_class != PCI_CLASS_DISPLAY_VGA)
continue;
subvendor = pci_read_word(dev, PCI_SUBSYSTEM_VENDOR_ID); subvendor = pci_read_word(dev, PCI_SUBSYSTEM_VENDOR_ID);
subdevice = pci_read_word(dev, PCI_SUBSYSTEM_ID); // model subdevice = pci_read_word(dev, PCI_SUBSYSTEM_ID); // model
for(int v=0; v < ARRAY_SIZE(vendors); v++) { translate_vendor_id(subvendor, vendorname);
if (subvendor == vendors[v].vid) {
strcpy(vendorname, vendors[v].name);
identified = true;
pid = subdevice;
break;
}
}
if (!identified && !opt_quiet)
applog(LOG_DEBUG, "%04x:%04x (Unknown vendor)\n",
subvendor, subdevice);
} }
} }
pci_cleanup(pci); pci_cleanup(pci);
@ -956,7 +966,15 @@ int gpu_vendor(uint8_t pci_bus_id, char *vendorname)
uint16_t pid = 0; uint16_t pid = 0;
return linux_gpu_vendor(pci_bus_id, vendorname, pid); return linux_gpu_vendor(pci_bus_id, vendorname, pid);
#else #else
return 0; uint16_t vid = 0, pid = 0;
if (hnvml) { // may not be initialized on start...
for (int id=0; id < hnvml->nvml_gpucount; id++) {
if (hnvml->nvml_pci_bus_id[id] == pci_bus_id) {
nvml_get_info(hnvml, id, vid, pid);
}
}
}
return translate_vendor_id(vid, vendorname);
#endif #endif
} }

1
x11/x11.cu

@ -231,6 +231,7 @@ extern "C" int scanhash_x11(int thr_id, uint32_t *pdata,
return res; return res;
} else { } else {
applog(LOG_WARNING, "GPU #%d: result for %08x does not validate on CPU!", device_map[thr_id], foundNonce); applog(LOG_WARNING, "GPU #%d: result for %08x does not validate on CPU!", device_map[thr_id], foundNonce);
pdata[19] = foundNonce + 1;
} }
} }

Loading…
Cancel
Save