From 20bf5bb1f70e39ee261f3190ef271749a7a00edc Mon Sep 17 00:00:00 2001 From: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com> Date: Tue, 14 Mar 2023 17:29:28 +0100 Subject: [PATCH] Check if ADL overdrive caps method exists and InpOut opened OK. --- LibreHardwareMonitorLib/Hardware/Gpu/AmdGpu.cs | 3 ++- LibreHardwareMonitorLib/Hardware/RyzenSMU.cs | 9 +-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/LibreHardwareMonitorLib/Hardware/Gpu/AmdGpu.cs b/LibreHardwareMonitorLib/Hardware/Gpu/AmdGpu.cs index a7e6cf9..b3e6e34 100644 --- a/LibreHardwareMonitorLib/Hardware/Gpu/AmdGpu.cs +++ b/LibreHardwareMonitorLib/Hardware/Gpu/AmdGpu.cs @@ -140,7 +140,8 @@ internal sealed class AmdGpu : GenericGpu ActivateSensor(_fullscreenFps); } - if (AtiAdlxx.ADL_Overdrive_Caps(_adapterInfo.AdapterIndex, ref supported, ref enabled, ref version) == AtiAdlxx.ADLStatus.ADL_OK) + if (AtiAdlxx.ADL_Method_Exists(nameof(AtiAdlxx.ADL_Overdrive_Caps)) && + AtiAdlxx.ADL_Overdrive_Caps(_adapterInfo.AdapterIndex, ref supported, ref enabled, ref version) == AtiAdlxx.ADLStatus.ADL_OK) { _overdriveApiSupported = supported == AtiAdlxx.ADL_TRUE; _currentOverdriveApiLevel = version; diff --git a/LibreHardwareMonitorLib/Hardware/RyzenSMU.cs b/LibreHardwareMonitorLib/Hardware/RyzenSMU.cs index 9e1b8ac..66481d2 100644 --- a/LibreHardwareMonitorLib/Hardware/RyzenSMU.cs +++ b/LibreHardwareMonitorLib/Hardware/RyzenSMU.cs @@ -162,11 +162,8 @@ internal class RyzenSMU _supportedCPU = Environment.Is64BitOperatingSystem == Environment.Is64BitProcess && SetAddresses(_cpuCodeName); - if (_supportedCPU) - { - InpOut.Open(); + if (_supportedCPU && InpOut.Open()) SetupPmTableAddrAndSize(); - } } private static CpuCodeName GetCpuCodeName(uint family, uint model, uint packageType) @@ -706,9 +703,7 @@ internal class RyzenSMU if (Ring0.WaitPciBusMutex(10)) { if (Ring0.WritePciConfig(0x00, SMU_PCI_ADDR_REG, addr)) - { Ring0.WritePciConfig(0x00, SMU_PCI_DATA_REG, data); - } Ring0.ReleasePciBusMutex(); } @@ -721,9 +716,7 @@ internal class RyzenSMU if (Ring0.WaitPciBusMutex(10)) { if (Ring0.WritePciConfig(0x00, SMU_PCI_ADDR_REG, addr)) - { read = Ring0.ReadPciConfig(0x00, SMU_PCI_DATA_REG, out data); - } Ring0.ReleasePciBusMutex(); }