Skip to content

Commit

Permalink
[CR] Optimize AMD temperature filtering function
Browse files Browse the repository at this point in the history
  • Loading branch information
cyring committed Jul 29, 2024
1 parent 6ab42d0 commit 0308f9b
Showing 1 changed file with 26 additions and 39 deletions.
65 changes: 26 additions & 39 deletions x86_64/corefreqk.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright (C) 2015-2024 CYRIL COURTIAT
* Licenses: GPL2
*
* Upadacitinib [07.29.2024]
* Infliximab [11.17.2023]
* Vedolizumab [05.25.2023]
*
Expand Down Expand Up @@ -16175,27 +16176,34 @@ static void Core_AMD_Family_17h_ThermTrip(CORE_RO *Core)
(Bit64)ThermTrip.CTF_THRESHOLD << LSHIFT_CRITIC_TMP;
}

static void CTL_AMD_Family_17h_Temp(CORE_RO *Core)
static void Core_AMD_Zen_Filter_Temp( CORE_RO *Core, unsigned int CurTmp,
bool scaleRangeSel )
{
TCTL_REGISTER TctlSensor = {.value = 0};

Core_AMD_SMN_Read( TctlSensor,
SMU_AMD_THM_TCTL_REGISTER_F17H,
PRIVATE(OF(Zen)).Device.DF );

Core->PowerThermal.Sensor = TctlSensor.CurTmp;

if ((TctlSensor.CurTempRangeSel == 1)
&& (Core->PowerThermal.Sensor >= (49 << 3)))
{
/* Register: SMU::THM::THM_TCON_CUR_TMP - Bit 19: CUR_TEMP_RANGE_SEL
0 = Report on 0C to 225C scale range.
1 = Report on -49C to 206C scale range.
*/
Core->PowerThermal.Sensor = CurTmp;

if ((scaleRangeSel == true)
&& (Core->PowerThermal.Sensor >= (49 << 3)))
{
Core->PowerThermal.Param.Offset[THERMAL_OFFSET_P1] = 49;
} else {
Core->PowerThermal.Param.Offset[THERMAL_OFFSET_P1] = 0;
}
}

static void CTL_AMD_Family_17h_Temp(CORE_RO *Core)
{
TCTL_REGISTER TctlSensor = {.value = 0};

Core_AMD_SMN_Read( TctlSensor,
SMU_AMD_THM_TCTL_REGISTER_F17H,
PRIVATE(OF(Zen)).Device.DF );

Core_AMD_Zen_Filter_Temp( Core, TctlSensor.CurTmp,
TctlSensor.CurTempRangeSel == 1 );

Core_AMD_Family_17h_ThermTrip(Core);
}
Expand All @@ -16209,15 +16217,8 @@ static void CCD_AMD_Family_17h_Zen2_Temp(CORE_RO *Core)
+ (Core->T.Cluster.CCD << 2)),
PRIVATE(OF(Zen)).Device.DF );

Core->PowerThermal.Sensor = TccdSensor.CurTmp;

if ((TccdSensor.CurTempRangeSel == 1)
&& (Core->PowerThermal.Sensor >= (49 << 3)))
{
Core->PowerThermal.Param.Offset[THERMAL_OFFSET_P1] = 49;
} else {
Core->PowerThermal.Param.Offset[THERMAL_OFFSET_P1] = 0;
}
Core_AMD_Zen_Filter_Temp( Core, TccdSensor.CurTmp,
TccdSensor.CurTempRangeSel == 1 );

Core_AMD_Family_17h_ThermTrip(Core);
}
Expand All @@ -16238,15 +16239,8 @@ static void CCD_AMD_Family_19h_Genoa_Temp(CORE_RO *Core)
+ (Core->T.Cluster.CCD << 2)),
PRIVATE(OF(Zen)).Device.DF );

Core->PowerThermal.Sensor = TccdSensor.CurTmp;

if ((TccdSensor.CurTempRangeSel == 1)
&& (Core->PowerThermal.Sensor >= (49 << 3)))
{
Core->PowerThermal.Param.Offset[THERMAL_OFFSET_P1] = 49;
} else {
Core->PowerThermal.Param.Offset[THERMAL_OFFSET_P1] = 0;
}
Core_AMD_Zen_Filter_Temp( Core, TccdSensor.CurTmp,
TccdSensor.CurTempRangeSel == 1 );

Core_AMD_Family_17h_ThermTrip(Core);
}
Expand All @@ -16260,15 +16254,8 @@ static void CCD_AMD_Family_19h_Zen4_Temp(CORE_RO *Core)
+ (Core->T.Cluster.CCD << 2)),
PRIVATE(OF(Zen)).Device.DF );

Core->PowerThermal.Sensor = TccdSensor.CurTmp;

if ((TccdSensor.CurTempRangeSel == 1)
&& (Core->PowerThermal.Sensor >= (49 << 3)))
{
Core->PowerThermal.Param.Offset[THERMAL_OFFSET_P1] = 49;
} else {
Core->PowerThermal.Param.Offset[THERMAL_OFFSET_P1] = 0;
}
Core_AMD_Zen_Filter_Temp( Core, TccdSensor.CurTmp,
TccdSensor.CurTempRangeSel == 1 );

Core_AMD_Family_17h_ThermTrip(Core);
}
Expand Down

0 comments on commit 0308f9b

Please sign in to comment.