@@ -203,8 +203,10 @@ static signed short C1E_Enable = -1;
203203module_param(C1E_Enable, short, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
204204MODULE_PARM_DESC(C1E_Enable, "Enable SpeedStep C1E");
205205
206- static signed short TurboBoost_Enable = -1;
207- module_param(TurboBoost_Enable, short, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
206+ static unsigned int TurboBoost_Enable_Count = 1;
207+ static signed short TurboBoost_Enable[2] = {-1, -1};
208+ module_param_array(TurboBoost_Enable, short, &TurboBoost_Enable_Count, \
209+ S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
208210MODULE_PARM_DESC(TurboBoost_Enable, "Enable Turbo Boost");
209211
210212static signed short C3A_Enable = -1;
@@ -259,6 +261,31 @@ static signed int PState_VID = -1;
259261module_param(PState_VID, int, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
260262MODULE_PARM_DESC(PState_VID, "P-State Voltage Id");
261263
264+ static enum RATIO_BOOST Ratio_Boost_Count = 0;
265+ static signed int Ratio_Boost[BOOST(SIZE) - BOOST(18C)] = {
266+ /* 18C */ -1,
267+ /* 17C */ -1,
268+ /* 16C */ -1,
269+ /* 15C */ -1,
270+ /* 14C */ -1,
271+ /* 13C */ -1,
272+ /* 12C */ -1,
273+ /* 11C */ -1,
274+ /* 10C */ -1,
275+ /* 9C */ -1,
276+ /* 8C */ -1,
277+ /* 7C */ -1,
278+ /* 6C */ -1,
279+ /* 5C */ -1,
280+ /* 4C */ -1,
281+ /* 3C */ -1,
282+ /* 2C */ -1,
283+ /* 1C */ -1
284+ };
285+ module_param_array(Ratio_Boost, int, &Ratio_Boost_Count, \
286+ S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
287+ MODULE_PARM_DESC(Ratio_Boost, "Turbo Boost Frequency ratios");
288+
262289static signed short HWP_Enable = -1;
263290module_param(HWP_Enable, short, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
264291MODULE_PARM_DESC(HWP_Enable, "Hardware-Controlled Performance States");
@@ -267,6 +294,16 @@ static signed short HWP_EPP = -1;
267294module_param(HWP_EPP, short, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
268295MODULE_PARM_DESC(HWP_EPP, "Energy Performance Preference");
269296
297+ static enum RATIO_BOOST Ratio_HWP_Count = 0;
298+ static signed int Ratio_HWP[1 + (BOOST(HWP_TGT) - BOOST(HWP_MIN))] = {
299+ /* HWP_MIN */ -1,
300+ /* HWP_MAX */ -1,
301+ /* HWP_TGT */ -1
302+ };
303+ module_param_array(Ratio_HWP, int, &Ratio_HWP_Count, \
304+ S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
305+ MODULE_PARM_DESC(Ratio_HWP, "Hardware-Controlled Performance ratios");
306+
270307static signed short HDC_Enable = -1;
271308module_param(HDC_Enable, short, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
272309MODULE_PARM_DESC(HDC_Enable, "Hardware Duty Cycling");
@@ -7785,7 +7822,7 @@ void TurboBoost_Technology(CORE_RO *Core, SET_TARGET SetTarget,
77857822 if ( (MiscFeatures.Turbo_IDA == 0)
77867823 && (PUBLIC(RO(Proc))->Features.Power.EAX.TurboIDA) )
77877824 {
7788- switch (TurboBoost_Enable) {
7825+ switch (TurboBoost_Enable[0] ) {
77897826 case COREFREQ_TOGGLE_OFF: /* Restore the nominal P-state */
77907827 Core->PowerThermal.PerfControl.Turbo_IDA = 1;
77917828 SetTarget(Core, Core->Boost[BOOST(MAX)]);
@@ -7876,7 +7913,7 @@ void DynamicAcceleration(CORE_RO *Core) /* Unique */
78767913 MISC_PROC_FEATURES MiscFeatures = {.value = 0};
78777914 RDMSR(MiscFeatures, MSR_IA32_MISC_ENABLE);
78787915
7879- switch (TurboBoost_Enable) {
7916+ switch (TurboBoost_Enable[0] ) {
78807917 case COREFREQ_TOGGLE_OFF:
78817918 MiscFeatures.Turbo_IDA = 1;
78827919 ToggleFeature = 1;
@@ -7932,7 +7969,7 @@ void SoC_Turbo_Override(CORE_RO *Core)
79327969 PKG_TURBO_CONFIG TurboCfg = {.value = 0};
79337970 RDMSR(TurboCfg, MSR_PKG_TURBO_CFG);
79347971
7935- switch (TurboBoost_Enable) {
7972+ switch (TurboBoost_Enable[0] ) {
79367973 case COREFREQ_TOGGLE_OFF:
79377974 TurboCfg.TjMax_Turbo = 0x0;
79387975 ToggleFeature = 1;
@@ -8219,7 +8256,7 @@ void PerCore_Query_AMD_Zen_Features(CORE_RO *Core) /* Per SMT */
82198256 BITCLR_CC(LOCKLESS, PUBLIC(RW(Proc))->SMM, Core->Bind);
82208257 }
82218258 /* Enable or Disable the Core Performance Boost. */
8222- switch (TurboBoost_Enable) {
8259+ switch (TurboBoost_Enable[0] ) {
82238260 case COREFREQ_TOGGLE_OFF:
82248261 HwCfgRegister.Family_17h.CpbDis = 1;
82258262 ToggleFeature = 1;
@@ -18752,9 +18789,9 @@ static int CoreFreqK_SetBoost(int state)
1875218789{
1875318790#endif /* 5.8.0 */
1875418791 Controller_Stop(1);
18755- TurboBoost_Enable = (state != 0);
18792+ TurboBoost_Enable[0] = (state != 0);
1875618793 Controller_Start(1);
18757- TurboBoost_Enable = -1;
18794+ TurboBoost_Enable[0] = -1;
1875818795 Policy_Aggregate_Turbo();
1875918796 BITSET(BUS_LOCK, PUBLIC(RW(Proc))->OS.Signal, NTFY); /* Notify Daemon*/
1876018797 return 0;
@@ -19929,9 +19966,9 @@ static long CoreFreqK_ioctl( struct file *filp,
1992919966 case COREFREQ_TOGGLE_OFF:
1993019967 case COREFREQ_TOGGLE_ON:
1993119968 Controller_Stop(1);
19932- TurboBoost_Enable = prm.dl.lo;
19969+ TurboBoost_Enable[0] = prm.dl.lo;
1993319970 Controller_Start(1);
19934- TurboBoost_Enable = -1;
19971+ TurboBoost_Enable[0] = -1;
1993519972 #ifdef CONFIG_CPU_FREQ
1993619973 Policy_Aggregate_Turbo();
1993719974 #endif /* CONFIG_CPU_FREQ */
@@ -21609,6 +21646,102 @@ static int CoreFreqK_User_Ops_Level_Up(INIT_ARG *pArg)
2160921646{
2161021647 UNUSED(pArg);
2161121648
21649+ if (Ratio_HWP_Count > 0)
21650+ {
21651+ CLOCK_ARG clockMod;
21652+ enum RATIO_BOOST boost;
21653+
21654+ Controller_Stop(1);
21655+ for (boost = 0; boost < Ratio_HWP_Count; boost++)
21656+ {
21657+ if (Ratio_HWP[boost] >= 0)
21658+ {
21659+ long rc = RC_SUCCESS;
21660+
21661+ switch (boost) {
21662+ case BOOST(HWP_MIN) - BOOST(HWP_MIN):
21663+ if (Arch[PUBLIC(RO(Proc))->ArchID].ClockMod) {
21664+ clockMod.Ratio = Ratio_HWP[boost];
21665+ clockMod.cpu = -1;
21666+ clockMod.NC = CLOCK_MOD_HWP_MIN;
21667+ rc = Arch[PUBLIC(RO(Proc))->ArchID].ClockMod(&clockMod);
21668+ #ifdef CONFIG_CPU_FREQ
21669+ Policy_Aggregate_Turbo();
21670+ #endif
21671+ }
21672+ break;
21673+ case BOOST(HWP_MAX) - BOOST(HWP_MIN):
21674+ if (Arch[PUBLIC(RO(Proc))->ArchID].ClockMod) {
21675+ clockMod.Ratio = Ratio_HWP[boost];
21676+ clockMod.cpu = -1;
21677+ clockMod.NC = CLOCK_MOD_HWP_MAX;
21678+ rc = Arch[PUBLIC(RO(Proc))->ArchID].ClockMod(&clockMod);
21679+ #ifdef CONFIG_CPU_FREQ
21680+ Policy_Aggregate_Turbo();
21681+ #endif
21682+ }
21683+ break;
21684+ case BOOST(HWP_TGT) - BOOST(HWP_MIN):
21685+ if (Arch[PUBLIC(RO(Proc))->ArchID].ClockMod) {
21686+ clockMod.Ratio = Ratio_HWP[boost];
21687+ clockMod.cpu = -1;
21688+ clockMod.NC = CLOCK_MOD_HWP_TGT;
21689+ rc = Arch[PUBLIC(RO(Proc))->ArchID].ClockMod(&clockMod);
21690+ #ifdef CONFIG_CPU_FREQ
21691+ Policy_Aggregate_Turbo();
21692+ #endif
21693+ }
21694+ break;
21695+ default:
21696+ rc = -RC_UNIMPLEMENTED;
21697+ break;
21698+ };
21699+ if (rc < RC_SUCCESS) {
21700+ pr_warn("CoreFreq: " \
21701+ "'Ratio_HWP' at #%d Execution failure code %ld\n",
21702+ boost, rc);
21703+ }
21704+ }
21705+ }
21706+ Controller_Start(1);
21707+ }
21708+ if (Ratio_Boost_Count > 0)
21709+ {
21710+ CLOCK_ARG clockMod;
21711+ enum RATIO_BOOST boost;
21712+
21713+ Controller_Stop(1);
21714+ for (boost = 0; boost < Ratio_Boost_Count; boost++)
21715+ {
21716+ if (Ratio_Boost[boost] >= 0)
21717+ {
21718+ long rc = RC_SUCCESS;
21719+
21720+ switch (boost) {
21721+ case BOOST(1C) - BOOST(1C) ... BOOST(1C) - BOOST(18C):
21722+ if (Arch[PUBLIC(RO(Proc))->ArchID].TurboClock) {
21723+ clockMod.Ratio = Ratio_Boost[boost];
21724+ clockMod.cpu = -1;
21725+ clockMod.NC = BOOST(SIZE) - BOOST(18C) - boost;
21726+ rc = Arch[PUBLIC(RO(Proc))->ArchID].TurboClock(&clockMod);
21727+ }
21728+ break;
21729+ default:
21730+ rc = -RC_UNIMPLEMENTED;
21731+ break;
21732+ };
21733+ if (rc < RC_SUCCESS) {
21734+ pr_warn("CoreFreq: " \
21735+ "'Ratio_Boost' at #%d Execution failure code %ld\n",
21736+ boost, rc);
21737+ }
21738+ }
21739+ }
21740+ if (TurboBoost_Enable_Count == 2) {
21741+ TurboBoost_Enable[0] = TurboBoost_Enable[1];
21742+ }
21743+ Controller_Start(1);
21744+ }
2161221745 if (PUBLIC(RO(Proc))->ArchID != AMD_Family_0Fh)
2161321746 {
2161421747 const unsigned int cpu = PUBLIC(RO(Proc))->Service.Core;
0 commit comments