public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpufreq: Always remove sysfs cpuX/cpufreq link on ->remove_dev()
       [not found] <1448074212.3450.4.camel@linux.intel.com>
@ 2015-11-21  3:34 ` Viresh Kumar
  2015-11-21  3:36 ` [PATCH V2] " Viresh Kumar
  1 sibling, 0 replies; 4+ messages in thread
From: Viresh Kumar @ 2015-11-21  3:34 UTC (permalink / raw)
  To: Rafael Wysocki, srinivas.pandruvada
  Cc: linaro-kernel, linux-pm, Viresh Kumar, open list

Subsys interface's ->remove_dev() is called when the cpufreq driver is
unregistering or the CPU is getting physically removed. We keep removing
the cpuX/cpufreq link for all CPUs except the last one, which is a
mistake as all CPUs contain a link now.

Because of this, one CPU from each policy will still contain a link (to
an already removed policyX directory), after the cpufreq driver is
unregistered.

Fix that by removing the link first and then only see if the policy is
required to be freed. That will make sure that no links are left out.

Fixes: 96bdda61f58b ("cpufreq: create cpu/cpufreq/policyX directories")
Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
@Srinivas: This should fix it for you.

 drivers/cpufreq/cpufreq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 7c48e7316d91..163ba0503ddf 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1401,13 +1401,12 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
 	}
 
 	cpumask_clear_cpu(cpu, policy->real_cpus);
+	remove_cpu_dev_symlink(policy, cpu);
 
 	if (cpumask_empty(policy->real_cpus)) {
 		cpufreq_policy_free(policy, true);
 		return;
 	}
-
-	remove_cpu_dev_symlink(policy, cpu);
 }
 
 static void handle_update(struct work_struct *work)
-- 
2.6.2.198.g614a2ac


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

* [PATCH V2] cpufreq: Always remove sysfs cpuX/cpufreq link on ->remove_dev()
       [not found] <1448074212.3450.4.camel@linux.intel.com>
  2015-11-21  3:34 ` [PATCH] cpufreq: Always remove sysfs cpuX/cpufreq link on ->remove_dev() Viresh Kumar
@ 2015-11-21  3:36 ` Viresh Kumar
  2015-11-21 14:42   ` Srinivas Pandruvada
  1 sibling, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2015-11-21  3:36 UTC (permalink / raw)
  To: Rafael Wysocki, srinivas.pandruvada
  Cc: linaro-kernel, linux-pm, Viresh Kumar, open list

Subsys interface's ->remove_dev() is called when the cpufreq driver is
unregistering or the CPU is getting physically removed. We keep removing
the cpuX/cpufreq link for all CPUs except the last one, which is a
mistake as all CPUs contain a link now.

Because of this, one CPU from each policy will still contain a link (to
an already removed policyX directory), after the cpufreq driver is
unregistered.

Fix that by removing the link first and then only see if the policy is
required to be freed. That will make sure that no links are left out.

Fixes: 96bdda61f58b ("cpufreq: create cpu/cpufreq/policyX directories")
Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
[v2] Drop the unnecessary 'return', sorry about that :(

 drivers/cpufreq/cpufreq.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 7c48e7316d91..a83c995a62df 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1401,13 +1401,10 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
 	}
 
 	cpumask_clear_cpu(cpu, policy->real_cpus);
+	remove_cpu_dev_symlink(policy, cpu);
 
-	if (cpumask_empty(policy->real_cpus)) {
+	if (cpumask_empty(policy->real_cpus))
 		cpufreq_policy_free(policy, true);
-		return;
-	}
-
-	remove_cpu_dev_symlink(policy, cpu);
 }
 
 static void handle_update(struct work_struct *work)
-- 
2.6.2.198.g614a2ac


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

* Re: [PATCH V2] cpufreq: Always remove sysfs cpuX/cpufreq link on ->remove_dev()
  2015-11-21  3:36 ` [PATCH V2] " Viresh Kumar
@ 2015-11-21 14:42   ` Srinivas Pandruvada
  2015-11-23 22:47     ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Srinivas Pandruvada @ 2015-11-21 14:42 UTC (permalink / raw)
  To: Viresh Kumar, Rafael Wysocki; +Cc: linaro-kernel, linux-pm, open list

On Sat, 2015-11-21 at 09:06 +0530, Viresh Kumar wrote:
> Subsys interface's ->remove_dev() is called when the cpufreq driver
> is
> unregistering or the CPU is getting physically removed. We keep
> removing
> the cpuX/cpufreq link for all CPUs except the last one, which is a
> mistake as all CPUs contain a link now.
> 
> Because of this, one CPU from each policy will still contain a link
> (to
> an already removed policyX directory), after the cpufreq driver is
> unregistered.
> 
> Fix that by removing the link first and then only see if the policy
> is
> required to be freed. That will make sure that no links are left out.
> 
> Fixes: 96bdda61f58b ("cpufreq: create cpu/cpufreq/policyX
> directories")
> Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com

Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com
> >
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> [v2] Drop the unnecessary 'return', sorry about that :(
> 
>  drivers/cpufreq/cpufreq.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 7c48e7316d91..a83c995a62df 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1401,13 +1401,10 @@ static void cpufreq_remove_dev(struct device
> *dev, struct subsys_interface *sif)
>  	}
>  
>  	cpumask_clear_cpu(cpu, policy->real_cpus);
> +	remove_cpu_dev_symlink(policy, cpu);
>  
> -	if (cpumask_empty(policy->real_cpus)) {
> +	if (cpumask_empty(policy->real_cpus))
>  		cpufreq_policy_free(policy, true);
> -		return;
> -	}
> -
> -	remove_cpu_dev_symlink(policy, cpu);
>  }
>  
>  static void handle_update(struct work_struct *work)

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

* Re: [PATCH V2] cpufreq: Always remove sysfs cpuX/cpufreq link on ->remove_dev()
  2015-11-21 14:42   ` Srinivas Pandruvada
@ 2015-11-23 22:47     ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2015-11-23 22:47 UTC (permalink / raw)
  To: Srinivas Pandruvada, Viresh Kumar; +Cc: linaro-kernel, linux-pm, open list

On Saturday, November 21, 2015 06:42:09 AM Srinivas Pandruvada wrote:
> On Sat, 2015-11-21 at 09:06 +0530, Viresh Kumar wrote:
> > Subsys interface's ->remove_dev() is called when the cpufreq driver
> > is
> > unregistering or the CPU is getting physically removed. We keep
> > removing
> > the cpuX/cpufreq link for all CPUs except the last one, which is a
> > mistake as all CPUs contain a link now.
> > 
> > Because of this, one CPU from each policy will still contain a link
> > (to
> > an already removed policyX directory), after the cpufreq driver is
> > unregistered.
> > 
> > Fix that by removing the link first and then only see if the policy
> > is
> > required to be freed. That will make sure that no links are left out.
> > 
> > Fixes: 96bdda61f58b ("cpufreq: create cpu/cpufreq/policyX
> > directories")
> > Reported-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com
> 
> Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com

Applied, thanks!

Rafael


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

end of thread, other threads:[~2015-11-23 22:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1448074212.3450.4.camel@linux.intel.com>
2015-11-21  3:34 ` [PATCH] cpufreq: Always remove sysfs cpuX/cpufreq link on ->remove_dev() Viresh Kumar
2015-11-21  3:36 ` [PATCH V2] " Viresh Kumar
2015-11-21 14:42   ` Srinivas Pandruvada
2015-11-23 22:47     ` 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