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

RE: [PATCH 6/9] dmaengine: consolidate tx_status functions

flat view
STALE5285d REVIEWED: 6 (6M)

From: H Hartley Sweeten <hidden>
Date: 2012-03-07 01:04:54
Also in: linux-arm-kernel

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

Revisions (6)
  1. v1 [diff vs current]
  2. v1 [diff vs current]
  3. v1 [diff vs current]
  4. v1 [diff vs current]
  5. v2
  6. v2 current
On Tuesday, March 06, 2012 3:35 PM, Russell King wrote:
Now that we have the completed cookie in the dma_chan structure, we
can consolidate the tx_status functions by providing a function to set
the txstate structure and returning the DMA status.  We also provide
a separate helper to set the residue for cookies which are still in
progress.

Signed-off-by: Russell King <redacted>
---
<snip>
 drivers/dma/dmaengine.h     |   31 +++++++++++++++++++++++++++++++
<snip>
 drivers/dma/ep93xx_dma.c    |    7 +------
<snip>
quoted hunk ↗ jump to hunk
diff --git a/drivers/dma/dmaengine.h b/drivers/dma/dmaengine.h
index 47e0997..1ca5e0e 100644
--- a/drivers/dma/dmaengine.h
+++ b/drivers/dma/dmaengine.h
@@ -45,4 +45,35 @@ static inline void dma_cookie_complete(struct dma_asyn=
c_tx_descriptor *tx)
 	tx->cookie =3D 0;
 }
=20
+/**
+ * dma_cookie_status - report cookie status
+ * @chan: dma channel
+ * @cookie: cookie we are interested in
+ * @state: dma_tx_state structure to return last/used cookies
+ *
+ * Report the status of the cookie, filling in the state structure if
+ * non-NULL.  No locking is required.
+ */
+static inline enum dma_status dma_cookie_status(struct dma_chan *chan,
+	dma_cookie_t cookie, struct dma_tx_state *state)
+{
+	dma_cookie_t used, complete;
+
+	used =3D chan->cookie;
+	complete =3D chan->completed_cookie;
+	barrier();
+	if (state) {
+		state->last =3D complete;
+		state->used =3D used;
+		state->residue =3D 0;
+	}
+	return dma_async_is_complete(cookie, complete, used);
+}
+
+static inline void dma_set_residue(struct dma_tx_state *state, u32 resid=
ue)
quoted hunk ↗ jump to hunk
+{
+	if (state)
+		state->residue =3D residue;
+}
+
 #endif
<snip>
quoted hunk ↗ jump to hunk
diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c
index 1c56f75..142ebf0 100644
--- a/drivers/dma/ep93xx_dma.c
+++ b/drivers/dma/ep93xx_dma.c
@@ -1241,18 +1241,13 @@ static enum dma_status ep93xx_dma_tx_status(struc=
t dma_chan *chan,
 					    struct dma_tx_state *state)
 {
 	struct ep93xx_dma_chan *edmac =3D to_ep93xx_dma_chan(chan);
-	dma_cookie_t last_used, last_completed;
 	enum dma_status ret;
 	unsigned long flags;
=20
 	spin_lock_irqsave(&edmac->lock, flags);
-	last_used =3D chan->cookie;
-	last_completed =3D chan->completed_cookie;
+	ret =3D dma_cookie_status(chan, cookie, state);
 	spin_unlock_irqrestore(&edmac->lock, flags);
=20
-	ret =3D dma_async_is_complete(cookie, last_completed, last_used);
-	dma_set_tx_state(state, last_completed, last_used, 0);
-
 	return ret;
 }
=20
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