linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Artem Savkov <artem.savkov@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: "Rafael J. Wysocki" <rjw@sisk.pl>,
	valdis.kletnieks@vt.edu, cpufreq@vger.kernel.org,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linaro-dev@lists.linaro.org, robin.randhawa@arm.com,
	Steve.Bannister@arm.com, Liviu.Dudau@arm.com,
	dirk.brandewie@gmail.com
Subject: Re: [PATCH 0/4] CPUFreq Fixes for 3.9
Date: Fri, 8 Feb 2013 10:27:36 +0400	[thread overview]
Message-ID: <20130208062736.GA5563@thinkpad.lan> (raw)
In-Reply-To: <CAKohpony25Ct94QyCOEmoNVS6Xc5O8=0Cnc6NxLxTP5Y-E1XJg@mail.gmail.com>

On Fri, Feb 08, 2013 at 10:39:13AM +0530, Viresh Kumar wrote:
> On 8 February 2013 04:37, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > BTW, there still are locking problems in linux-next.  Why do we need
> > to take cpufreq_driver_lock() around driver->init() in cpufreq_add_dev(),
> > in particular?
> I thought a bit more and realized there is no such limitation on
> cpufreq_driver->ops about calling routines which can sleep. And thus
> we shoudln't
> have locks around any of these. I have got a patch for it, that i
> would fold-back into
> the original patch that introduced locking fixes (attached too for testing):
Tested this patch on top of linux-pm.git/bleeding-edge
Now everything seems to be alright.

> From: Viresh Kumar <viresh.kumar@linaro.org>
> Date: Fri, 8 Feb 2013 10:35:31 +0530
> Subject: [PATCH] cpufreq: Remove unnecessary locking
> 
> I have placed some locks intentionally around calls to driver->ops (init/exit),
> which look to be wrong as these calls can call routines that potentially sleep.
> 
> Lets remove these locks.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  drivers/cpufreq/cpufreq.c | 7 -------
>  1 file changed, 7 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 5d8a422..04aab05 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -795,10 +795,8 @@ static int cpufreq_add_dev_interface(unsigned int cpu,
> 
>  	if (ret) {
>  		pr_debug("setting policy failed\n");
> -		spin_lock_irqsave(&cpufreq_driver_lock, flags);
>  		if (driver->exit)
>  			driver->exit(policy);
> -		spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
>  	}
>  	return ret;
> 
> @@ -920,17 +918,14 @@ static int cpufreq_add_dev(struct device *dev,
> struct subsys_interface *sif)
>  	init_completion(&policy->kobj_unregister);
>  	INIT_WORK(&policy->update, handle_update);
> 
> -	spin_lock_irqsave(&cpufreq_driver_lock, flags);
>  	/* call driver. From then on the cpufreq must be able
>  	 * to accept all calls to ->verify and ->setpolicy for this CPU
>  	 */
>  	ret = driver->init(policy);
>  	if (ret) {
>  		pr_debug("initialization failed\n");
> -		spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
>  		goto err_set_policy_cpu;
>  	}
> -	spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
> 
>  	/* related cpus should atleast have policy->cpus */
>  	cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus);
> @@ -1100,10 +1095,8 @@ static int __cpufreq_remove_dev(struct device
> *dev, struct subsys_interface *sif
>  		wait_for_completion(cmp);
>  		pr_debug("wait complete\n");
> 
> -		spin_lock_irqsave(&cpufreq_driver_lock, flags);
>  		if (driver->exit)
>  			driver->exit(data);
> -		spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
> 
>  		free_cpumask_var(data->related_cpus);
>  		free_cpumask_var(data->cpus);

Tested-by: Artem Savkov <artem.savkov@gmail.com>

-- 
Kind regards,
Artem

  reply	other threads:[~2013-02-08  6:27 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-07 10:27 [PATCH 0/4] CPUFreq Fixes for 3.9 Viresh Kumar
2013-02-07 10:27 ` [PATCH 1/4] cpufreq: governors: Fix WARN_ON() for multi-policy platforms Viresh Kumar
2013-02-07 10:27 ` [PATCH 2/4] cpufreq: Remove unused HOTPLUG_CPU code Viresh Kumar
2013-02-07 10:27 ` [PATCH 3/4] cpufreq: Create a macro for unlock_policy_rwsem{read,write} Viresh Kumar
2013-02-07 10:27 ` [PATCH 4/4] cpufreq: Fix locking issues Viresh Kumar
2013-02-07 13:05 ` [PATCH 0/4] CPUFreq Fixes for 3.9 Rafael J. Wysocki
2013-02-07 13:22   ` Viresh Kumar
2013-02-07 23:07     ` Rafael J. Wysocki
2013-02-08  2:49       ` Viresh Kumar
2013-02-08  5:09       ` Viresh Kumar
2013-02-08  6:27         ` Artem Savkov [this message]
2013-02-07 19:39 ` Artem Savkov
2013-02-08  2:52   ` Viresh Kumar
2013-02-07 23:33 ` Rafael J. Wysocki
2013-02-07 23:48   ` Rafael J. Wysocki
2013-02-08  2:50   ` Viresh Kumar
2013-02-08 12:32     ` Rafael J. Wysocki
2013-02-08 14:36       ` Viresh Kumar
2013-02-08 20:02         ` Rafael J. Wysocki
2013-02-08 23:56           ` Rafael J. Wysocki
2013-02-09  0:08             ` Dirk Brandewie
2013-02-09  0:21               ` Rafael J. Wysocki
2013-02-09  2:10               ` Viresh Kumar
2013-02-09 11:44                 ` Rafael J. Wysocki
2013-02-08  5:32   ` Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130208062736.GA5563@thinkpad.lan \
    --to=artem.savkov@gmail.com \
    --cc=Liviu.Dudau@arm.com \
    --cc=Steve.Bannister@arm.com \
    --cc=cpufreq@vger.kernel.org \
    --cc=dirk.brandewie@gmail.com \
    --cc=linaro-dev@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --cc=robin.randhawa@arm.com \
    --cc=valdis.kletnieks@vt.edu \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).