linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq: imx6: prorect calls to dev_pm_opp_get_opp_count with RCU lock
@ 2014-12-16  0:50 Dmitry Torokhov
  2014-12-16  5:33 ` Viresh Kumar
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2014-12-16  0:50 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Viresh Kumar, Shawn Guo, Philipp Zabel, Anson Huang, John Tobias,
	linux-pm, linux-kernel

dev_pm_opp_get_opp_count() must be called with RCU lock held.

Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
---

Not tested at all...

 drivers/cpufreq/imx6q-cpufreq.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index 380a90d..851d4fd 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -200,7 +200,9 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
 	 * Just, incase the platform did not supply the OPP
 	 * table, it will try to get it.
 	 */
+	rcu_read_lock();
 	num = dev_pm_opp_get_opp_count(cpu_dev);
+	rcu_read_unlock();
 	if (num < 0) {
 		ret = of_init_opp_table(cpu_dev);
 		if (ret < 0) {
@@ -211,7 +213,9 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
 		/* Because we have added the OPPs here, we must free them */
 		free_opp = true;
 
+		rcu_read_lock();
 		num = dev_pm_opp_get_opp_count(cpu_dev);
+		rcu_read_unlock();
 		if (num < 0) {
 			ret = num;
 			dev_err(cpu_dev, "no OPP table is found: %d\n", ret);
-- 
2.2.0.rc0.207.ga3a616c


-- 
Dmitry

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

* Re: [PATCH] cpufreq: imx6: prorect calls to dev_pm_opp_get_opp_count with RCU lock
  2014-12-16  0:50 [PATCH] cpufreq: imx6: prorect calls to dev_pm_opp_get_opp_count with RCU lock Dmitry Torokhov
@ 2014-12-16  5:33 ` Viresh Kumar
  2014-12-16  5:41   ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2014-12-16  5:33 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Rafael J. Wysocki, Shawn Guo, Philipp Zabel, Anson Huang,
	John Tobias, linux-pm@vger.kernel.org, Linux Kernel Mailing List

On 16 December 2014 at 06:20, Dmitry Torokhov <dtor@chromium.org> wrote:
> dev_pm_opp_get_opp_count() must be called with RCU lock held.
>
> Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
> ---
>
> Not tested at all...
>
>  drivers/cpufreq/imx6q-cpufreq.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
> index 380a90d..851d4fd 100644
> --- a/drivers/cpufreq/imx6q-cpufreq.c
> +++ b/drivers/cpufreq/imx6q-cpufreq.c
> @@ -200,7 +200,9 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
>          * Just, incase the platform did not supply the OPP
>          * table, it will try to get it.
>          */
> +       rcu_read_lock();
>         num = dev_pm_opp_get_opp_count(cpu_dev);
> +       rcu_read_unlock();
>         if (num < 0) {
>                 ret = of_init_opp_table(cpu_dev);
>                 if (ret < 0) {
> @@ -211,7 +213,9 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
>                 /* Because we have added the OPPs here, we must free them */
>                 free_opp = true;
>
> +               rcu_read_lock();
>                 num = dev_pm_opp_get_opp_count(cpu_dev);
> +               rcu_read_unlock();
>                 if (num < 0) {
>                         ret = num;
>                         dev_err(cpu_dev, "no OPP table is found: %d\n", ret);

This one looks fine for sure but I was wondering for the users which just
need to call opp-count from under the locks, what about something like:

dev_pm_opp_get_opp_count_locked() ?

--
viresh

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

* Re: [PATCH] cpufreq: imx6: prorect calls to dev_pm_opp_get_opp_count with RCU lock
  2014-12-16  5:33 ` Viresh Kumar
@ 2014-12-16  5:41   ` Dmitry Torokhov
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2014-12-16  5:41 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Dmitry Torokhov, Rafael J. Wysocki, Shawn Guo, Philipp Zabel,
	Anson Huang, John Tobias, linux-pm@vger.kernel.org,
	Linux Kernel Mailing List

On Mon, Dec 15, 2014 at 9:33 PM, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> On 16 December 2014 at 06:20, Dmitry Torokhov <dtor@chromium.org> wrote:
>> dev_pm_opp_get_opp_count() must be called with RCU lock held.
>>
>> Signed-off-by: Dmitry Torokhov <dtor@chromium.org>
>> ---
>>
>> Not tested at all...
>>
>>  drivers/cpufreq/imx6q-cpufreq.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
>> index 380a90d..851d4fd 100644
>> --- a/drivers/cpufreq/imx6q-cpufreq.c
>> +++ b/drivers/cpufreq/imx6q-cpufreq.c
>> @@ -200,7 +200,9 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
>>          * Just, incase the platform did not supply the OPP
>>          * table, it will try to get it.
>>          */
>> +       rcu_read_lock();
>>         num = dev_pm_opp_get_opp_count(cpu_dev);
>> +       rcu_read_unlock();
>>         if (num < 0) {
>>                 ret = of_init_opp_table(cpu_dev);
>>                 if (ret < 0) {
>> @@ -211,7 +213,9 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
>>                 /* Because we have added the OPPs here, we must free them */
>>                 free_opp = true;
>>
>> +               rcu_read_lock();
>>                 num = dev_pm_opp_get_opp_count(cpu_dev);
>> +               rcu_read_unlock();
>>                 if (num < 0) {
>>                         ret = num;
>>                         dev_err(cpu_dev, "no OPP table is found: %d\n", ret);
>
> This one looks fine for sure but I was wondering for the users which just
> need to call opp-count from under the locks, what about something like:
>
> dev_pm_opp_get_opp_count_locked() ?

Yeah, for the majority of callers taking the lock won't hurt as they
call it in their init code.

Thanks,
Dmitry

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

end of thread, other threads:[~2014-12-16  5:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-16  0:50 [PATCH] cpufreq: imx6: prorect calls to dev_pm_opp_get_opp_count with RCU lock Dmitry Torokhov
2014-12-16  5:33 ` Viresh Kumar
2014-12-16  5:41   ` Dmitry Torokhov

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