@@ -73,20 +73,17 @@ static unsigned int acpi_pstate_strict;
7373
7474static bool boost_state (unsigned int cpu )
7575{
76- u32 lo , hi ;
7776 u64 msr ;
7877
7978 switch (boot_cpu_data .x86_vendor ) {
8079 case X86_VENDOR_INTEL :
8180 case X86_VENDOR_CENTAUR :
8281 case X86_VENDOR_ZHAOXIN :
83- rdmsr_on_cpu (cpu , MSR_IA32_MISC_ENABLE , & lo , & hi );
84- msr = lo | ((u64 )hi << 32 );
82+ rdmsrl_on_cpu (cpu , MSR_IA32_MISC_ENABLE , & msr );
8583 return !(msr & MSR_IA32_MISC_ENABLE_TURBO_DISABLE );
8684 case X86_VENDOR_HYGON :
8785 case X86_VENDOR_AMD :
88- rdmsr_on_cpu (cpu , MSR_K7_HWCR , & lo , & hi );
89- msr = lo | ((u64 )hi << 32 );
86+ rdmsrl_on_cpu (cpu , MSR_K7_HWCR , & msr );
9087 return !(msr & MSR_K7_HWCR_CPB_DIS );
9188 }
9289 return false;
@@ -626,7 +623,14 @@ static int acpi_cpufreq_blacklist(struct cpuinfo_x86 *c)
626623#endif
627624
628625#ifdef CONFIG_ACPI_CPPC_LIB
629- static u64 get_max_boost_ratio (unsigned int cpu )
626+ /*
627+ * get_max_boost_ratio: Computes the max_boost_ratio as the ratio
628+ * between the highest_perf and the nominal_perf.
629+ *
630+ * Returns the max_boost_ratio for @cpu. Returns the CPPC nominal
631+ * frequency via @nominal_freq if it is non-NULL pointer.
632+ */
633+ static u64 get_max_boost_ratio (unsigned int cpu , u64 * nominal_freq )
630634{
631635 struct cppc_perf_caps perf_caps ;
632636 u64 highest_perf , nominal_perf ;
@@ -655,6 +659,9 @@ static u64 get_max_boost_ratio(unsigned int cpu)
655659
656660 nominal_perf = perf_caps .nominal_perf ;
657661
662+ if (nominal_freq )
663+ * nominal_freq = perf_caps .nominal_freq * 1000 ;
664+
658665 if (!highest_perf || !nominal_perf ) {
659666 pr_debug ("CPU%d: highest or nominal performance missing\n" , cpu );
660667 return 0 ;
@@ -667,8 +674,12 @@ static u64 get_max_boost_ratio(unsigned int cpu)
667674
668675 return div_u64 (highest_perf << SCHED_CAPACITY_SHIFT , nominal_perf );
669676}
677+
670678#else
671- static inline u64 get_max_boost_ratio (unsigned int cpu ) { return 0 ; }
679+ static inline u64 get_max_boost_ratio (unsigned int cpu , u64 * nominal_freq )
680+ {
681+ return 0 ;
682+ }
672683#endif
673684
674685static int acpi_cpufreq_cpu_init (struct cpufreq_policy * policy )
@@ -678,9 +689,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
678689 struct acpi_cpufreq_data * data ;
679690 unsigned int cpu = policy -> cpu ;
680691 struct cpuinfo_x86 * c = & cpu_data (cpu );
692+ u64 max_boost_ratio , nominal_freq = 0 ;
681693 unsigned int valid_states = 0 ;
682694 unsigned int result = 0 ;
683- u64 max_boost_ratio ;
684695 unsigned int i ;
685696#ifdef CONFIG_SMP
686697 static int blacklisted ;
@@ -830,16 +841,20 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
830841 }
831842 freq_table [valid_states ].frequency = CPUFREQ_TABLE_END ;
832843
833- max_boost_ratio = get_max_boost_ratio (cpu );
844+ max_boost_ratio = get_max_boost_ratio (cpu , & nominal_freq );
834845 if (max_boost_ratio ) {
835- unsigned int freq = freq_table [ 0 ]. frequency ;
846+ unsigned int freq = nominal_freq ;
836847
837848 /*
838- * Because the loop above sorts the freq_table entries in the
839- * descending order, freq is the maximum frequency in the table.
840- * Assume that it corresponds to the CPPC nominal frequency and
841- * use it to set cpuinfo.max_freq.
849+ * The loop above sorts the freq_table entries in the
850+ * descending order. If ACPI CPPC has not advertised
851+ * the nominal frequency (this is possible in CPPC
852+ * revisions prior to 3), then use the first entry in
853+ * the pstate table as a proxy for nominal frequency.
842854 */
855+ if (!freq )
856+ freq = freq_table [0 ].frequency ;
857+
843858 policy -> cpuinfo .max_freq = freq * max_boost_ratio >> SCHED_CAPACITY_SHIFT ;
844859 } else {
845860 /*
@@ -895,8 +910,17 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
895910 pr_warn (FW_WARN "P-state 0 is not max freq\n" );
896911
897912 if (acpi_cpufreq_driver .set_boost ) {
898- set_boost (policy , acpi_cpufreq_driver .boost_enabled );
899- policy -> boost_enabled = acpi_cpufreq_driver .boost_enabled ;
913+ if (policy -> boost_supported ) {
914+ /*
915+ * The firmware may have altered boost state while the
916+ * CPU was offline (for example during a suspend-resume
917+ * cycle).
918+ */
919+ if (policy -> boost_enabled != boost_state (cpu ))
920+ set_boost (policy , policy -> boost_enabled );
921+ } else {
922+ policy -> boost_supported = true;
923+ }
900924 }
901925
902926 return result ;
@@ -939,7 +963,6 @@ static int acpi_cpufreq_resume(struct cpufreq_policy *policy)
939963}
940964
941965static struct freq_attr * acpi_cpufreq_attr [] = {
942- & cpufreq_freq_attr_scaling_available_freqs ,
943966 & freqdomain_cpus ,
944967#ifdef CONFIG_X86_ACPI_CPUFREQ_CPB
945968 & cpb ,
@@ -1028,7 +1051,7 @@ static struct platform_driver acpi_cpufreq_platdrv = {
10281051 .driver = {
10291052 .name = "acpi-cpufreq" ,
10301053 },
1031- .remove_new = acpi_cpufreq_remove ,
1054+ .remove = acpi_cpufreq_remove ,
10321055};
10331056
10341057static int __init acpi_cpufreq_init (void )
0 commit comments