All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/1] cpufreq: CPPC: Fix unused-function warning
@ 2022-05-30 10:04 Pierre Gondois
  2022-05-30 10:04 ` [PATCH -next v2 1/1] " Pierre Gondois
  0 siblings, 1 reply; 4+ messages in thread
From: Pierre Gondois @ 2022-05-30 10:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: zhangshaokun, Ionela.Voinescu, Dietmar.Eggemann, Pierre Gondois,
	Rafael J. Wysocki, Viresh Kumar, Pierre Gondois, linux-pm

v2:
- Put the Energy Model related functions inside specific guards
  instead of using the '__maybe_unused' flag.

A warning was reported when the cppc_cpufreq driver is built
with CONFIG_ENERGY_MODEL=n at:
https://lore.kernel.org/all/626c99d3-edaf-4544-7e64-5b3653591086@hisilicon.com/

The patch should be applied on top of:
https://lore.kernel.org/all/20220521032438.2504155-1-zhengbin13@huawei.com/

Pierre Gondois (1):
  cpufreq: CPPC: Fix unused-function warning

 drivers/cpufreq/cppc_cpufreq.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

-- 
2.25.1


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

* [PATCH -next v2 1/1] cpufreq: CPPC: Fix unused-function warning
  2022-05-30 10:04 [PATCH v2 0/1] cpufreq: CPPC: Fix unused-function warning Pierre Gondois
@ 2022-05-30 10:04 ` Pierre Gondois
  2022-05-30 11:55   ` Shaokun Zhang
  0 siblings, 1 reply; 4+ messages in thread
From: Pierre Gondois @ 2022-05-30 10:04 UTC (permalink / raw)
  To: linux-kernel
  Cc: zhangshaokun, Ionela.Voinescu, Dietmar.Eggemann, Pierre Gondois,
	Rafael J. Wysocki, Viresh Kumar, Pierre Gondois, linux-pm

Building the cppc_cpufreq driver with for arm64 with
CONFIG_ENERGY_MODEL=n triggers the following warnings:
 drivers/cpufreq/cppc_cpufreq.c:550:12: error: ‘cppc_get_cpu_cost’ defined but not used
[-Werror=unused-function]
   550 | static int cppc_get_cpu_cost(struct device *cpu_dev, unsigned long KHz,
       |            ^~~~~~~~~~~~~~~~~
 drivers/cpufreq/cppc_cpufreq.c:481:12: error: ‘cppc_get_cpu_power’ defined but not used
[-Werror=unused-function]
   481 | static int cppc_get_cpu_power(struct device *cpu_dev,
       |            ^~~~~~~~~~~~~~~~~~

Move the Energy Model related functions into specific guards.
This allows to fix the warning and prevent doing extra work
when the Energy Model is not present.

Fixes: 740fcdc2c20e ("cpufreq: CPPC: Register EM based on efficiency class information")
Reported-by: Shaokun Zhang <zhangshaokun@hisilicon.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
---
 drivers/cpufreq/cppc_cpufreq.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
index f0a8bb2c59e5..24eaf0ec344d 100644
--- a/drivers/cpufreq/cppc_cpufreq.c
+++ b/drivers/cpufreq/cppc_cpufreq.c
@@ -441,6 +441,14 @@ static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu)
 	}
 	return cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
 }
+#else
+static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu)
+{
+	return cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
+}
+#endif
+
+#if defined(CONFIG_ARM64) && defined(CONFIG_ENERGY_MODEL)
 
 static DEFINE_PER_CPU(unsigned int, efficiency_class);
 static void cppc_cpufreq_register_em(struct cpufreq_policy *policy);
@@ -621,21 +629,12 @@ static void cppc_cpufreq_register_em(struct cpufreq_policy *policy)
 }
 
 #else
-
-static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu)
-{
-	return cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
-}
 static int populate_efficiency_class(void)
 {
 	return 0;
 }
-static void cppc_cpufreq_register_em(struct cpufreq_policy *policy)
-{
-}
 #endif
 
-
 static struct cppc_cpudata *cppc_cpufreq_get_cpu_data(unsigned int cpu)
 {
 	struct cppc_cpudata *cpu_data;
-- 
2.25.1


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

* Re: [PATCH -next v2 1/1] cpufreq: CPPC: Fix unused-function warning
  2022-05-30 10:04 ` [PATCH -next v2 1/1] " Pierre Gondois
@ 2022-05-30 11:55   ` Shaokun Zhang
  2022-05-30 13:36     ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Shaokun Zhang @ 2022-05-30 11:55 UTC (permalink / raw)
  To: Pierre Gondois, linux-kernel
  Cc: Ionela.Voinescu, Dietmar.Eggemann, Rafael J. Wysocki,
	Viresh Kumar, linux-pm

Hi,

It works for me on compile when CONFIG_ENERGY_MODEL=n, please feel free to add:
Tested-by: Shaokun Zhang <zhangshaokun@hisilicon.com>

Thanks,
Shaokun

On 2022/5/30 18:04, Pierre Gondois wrote:
> Building the cppc_cpufreq driver with for arm64 with
> CONFIG_ENERGY_MODEL=n triggers the following warnings:
>  drivers/cpufreq/cppc_cpufreq.c:550:12: error: ‘cppc_get_cpu_cost’ defined but not used
> [-Werror=unused-function]
>    550 | static int cppc_get_cpu_cost(struct device *cpu_dev, unsigned long KHz,
>        |            ^~~~~~~~~~~~~~~~~
>  drivers/cpufreq/cppc_cpufreq.c:481:12: error: ‘cppc_get_cpu_power’ defined but not used
> [-Werror=unused-function]
>    481 | static int cppc_get_cpu_power(struct device *cpu_dev,
>        |            ^~~~~~~~~~~~~~~~~~
> 
> Move the Energy Model related functions into specific guards.
> This allows to fix the warning and prevent doing extra work
> when the Energy Model is not present.
> 
> Fixes: 740fcdc2c20e ("cpufreq: CPPC: Register EM based on efficiency class information")
> Reported-by: Shaokun Zhang <zhangshaokun@hisilicon.com>
> Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
> ---
>  drivers/cpufreq/cppc_cpufreq.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> index f0a8bb2c59e5..24eaf0ec344d 100644
> --- a/drivers/cpufreq/cppc_cpufreq.c
> +++ b/drivers/cpufreq/cppc_cpufreq.c
> @@ -441,6 +441,14 @@ static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu)
>  	}
>  	return cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
>  }
> +#else
> +static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu)
> +{
> +	return cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
> +}
> +#endif
> +
> +#if defined(CONFIG_ARM64) && defined(CONFIG_ENERGY_MODEL)
>  
>  static DEFINE_PER_CPU(unsigned int, efficiency_class);
>  static void cppc_cpufreq_register_em(struct cpufreq_policy *policy);
> @@ -621,21 +629,12 @@ static void cppc_cpufreq_register_em(struct cpufreq_policy *policy)
>  }
>  
>  #else
> -
> -static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu)
> -{
> -	return cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
> -}
>  static int populate_efficiency_class(void)
>  {
>  	return 0;
>  }
> -static void cppc_cpufreq_register_em(struct cpufreq_policy *policy)
> -{
> -}
>  #endif
>  
> -
>  static struct cppc_cpudata *cppc_cpufreq_get_cpu_data(unsigned int cpu)
>  {
>  	struct cppc_cpudata *cpu_data;
> 

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

* Re: [PATCH -next v2 1/1] cpufreq: CPPC: Fix unused-function warning
  2022-05-30 11:55   ` Shaokun Zhang
@ 2022-05-30 13:36     ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2022-05-30 13:36 UTC (permalink / raw)
  To: Shaokun Zhang, Pierre Gondois
  Cc: Linux Kernel Mailing List, Ionela Voinescu, Dietmar Eggemann,
	Rafael J. Wysocki, Viresh Kumar, Linux PM

On Mon, May 30, 2022 at 1:56 PM Shaokun Zhang
<zhangshaokun@hisilicon.com> wrote:
>
> Hi,
>
> It works for me on compile when CONFIG_ENERGY_MODEL=n, please feel free to add:
> Tested-by: Shaokun Zhang <zhangshaokun@hisilicon.com>

Applied, thanks!

> On 2022/5/30 18:04, Pierre Gondois wrote:
> > Building the cppc_cpufreq driver with for arm64 with
> > CONFIG_ENERGY_MODEL=n triggers the following warnings:
> >  drivers/cpufreq/cppc_cpufreq.c:550:12: error: ‘cppc_get_cpu_cost’ defined but not used
> > [-Werror=unused-function]
> >    550 | static int cppc_get_cpu_cost(struct device *cpu_dev, unsigned long KHz,
> >        |            ^~~~~~~~~~~~~~~~~
> >  drivers/cpufreq/cppc_cpufreq.c:481:12: error: ‘cppc_get_cpu_power’ defined but not used
> > [-Werror=unused-function]
> >    481 | static int cppc_get_cpu_power(struct device *cpu_dev,
> >        |            ^~~~~~~~~~~~~~~~~~
> >
> > Move the Energy Model related functions into specific guards.
> > This allows to fix the warning and prevent doing extra work
> > when the Energy Model is not present.
> >
> > Fixes: 740fcdc2c20e ("cpufreq: CPPC: Register EM based on efficiency class information")
> > Reported-by: Shaokun Zhang <zhangshaokun@hisilicon.com>
> > Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
> > ---
> >  drivers/cpufreq/cppc_cpufreq.c | 17 ++++++++---------
> >  1 file changed, 8 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> > index f0a8bb2c59e5..24eaf0ec344d 100644
> > --- a/drivers/cpufreq/cppc_cpufreq.c
> > +++ b/drivers/cpufreq/cppc_cpufreq.c
> > @@ -441,6 +441,14 @@ static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu)
> >       }
> >       return cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
> >  }
> > +#else
> > +static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu)
> > +{
> > +     return cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
> > +}
> > +#endif
> > +
> > +#if defined(CONFIG_ARM64) && defined(CONFIG_ENERGY_MODEL)
> >
> >  static DEFINE_PER_CPU(unsigned int, efficiency_class);
> >  static void cppc_cpufreq_register_em(struct cpufreq_policy *policy);
> > @@ -621,21 +629,12 @@ static void cppc_cpufreq_register_em(struct cpufreq_policy *policy)
> >  }
> >
> >  #else
> > -
> > -static unsigned int cppc_cpufreq_get_transition_delay_us(unsigned int cpu)
> > -{
> > -     return cppc_get_transition_latency(cpu) / NSEC_PER_USEC;
> > -}
> >  static int populate_efficiency_class(void)
> >  {
> >       return 0;
> >  }
> > -static void cppc_cpufreq_register_em(struct cpufreq_policy *policy)
> > -{
> > -}
> >  #endif
> >
> > -
> >  static struct cppc_cpudata *cppc_cpufreq_get_cpu_data(unsigned int cpu)
> >  {
> >       struct cppc_cpudata *cpu_data;
> >

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

end of thread, other threads:[~2022-05-30 13:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-30 10:04 [PATCH v2 0/1] cpufreq: CPPC: Fix unused-function warning Pierre Gondois
2022-05-30 10:04 ` [PATCH -next v2 1/1] " Pierre Gondois
2022-05-30 11:55   ` Shaokun Zhang
2022-05-30 13:36     ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.