RE: [PATCH 5/9] dmaengine: provide a common function for completing a dma descriptor
flat view
From: H Hartley Sweeten <hidden>
Date: 2012-03-07 00:56:45
Also in:
linux-arm-kernel
On Tuesday, March 06, 2012 3:35 PM, Russell King wrote:
Provide a common function to do the cookie mechanics for completing a DMA descriptor. Signed-off-by: Russell King <redacted> ---
<snip>
drivers/dma/dmaengine.h | 18 ++++++++++++++++++
<snip>
drivers/dma/ep93xx_dma.c | 2 +-
<snip>
quoted hunk ↗ jump to hunk
diff --git a/drivers/dma/dmaengine.h b/drivers/dma/dmaengine.h index 7692c86..47e0997 100644 --- a/drivers/dma/dmaengine.h +++ b/drivers/dma/dmaengine.h@@ -5,6 +5,7 @@ #ifndef DMAENGINE_H #define DMAENGINE_H=20 +#include <linux/bug.h> #include <linux/dmaengine.h> =20 /**@@ -27,4 +28,21 @@ static inline dma_cookie_t dma_cookie_assign(struct dm=
a_async_tx_descriptor *tx)
return cookie; } =20 +/** + * dma_cookie_complete - complete a descriptor + * @tx: descriptor to complete + * + * Mark this descriptor complete by updating the channels completed + * cookie marker. Zero the descriptors cookie to prevent accidental + * repeated completions. + * + * Note: caller is expected to hold a lock to prevent concurrency. + */ +static inline void dma_cookie_complete(struct dma_async_tx_descriptor *t=
x)
quoted hunk ↗ jump to hunk
+{ + BUG_ON(tx->cookie < DMA_MIN_COOKIE); + tx->chan->completed_cookie =3D tx->cookie; + tx->cookie =3D 0; +} + #endif
<snip>
quoted hunk ↗ jump to hunk
diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c index e5aaae8..1c56f75 100644 --- a/drivers/dma/ep93xx_dma.c +++ b/drivers/dma/ep93xx_dma.c@@ -703,7 +703,7 @@ static void ep93xx_dma_tasklet(unsigned long data) desc =3D ep93xx_dma_get_active(edmac); if (desc) { if (desc->complete) { - edmac->chan.completed_cookie =3D desc->txd.cookie; + dma_cookie_complete(&desc->txd); list_splice_init(&edmac->active, &list); } callback =3D desc->txd.callback;
For ep93xx: Tested-by: H Hartley Sweeten <hsweeten@visionengravers.com> Acked-by: H Hartley Sweeten <hsweeten@visionengravers.com>