linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] cpufreq: cppc_cpufreq: Initialize shared cpu's perf capabilities
@ 2018-04-04  9:16 Shunyong Yang
  2018-04-04 10:36 ` Viresh Kumar
  0 siblings, 1 reply; 4+ messages in thread
From: Shunyong Yang @ 2018-04-04  9:16 UTC (permalink / raw)
  To: rjw; +Cc: viresh.kumar, linux-pm, linux-kernel, Shunyong Yang, Joey Zheng

When multiple cpus are related in one cpufreq policy, the first online
cpu will be chosen by default to handle cpufreq operations. Let's take
cpu0 and cpu1 as an example.

When cpu0 is offline, policy->cpu will be shifted to cpu1. Cpu1's perf
capabilities should be initialized. Otherwise, perf capabilities are 0s
and speed change can not take effect.

This patch copies perf capabilities of the first online cpu to other
shared cpus when policy shared type is CPUFREQ_SHARED_TYPE_ANY.

Cc: Joey Zheng <yu.zheng@hxt-semitech.com>
Signed-off-by: Shunyong Yang <shunyong.yang@hxt-semitech.com>
---

Changes in v2:
  -Add unlikely in cpu comparison per Kumar's comments.
  -Fix coding style per Kumar's comments.

Changes in v1:
  -Drop RFC tag,
     The original RFC link,
     https://patchwork.kernel.org/patch/10299055/.

     This patch solves same issue as RFC above.

     Patch name is changed as code is too much different with RFC above.

  -Remove extra init() per Viresh Kumar's comments and only handle
   CPPC CPUFREQ_SHARED_TYPE_ANY case.

---
 drivers/cpufreq/cppc_cpufreq.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
index 8f7b21a4d537..679e43b9c980 100644
--- a/drivers/cpufreq/cppc_cpufreq.c
+++ b/drivers/cpufreq/cppc_cpufreq.c
@@ -164,9 +164,20 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
 	policy->cpuinfo.transition_latency = cppc_get_transition_latency(cpu_num);
 	policy->shared_type = cpu->shared_type;
 
-	if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
+	if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) {
+		int i;
+
 		cpumask_copy(policy->cpus, cpu->shared_cpu_map);
-	else if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL) {
+
+		for_each_cpu(i, policy->cpus) {
+			if (unlikely(i == policy->cpu))
+				continue;
+
+			memcpy(&all_cpu_data[i]->perf_caps,
+			       &cpu->perf_caps,
+			       sizeof(cpu->perf_caps));
+		}
+	} else if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL) {
 		/* Support only SW_ANY for now. */
 		pr_debug("Unsupported CPU co-ord type\n");
 		return -EFAULT;
-- 
1.8.3.1

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

* Re: [PATCH v2] cpufreq: cppc_cpufreq: Initialize shared cpu's perf capabilities
  2018-04-04  9:16 [PATCH v2] cpufreq: cppc_cpufreq: Initialize shared cpu's perf capabilities Shunyong Yang
@ 2018-04-04 10:36 ` Viresh Kumar
  2018-04-06  1:10   ` Yang, Shunyong
  2018-04-06  1:21   ` Yang, Shunyong
  0 siblings, 2 replies; 4+ messages in thread
From: Viresh Kumar @ 2018-04-04 10:36 UTC (permalink / raw)
  To: Shunyong Yang; +Cc: rjw, linux-pm, linux-kernel, Joey Zheng

On 04-04-18, 17:16, Shunyong Yang wrote:
> When multiple cpus are related in one cpufreq policy, the first online
> cpu will be chosen by default to handle cpufreq operations. Let's take
> cpu0 and cpu1 as an example.
> 
> When cpu0 is offline, policy->cpu will be shifted to cpu1. Cpu1's perf
> capabilities should be initialized. Otherwise, perf capabilities are 0s
> and speed change can not take effect.
> 
> This patch copies perf capabilities of the first online cpu to other
> shared cpus when policy shared type is CPUFREQ_SHARED_TYPE_ANY.
> 
> Cc: Joey Zheng <yu.zheng@hxt-semitech.com>
> Signed-off-by: Shunyong Yang <shunyong.yang@hxt-semitech.com>
> ---
> 
> Changes in v2:
>   -Add unlikely in cpu comparison per Kumar's comments.
>   -Fix coding style per Kumar's comments.
> 
> Changes in v1:
>   -Drop RFC tag,
>      The original RFC link,
>      https://patchwork.kernel.org/patch/10299055/.
> 
>      This patch solves same issue as RFC above.
> 
>      Patch name is changed as code is too much different with RFC above.
> 
>   -Remove extra init() per Viresh Kumar's comments and only handle
>    CPPC CPUFREQ_SHARED_TYPE_ANY case.
> 
> ---
>  drivers/cpufreq/cppc_cpufreq.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> index 8f7b21a4d537..679e43b9c980 100644
> --- a/drivers/cpufreq/cppc_cpufreq.c
> +++ b/drivers/cpufreq/cppc_cpufreq.c
> @@ -164,9 +164,20 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
>  	policy->cpuinfo.transition_latency = cppc_get_transition_latency(cpu_num);
>  	policy->shared_type = cpu->shared_type;
>  
> -	if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
> +	if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) {
> +		int i;
> +
>  		cpumask_copy(policy->cpus, cpu->shared_cpu_map);
> -	else if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL) {
> +
> +		for_each_cpu(i, policy->cpus) {
> +			if (unlikely(i == policy->cpu))
> +				continue;
> +
> +			memcpy(&all_cpu_data[i]->perf_caps,
> +			       &cpu->perf_caps,
> +			       sizeof(cpu->perf_caps));

I think this can be written in two lines without violating the 80
columns rule.

> +		}
> +	} else if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL) {
>  		/* Support only SW_ANY for now. */
>  		pr_debug("Unsupported CPU co-ord type\n");
>  		return -EFAULT;

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

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

* Re: [PATCH v2] cpufreq: cppc_cpufreq: Initialize shared cpu's perf capabilities
  2018-04-04 10:36 ` Viresh Kumar
@ 2018-04-06  1:10   ` Yang, Shunyong
  2018-04-06  1:21   ` Yang, Shunyong
  1 sibling, 0 replies; 4+ messages in thread
From: Yang, Shunyong @ 2018-04-06  1:10 UTC (permalink / raw)
  To: viresh.kumar; +Cc: linux-kernel, Zheng, Joey, linux-pm, rjw

Hi, Kumar,

On Wed, 2018-04-04 at 16:06 +0530, Viresh Kumar wrote:
> On 04-04-18, 17:16, Shunyong Yang wrote:
> > 
> > When multiple cpus are related in one cpufreq policy, the first
> > online
> > cpu will be chosen by default to handle cpufreq operations. Let's
> > take
> > cpu0 and cpu1 as an example.
> > 
> > When cpu0 is offline, policy->cpu will be shifted to cpu1. Cpu1's
> > perf
> > capabilities should be initialized. Otherwise, perf capabilities
> > are 0s
> > and speed change can not take effect.
> > 
> > This patch copies perf capabilities of the first online cpu to
> > other
> > shared cpus when policy shared type is CPUFREQ_SHARED_TYPE_ANY.
> > 
> > Cc: Joey Zheng <yu.zheng@hxt-semitech.com>
> > Signed-off-by: Shunyong Yang <shunyong.yang@hxt-semitech.com>
> > ---
> > 
> > Changes in v2:
> >   -Add unlikely in cpu comparison per Kumar's comments.
> >   -Fix coding style per Kumar's comments.
> > 
> > Changes in v1:
> >   -Drop RFC tag,
> >      The original RFC link,
> >      https://patchwork.kernel.org/patch/10299055/.
> > 
> >      This patch solves same issue as RFC above.
> > 
> >      Patch name is changed as code is too much different with RFC
> > above.
> > 
> >   -Remove extra init() per Viresh Kumar's comments and only handle
> >    CPPC CPUFREQ_SHARED_TYPE_ANY case.
> > 
> > ---
> >  drivers/cpufreq/cppc_cpufreq.c | 15 +++++++++++++--
> >  1 file changed, 13 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/cpufreq/cppc_cpufreq.c
> > b/drivers/cpufreq/cppc_cpufreq.c
> > index 8f7b21a4d537..679e43b9c980 100644
> > --- a/drivers/cpufreq/cppc_cpufreq.c
> > +++ b/drivers/cpufreq/cppc_cpufreq.c
> > @@ -164,9 +164,20 @@ static int cppc_cpufreq_cpu_init(struct
> > cpufreq_policy *policy)
> >  	policy->cpuinfo.transition_latency =
> > cppc_get_transition_latency(cpu_num);
> >  	policy->shared_type = cpu->shared_type;
> >  
> > -	if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
> > +	if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) {
> > +		int i;
> > +
> >  		cpumask_copy(policy->cpus, cpu->shared_cpu_map);
> > -	else if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL) {
> > +
> > +		for_each_cpu(i, policy->cpus) {
> > +			if (unlikely(i == policy->cpu))
> > +				continue;
> > +
> > +			memcpy(&all_cpu_data[i]->perf_caps,
> > +			       &cpu->perf_caps,
> > +			       sizeof(cpu->perf_caps));
> I think this can be written in two lines without violating the 80
> columns rule.

The memcpy() is split in three lines (the three "+"). And I rechecked
it by downloading from

https://patchwork.kernel.org/patch/10322305/

and apply to code. The maximum column number is 59. 
And I re-run checkpatch.pl and it passed.
I am not sure why it is over 80 columns in your tool. 

> 
> > 
> > +		}
> > +	} else if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL)
> > {
> >  		/* Support only SW_ANY for now. */
> >  		pr_debug("Unsupported CPU co-ord type\n");
> >  		return -EFAULT;
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

Thanks for your ACK.

Thanks.
Shunyong.


> 

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

* Re: [PATCH v2] cpufreq: cppc_cpufreq: Initialize shared cpu's perf capabilities
  2018-04-04 10:36 ` Viresh Kumar
  2018-04-06  1:10   ` Yang, Shunyong
@ 2018-04-06  1:21   ` Yang, Shunyong
  1 sibling, 0 replies; 4+ messages in thread
From: Yang, Shunyong @ 2018-04-06  1:21 UTC (permalink / raw)
  To: viresh.kumar; +Cc: linux-kernel, Zheng, Joey, linux-pm, rjw

Hi, Kumar,

On Wed, 2018-04-04 at 16:06 +0530, Viresh Kumar wrote:
> On 04-04-18, 17:16, Shunyong Yang wrote:
> > 
> > When multiple cpus are related in one cpufreq policy, the first
> > online
> > cpu will be chosen by default to handle cpufreq operations. Let's
> > take
> > cpu0 and cpu1 as an example.
> > 
> > When cpu0 is offline, policy->cpu will be shifted to cpu1. Cpu1's
> > perf
> > capabilities should be initialized. Otherwise, perf capabilities
> > are 0s
> > and speed change can not take effect.
> > 
> > This patch copies perf capabilities of the first online cpu to
> > other
> > shared cpus when policy shared type is CPUFREQ_SHARED_TYPE_ANY.
> > 
> > Cc: Joey Zheng <yu.zheng@hxt-semitech.com>
> > Signed-off-by: Shunyong Yang <shunyong.yang@hxt-semitech.com>
> > ---
> > 
> > Changes in v2:
> >   -Add unlikely in cpu comparison per Kumar's comments.
> >   -Fix coding style per Kumar's comments.
> > 
> > Changes in v1:
> >   -Drop RFC tag,
> >      The original RFC link,
> >      https://patchwork.kernel.org/patch/10299055/.
> > 
> >      This patch solves same issue as RFC above.
> > 
> >      Patch name is changed as code is too much different with RFC
> > above.
> > 
> >   -Remove extra init() per Viresh Kumar's comments and only handle
> >    CPPC CPUFREQ_SHARED_TYPE_ANY case.
> > 
> > ---
> >  drivers/cpufreq/cppc_cpufreq.c | 15 +++++++++++++--
> >  1 file changed, 13 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/cpufreq/cppc_cpufreq.c
> > b/drivers/cpufreq/cppc_cpufreq.c
> > index 8f7b21a4d537..679e43b9c980 100644
> > --- a/drivers/cpufreq/cppc_cpufreq.c
> > +++ b/drivers/cpufreq/cppc_cpufreq.c
> > @@ -164,9 +164,20 @@ static int cppc_cpufreq_cpu_init(struct
> > cpufreq_policy *policy)
> >  	policy->cpuinfo.transition_latency =
> > cppc_get_transition_latency(cpu_num);
> >  	policy->shared_type = cpu->shared_type;
> >  
> > -	if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
> > +	if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY) {
> > +		int i;
> > +
> >  		cpumask_copy(policy->cpus, cpu->shared_cpu_map);
> > -	else if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL) {
> > +
> > +		for_each_cpu(i, policy->cpus) {
> > +			if (unlikely(i == policy->cpu))
> > +				continue;
> > +
> > +			memcpy(&all_cpu_data[i]->perf_caps,
> > +			       &cpu->perf_caps,
> > +			       sizeof(cpu->perf_caps));
> I think this can be written in two lines without violating the 80
> columns rule.

I think you mean change like following?

     memcpy(&all_cpu_data[i]->perf_caps, &cpu->perf_caps,
            sizeof(cpu->perf_caps));

I will send v3 to change this.

Thanks.
Shunyong.

> 
> > 
> > +		}
> > +	} else if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL)
> > {
> >  		/* Support only SW_ANY for now. */
> >  		pr_debug("Unsupported CPU co-ord type\n");
> >  		return -EFAULT;
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> 

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

end of thread, other threads:[~2018-04-06  1:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-04  9:16 [PATCH v2] cpufreq: cppc_cpufreq: Initialize shared cpu's perf capabilities Shunyong Yang
2018-04-04 10:36 ` Viresh Kumar
2018-04-06  1:10   ` Yang, Shunyong
2018-04-06  1:21   ` Yang, Shunyong

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).