linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: acpi: policy->driver_data can't be NULL in ->exit()
@ 2016-03-30  4:24 Viresh Kumar
  2016-03-30 11:15 ` Rafael J. Wysocki
  0 siblings, 1 reply; 7+ messages in thread
From: Viresh Kumar @ 2016-03-30  4:24 UTC (permalink / raw)
  To: Rafael Wysocki, Viresh Kumar; +Cc: linaro-kernel, linux-pm, linux-kernel

Its always set by ->init() and so it will always be there in ->exit().
There is no need to have a special check for just that.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/acpi-cpufreq.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
index eb2196f9d7fa..e20cbb1317cc 100644
--- a/drivers/cpufreq/acpi-cpufreq.c
+++ b/drivers/cpufreq/acpi-cpufreq.c
@@ -847,13 +847,11 @@ static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy)
 
 	pr_debug("acpi_cpufreq_cpu_exit\n");
 
-	if (data) {
-		policy->driver_data = NULL;
-		acpi_processor_unregister_performance(data->acpi_perf_cpu);
-		free_cpumask_var(data->freqdomain_cpus);
-		kfree(policy->freq_table);
-		kfree(data);
-	}
+	policy->driver_data = NULL;
+	acpi_processor_unregister_performance(data->acpi_perf_cpu);
+	free_cpumask_var(data->freqdomain_cpus);
+	kfree(policy->freq_table);
+	kfree(data);
 
 	return 0;
 }
-- 
2.7.1.410.g6faf27b


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

* Re: [PATCH] cpufreq: acpi: policy->driver_data can't be NULL in ->exit()
  2016-03-30  4:24 [PATCH] cpufreq: acpi: policy->driver_data can't be NULL in ->exit() Viresh Kumar
@ 2016-03-30 11:15 ` Rafael J. Wysocki
  2016-03-30 11:18   ` Rafael J. Wysocki
  2016-03-30 11:21   ` Viresh Kumar
  0 siblings, 2 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2016-03-30 11:15 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Rafael Wysocki, Lists linaro-kernel, linux-pm@vger.kernel.org,
	Linux Kernel Mailing List

On Wed, Mar 30, 2016 at 6:24 AM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> Its always set by ->init() and so it will always be there in ->exit().
> There is no need to have a special check for just that.

I'm not sure what happens if there are two (or more) CPUs in the policy, though.

That case is almost certainly handled incorrectly here (or rather not
handled at all), but it may just happen to sort of work, because the
first exiting CPU will clear driver_data and the second one will
notice that it is NULL now.  Of course, that still is racy with
respect to governors etc, but I'd rather fix the driver properly.

> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/cpufreq/acpi-cpufreq.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> index eb2196f9d7fa..e20cbb1317cc 100644
> --- a/drivers/cpufreq/acpi-cpufreq.c
> +++ b/drivers/cpufreq/acpi-cpufreq.c
> @@ -847,13 +847,11 @@ static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy)
>
>         pr_debug("acpi_cpufreq_cpu_exit\n");
>
> -       if (data) {
> -               policy->driver_data = NULL;
> -               acpi_processor_unregister_performance(data->acpi_perf_cpu);
> -               free_cpumask_var(data->freqdomain_cpus);
> -               kfree(policy->freq_table);
> -               kfree(data);
> -       }
> +       policy->driver_data = NULL;
> +       acpi_processor_unregister_performance(data->acpi_perf_cpu);
> +       free_cpumask_var(data->freqdomain_cpus);
> +       kfree(policy->freq_table);
> +       kfree(data);
>
>         return 0;
>  }
> --
> 2.7.1.410.g6faf27b
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] cpufreq: acpi: policy->driver_data can't be NULL in ->exit()
  2016-03-30 11:15 ` Rafael J. Wysocki
@ 2016-03-30 11:18   ` Rafael J. Wysocki
  2016-03-30 11:23     ` Viresh Kumar
  2016-04-01  8:22     ` Viresh Kumar
  2016-03-30 11:21   ` Viresh Kumar
  1 sibling, 2 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2016-03-30 11:18 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Viresh Kumar, Rafael Wysocki, Lists linaro-kernel,
	linux-pm@vger.kernel.org, Linux Kernel Mailing List

On Wed, Mar 30, 2016 at 1:15 PM, Rafael J. Wysocki <rafael@kernel.org> wrote:
> On Wed, Mar 30, 2016 at 6:24 AM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
>> Its always set by ->init() and so it will always be there in ->exit().
>> There is no need to have a special check for just that.
>
> I'm not sure what happens if there are two (or more) CPUs in the policy, though.
>
> That case is almost certainly handled incorrectly here (or rather not
> handled at all), but it may just happen to sort of work, because the
> first exiting CPU will clear driver_data and the second one will
> notice that it is NULL now.  Of course, that still is racy with
> respect to governors etc, but I'd rather fix the driver properly.

Sorry, scratch that.  To core only calls ->exit for the last CPU in
the policy, so I agree with the patch.

It conflicts with other stuff (as you know), so I'm not sure about the
order in which they are going to be applied, though.

Thanks,
Rafael

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

* Re: [PATCH] cpufreq: acpi: policy->driver_data can't be NULL in ->exit()
  2016-03-30 11:15 ` Rafael J. Wysocki
  2016-03-30 11:18   ` Rafael J. Wysocki
@ 2016-03-30 11:21   ` Viresh Kumar
  1 sibling, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2016-03-30 11:21 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Rafael Wysocki, Lists linaro-kernel, linux-pm@vger.kernel.org,
	Linux Kernel Mailing List

On 30-03-16, 13:15, Rafael J. Wysocki wrote:
> On Wed, Mar 30, 2016 at 6:24 AM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> > Its always set by ->init() and so it will always be there in ->exit().
> > There is no need to have a special check for just that.
> 
> I'm not sure what happens if there are two (or more) CPUs in the policy, though.
> 
> That case is almost certainly handled incorrectly here (or rather not
> handled at all), but it may just happen to sort of work, because the
> first exiting CPU will clear driver_data and the second one will
> notice that it is NULL now.  Of course, that still is racy with
> respect to governors etc, but I'd rather fix the driver properly.

Sorry, I probably didn't understood your comments properly.

But, the core will call ->exit() only for the last exiting CPU. So,
driver_data will never be NULL.

-- 
viresh

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

* Re: [PATCH] cpufreq: acpi: policy->driver_data can't be NULL in ->exit()
  2016-03-30 11:18   ` Rafael J. Wysocki
@ 2016-03-30 11:23     ` Viresh Kumar
  2016-04-01  8:22     ` Viresh Kumar
  1 sibling, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2016-03-30 11:23 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Rafael Wysocki, Lists linaro-kernel, linux-pm@vger.kernel.org,
	Linux Kernel Mailing List

On 30-03-16, 13:18, Rafael J. Wysocki wrote:
> It conflicts with other stuff (as you know), so I'm not sure about the
> order in which they are going to be applied, though.

Yeah, I know. I noticed the ugliness only after looking at your
changes :)

I am fine to rebase them over if you want. Its really trivial.

-- 
viresh

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

* Re: [PATCH] cpufreq: acpi: policy->driver_data can't be NULL in ->exit()
  2016-03-30 11:18   ` Rafael J. Wysocki
  2016-03-30 11:23     ` Viresh Kumar
@ 2016-04-01  8:22     ` Viresh Kumar
  2016-04-01 21:00       ` Rafael J. Wysocki
  1 sibling, 1 reply; 7+ messages in thread
From: Viresh Kumar @ 2016-04-01  8:22 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Rafael Wysocki, Lists linaro-kernel, linux-pm@vger.kernel.org,
	Linux Kernel Mailing List

On 30-03-16, 13:18, Rafael J. Wysocki wrote:
> It conflicts with other stuff (as you know), so I'm not sure about the
> order in which they are going to be applied, though.

Please let me know when can I rebase and resend this one. I saw that you have
moved your patches to linux-next now.

-- 
viresh

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

* Re: [PATCH] cpufreq: acpi: policy->driver_data can't be NULL in ->exit()
  2016-04-01  8:22     ` Viresh Kumar
@ 2016-04-01 21:00       ` Rafael J. Wysocki
  0 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2016-04-01 21:00 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Rafael J. Wysocki, Lists linaro-kernel, linux-pm@vger.kernel.org,
	Linux Kernel Mailing List

On Friday, April 01, 2016 01:52:54 PM Viresh Kumar wrote:
> On 30-03-16, 13:18, Rafael J. Wysocki wrote:
> > It conflicts with other stuff (as you know), so I'm not sure about the
> > order in which they are going to be applied, though.
> 
> Please let me know when can I rebase and resend this one. I saw that you have
> moved your patches to linux-next now.

I have, but they need to be rebased on top of 2 intel_pstate fixes I want to
push for v4.6 still and some more minor changes will be necessary.

I guess next week will be the right time kind of, but I will be traveling
10-17 Apr, so I may not have much time to process stuff.

Thanks,
Rafael


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

end of thread, other threads:[~2016-04-01 20:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-30  4:24 [PATCH] cpufreq: acpi: policy->driver_data can't be NULL in ->exit() Viresh Kumar
2016-03-30 11:15 ` Rafael J. Wysocki
2016-03-30 11:18   ` Rafael J. Wysocki
2016-03-30 11:23     ` Viresh Kumar
2016-04-01  8:22     ` Viresh Kumar
2016-04-01 21:00       ` Rafael J. Wysocki
2016-03-30 11:21   ` Viresh Kumar

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