kernel/eka/drivers/dma/dma2_pil.cpp
changeset 109 b3a1d9898418
parent 90 947f0dc9f7a8
child 130 c30940f6d922
equal deleted inserted replaced
102:ef2a444a7410 109:b3a1d9898418
  1203 		// that the channel's Transfer() function is not called by both the ISR
  1203 		// that the channel's Transfer() function is not called by both the ISR
  1204 		// and the client thread at the same time.
  1204 		// and the client thread at the same time.
  1205 		__KTRACE_OPT(KPANIC, Kern::Printf("An ISR cb request exists - not queueing"));
  1205 		__KTRACE_OPT(KPANIC, Kern::Printf("An ISR cb request exists - not queueing"));
  1206 		// Undo the request count increment...
  1206 		// Undo the request count increment...
  1207 		req_count = --iChannel.iQueuedRequests;
  1207 		req_count = --iChannel.iQueuedRequests;
       
  1208 		__DMA_INVARIANT();
  1208 		iChannel.Signal();
  1209 		iChannel.Signal();
  1209 		if (req_count == 0)
  1210 		if (req_count == 0)
  1210 			{
  1211 			{
  1211 			iChannel.QueuedRequestCountChanged();
  1212 			iChannel.QueuedRequestCountChanged();
  1212 			}
  1213 			}
  1218 		// the ISR callback doesn't get executed together with the DFC(s) of
  1219 		// the ISR callback doesn't get executed together with the DFC(s) of
  1219 		// any previous request(s).
  1220 		// any previous request(s).
  1220 		__KTRACE_OPT(KPANIC, Kern::Printf("Request queue not empty - not queueing"));
  1221 		__KTRACE_OPT(KPANIC, Kern::Printf("Request queue not empty - not queueing"));
  1221 		// Undo the request count increment...
  1222 		// Undo the request count increment...
  1222 		req_count = --iChannel.iQueuedRequests;
  1223 		req_count = --iChannel.iQueuedRequests;
       
  1224 		__DMA_INVARIANT();
  1223 		iChannel.Signal();
  1225 		iChannel.Signal();
  1224 		if (req_count == 0)
  1226 		if (req_count == 0)
  1225 			{
  1227 			{
  1226 			iChannel.QueuedRequestCountChanged();
  1228 			iChannel.QueuedRequestCountChanged();
  1227 			}
  1229 			}
  1229 	else if (iChannel.iIsrDfc & (TUint32)TDmaChannel::KCancelFlagMask)
  1231 	else if (iChannel.iIsrDfc & (TUint32)TDmaChannel::KCancelFlagMask)
  1230 		{
  1232 		{
  1231 		__KTRACE_OPT(KPANIC, Kern::Printf("Channel requests cancelled - not queueing"));
  1233 		__KTRACE_OPT(KPANIC, Kern::Printf("Channel requests cancelled - not queueing"));
  1232 		// Someone is cancelling all requests - undo the request count increment...
  1234 		// Someone is cancelling all requests - undo the request count increment...
  1233 		req_count = --iChannel.iQueuedRequests;
  1235 		req_count = --iChannel.iQueuedRequests;
       
  1236 		__DMA_INVARIANT();
  1234 		iChannel.Signal();
  1237 		iChannel.Signal();
  1235 		if (req_count == 0)
  1238 		if (req_count == 0)
  1236 			{
  1239 			{
  1237 			iChannel.QueuedRequestCountChanged();
  1240 			iChannel.QueuedRequestCountChanged();
  1238 			}
  1241 			}
  1255 			// possible.
  1258 			// possible.
  1256 			__e32_atomic_store_rel32(&iChannel.iIsrCbRequest, ETrue);
  1259 			__e32_atomic_store_rel32(&iChannel.iIsrCbRequest, ETrue);
  1257 			}
  1260 			}
  1258 		iChannel.DoQueue(const_cast<const DDmaRequest&>(*this));
  1261 		iChannel.DoQueue(const_cast<const DDmaRequest&>(*this));
  1259 		r = KErrNone;
  1262 		r = KErrNone;
       
  1263 		__DMA_INVARIANT();
  1260 		iChannel.Signal();
  1264 		iChannel.Signal();
  1261 		}
  1265 		}
  1262 
  1266 
  1263 	__DMA_INVARIANT();
       
  1264 	return r;
  1267 	return r;
  1265 	}
  1268 	}
  1266 
  1269 
  1267 
  1270 
  1268 EXPORT_C TInt DDmaRequest::ExpandDesList(TInt aCount)
  1271 EXPORT_C TInt DDmaRequest::ExpandDesList(TInt aCount)
  1475 
  1478 
  1476 
  1479 
  1477 #ifdef _DEBUG
  1480 #ifdef _DEBUG
  1478 void DDmaRequest::Invariant()
  1481 void DDmaRequest::Invariant()
  1479 	{
  1482 	{
  1480 	iChannel.Wait();
  1483 	// This invariant may be called either with,
       
  1484 	// or without the channel lock already held
       
  1485 	TBool channelLockAquired=EFalse;
       
  1486 	if(!iChannel.iLock.HeldByCurrentThread())
       
  1487 		{
       
  1488 		iChannel.Wait();
       
  1489 		channelLockAquired = ETrue;
       
  1490 		}
       
  1491 
  1481 	__DMA_ASSERTD(LOGICAL_XOR(iCb, iDmaCb));
  1492 	__DMA_ASSERTD(LOGICAL_XOR(iCb, iDmaCb));
  1482 	if (iChannel.iDmacCaps->iAsymHwDescriptors)
  1493 	if (iChannel.iDmacCaps->iAsymHwDescriptors)
  1483 		{
  1494 		{
  1484 		__DMA_ASSERTD((0 <= iSrcDesCount) && (iSrcDesCount <= iChannel.iMaxDesCount) &&
  1495 		__DMA_ASSERTD((0 <= iSrcDesCount) && (iSrcDesCount <= iChannel.iMaxDesCount) &&
  1485 					  (0 <= iDstDesCount) && (iDstDesCount <= iChannel.iMaxDesCount));
  1496 					  (0 <= iDstDesCount) && (iDstDesCount <= iChannel.iMaxDesCount));
  1510 			{
  1521 			{
  1511 			__DMA_ASSERTD(iChannel.iController->IsValidHdr(iFirstHdr));
  1522 			__DMA_ASSERTD(iChannel.iController->IsValidHdr(iFirstHdr));
  1512 			__DMA_ASSERTD(iChannel.iController->IsValidHdr(iLastHdr));
  1523 			__DMA_ASSERTD(iChannel.iController->IsValidHdr(iLastHdr));
  1513 			}
  1524 			}
  1514 		}
  1525 		}
  1515 	iChannel.Signal();
  1526 
       
  1527 	if(channelLockAquired)
       
  1528 			{
       
  1529 			iChannel.Signal();
       
  1530 			}
  1516 	}
  1531 	}
  1517 #endif
  1532 #endif
  1518 
  1533 
  1519 
  1534 
  1520 //////////////////////////////////////////////////////////////////////////////
  1535 //////////////////////////////////////////////////////////////////////////////