kernel/eka/drivers/dma/dmapil.cpp
changeset 231 75252ea6123b
parent 130 c30940f6d922
--- a/kernel/eka/drivers/dma/dmapil.cpp	Mon Jul 12 14:24:01 2010 +0100
+++ b/kernel/eka/drivers/dma/dmapil.cpp	Mon Jul 26 10:52:56 2010 +0100
@@ -13,7 +13,7 @@
 // Description:
 // e32\drivers\dmapil.cpp
 // DMA Platform Independent Layer (PIL)
-// 
+//
 //
 
 #include <drivers/dma.h>
@@ -477,11 +477,14 @@
 	iChannel.Wait();
 
 	TUint32 req_count = iChannel.iQueuedRequests++;
-	if (req_count == 0)
+	if (iChannel.iCallQueuedRequestFn)
 		{
-		iChannel.Signal();
-		iChannel.QueuedRequestCountChanged();
-		iChannel.Wait();
+		if (req_count == 0)
+			{
+			iChannel.Signal();
+			iChannel.QueuedRequestCountChanged();
+			iChannel.Wait();
+			}
 		}
 
 	if (!(iChannel.iIsrDfc & (TUint32)TDmaChannel::KCancelFlagMask))
@@ -500,9 +503,12 @@
 		req_count = --iChannel.iQueuedRequests;
 		__DMA_INVARIANT();
 		iChannel.Signal();
-		if (req_count == 0)
+		if (iChannel.iCallQueuedRequestFn)
 			{
-			iChannel.QueuedRequestCountChanged();
+			if (req_count == 0)
+				{
+				iChannel.QueuedRequestCountChanged();
+				}
 			}
 		}
 	}
@@ -628,6 +634,7 @@
 	  iReqQ(),
 	  iReqCount(0),
 	  iQueuedRequests(0),
+	  iCallQueuedRequestFn(ETrue),
 	  iCancelInfo(NULL)
 	{
 	__DMA_INVARIANT();
@@ -760,9 +767,12 @@
 
 	// Only call PSL if there were requests queued when we entered AND there
 	// are now no requests left on the queue.
-	if ((req_count_before != 0) && (req_count_after == 0))
+	if (iCallQueuedRequestFn)
 		{
-		QueuedRequestCountChanged();
+		if ((req_count_before != 0) && (req_count_after == 0))
+			{
+			QueuedRequestCountChanged();
+			}
 		}
 
 	__DMA_INVARIANT();
@@ -942,9 +952,12 @@
 	// Only call PSL if there were requests queued when we entered AND there
 	// are now no requests left on the queue (after also having executed all
 	// client callbacks).
-	if ((req_count_before != 0) && (req_count_after == 0))
+	if (iCallQueuedRequestFn)
 		{
-		QueuedRequestCountChanged();
+		if ((req_count_before != 0) && (req_count_after == 0))
+			{
+			QueuedRequestCountChanged();
+			}
 		}
 
 	__DMA_INVARIANT();
@@ -972,14 +985,11 @@
 /** PSL may override */
 void TDmaChannel::QueuedRequestCountChanged()
 	{
-#ifdef _DEBUG
+	__KTRACE_OPT(KDMA, Kern::Printf("TDmaChannel::QueuedRequestCountChanged(): "
+									"disabling further calls"));
 	Wait();
-	__KTRACE_OPT(KDMA,
-				 Kern::Printf("TDmaChannel::QueuedRequestCountChanged() %d",
-							  iQueuedRequests));
-	__DMA_ASSERTA(iQueuedRequests >= 0);
+	iCallQueuedRequestFn = EFalse;
 	Signal();
-#endif
 	}