Skip to contentSkip to conversation

fsldma: Fix cookie issues

PATCH Superseded Steven J. Magnani 3 participants 3 messages Feb 22, 2010 – Feb 25, 2010

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 fsldma: Fix cookie issues

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.

---

drivers/dma/fsldma.c +4 -1
diff -uprN a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
@@ -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;
 
include/linux/dmaengine.h +2 -0
diff -uprN a/include/linux/dmaengine.h b/include/linux/dmaengine.h
@@ -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)
 
#1 lore raw

include/linux/dmaengine.h line 35

Quoted 9 lines · Steven J. Magnani

diff -uprN a/include/linux/dmaengine.h b/include/linux/dmaengine.h

include/linux/dmaengine.h +2 -0
@@ -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/

#2 lore raw
Quoted 14 lines · Guennadi Liakhovetski

include/linux/dmaengine.h line 35

Quoted 9 lines · Steven J. Magnani

diff -uprN a/include/linux/dmaengine.h b/include/linux/dmaengine.h

include/linux/dmaengine.h +2 -0
@@ -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:

Quoted 2 lines

+#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