public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Artem Bityutskiy <dedekind@yandex.ru>
To: Tony Lindgren <tony@atomide.com>
Cc: "Shilimkar, Santosh" <santosh.shilimkar@ti.com>,
	"'linux-omap@vger.kernel.org'" <linux-omap@vger.kernel.org>
Subject: Re: [OMAP][sDMA]Fix for possible race condition in omap_free_dma()
Date: Tue, 07 Apr 2009 15:00:09 +0300	[thread overview]
Message-ID: <49DB4049.2030004@yandex.ru> (raw)
In-Reply-To: <EAF47CD23C76F840A9E7FCE10091EFAB02A93B8033@dbde02.ent.ti.com>

Hi Tony,

I wonder, what happened to this patch?

Shilimkar, Santosh wrote:
> From: Santosh Shilimkar <santosh.shilimkar@ti.com>
> 
> Fix the possible race condition in omap_free_dma(). Function omap_free_dma() 
> sets the dev_id = -1 and then accesses the channel afterwards to clear it.
> But setting the dev_id=-1 makes the channel available for allocation again.
> So it is possible someone else can grab it and results are unpredictable.
> To avod this DMA channle is cleared first and then the dev_id = -1 is set.
> 
> Thanks to McNeil, Sean <sean.mcneil@ti.com> for ointing out this issue.
> 
> Signed-off-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
> ---
>  arch/arm/plat-omap/dma.c |   13 ++++++-------
>  1 files changed, 6 insertions(+), 7 deletions(-)
> 
> Index: omapkernel/arch/arm/plat-omap/dma.c
> ===================================================================
> --- omapkernel.orig/arch/arm/plat-omap/dma.c
> +++ omapkernel/arch/arm/plat-omap/dma.c
> @@ -785,19 +785,12 @@ void omap_free_dma(int lch)
>  {
>  	unsigned long flags;
>  
> -	spin_lock_irqsave(&dma_chan_lock, flags);
>  	if (dma_chan[lch].dev_id == -1) {
>  		pr_err("omap_dma: trying to free unallocated DMA channel %d\n",
>  		       lch);
> -		spin_unlock_irqrestore(&dma_chan_lock, flags);
>  		return;
>  	}
>  
> -	dma_chan[lch].dev_id = -1;
> -	dma_chan[lch].next_lch = -1;
> -	dma_chan[lch].callback = NULL;
> -	spin_unlock_irqrestore(&dma_chan_lock, flags);
> -
>  	if (cpu_class_is_omap1()) {
>  		/* Disable all DMA interrupts for the channel. */
>  		dma_write(0, CICR(lch));
> @@ -823,6 +816,12 @@ void omap_free_dma(int lch)
>  		dma_write(0, CCR(lch));
>  		omap_clear_dma(lch);
>  	}
> +
> +	spin_lock_irqsave(&dma_chan_lock, flags);
> +	dma_chan[lch].dev_id = -1;
> +	dma_chan[lch].next_lch = -1;
> +	dma_chan[lch].callback = NULL;
> +	spin_unlock_irqrestore(&dma_chan_lock, flags);
>  }
>  EXPORT_SYMBOL(omap_free_dma);
>  
> 
> Regards,
> Santosh
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2009-04-07 12:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-29 11:58 [OMAP][sDMA]Fix for possible race condition in omap_free_dma() Shilimkar, Santosh
2009-04-07 12:00 ` Artem Bityutskiy [this message]
2009-04-07 17:24 ` [APPLIED] " Tony Lindgren

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=49DB4049.2030004@yandex.ru \
    --to=dedekind@yandex.ru \
    --cc=linux-omap@vger.kernel.org \
    --cc=santosh.shilimkar@ti.com \
    --cc=tony@atomide.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox