RE: [PATCH 2/2] DMAENGINE: COH 901 318 fix bytesleft

Previous thread: [PATCH 2/2] DMAENGINE: COH 901 318 fix bytesleft by Linus Walleij on Thursday, March 4, 2010 - 6:31 am. (1 message)

Next thread: [PATCH 12/14] perf, x86: Expose the full PEBS record using PERF_SAMPLE_RAW by Peter Zijlstra on Thursday, March 4, 2010 - 7:00 am. (2 messages)
From: Linus Walleij
Date: Thursday, March 4, 2010 - 6:40 am

This makes the function to get the number of bytes left in the
ongoing DMA transaction actually work: the old code did not take
neither lli:s nor queued jobs into account. Also fix a missing
spinlock while we're at it.

Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
----
Sorry last version of the 0002 patch had a debug print stuck in
it still. This one is fixed, both patches apply on top of the
previous ones by the way, I'm digging around in this DMA driver
now so might as well try to fix a number of issues with it.
---
 drivers/dma/coh901318.c |   96 +++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 88 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c
index 20889c9..f636c4a 100644
--- a/drivers/dma/coh901318.c
+++ b/drivers/dma/coh901318.c
@@ -408,25 +408,100 @@ coh901318_first_queued(struct coh901318_chan *cohc)
 	return d;
 }
 
+static inline u32 coh901318_get_bytes_in_lli(struct coh901318_lli *in_lli)
+{
+	struct coh901318_lli *lli = in_lli;
+	u32 bytes = 0;
+
+	while (lli) {
+		bytes += lli->control & COH901318_CX_CTRL_TC_VALUE_MASK;
+		lli = lli->virt_link_addr;
+	}
+	return bytes;
+}
+
 /*
- * DMA start/stop controls
+ * Get the number of bytes left to transfer on this channel,
+ * it is unwise to call this before stopping the channel for
+ * absolute measures, but for a rough guess you can still call
+ * it.
  */
 u32 coh901318_get_bytes_left(struct dma_chan *chan)
 {
-	unsigned long flags;
-	u32 ret;
 	struct coh901318_chan *cohc = to_coh901318_chan(chan);
+	struct coh901318_desc *cohd;
+	struct list_head *pos;
+	unsigned long flags;
+	u32 left = 0;
+	int i = 0;
 
 	spin_lock_irqsave(&cohc->lock, flags);
 
-	/* Read transfer count value */
-	ret = readl(cohc->base->virtbase +
-		    COH901318_CX_CTRL+COH901318_CX_CTRL_SPACING *
-		    cohc->id) & COH901318_CX_CTRL_TC_VALUE_MASK;
+	/*
+	 * If there are many queued jobs, we iterate and add the
+	 * size of them all. We ...
From: Dan Williams
Date: Wednesday, March 24, 2010 - 2:35 pm

On Thu, Mar 4, 2010 at 6:40 AM, Linus Walleij

Should this hunk be broken off and sent to -stable?  My guess is no.
It should be mostly impossible to trigger a problem here since the
channel is expected to be idle while resources are being allocated and
the dmaengine mutex is already protecting against parallel
allocations.  It is an unrelated fix however.

--
Dan
--

From: Linus WALLEIJ
Date: Wednesday, March 24, 2010 - 3:09 pm

Nah, just stack it up for -next, no hurries.

Yours,
Linus Walleij
--

Previous thread: [PATCH 2/2] DMAENGINE: COH 901 318 fix bytesleft by Linus Walleij on Thursday, March 4, 2010 - 6:31 am. (1 message)

Next thread: [PATCH 12/14] perf, x86: Expose the full PEBS record using PERF_SAMPLE_RAW by Peter Zijlstra on Thursday, March 4, 2010 - 7:00 am. (2 messages)