[alsa-devel] Deadlock over semaphore issue with aplay while using dmix

mateen abdulmateen.shaikh at gmail.com
Thu Apr 4 11:27:39 CEST 2013


I seeing sometimes deadlock issue with dmix when I press CTRL+C.

Aplay's signal handler calls snd_pcm_close() if an interrupt occurs.
snd_pcm_close() will internally call  pcm->ops->close() which will fall to
snd_pcm_dmix_close() in case you are using dmix.

snd_pcm_dmix_close() will try to acquire the semaphore with
snd_pcm_direct_semaphore_down(dmix, DIRECT_IPC_SEM_CLIENT).
The same semaphore is acquired in snd_pcm_dmix_sync_area() with
dmix_down_sem() in case of non-concurrent access.

If semaphore is acquired in snd_pcm_dmix_sync_area() which is in thread
context and interrupt comes, which invokes the signal handler which is in
ISR context, which calls snd_pcm_close() which in turn calls
snd_pcm_dmix_close() then we see a deadlock since semaphore is not released
from thread context and ISR is waiting indefinitely on the same semaphore.

Please suggest a suitable solution for this.

Shaikh Mateen S.

More information about the Alsa-devel mailing list