linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: intel_pstate: hybrid: Fix build with CONFIG_ACPI unset
@ 2021-05-26 15:01 Rafael J. Wysocki
  2021-05-26 16:10 ` Randy Dunlap
  0 siblings, 1 reply; 3+ messages in thread
From: Rafael J. Wysocki @ 2021-05-26 15:01 UTC (permalink / raw)
  To: Linux PM; +Cc: LKML, Srinivas Pandruvada, Chen Yu, Randy Dunlap

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

One of the previous commits introducing hybrid processor support to
intel_pstate broke build with CONFIG_ACPI unset.

Fix that and while at it fix up empty stubs of two functions related
to ACPI CPPC.

Fixes: eb3693f0521e ("cpufreq: intel_pstate: hybrid: CPU-specific scaling factor")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpufreq/intel_pstate.c |   97 +++++++++++++++++++++--------------------
 1 file changed, 50 insertions(+), 47 deletions(-)

Index: linux-pm/drivers/cpufreq/intel_pstate.c
===================================================================
--- linux-pm.orig/drivers/cpufreq/intel_pstate.c
+++ linux-pm/drivers/cpufreq/intel_pstate.c
@@ -385,9 +385,14 @@ static int intel_pstate_get_cppc_gurante
 }
 
 #else /* CONFIG_ACPI_CPPC_LIB */
-static void intel_pstate_set_itmt_prio(int cpu)
+static inline void intel_pstate_set_itmt_prio(int cpu)
 {
 }
+
+static inline int intel_pstate_get_cppc_guranteed(int cpu)
+{
+	return -ENOTSUPP;
+}
 #endif /* CONFIG_ACPI_CPPC_LIB */
 
 static void intel_pstate_init_acpi_perf_limits(struct cpufreq_policy *policy)
@@ -470,27 +475,6 @@ static void intel_pstate_exit_perf_limit
 
 	acpi_processor_unregister_performance(policy->cpu);
 }
-#else /* CONFIG_ACPI */
-static inline void intel_pstate_init_acpi_perf_limits(struct cpufreq_policy *policy)
-{
-}
-
-static inline void intel_pstate_exit_perf_limits(struct cpufreq_policy *policy)
-{
-}
-
-static inline bool intel_pstate_acpi_pm_profile_server(void)
-{
-	return false;
-}
-#endif /* CONFIG_ACPI */
-
-#ifndef CONFIG_ACPI_CPPC_LIB
-static int intel_pstate_get_cppc_guranteed(int cpu)
-{
-	return -ENOTSUPP;
-}
-#endif /* CONFIG_ACPI_CPPC_LIB */
 
 static bool intel_pstate_cppc_perf_valid(u32 perf, struct cppc_perf_caps *caps)
 {
@@ -505,6 +489,20 @@ static bool intel_pstate_cppc_perf_caps(
 
 	return caps->highest_perf && caps->lowest_perf <= caps->highest_perf;
 }
+#else /* CONFIG_ACPI */
+static inline void intel_pstate_init_acpi_perf_limits(struct cpufreq_policy *policy)
+{
+}
+
+static inline void intel_pstate_exit_perf_limits(struct cpufreq_policy *policy)
+{
+}
+
+static inline bool intel_pstate_acpi_pm_profile_server(void)
+{
+	return false;
+}
+#endif /* CONFIG_ACPI */
 
 static void intel_pstate_hybrid_hwp_perf_ctl_parity(struct cpudata *cpu)
 {
@@ -530,7 +528,6 @@ static void intel_pstate_hybrid_hwp_perf
  */
 static void intel_pstate_hybrid_hwp_calibrate(struct cpudata *cpu)
 {
-	struct cppc_perf_caps caps;
 	int perf_ctl_max_phys = cpu->pstate.max_pstate_physical;
 	int perf_ctl_scaling = cpu->pstate.perf_ctl_scaling;
 	int perf_ctl_turbo = pstate_funcs.get_turbo();
@@ -548,33 +545,39 @@ static void intel_pstate_hybrid_hwp_cali
 	pr_debug("CPU%d: HWP_CAP guaranteed = %d\n", cpu->cpu, cpu->pstate.max_pstate);
 	pr_debug("CPU%d: HWP_CAP highest = %d\n", cpu->cpu, cpu->pstate.turbo_pstate);
 
-	if (intel_pstate_cppc_perf_caps(cpu, &caps)) {
-		if (intel_pstate_cppc_perf_valid(caps.nominal_perf, &caps)) {
-			pr_debug("CPU%d: Using CPPC nominal\n", cpu->cpu);
-
-			/*
-			 * If the CPPC nominal performance is valid, it can be
-			 * assumed to correspond to cpu_khz.
-			 */
-			if (caps.nominal_perf == perf_ctl_max_phys) {
-				intel_pstate_hybrid_hwp_perf_ctl_parity(cpu);
-				return;
-			}
-			scaling = DIV_ROUND_UP(cpu_khz, caps.nominal_perf);
-		} else if (intel_pstate_cppc_perf_valid(caps.guaranteed_perf, &caps)) {
-			pr_debug("CPU%d: Using CPPC guaranteed\n", cpu->cpu);
-
-			/*
-			 * If the CPPC guaranteed performance is valid, it can
-			 * be assumed to correspond to max_freq.
-			 */
-			if (caps.guaranteed_perf == perf_ctl_max) {
-				intel_pstate_hybrid_hwp_perf_ctl_parity(cpu);
-				return;
+#ifdef CONFIG_ACPI
+	if (IS_ENABLED(CONFIG_ACPI_CPPC_LIB)) {
+		struct cppc_perf_caps caps;
+
+		if (intel_pstate_cppc_perf_caps(cpu, &caps)) {
+			if (intel_pstate_cppc_perf_valid(caps.nominal_perf, &caps)) {
+				pr_debug("CPU%d: Using CPPC nominal\n", cpu->cpu);
+
+				/*
+				 * If the CPPC nominal performance is valid, it
+				 * can be assumed to correspond to cpu_khz.
+				 */
+				if (caps.nominal_perf == perf_ctl_max_phys) {
+					intel_pstate_hybrid_hwp_perf_ctl_parity(cpu);
+					return;
+				}
+				scaling = DIV_ROUND_UP(cpu_khz, caps.nominal_perf);
+			} else if (intel_pstate_cppc_perf_valid(caps.guaranteed_perf, &caps)) {
+				pr_debug("CPU%d: Using CPPC guaranteed\n", cpu->cpu);
+
+				/*
+				 * If the CPPC guaranteed performance is valid,
+				 * it can be assumed to correspond to max_freq.
+				 */
+				if (caps.guaranteed_perf == perf_ctl_max) {
+					intel_pstate_hybrid_hwp_perf_ctl_parity(cpu);
+					return;
+				}
+				scaling = DIV_ROUND_UP(max_freq, caps.guaranteed_perf);
 			}
-			scaling = DIV_ROUND_UP(max_freq, caps.guaranteed_perf);
 		}
 	}
+#endif
 	/*
 	 * If using the CPPC data to compute the HWP-to-frequency scaling factor
 	 * doesn't work, use the HWP_CAP gauranteed perf for this purpose with




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpufreq: intel_pstate: hybrid: Fix build with CONFIG_ACPI unset
  2021-05-26 15:01 [PATCH] cpufreq: intel_pstate: hybrid: Fix build with CONFIG_ACPI unset Rafael J. Wysocki
@ 2021-05-26 16:10 ` Randy Dunlap
  2021-05-26 17:12   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Randy Dunlap @ 2021-05-26 16:10 UTC (permalink / raw)
  To: Rafael J. Wysocki, Linux PM; +Cc: LKML, Srinivas Pandruvada, Chen Yu

On 5/26/21 8:01 AM, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> One of the previous commits introducing hybrid processor support to
> intel_pstate broke build with CONFIG_ACPI unset.
> 
> Fix that and while at it fix up empty stubs of two functions related
> to ACPI CPPC.
> 
> Fixes: eb3693f0521e ("cpufreq: intel_pstate: hybrid: CPU-specific scaling factor")
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Hi Rafael,

I still have this build error:

../drivers/cpufreq/intel_pstate.c: In function ‘show_base_frequency’:
../drivers/cpufreq/intel_pstate.c:950:10: error: implicit declaration of function ‘intel_pstate_get_cppc_guranteed’; did you mean ‘intel_pstate_get_epp’? [-Werror=implicit-function-declaration]
  ratio = intel_pstate_get_cppc_guranteed(policy->cpu);


BTW: s/guranteed/guaranteed/g

Thanks.

> ---
>  drivers/cpufreq/intel_pstate.c |   97 +++++++++++++++++++++--------------------
>  1 file changed, 50 insertions(+), 47 deletions(-)
> 
> Index: linux-pm/drivers/cpufreq/intel_pstate.c
> ===================================================================
> --- linux-pm.orig/drivers/cpufreq/intel_pstate.c
> +++ linux-pm/drivers/cpufreq/intel_pstate.c
> @@ -385,9 +385,14 @@ static int intel_pstate_get_cppc_gurante
>  }
>  
>  #else /* CONFIG_ACPI_CPPC_LIB */
> -static void intel_pstate_set_itmt_prio(int cpu)
> +static inline void intel_pstate_set_itmt_prio(int cpu)
>  {
>  }
> +
> +static inline int intel_pstate_get_cppc_guranteed(int cpu)
> +{
> +	return -ENOTSUPP;
> +}
>  #endif /* CONFIG_ACPI_CPPC_LIB */
>  
>  static void intel_pstate_init_acpi_perf_limits(struct cpufreq_policy *policy)
> @@ -470,27 +475,6 @@ static void intel_pstate_exit_perf_limit
>  
>  	acpi_processor_unregister_performance(policy->cpu);
>  }
> -#else /* CONFIG_ACPI */
> -static inline void intel_pstate_init_acpi_perf_limits(struct cpufreq_policy *policy)
> -{
> -}
> -
> -static inline void intel_pstate_exit_perf_limits(struct cpufreq_policy *policy)
> -{
> -}
> -
> -static inline bool intel_pstate_acpi_pm_profile_server(void)
> -{
> -	return false;
> -}
> -#endif /* CONFIG_ACPI */
> -
> -#ifndef CONFIG_ACPI_CPPC_LIB
> -static int intel_pstate_get_cppc_guranteed(int cpu)
> -{
> -	return -ENOTSUPP;
> -}
> -#endif /* CONFIG_ACPI_CPPC_LIB */
>  
>  static bool intel_pstate_cppc_perf_valid(u32 perf, struct cppc_perf_caps *caps)
>  {
> @@ -505,6 +489,20 @@ static bool intel_pstate_cppc_perf_caps(
>  
>  	return caps->highest_perf && caps->lowest_perf <= caps->highest_perf;
>  }
> +#else /* CONFIG_ACPI */
> +static inline void intel_pstate_init_acpi_perf_limits(struct cpufreq_policy *policy)
> +{
> +}
> +
> +static inline void intel_pstate_exit_perf_limits(struct cpufreq_policy *policy)
> +{
> +}
> +
> +static inline bool intel_pstate_acpi_pm_profile_server(void)
> +{
> +	return false;
> +}
> +#endif /* CONFIG_ACPI */
>  
>  static void intel_pstate_hybrid_hwp_perf_ctl_parity(struct cpudata *cpu)
>  {
> @@ -530,7 +528,6 @@ static void intel_pstate_hybrid_hwp_perf
>   */
>  static void intel_pstate_hybrid_hwp_calibrate(struct cpudata *cpu)
>  {
> -	struct cppc_perf_caps caps;
>  	int perf_ctl_max_phys = cpu->pstate.max_pstate_physical;
>  	int perf_ctl_scaling = cpu->pstate.perf_ctl_scaling;
>  	int perf_ctl_turbo = pstate_funcs.get_turbo();
> @@ -548,33 +545,39 @@ static void intel_pstate_hybrid_hwp_cali
>  	pr_debug("CPU%d: HWP_CAP guaranteed = %d\n", cpu->cpu, cpu->pstate.max_pstate);
>  	pr_debug("CPU%d: HWP_CAP highest = %d\n", cpu->cpu, cpu->pstate.turbo_pstate);
>  
> -	if (intel_pstate_cppc_perf_caps(cpu, &caps)) {
> -		if (intel_pstate_cppc_perf_valid(caps.nominal_perf, &caps)) {
> -			pr_debug("CPU%d: Using CPPC nominal\n", cpu->cpu);
> -
> -			/*
> -			 * If the CPPC nominal performance is valid, it can be
> -			 * assumed to correspond to cpu_khz.
> -			 */
> -			if (caps.nominal_perf == perf_ctl_max_phys) {
> -				intel_pstate_hybrid_hwp_perf_ctl_parity(cpu);
> -				return;
> -			}
> -			scaling = DIV_ROUND_UP(cpu_khz, caps.nominal_perf);
> -		} else if (intel_pstate_cppc_perf_valid(caps.guaranteed_perf, &caps)) {
> -			pr_debug("CPU%d: Using CPPC guaranteed\n", cpu->cpu);
> -
> -			/*
> -			 * If the CPPC guaranteed performance is valid, it can
> -			 * be assumed to correspond to max_freq.
> -			 */
> -			if (caps.guaranteed_perf == perf_ctl_max) {
> -				intel_pstate_hybrid_hwp_perf_ctl_parity(cpu);
> -				return;
> +#ifdef CONFIG_ACPI
> +	if (IS_ENABLED(CONFIG_ACPI_CPPC_LIB)) {
> +		struct cppc_perf_caps caps;
> +
> +		if (intel_pstate_cppc_perf_caps(cpu, &caps)) {
> +			if (intel_pstate_cppc_perf_valid(caps.nominal_perf, &caps)) {
> +				pr_debug("CPU%d: Using CPPC nominal\n", cpu->cpu);
> +
> +				/*
> +				 * If the CPPC nominal performance is valid, it
> +				 * can be assumed to correspond to cpu_khz.
> +				 */
> +				if (caps.nominal_perf == perf_ctl_max_phys) {
> +					intel_pstate_hybrid_hwp_perf_ctl_parity(cpu);
> +					return;
> +				}
> +				scaling = DIV_ROUND_UP(cpu_khz, caps.nominal_perf);
> +			} else if (intel_pstate_cppc_perf_valid(caps.guaranteed_perf, &caps)) {
> +				pr_debug("CPU%d: Using CPPC guaranteed\n", cpu->cpu);
> +
> +				/*
> +				 * If the CPPC guaranteed performance is valid,
> +				 * it can be assumed to correspond to max_freq.
> +				 */
> +				if (caps.guaranteed_perf == perf_ctl_max) {
> +					intel_pstate_hybrid_hwp_perf_ctl_parity(cpu);
> +					return;
> +				}
> +				scaling = DIV_ROUND_UP(max_freq, caps.guaranteed_perf);
>  			}
> -			scaling = DIV_ROUND_UP(max_freq, caps.guaranteed_perf);
>  		}
>  	}
> +#endif
>  	/*
>  	 * If using the CPPC data to compute the HWP-to-frequency scaling factor
>  	 * doesn't work, use the HWP_CAP gauranteed perf for this purpose with
> 
> 
> 


-- 
~Randy


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cpufreq: intel_pstate: hybrid: Fix build with CONFIG_ACPI unset
  2021-05-26 16:10 ` Randy Dunlap
@ 2021-05-26 17:12   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2021-05-26 17:12 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Rafael J. Wysocki, Linux PM, LKML, Srinivas Pandruvada, Chen Yu

On Wed, May 26, 2021 at 6:10 PM Randy Dunlap <rdunlap@infradead.org> wrote:
>
> On 5/26/21 8:01 AM, Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> >
> > One of the previous commits introducing hybrid processor support to
> > intel_pstate broke build with CONFIG_ACPI unset.
> >
> > Fix that and while at it fix up empty stubs of two functions related
> > to ACPI CPPC.
> >
> > Fixes: eb3693f0521e ("cpufreq: intel_pstate: hybrid: CPU-specific scaling factor")
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Hi Rafael,
>
> I still have this build error:
>
> ../drivers/cpufreq/intel_pstate.c: In function ‘show_base_frequency’:
> ../drivers/cpufreq/intel_pstate.c:950:10: error: implicit declaration of function ‘intel_pstate_get_cppc_guranteed’; did you mean ‘intel_pstate_get_epp’? [-Werror=implicit-function-declaration]
>   ratio = intel_pstate_get_cppc_guranteed(policy->cpu);

Well, I did too much in this patch, will send an update shortly.

> BTW: s/guranteed/guaranteed/g

Right.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-26 17:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-26 15:01 [PATCH] cpufreq: intel_pstate: hybrid: Fix build with CONFIG_ACPI unset Rafael J. Wysocki
2021-05-26 16:10 ` Randy Dunlap
2021-05-26 17:12   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).