Explicitly save previous power limits

This commit is contained in:
IceStormNG
2024-03-02 13:26:37 +01:00
parent 89de581e1f
commit b104d852c7
4 changed files with 17 additions and 7 deletions

View File

@@ -299,6 +299,8 @@ namespace GHelper.AutoTDP
tdpThread = new Thread(() =>
{
CurrentTDP = powerLimiter.GetCPUPowerLimit();
powerLimiter.SavePowerLimits(); // save current power limits to restore them afterwards
LowestStableTDP = profile.MaxTdp;
LowestTDP = profile.MaxTdp;

View File

@@ -13,6 +13,11 @@ namespace GHelper.AutoTDP.PowerLimiter
private int DefaultC1 = 0;
public ASUSACPIPowerLimiter()
{
}
public void SavePowerLimits()
{
DefaultA0 = Program.acpi.DeviceGet(AsusACPI.PPT_APUA0);
DefaultA3 = Program.acpi.DeviceGet(AsusACPI.PPT_APUA3);

View File

@@ -8,5 +8,7 @@
public void ResetPowerLimits();
public void SavePowerLimits();
}
}

View File

@@ -27,6 +27,14 @@ namespace GHelper.AutoTDP.PowerLimiter
ReadPowerUnit();
}
public void SavePowerLimits()
{
DefaultEax = 0;
DefaultEdx = 0;
ols.Rdmsr(MSR_PKG_POWER_LIMIT, ref DefaultEax, ref DefaultEdx);
}
public void ReadPowerUnit()
{
uint eax = 0;
@@ -72,13 +80,6 @@ namespace GHelper.AutoTDP.PowerLimiter
ols.Rdmsr(MSR_PKG_POWER_LIMIT, ref eax, ref edx);
if (DefaultEax == 0)
{
//Store default settings to reset them on exit
DefaultEax = eax;
DefaultEdx = edx;
}
uint pl1 = eax & PL1_MASK;
uint pl2 = edx & PL2_MASK;