diff --git a/linux/AmdMemTweak.cpp b/linux/AmdMemTweak.cpp index f28ff54..0990fc6 100644 --- a/linux/AmdMemTweak.cpp +++ b/linux/AmdMemTweak.cpp @@ -31,7 +31,7 @@ #include // close lseek read write #include // open #include // opendir readdir closedir - +#include extern "C" { #include "pci/pci.h" // full path /usr/local/include/pci/pci.h } @@ -71,6 +71,7 @@ bool IsRelevantDeviceID(struct pci_dev* dev) (dev->device_id == 0x6867) || // Vega 10 XL [Radeon Pro Vega 56] (dev->device_id == 0x6863) || // Vega 10 XTX [Radeon Vega Frontier Edition] (dev->device_id == 0x67df) || // Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] + (dev->device_id == 0x6fdf) || // Ellesmere [Radeon RX 580SP] (dev->device_id == 0x67c4) || // Ellesmere [Radeon Pro WX 7100] (dev->device_id == 0x67c7) || // Ellesmere [Radeon Pro WX 5100] (dev->device_id == 0x67ef) || // Baffin [Radeon RX 460/560D / Pro 450/455/460/555/555X/560/560X] @@ -1475,14 +1476,25 @@ int main(int argc, const char* argv[]) pci_init(pci); pci_scan_bus(pci); int gpuCount = 0; + regex_t regex; + if (regcomp(®ex, "(Kaveri|Beavercreek|Sumo|Wrestler|Kabini|Mullins|Temash|Trinity|Richland|Stoney|Carrizo|Raven)", REG_ICASE | REG_EXTENDED) != 0){ + fprintf(stderr, "regcomp: error"); + return 1; + } for (struct pci_dev* dev = pci->devices; dev; dev = dev->next) { pci_fill_info(dev, PCI_FILL_IDENT | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES | PCI_FILL_CLASS); + char buffer[1024]; + char* name = pci_lookup_name(pci, buffer, sizeof(buffer), PCI_LOOKUP_DEVICE, dev->vendor_id, dev->device_id); + if (regexec(®ex, buffer, 0, NULL, 0) == 0) { + continue; + } if (IsAmdDisplayDevice(dev)) { gpus[gpuCount++].dev = dev; } } + regfree(®ex); if (gpuCount == 0) { @@ -1506,6 +1518,7 @@ int main(int argc, const char* argv[]) if (instance == -1) { fprintf(stderr, "Cannot find DRI instance for pci:%s\n", buffer); + continue; return 1; } @@ -1514,6 +1527,7 @@ int main(int argc, const char* argv[]) if (gpu->mmio == -1) { fprintf(stderr, "Failed to open %s\n", buffer); + // continue; return 1; } @@ -1589,8 +1603,8 @@ int main(int argc, const char* argv[]) for (int index = 0; index < gpuCount; index++) { GPU* gpu = &gpus[index]; - char buffer[1024]; - char* name = pci_lookup_name(pci, buffer, sizeof(buffer), PCI_LOOKUP_DEVICE, gpu->dev->vendor_id, gpu->dev->device_id); + // char buffer[1024]; + // char* name = pci_lookup_name(pci, buffer, sizeof(buffer), PCI_LOOKUP_DEVICE, gpu->dev->vendor_id, gpu->dev->device_id); if (gpu->dev && IsRelevantDeviceID(gpu->dev)) { printf("Scanning GPU %d\n", index);