diff --git a/SettingsForm.cs b/SettingsForm.cs index 654fca4..1b37695 100644 --- a/SettingsForm.cs +++ b/SettingsForm.cs @@ -922,7 +922,7 @@ public bool ApplyTscWorkaround() if (OPS.Ols.Rdmsr(0xC0010015, ref eax, ref edx) != -1) { eax |= 0x200000; - return OPS.Ols.Wrmsr(0xC0010015, eax, edx) != -1; + return OPS.WriteMsr(0xC0010015, eax, edx); } SetStatusText($@"Error applying TSC fix!"); @@ -935,7 +935,7 @@ private bool WritePstateClick(int pstateId, uint eax, uint edx, int numanode = 0 if (!ApplyTscWorkaround()) return false; - if (OPS.Ols.Wrmsr(Convert.ToUInt32(Convert.ToInt64(0xC0010064) + pstateId), eax, edx) != 1) + if (!OPS.WriteMsr(Convert.ToUInt32(Convert.ToInt64(0xC0010064) + pstateId), eax, edx)) { SetStatusText($@"Error writing PState {pstateId}!"); return false; @@ -1081,7 +1081,7 @@ private void ButtonMsrWrite_Click(object sender, EventArgs e) TryConvertToUint(textBoxMsrEax.Text, out uint eax); TryConvertToUint(textBoxMsrAddress.Text, out uint msr); - if (OPS.Ols.Wrmsr(msr, eax, edx) != 1) + if (!OPS.WriteMsr(msr, eax, edx)) { HandleError($@"Error writing MSR {textBoxMsrAddress.Text}!"); return; diff --git a/Utils/Ops.cs b/Utils/Ops.cs index dea49da..b19386e 100644 --- a/Utils/Ops.cs +++ b/Utils/Ops.cs @@ -8,6 +8,7 @@ public class Ops : IDisposable { private static Mutex amdSmuMutex; private const ushort SMU_TIMEOUT = 8192; + private readonly int Threads; public Ops() { @@ -18,6 +19,7 @@ public Ops() CpuType = GetCPUType(GetPkgType()); Smu = GetMaintainedSettings.GetByType(CpuType); Smu.Version = GetSmuVersion(); + Threads = GetCoreCount()[1]; //if (!SendTestMessage()) // throw new ApplicationException("SMU is not responding"); @@ -174,6 +176,18 @@ public uint ReadDword(uint value) return Ols.ReadPciConfigDword(Smu.SMU_PCI_ADDR, (byte)Smu.SMU_OFFSET_DATA); } + public bool WriteMsr(uint msr, uint eax, uint edx) + { + bool res = true; + + for (var i = 0; i < Threads; i++) + { + if (Ols.WrmsrTx(msr, eax, edx, (UIntPtr)(1 << i)) != 1) res = false; + } + + return res; + } + public SMU.CpuFamily GetCpuFamily() { uint eax = 0, ebx = 0, ecx = 0, edx = 0;