Thread (31 messages) 31 messages, 9 authors, 2012-04-23

RE: [PATCH 4/9] dmaengine: consolidate assignment of DMA cookies

flat view
STALE5281d REVIEWED: 6 (6M)

From: H Hartley Sweeten <hidden>
Date: 2012-03-07 00:53:27
Also in: linux-arm-kernel

Revision v2 of 3 in this series; 2 review trailers.

Revisions (3)
  1. v1 [diff vs current]
  2. v2
  3. v2 current
On Tuesday, March 06, 2012 3:35 PM, Russell King wrote:
Everyone deals with assigning DMA cookies in the same way (it's part of
the API so they should be), so lets consolidate the common code into a
helper function to avoid this duplication.

Signed-off-by: Russell King <redacted>
---
<snip>
 drivers/dma/dmaengine.h     |   20 ++++++++++++++++++++
<snip>
 drivers/dma/ep93xx_dma.c    |    9 +--------
<snip>
quoted hunk ↗ jump to hunk
diff --git a/drivers/dma/dmaengine.h b/drivers/dma/dmaengine.h
index 968570d..7692c86 100644
--- a/drivers/dma/dmaengine.h
+++ b/drivers/dma/dmaengine.h
@@ -7,4 +7,24 @@
=20
 #include <linux/dmaengine.h>
=20
+/**
+ * dma_cookie_assign - assign a DMA engine cookie to the descriptor
+ * @tx: descriptor needing cookie
+ *
+ * Assign a unique non-zero per-channel cookie to the descriptor.
+ * Note: caller is expected to hold a lock to prevent concurrency.
+ */
+static inline dma_cookie_t dma_cookie_assign(struct dma_async_tx_descrip=
tor *tx)
quoted hunk ↗ jump to hunk
+{
+	struct dma_chan *chan =3D tx->chan;
+	dma_cookie_t cookie;
+
+	cookie =3D chan->cookie + 1;
+	if (cookie < DMA_MIN_COOKIE)
+		cookie =3D DMA_MIN_COOKIE;
+	tx->cookie =3D chan->cookie =3D cookie;
+
+	return cookie;
+}
+
 #endif
<snip>
quoted hunk ↗ jump to hunk
diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c
index 3260198..e5aaae8 100644
--- a/drivers/dma/ep93xx_dma.c
+++ b/drivers/dma/ep93xx_dma.c
@@ -783,17 +783,10 @@ static dma_cookie_t ep93xx_dma_tx_submit(struct dma=
_async_tx_descriptor *tx)
 	unsigned long flags;
=20
 	spin_lock_irqsave(&edmac->lock, flags);
-
-	cookie =3D edmac->chan.cookie;
-
-	if (++cookie < 0)
-		cookie =3D 1;
+	cookie =3D dma_cookie_assign(tx);
=20
 	desc =3D container_of(tx, struct ep93xx_dma_desc, txd);
=20
-	edmac->chan.cookie =3D cookie;
-	desc->txd.cookie =3D cookie;
-
 	/*
 	 * If nothing is currently prosessed, we push this descriptor
 	 * directly to the hardware. Otherwise we put the descriptor
For ep93xx:

Tested-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Acked-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help