From f39b4506fe4bb35b8cb68f23626ba5d5060913a8 Mon Sep 17 00:00:00 2001 From: Visual Ehrmanntraut <30368284+VisualEhrmanntraut@users.noreply.github.com> Date: Sun, 3 Dec 2023 13:18:31 +0200 Subject: [PATCH] Fix spurious panic in sendMsgToSmc on some machines Signed-off-by: Visual Ehrmanntraut <30368284+VisualEhrmanntraut@users.noreply.github.com> --- NootedRed/NRed.hpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/NootedRed/NRed.hpp b/NootedRed/NRed.hpp index 32bc0a80..eea24a9c 100644 --- a/NootedRed/NRed.hpp +++ b/NootedRed/NRed.hpp @@ -173,26 +173,26 @@ class NRed { } } - UInt32 sendMsgToSmc(UInt32 msg, UInt32 param = 0) { - auto smuWaitForResp = [=]() { - UInt32 ret = 0; - for (UInt32 i = 0; i < AMDGPU_MAX_USEC_TIMEOUT; i++) { - ret = this->readReg32(MP_BASE + mmMP1_SMN_C2PMSG_90); - if (ret) return ret; + UInt32 smuWaitForResponse() { + UInt32 ret = 0; + for (UInt32 i = 0; i < AMDGPU_MAX_USEC_TIMEOUT; i++) { + ret = this->readReg32(MP_BASE + mmMP1_SMN_C2PMSG_90); + if (ret) return ret; - IOSleep(1); - } + IOSleep(1); + } - return ret; - }; + return ret; + } - PANIC_COND(smuWaitForResp() != 1, "NRed", "Msg issuing pre-check failed; SMU may be in an improper state"); + UInt32 sendMsgToSmc(UInt32 msg, UInt32 param = 0) { + this->smuWaitForResponse(); this->writeReg32(MP_BASE + mmMP1_SMN_C2PMSG_90, 0); this->writeReg32(MP_BASE + mmMP1_SMN_C2PMSG_82, param); this->writeReg32(MP_BASE + mmMP1_SMN_C2PMSG_66, msg); - SYSLOG_COND(smuWaitForResp() == 0, "NRed", "No response from SMU"); + SYSLOG_COND(this->smuWaitForResponse() == 0, "NRed", "No response from SMU"); return this->readReg32(MP_BASE + mmMP1_SMN_C2PMSG_82); }