All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tushar Behera <tushar.behera@linaro.org>
To: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org
Cc: kgene.kim@samsung.com, patches@linaro.org
Subject: Re: [PATCH] ARM: SAMSUNG: Use spin_lock_{irqsave,irqrestore} in clk_set_rate
Date: Fri, 14 Sep 2012 10:32:20 +0530	[thread overview]
Message-ID: <5052BA5C.2040900@linaro.org> (raw)
In-Reply-To: <1346998102-5317-1-git-send-email-tushar.behera@linaro.org>

Ping !

On 09/07/2012 11:38 AM, Tushar Behera wrote:
> The spinlock clocks_lock can be held during ISR, hence it is not safe to
> hold that lock with disabling interrupts.
> 
> It fixes following potential deadlock.
> 
> =========================================================
> [ INFO: possible irq lock inversion dependency detected ]
> 3.6.0-rc4+ #2 Not tainted
> ---------------------------------------------------------
> swapper/0/1 just changed the state of lock:
>  (&(&host->lock)->rlock){-.....}, at: [<c027fb0d>] sdhci_irq+0x15/0x564
> but this lock took another, HARDIRQ-unsafe lock in the past:
>  (clocks_lock){+.+...}
> 
> and interrupts could create inverse lock ordering between them.
> 
> other info that might help us debug this:
>  Possible interrupt unsafe locking scenario:
> 
>        CPU0                    CPU1
>        ----                    ----
>   lock(clocks_lock);
>                                local_irq_disable();
>                                lock(&(&host->lock)->rlock);
>                                lock(clocks_lock);
>   <Interrupt>
>     lock(&(&host->lock)->rlock);
> 
>  *** DEADLOCK ***
> 
> Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
> ---
>  arch/arm/plat-samsung/clock.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c
> index 65c5eca..9b71719 100644
> --- a/arch/arm/plat-samsung/clock.c
> +++ b/arch/arm/plat-samsung/clock.c
> @@ -144,6 +144,7 @@ long clk_round_rate(struct clk *clk, unsigned long rate)
>  
>  int clk_set_rate(struct clk *clk, unsigned long rate)
>  {
> +	unsigned long flags;
>  	int ret;
>  
>  	if (IS_ERR(clk))
> @@ -159,9 +160,9 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
>  	if (clk->ops == NULL || clk->ops->set_rate == NULL)
>  		return -EINVAL;
>  
> -	spin_lock(&clocks_lock);
> +	spin_lock_irqsave(&clocks_lock, flags);
>  	ret = (clk->ops->set_rate)(clk, rate);
> -	spin_unlock(&clocks_lock);
> +	spin_unlock_irqrestore(&clocks_lock, flags);
>  
>  	return ret;
>  }
> 


-- 
Tushar Behera

WARNING: multiple messages have this Message-ID (diff)
From: tushar.behera@linaro.org (Tushar Behera)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: SAMSUNG: Use spin_lock_{irqsave, irqrestore} in clk_set_rate
Date: Fri, 14 Sep 2012 10:32:20 +0530	[thread overview]
Message-ID: <5052BA5C.2040900@linaro.org> (raw)
In-Reply-To: <1346998102-5317-1-git-send-email-tushar.behera@linaro.org>

Ping !

On 09/07/2012 11:38 AM, Tushar Behera wrote:
> The spinlock clocks_lock can be held during ISR, hence it is not safe to
> hold that lock with disabling interrupts.
> 
> It fixes following potential deadlock.
> 
> =========================================================
> [ INFO: possible irq lock inversion dependency detected ]
> 3.6.0-rc4+ #2 Not tainted
> ---------------------------------------------------------
> swapper/0/1 just changed the state of lock:
>  (&(&host->lock)->rlock){-.....}, at: [<c027fb0d>] sdhci_irq+0x15/0x564
> but this lock took another, HARDIRQ-unsafe lock in the past:
>  (clocks_lock){+.+...}
> 
> and interrupts could create inverse lock ordering between them.
> 
> other info that might help us debug this:
>  Possible interrupt unsafe locking scenario:
> 
>        CPU0                    CPU1
>        ----                    ----
>   lock(clocks_lock);
>                                local_irq_disable();
>                                lock(&(&host->lock)->rlock);
>                                lock(clocks_lock);
>   <Interrupt>
>     lock(&(&host->lock)->rlock);
> 
>  *** DEADLOCK ***
> 
> Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
> ---
>  arch/arm/plat-samsung/clock.c |    5 +++--
>  1 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c
> index 65c5eca..9b71719 100644
> --- a/arch/arm/plat-samsung/clock.c
> +++ b/arch/arm/plat-samsung/clock.c
> @@ -144,6 +144,7 @@ long clk_round_rate(struct clk *clk, unsigned long rate)
>  
>  int clk_set_rate(struct clk *clk, unsigned long rate)
>  {
> +	unsigned long flags;
>  	int ret;
>  
>  	if (IS_ERR(clk))
> @@ -159,9 +160,9 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
>  	if (clk->ops == NULL || clk->ops->set_rate == NULL)
>  		return -EINVAL;
>  
> -	spin_lock(&clocks_lock);
> +	spin_lock_irqsave(&clocks_lock, flags);
>  	ret = (clk->ops->set_rate)(clk, rate);
> -	spin_unlock(&clocks_lock);
> +	spin_unlock_irqrestore(&clocks_lock, flags);
>  
>  	return ret;
>  }
> 


-- 
Tushar Behera

  reply	other threads:[~2012-09-14  5:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-07  6:08 [PATCH] ARM: SAMSUNG: Use spin_lock_{irqsave,irqrestore} in clk_set_rate Tushar Behera
2012-09-07  6:08 ` [PATCH] ARM: SAMSUNG: Use spin_lock_{irqsave, irqrestore} " Tushar Behera
2012-09-14  5:02 ` Tushar Behera [this message]
2012-09-14  5:02   ` Tushar Behera
2012-09-17 11:25 ` [PATCH] ARM: SAMSUNG: Use spin_lock_{irqsave,irqrestore} " Kukjin Kim
2012-09-17 11:25   ` Kukjin Kim

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=5052BA5C.2040900@linaro.org \
    --to=tushar.behera@linaro.org \
    --cc=kgene.kim@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=patches@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 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.