linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [async_tx-next PATCH 2/2] fsldma: Fix cookie issues
@ 2010-02-22 17:40 Steven J. Magnani
  2010-02-22 20:26 ` Guennadi Liakhovetski
  0 siblings, 1 reply; 3+ messages in thread
From: Steven J. Magnani @ 2010-02-22 17:40 UTC (permalink / raw)
  To: Dan Williams; +Cc: Zhang Wei, linux-kernel, Steven J. Magnani, linuxppc-dev

fsl_dma_update_completed_cookie() appears to calculate the last completed
cookie incorrectly in the corner case where DMA on cookie 1 is in progress
just following a cookie wrap.

Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
---
diff -uprN a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
--- a/drivers/dma/fsldma.c	2010-02-22 11:16:36.000000000 -0600
+++ b/drivers/dma/fsldma.c	2010-02-22 11:08:41.000000000 -0600
@@ -819,8 +819,11 @@ static void fsl_dma_update_completed_coo
 	desc = to_fsl_desc(chan->ld_running.prev);
 	if (dma_is_idle(chan))
 		cookie = desc->async_tx.cookie;
-	else
+	else {
 		cookie = desc->async_tx.cookie - 1;
+		if (unlikely(cookie < DMA_MIN_COOKIE))
+			cookie = DMA_MAX_COOKIE;
+	}
 
 	chan->completed_cookie = cookie;
 
diff -uprN a/include/linux/dmaengine.h b/include/linux/dmaengine.h
--- a/include/linux/dmaengine.h	2010-02-22 11:18:11.000000000 -0600
+++ b/include/linux/dmaengine.h	2010-02-22 11:18:30.000000000 -0600
@@ -31,6 +31,8 @@
  * if dma_cookie_t is >0 it's a DMA request cookie, <0 it's an error code
  */
 typedef s32 dma_cookie_t;
+#define DMA_MIN_COOKIE	1
+#define DMA_MAX_COOKIE	2147483647
 
 #define dma_submit_error(cookie) ((cookie) < 0 ? 1 : 0)
 

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

* Re: [async_tx-next PATCH 2/2] fsldma: Fix cookie issues
  2010-02-22 17:40 [async_tx-next PATCH 2/2] fsldma: Fix cookie issues Steven J. Magnani
@ 2010-02-22 20:26 ` Guennadi Liakhovetski
  2010-02-25 19:25   ` Ira W. Snyder
  0 siblings, 1 reply; 3+ messages in thread
From: Guennadi Liakhovetski @ 2010-02-22 20:26 UTC (permalink / raw)
  To: Steven J. Magnani; +Cc: Zhang Wei, Dan Williams, linux-kernel, linuxppc-dev

On Mon, 22 Feb 2010, Steven J. Magnani wrote:

> diff -uprN a/include/linux/dmaengine.h b/include/linux/dmaengine.h
> --- a/include/linux/dmaengine.h	2010-02-22 11:18:11.000000000 -0600
> +++ b/include/linux/dmaengine.h	2010-02-22 11:18:30.000000000 -0600
> @@ -31,6 +31,8 @@
>   * if dma_cookie_t is >0 it's a DMA request cookie, <0 it's an error code
>   */
>  typedef s32 dma_cookie_t;
> +#define DMA_MIN_COOKIE	1
> +#define DMA_MAX_COOKIE	2147483647

Taking into account, that dma_cookie_t is 32 bits:

+#define DMA_MAX_COOKIE		((1 << 31) - 1)

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/

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

* Re: [async_tx-next PATCH 2/2] fsldma: Fix cookie issues
  2010-02-22 20:26 ` Guennadi Liakhovetski
@ 2010-02-25 19:25   ` Ira W. Snyder
  0 siblings, 0 replies; 3+ messages in thread
From: Ira W. Snyder @ 2010-02-25 19:25 UTC (permalink / raw)
  To: Guennadi Liakhovetski
  Cc: Zhang Wei, Dan Williams, linux-kernel, Steven J. Magnani,
	linuxppc-dev

On Mon, Feb 22, 2010 at 09:26:13PM +0100, Guennadi Liakhovetski wrote:
> On Mon, 22 Feb 2010, Steven J. Magnani wrote:
> 
> > diff -uprN a/include/linux/dmaengine.h b/include/linux/dmaengine.h
> > --- a/include/linux/dmaengine.h	2010-02-22 11:18:11.000000000 -0600
> > +++ b/include/linux/dmaengine.h	2010-02-22 11:18:30.000000000 -0600
> > @@ -31,6 +31,8 @@
> >   * if dma_cookie_t is >0 it's a DMA request cookie, <0 it's an error code
> >   */
> >  typedef s32 dma_cookie_t;
> > +#define DMA_MIN_COOKIE	1
> > +#define DMA_MAX_COOKIE	2147483647
> 
> Taking into account, that dma_cookie_t is 32 bits:
> 
> +#define DMA_MAX_COOKIE		((1 << 31) - 1)
> 

Steven,

After you take Guennadi's comment into acount, the rest of the patch
looks good. I'm sure I've never rolled the cookie around during testing.

Ira

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

end of thread, other threads:[~2010-02-25 19:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-22 17:40 [async_tx-next PATCH 2/2] fsldma: Fix cookie issues Steven J. Magnani
2010-02-22 20:26 ` Guennadi Liakhovetski
2010-02-25 19:25   ` Ira W. Snyder

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