Skip to content
Open

Dev #55

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions linux/AmdMemTweak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include <unistd.h> // close lseek read write
#include <fcntl.h> // open
#include <dirent.h> // opendir readdir closedir

#include <regex.h>
extern "C" {
#include "pci/pci.h" // full path /usr/local/include/pci/pci.h
}
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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(&regex, "(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(&regex, buffer, 0, NULL, 0) == 0) {
continue;
}
if (IsAmdDisplayDevice(dev))
{
gpus[gpuCount++].dev = dev;
}
}
regfree(&regex);

if (gpuCount == 0)
{
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down