@@ -548,7 +548,7 @@ static inline bool amd_pstate_sample(struct amd_cpudata *cpudata)
548548static void amd_pstate_update (struct amd_cpudata * cpudata , u8 min_perf ,
549549 u8 des_perf , u8 max_perf , bool fast_switch , int gov_flags )
550550{
551- struct cpufreq_policy * policy = cpufreq_cpu_get (cpudata -> cpu );
551+ struct cpufreq_policy * policy __free ( put_cpufreq_policy ) = cpufreq_cpu_get (cpudata -> cpu );
552552 u8 nominal_perf = READ_ONCE (cpudata -> nominal_perf );
553553
554554 if (!policy )
@@ -574,8 +574,6 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u8 min_perf,
574574 }
575575
576576 amd_pstate_update_perf (cpudata , min_perf , des_perf , max_perf , 0 , fast_switch );
577-
578- cpufreq_cpu_put (policy );
579577}
580578
581579static int amd_pstate_verify (struct cpufreq_policy_data * policy_data )
@@ -587,15 +585,15 @@ static int amd_pstate_verify(struct cpufreq_policy_data *policy_data)
587585 * amd-pstate qos_requests.
588586 */
589587 if (policy_data -> min == FREQ_QOS_MIN_DEFAULT_VALUE ) {
590- struct cpufreq_policy * policy = cpufreq_cpu_get (policy_data -> cpu );
588+ struct cpufreq_policy * policy __free (put_cpufreq_policy ) =
589+ cpufreq_cpu_get (policy_data -> cpu );
591590 struct amd_cpudata * cpudata ;
592591
593592 if (!policy )
594593 return - EINVAL ;
595594
596595 cpudata = policy -> driver_data ;
597596 policy_data -> min = cpudata -> lowest_nonlinear_freq ;
598- cpufreq_cpu_put (policy );
599597 }
600598
601599 cpufreq_verify_within_cpu_limits (policy_data );
@@ -678,7 +676,7 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
678676 unsigned long capacity )
679677{
680678 u8 max_perf , min_perf , des_perf , cap_perf , min_limit_perf ;
681- struct cpufreq_policy * policy = cpufreq_cpu_get (cpu );
679+ struct cpufreq_policy * policy __free ( put_cpufreq_policy ) = cpufreq_cpu_get (cpu );
682680 struct amd_cpudata * cpudata ;
683681
684682 if (!policy )
@@ -710,7 +708,6 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
710708
711709 amd_pstate_update (cpudata , min_perf , des_perf , max_perf , true,
712710 policy -> governor -> flags );
713- cpufreq_cpu_put (policy );
714711}
715712
716713static int amd_pstate_cpu_boost_update (struct cpufreq_policy * policy , bool on )
@@ -824,28 +821,23 @@ static void amd_pstate_init_prefcore(struct amd_cpudata *cpudata)
824821
825822static void amd_pstate_update_limits (unsigned int cpu )
826823{
827- struct cpufreq_policy * policy = NULL ;
824+ struct cpufreq_policy * policy __free ( put_cpufreq_policy ) = cpufreq_cpu_get ( cpu ) ;
828825 struct amd_cpudata * cpudata ;
829826 u32 prev_high = 0 , cur_high = 0 ;
830- int ret ;
831827 bool highest_perf_changed = false;
832828
833829 if (!amd_pstate_prefcore )
834830 return ;
835831
836- policy = cpufreq_cpu_get (cpu );
837832 if (!policy )
838833 return ;
839834
840- cpudata = policy -> driver_data ;
841-
842835 guard (mutex )(& amd_pstate_driver_lock );
843836
844- ret = amd_get_highest_perf (cpu , & cur_high );
845- if (ret ) {
846- cpufreq_cpu_put (policy );
837+ if (amd_get_highest_perf (cpu , & cur_high ))
847838 return ;
848- }
839+
840+ cpudata = policy -> driver_data ;
849841
850842 prev_high = READ_ONCE (cpudata -> prefcore_ranking );
851843 highest_perf_changed = (prev_high != cur_high );
@@ -855,7 +847,6 @@ static void amd_pstate_update_limits(unsigned int cpu)
855847 if (cur_high < CPPC_MAX_PERF )
856848 sched_set_itmt_core_prio ((int )cur_high , cpu );
857849 }
858- cpufreq_cpu_put (policy );
859850}
860851
861852/*
0 commit comments