diff mbox series

cpufreq: Judging new_policy before update related_cpus

Message ID 20210202093619.543-1-xuewen.yan94@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show
Series cpufreq: Judging new_policy before update related_cpus | expand

Commit Message

Xuewen Yan Feb. 2, 2021, 9:36 a.m. UTC
From: Xuewen Yan <xuewen.yan@unisoc.com>

When the policy->related_cpus are all offline, and then
bring up one cpu, this time, if the ->online is NULL,
the code would update the ->related_cpus with ->cpus,
and now ->cpus is only one online cpu, as a result, the
->related_cpus is different from the origion ->related_cpus.

Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
---
 drivers/cpufreq/cpufreq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Viresh Kumar Feb. 2, 2021, 9:41 a.m. UTC | #1
On 02-02-21, 17:36, Xuewen Yan wrote:
> From: Xuewen Yan <xuewen.yan@unisoc.com>
> 
> When the policy->related_cpus are all offline, and then
> bring up one cpu, this time, if the ->online is NULL,
> the code would update the ->related_cpus with ->cpus,
> and now ->cpus is only one online cpu, as a result, the
> ->related_cpus is different from the origion ->related_cpus.
> 
> Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
> ---
>  drivers/cpufreq/cpufreq.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index d0a3525ce27f..3d512ac463a5 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1374,8 +1374,10 @@ static int cpufreq_online(unsigned int cpu)
>  		if (ret)
>  			goto out_exit_policy;
>  
> -		/* related_cpus should at least include policy->cpus. */
> -		cpumask_copy(policy->related_cpus, policy->cpus);
> +		if (new_policy) {
> +			/* related_cpus should at least include policy->cpus. */
> +			cpumask_copy(policy->related_cpus, policy->cpus);
> +		}
>  	}

The driver's ->init() callback is responsible for filling policy->cpus
here.
diff mbox series

Patch

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index d0a3525ce27f..3d512ac463a5 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1374,8 +1374,10 @@  static int cpufreq_online(unsigned int cpu)
 		if (ret)
 			goto out_exit_policy;
 
-		/* related_cpus should at least include policy->cpus. */
-		cpumask_copy(policy->related_cpus, policy->cpus);
+		if (new_policy) {
+			/* related_cpus should at least include policy->cpus. */
+			cpumask_copy(policy->related_cpus, policy->cpus);
+		}
 	}
 
 	down_write(&policy->rwsem);