From fdfaa8cdeebc665d8474c0b71979ef060136d138 Mon Sep 17 00:00:00 2001 From: brock Date: Tue, 16 Mar 2021 10:42:30 +0800 Subject: [PATCH 1/3] - skip amd apu - support 580sp --- linux/AmdMemTweak.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/linux/AmdMemTweak.cpp b/linux/AmdMemTweak.cpp index f28ff54..271002c 100644 --- a/linux/AmdMemTweak.cpp +++ b/linux/AmdMemTweak.cpp @@ -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] @@ -1481,6 +1482,7 @@ int main(int argc, const char* argv[]) if (IsAmdDisplayDevice(dev)) { gpus[gpuCount++].dev = dev; + printf("IsAmdDisplayDevice!\n"); } } @@ -1506,6 +1508,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 +1517,7 @@ int main(int argc, const char* argv[]) if (gpu->mmio == -1) { fprintf(stderr, "Failed to open %s\n", buffer); + // continue; return 1; } @@ -1611,8 +1615,10 @@ int main(int argc, const char* argv[]) 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); + fprintf(stdout, "pci_lookup_name: %s\n", name); if (gpu->dev && IsRelevantDeviceID(gpu->dev)) { + fprintf(stdout, "current 0: \n"); u64 affectedGPUs = 0xFFFFFFFFFFFFFFFF; // apply to all GPUs by default for (int i = 1; i < argc; i++) { @@ -1628,6 +1634,7 @@ int main(int argc, const char* argv[]) } else if (!strcasecmp("--current", argv[i]) || !strcasecmp("--c", argv[i])) { + fprintf(stdout, "current 1: \n"); if (affectedGPUs & ((u64)1 << index)) { std::cout << "GPU " << index << ": "; @@ -1637,6 +1644,7 @@ int main(int argc, const char* argv[]) } else if (affectedGPUs & ((u64)1 << index)) { + fprintf(stdout, "current 2: \n"); u32 value = 0; if (DetermineMemoryType(gpu->dev) == HBM2) { @@ -2615,6 +2623,7 @@ int main(int argc, const char* argv[]) } else // GDDR5 { + fprintf(stdout, "current 3: \n"); if (ParseNumericArg(argc, argv, i, "--DAT_DLY0", value)) { gpu->ctl1.rx.DAT_DLY = value; From 9cde386d50647bdff95bcefd868e716867163df3 Mon Sep 17 00:00:00 2001 From: brock Date: Tue, 16 Mar 2021 15:10:28 +0800 Subject: [PATCH 2/3] - skip amd apu - support 580sp --- linux/AmdMemTweak.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/linux/AmdMemTweak.cpp b/linux/AmdMemTweak.cpp index 271002c..29c3a49 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 } @@ -1476,15 +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; - printf("IsAmdDisplayDevice!\n"); } } + regfree(®ex); if (gpuCount == 0) { @@ -1593,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); From 536d24f2675deb16ea2f890aaf939a2dd597e3bb Mon Sep 17 00:00:00 2001 From: brock Date: Tue, 16 Mar 2021 15:17:43 +0800 Subject: [PATCH 3/3] del debug printers --- linux/AmdMemTweak.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/linux/AmdMemTweak.cpp b/linux/AmdMemTweak.cpp index 29c3a49..0990fc6 100644 --- a/linux/AmdMemTweak.cpp +++ b/linux/AmdMemTweak.cpp @@ -1625,10 +1625,8 @@ int main(int argc, const char* argv[]) 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); - fprintf(stdout, "pci_lookup_name: %s\n", name); if (gpu->dev && IsRelevantDeviceID(gpu->dev)) { - fprintf(stdout, "current 0: \n"); u64 affectedGPUs = 0xFFFFFFFFFFFFFFFF; // apply to all GPUs by default for (int i = 1; i < argc; i++) { @@ -1644,7 +1642,6 @@ int main(int argc, const char* argv[]) } else if (!strcasecmp("--current", argv[i]) || !strcasecmp("--c", argv[i])) { - fprintf(stdout, "current 1: \n"); if (affectedGPUs & ((u64)1 << index)) { std::cout << "GPU " << index << ": "; @@ -1654,7 +1651,6 @@ int main(int argc, const char* argv[]) } else if (affectedGPUs & ((u64)1 << index)) { - fprintf(stdout, "current 2: \n"); u32 value = 0; if (DetermineMemoryType(gpu->dev) == HBM2) { @@ -2633,7 +2629,6 @@ int main(int argc, const char* argv[]) } else // GDDR5 { - fprintf(stdout, "current 3: \n"); if (ParseNumericArg(argc, argv, i, "--DAT_DLY0", value)) { gpu->ctl1.rx.DAT_DLY = value;