[PATCH 5/9] dmaengine: provide a common function for completing a dma descriptor
H Hartley Sweeten
hartleys at visionengravers.com
Tue Mar 6 19:56:45 EST 2012
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 <rmk+kernel at arm.linux.org.uk>
> ---
<snip>
> drivers/dma/dmaengine.h | 18 ++++++++++++++++++
<snip>
> drivers/dma/ep93xx_dma.c | 2 +-
<snip>
> 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
>
> +#include <linux/bug.h>
> #include <linux/dmaengine.h>
>
> /**
> @@ -27,4 +28,21 @@ static inline dma_cookie_t dma_cookie_assign(struct dma_async_tx_descriptor *tx)
> return cookie;
> }
>
> +/**
> + * 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 *tx)
> +{
> + BUG_ON(tx->cookie < DMA_MIN_COOKIE);
> + tx->chan->completed_cookie = tx->cookie;
> + tx->cookie = 0;
> +}
> +
> #endif
<snip>
> 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 = ep93xx_dma_get_active(edmac);
> if (desc) {
> if (desc->complete) {
> - edmac->chan.completed_cookie = desc->txd.cookie;
> + dma_cookie_complete(&desc->txd);
> list_splice_init(&edmac->active, &list);
> }
> callback = desc->txd.callback;
For ep93xx:
Tested-by: H Hartley Sweeten <hsweeten at visionengravers.com>
Acked-by: H Hartley Sweeten <hsweeten at visionengravers.com>
More information about the linux-arm-kernel
mailing list