linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* at_hdmac does not release lock before the callback - deadlock
@ 2014-01-27 12:58 Jouko Haapaluoma
  2014-01-27 14:12 ` Jouko Haapaluoma
  2014-01-27 14:23 ` [RFC PATCH 0/2] dmaengine: at_hdmac: fix locking according to slave DMA requirements Nicolas Ferre
  0 siblings, 2 replies; 7+ messages in thread
From: Jouko Haapaluoma @ 2014-01-27 12:58 UTC (permalink / raw)
  To: linux-arm-kernel

Hello

It seems that the at_hdmac driver keeps the atchan->lock even when the device driver callback is called.
This will cause a deadlock in those cases when the device driver calls certain DMA Engine methods
from the callback function.

The DMA Engine documentation (https://www.kernel.org/doc/Documentation/dmaengine.txt) states:
" 
Although the async_tx API specifies that completion callback
routines cannot submit any new operations, this is not the
case for slave/cyclic DMA.

For slave DMA, the subsequent transaction may not be available
for submission prior to callback function being invoked, so
slave DMA callbacks are permitted to prepare and submit a new
transaction.

For cyclic DMA, a callback function may wish to terminate the
DMA via dmaengine_terminate_all().

Therefore, it is important that DMA engine drivers drop any
locks before calling the callback function which may cause a
deadlock.
"

According to the documentation it seems that the at_hdmac driver violates the DMA Engine API because
locking is not released before entering the callback function.

One possible deadlock situation:

atc_tasklet()
spin_lock_irqsave(&atchan->lock)
atc_handle_cyclic()
callback()
dmaengine_terminate_all()
atc_control()
spin_lock_irqsave(&atchan->lock) 


BR,
Jouko Haapaluoma

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-03-11 10:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-27 12:58 at_hdmac does not release lock before the callback - deadlock Jouko Haapaluoma
2014-01-27 14:12 ` Jouko Haapaluoma
2014-01-27 14:23 ` [RFC PATCH 0/2] dmaengine: at_hdmac: fix locking according to slave DMA requirements Nicolas Ferre
2014-01-27 14:23   ` [PATCH 1/2] dmaengine: at_hdmac: remove the call to issue_pending from tx_status Nicolas Ferre
2014-01-27 14:23   ` [PATCH 2/2] dmaengine: at_hdmac: run callback function with no lock held nor interrupts disabled Nicolas Ferre
2014-03-11 10:56     ` Vinod Koul
2014-01-31 10:56   ` [RFC PATCH 0/2] dmaengine: at_hdmac: fix locking according to slave DMA requirements Jouko Haapaluoma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).