sysclk: revise cpu volt bugfix, now fully fixes the bug

This commit is contained in:
souldbminersmwc
2026-01-02 13:30:07 -05:00
parent ca72c1fc5e
commit 82f57ee702
4 changed files with 44 additions and 11 deletions

View File

@@ -64,6 +64,8 @@ typedef enum {
HorizonOCConfigValue_OverwriteRefreshRate,
HocClkConfigValue_FixCpuVoltBug,
KipConfigValue_custRev,
KipConfigValue_mtcConf,
KipConfigValue_hpMode,
@@ -235,6 +237,9 @@ static inline const char* sysclkFormatConfigValue(SysClkConfigValue val, bool pr
case HorizonOCConfigValue_OverwriteRefreshRate:
return pretty ? "Display Refresh Rate Changing" : "drr_changing";
case HocClkConfigValue_FixCpuVoltBug:
return pretty ? "Fix CPU Volt Bug" : "cpu_volt_bugfix";
// KIP config values
case KipConfigValue_custRev:
return pretty ? "Custom Revision" : "kip_cust_rev";
@@ -403,6 +408,8 @@ static inline uint64_t sysclkDefaultConfigValue(SysClkConfigValue val)
case HocClkConfigValue_UncappedClocks:
case HocClkConfigValue_OverwriteBoostMode:
case HocClkConfigValue_KipFileName:
case HorizonOCConfigValue_BatteryChargeCurrent:
case HorizonOCConfigValue_OverwriteRefreshRate:
return 0ULL;
case HocClkConfigValue_EristaMaxCpuClock:
return 1785ULL;
@@ -422,6 +429,7 @@ static inline uint64_t sysclkDefaultConfigValue(SysClkConfigValue val)
case HocClkConfigValue_HandheldTDP:
case HocClkConfigValue_EnforceBoardLimit:
case HocClkConfigValue_KipEditing:
case HocClkConfigValue_FixCpuVoltBug:
return 1ULL;
case HocClkConfigValue_ThermalThrottleThreshold:
return 70ULL;
@@ -429,9 +437,6 @@ static inline uint64_t sysclkDefaultConfigValue(SysClkConfigValue val)
return 8600ULL;
case HocClkConfigValue_LiteTDPLimit:
return 6400ULL;
case HorizonOCConfigValue_BatteryChargeCurrent:
case HorizonOCConfigValue_OverwriteRefreshRate:
return 0ULL;
default:
return 0ULL;
}
@@ -465,6 +470,7 @@ static inline uint64_t sysclkValidConfigValue(SysClkConfigValue val, uint64_t in
case HocClkConfigValue_KipEditing:
case HocClkConfigValue_KipFileName:
case HorizonOCConfigValue_OverwriteRefreshRate:
case HocClkConfigValue_FixCpuVoltBug:
return (input & 0x1) == input;
case KipConfigValue_custRev:

View File

@@ -264,6 +264,7 @@ void MiscGui::listUI()
addConfigToggle(HocClkConfigValue_UncappedClocks, nullptr);
addConfigToggle(HocClkConfigValue_OverwriteBoostMode, nullptr);
addConfigToggle(HocClkConfigValue_FixCpuVoltBug, nullptr);
addConfigToggle(HocClkConfigValue_ThermalThrottle, nullptr);
addConfigToggle(HocClkConfigValue_HandheldTDP, nullptr);

View File

@@ -101,7 +101,6 @@ ClockManager::ClockManager()
);
threadStart(&governorTHREAD);
FixCpuBug();
this->context->speedos[HorizonOCSpeedo_CPU] = Board::getCPUSpeedo();
this->context->speedos[HorizonOCSpeedo_GPU] = Board::getGPUSpeedo();
@@ -111,16 +110,33 @@ ClockManager::ClockManager()
void ClockManager::FixCpuBug() {
Board::SetHz(SysClkModule_CPU, 1785000000); // this will just set to the max when kip is unloaded so idgaf
svcSleepThread(5'000'000);
Board::SetHz(SysClkModule_CPU, 1963000000);
svcSleepThread(5'000'000);
Board::SetHz(SysClkModule_CPU, 2091000000);
svcSleepThread(5'000'000);
Board::SetHz(SysClkModule_CPU, 2397000000);
svcSleepThread(5'000'000);
Board::SetHz(SysClkModule_CPU, 1020000000);
svcSleepThread(5'000'000);
ResetToStockClocks();
u32 targetHz = 0;
u32 maxHz = 0;
u32 nearestHz = 0;
targetHz = this->context->overrideFreqs[SysClkModule_CPU];
if (!targetHz)
{
targetHz = this->config->GetAutoClockHz(this->context->applicationId, SysClkModule_CPU, this->context->profile, false);
if(!targetHz)
targetHz = this->config->GetAutoClockHz(GLOBAL_PROFILE_ID, SysClkModule_CPU, this->context->profile, false);
}
if (targetHz)
{
maxHz = this->GetMaxAllowedHz(SysClkModule_CPU, this->context->profile);
nearestHz = this->GetNearestHz(SysClkModule_CPU, targetHz, maxHz);
if (nearestHz != this->context->freqs[SysClkModule_CPU] && this->context->enabled) {
Board::SetHz(SysClkModule_CPU, nearestHz);
this->context->freqs[SysClkModule_CPU] = nearestHz;
}
}
}
ClockManager::~ClockManager()
@@ -387,6 +403,8 @@ void ClockManager::GovernorThread(void* arg)
}
}
bool prevBoostMode = true;
void ClockManager::Tick()
{
std::scoped_lock lock{this->contextMutex};
@@ -401,12 +419,12 @@ void ClockManager::Tick()
if(this->config->GetConfigValue(HocClkConfigValue_HandheldTDP) && opMode == AppletOperationMode_Handheld) {
if(Board::GetConsoleType() == HorizonOCConsoleType_Lite) {
if(Board::GetPowerMw(SysClkPowerSensor_Now) < -(int)this->config->GetConfigValue(HocClkConfigValue_LiteTDPLimit)) {
if(Board::GetPowerMw(SysClkPowerSensor_Avg) < -(int)this->config->GetConfigValue(HocClkConfigValue_LiteTDPLimit)) {
ResetToStockClocks();
return;
}
} else {
if(Board::GetPowerMw(SysClkPowerSensor_Now) < -(int)this->config->GetConfigValue(HocClkConfigValue_HandheldTDPLimit)) {
if(Board::GetPowerMw(SysClkPowerSensor_Avg) < -(int)this->config->GetConfigValue(HocClkConfigValue_HandheldTDPLimit)) {
ResetToStockClocks();
return;
}
@@ -417,6 +435,14 @@ void ClockManager::Tick()
ResetToStockClocks();
return;
}
bool isBoost = apmExtIsBoostMode(mode);
if (prevBoostMode && !isBoost) {
if(this->config->GetConfigValue(HocClkConfigValue_FixCpuVoltBug))
FixCpuBug();
}
prevBoostMode = isBoost;
bool noGPU = false;