diff --git a/PowerControl/Helpers/AMD/VangoghGPU.cs b/PowerControl/Helpers/AMD/VangoghGPU.cs index 88b043d..56e10f2 100644 --- a/PowerControl/Helpers/AMD/VangoghGPU.cs +++ b/PowerControl/Helpers/AMD/VangoghGPU.cs @@ -1,5 +1,6 @@ using CommonHelpers; using System.Diagnostics; +using static CommonHelpers.Log; using Device = System.Tuple; namespace PowerControl.Helpers.AMD @@ -35,7 +36,14 @@ namespace PowerControl.Helpers.AMD return OpenMMIO(new IntPtr((long)device.Item2), (uint)(device.Item3 - device.Item2 + 1)); } - public static bool Detect() + public enum DetectionStatus + { + Detected, + Retryable, + NotDetected + } + + public static DetectionStatus Detect() { var discoveredDevices = new Dictionary(); @@ -61,12 +69,17 @@ namespace PowerControl.Helpers.AMD var ranges = DeviceManager.GetDeviceMemResources(devicePNP); if (ranges is null) { - TraceLine("GPU: {0}: {1}: No memory ranges", deviceName, devicePNP); + TraceError("GPU: {0}: {1}: No memory ranges", deviceName, devicePNP); continue; } - if (!ranges.Contains(new Tuple(new UIntPtr(device.Item2), new UIntPtr(device.Item3)))) + var expectedRange = new Tuple(new UIntPtr(device.Item2), new UIntPtr(device.Item3)); + if (!ranges.Contains(expectedRange)) { - TraceLine("GPU: {0}: {1}: Memory range not found", deviceName, devicePNP); + TraceError("GPU: {0}: {1}: Memory range not found: {2}", + deviceName, + devicePNP, + String.Join(",", ranges.Select((item) => item.ToString())) + ); continue; } @@ -74,24 +87,24 @@ namespace PowerControl.Helpers.AMD { if (gpu is null) { - TraceLine("GPU: {0}: {1}: Failed to open.", deviceName, devicePNP); + TraceError("GPU: {0}: {1}: Failed to open.", deviceName, devicePNP); continue; } var smuVersion = gpu.SMUVersion; if (smuVersion != device.Item4) { - TraceLine("GPU: {0}: {1}: SMU not supported: {2:X8}", deviceName, devicePNP, smuVersion); - continue; + TraceError("GPU: {0}: {1}: SMU not supported: {2:X8} (IO: {3})", deviceName, devicePNP, smuVersion, expectedRange); + return DetectionStatus.Retryable; } TraceLine("GPU: {0}: Matched!", deviceName); DetectedDevice = device; - return true; + return DetectionStatus.Detected; } } DetectedDevice = null; - return false; + return DetectionStatus.Detected; } // Addresses: @@ -441,10 +454,5 @@ namespace PowerControl.Helpers.AMD CC6_BIT = 58, GFX_EDC_BIT = 59 } - - private static void TraceLine(string format, params object?[]? arg) - { - Trace.WriteLine(string.Format(format, arg)); - } } } diff --git a/PowerControl/Program.cs b/PowerControl/Program.cs index 216d822..2c331d4 100644 --- a/PowerControl/Program.cs +++ b/PowerControl/Program.cs @@ -8,6 +8,8 @@ namespace PowerControl { internal static class Program { + const int MAX_GPU_RETRIES = 3; + /// /// The main entry point for the application. /// @@ -24,11 +26,13 @@ namespace PowerControl "You are running EXPERIMENTAL build.")) return; - for (int i = 0; !VangoghGPU.IsSupported; i++) + for (int i = 0; !VangoghGPU.IsSupported && i < MAX_GPU_RETRIES; i++) { - Instance.WithGlobalMutex(1000, () => VangoghGPU.Detect()); - if (VangoghGPU.IsSupported) - Thread.Sleep(300); + var status = Instance.WithGlobalMutex(1000, () => VangoghGPU.Detect()); + if (status != VangoghGPU.DetectionStatus.Retryable) + break; + + Thread.Sleep(300); } } diff --git a/RELEASE.md b/RELEASE.md index 80d9257..9bbf2a3 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -16,7 +16,8 @@ - Use `white` icons when using `Dark Theme` (thanks @maniman303 https://github.com/ayufan/steam-deck-tools/pull/23) - Validate that all dependencies are installed - Allow `Updater.exe` to disable automatic updates - this is selectable option via `setup.exe` -- Use `Sentry.io` for error tracking +- Use `Sentry.io` for error tracking for all builds - Make `Updater.exe` to be able to update from `.zip` to `setup.exe` - Bug fixing to handle all known exceptions - Require to acknowledge when using function that might trigger `Anti-Cheat` protection via top-most window +- GPU detection will log errors to `Sentry.io`