Skip to content

Commit

Permalink
Fix spurious panic in sendMsgToSmc on some machines
Browse files Browse the repository at this point in the history
Signed-off-by: Visual Ehrmanntraut <[email protected]>
  • Loading branch information
VisualEhrmanntraut committed Dec 3, 2023
1 parent 0cb78d7 commit f39b450
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions NootedRed/NRed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit f39b450

Please sign in to comment.