All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Dooks <ben-linux@fluff.org>
To: Jaecheol Lee <jc.lee@samsung.com>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org, kgene.kim@samsung.com,
	Minho Ban <mhban@samsung.com>,
	ben-linux@fluff.org
Subject: Re: [PATCH] ARM: SAMSUNG: Bug fix spin_lock recursion in clk_enable() and	clk_disable()
Date: Tue, 19 Oct 2010 00:09:25 +0100	[thread overview]
Message-ID: <4CBCD3A5.5070701@fluff.org> (raw)
In-Reply-To: <1286843980-23684-1-git-send-email-jc.lee@samsung.com>

On 12/10/10 01:39, Jaecheol Lee wrote:
> From: Minho Ban <mhban@samsung.com>
> 
> The clk_enable() and clk_disable() can be used process and ISR either.
> So spin_lock_irqsave should be used instead.
> 
> Signed-off-by: Minho Ban <mhban@samsung.com>
> Signed-off-by: Jaecheol Lee <jc.lee@samsung.com>
> ---
>  arch/arm/plat-samsung/clock.c |   12 ++++++++----
>  1 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c
> index e8d20b0..2a991a5 100644
> --- a/arch/arm/plat-samsung/clock.c
> +++ b/arch/arm/plat-samsung/clock.c
> @@ -138,31 +138,35 @@ void clk_put(struct clk *clk)
>  
>  int clk_enable(struct clk *clk)
>  {
> +	unsigned long flags;
> +
>  	if (IS_ERR(clk) || clk == NULL)
>  		return -EINVAL;
>  
>  	clk_enable(clk->parent);
>  
> -	spin_lock(&clocks_lock);
> +	spin_lock_irqsave(&clocks_lock, flags);
>  
>  	if ((clk->usage++) == 0)
>  		(clk->enable)(clk, 1);
>  
> -	spin_unlock(&clocks_lock);
> +	spin_unlock_irqrestore(&clocks_lock, flags);
>  	return 0;
>  }
>  
>  void clk_disable(struct clk *clk)
>  {
> +	unsigned long flags;
> +
>  	if (IS_ERR(clk) || clk == NULL)
>  		return;
>  
> -	spin_lock(&clocks_lock);
> +	spin_lock_irqsave(&clocks_lock, flags);
>  
>  	if ((--clk->usage) == 0)
>  		(clk->enable)(clk, 0);
>  
> -	spin_unlock(&clocks_lock);
> +	spin_unlock_irqrestore(&clocks_lock, flags);
>  	clk_disable(clk->parent);

I'm not sure, but I don't belive that the clk_ api has
ever been callable from non-sleepable contexts such as
interrupt handlers.

I would welcome RMK's response (or any other response)
about this issue?

Personally, given that some clk_ calls may sleep esp.
for pll enables, I would prefer to see this patch
dropped in favour of fixing the users.

-- 
Ben

WARNING: multiple messages have this Message-ID (diff)
From: ben-linux@fluff.org (Ben Dooks)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: SAMSUNG: Bug fix spin_lock recursion in clk_enable() and	clk_disable()
Date: Tue, 19 Oct 2010 00:09:25 +0100	[thread overview]
Message-ID: <4CBCD3A5.5070701@fluff.org> (raw)
In-Reply-To: <1286843980-23684-1-git-send-email-jc.lee@samsung.com>

On 12/10/10 01:39, Jaecheol Lee wrote:
> From: Minho Ban <mhban@samsung.com>
> 
> The clk_enable() and clk_disable() can be used process and ISR either.
> So spin_lock_irqsave should be used instead.
> 
> Signed-off-by: Minho Ban <mhban@samsung.com>
> Signed-off-by: Jaecheol Lee <jc.lee@samsung.com>
> ---
>  arch/arm/plat-samsung/clock.c |   12 ++++++++----
>  1 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c
> index e8d20b0..2a991a5 100644
> --- a/arch/arm/plat-samsung/clock.c
> +++ b/arch/arm/plat-samsung/clock.c
> @@ -138,31 +138,35 @@ void clk_put(struct clk *clk)
>  
>  int clk_enable(struct clk *clk)
>  {
> +	unsigned long flags;
> +
>  	if (IS_ERR(clk) || clk == NULL)
>  		return -EINVAL;
>  
>  	clk_enable(clk->parent);
>  
> -	spin_lock(&clocks_lock);
> +	spin_lock_irqsave(&clocks_lock, flags);
>  
>  	if ((clk->usage++) == 0)
>  		(clk->enable)(clk, 1);
>  
> -	spin_unlock(&clocks_lock);
> +	spin_unlock_irqrestore(&clocks_lock, flags);
>  	return 0;
>  }
>  
>  void clk_disable(struct clk *clk)
>  {
> +	unsigned long flags;
> +
>  	if (IS_ERR(clk) || clk == NULL)
>  		return;
>  
> -	spin_lock(&clocks_lock);
> +	spin_lock_irqsave(&clocks_lock, flags);
>  
>  	if ((--clk->usage) == 0)
>  		(clk->enable)(clk, 0);
>  
> -	spin_unlock(&clocks_lock);
> +	spin_unlock_irqrestore(&clocks_lock, flags);
>  	clk_disable(clk->parent);

I'm not sure, but I don't belive that the clk_ api has
ever been callable from non-sleepable contexts such as
interrupt handlers.

I would welcome RMK's response (or any other response)
about this issue?

Personally, given that some clk_ calls may sleep esp.
for pll enables, I would prefer to see this patch
dropped in favour of fixing the users.

-- 
Ben

  reply	other threads:[~2010-10-18 23:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-12  0:39 [PATCH] ARM: SAMSUNG: Bug fix spin_lock recursion in clk_enable() and clk_disable() Jaecheol Lee
2010-10-12  0:39 ` Jaecheol Lee
2010-10-18 23:09 ` Ben Dooks [this message]
2010-10-18 23:09   ` Ben Dooks
2010-10-19  1:12   ` Jassi Brar
2010-10-19  1:12     ` Jassi Brar
2010-10-19  2:55     ` mhban
2010-10-19  2:55       ` mhban
2010-10-19 18:57   ` Russell King - ARM Linux
2010-10-19 18:57     ` Russell King - ARM Linux
2010-10-21 22:39     ` Ben Dooks

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=4CBCD3A5.5070701@fluff.org \
    --to=ben-linux@fluff.org \
    --cc=jc.lee@samsung.com \
    --cc=kgene.kim@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=mhban@samsung.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.