The improved and more clean fix in now in my tree:
http://git.alsa-project.org/?p=alsa-kernel.git;a=commitdiff;h=1250932e48d3b6...
The race condition is definitely gone. However I still see a NULL event in snd_pcm_playback_poll() in pcm_native.c.
[13312.575829] snd_intel8x0_interrupt [13312.575839] snd_intel8x0_update [13312.575847] snd_pcm_period_elapsed [13312.575853] snd_pcm_update_hw_ptr0 [13312.575862] snd_pcm_update_state [13312.575870] wakeup in snd_pcm_update_state: avail 8194, avail_min 8192 [13312.575894] ALSA: poll event POLLOUT|POLLWRNORM, avail 8194 avail_min 8192 [13312.581259] snd_pcm_lib_write1: in [13312.581267] snd_pcm_lib_write1 loop [13312.581273] snd_pcm_update_hw_ptr0 [13312.581282] snd_pcm_update_state [13312.581312] snd_pcm_lib_write1: end [13312.581317] snd_pcm_update_state [13312.581328] ALSA: null poll event, avail 262 avail_min 8192 [13312.746498] snd_intel8x0_interrupt [13312.746511] snd_intel8x0_update [13312.746520] snd_pcm_period_elapsed [13312.746526] snd_pcm_update_hw_ptr0 [13312.746536] snd_pcm_update_state [13312.746544] wakeup in snd_pcm_update_state: avail 8194, avail_min 8192 [13312.746571] ALSA: poll event POLLOUT|POLLWRNORM, avail 8194 avail_min 8192 [13312.751990] snd_pcm_lib_write1: in [13312.751998] snd_pcm_lib_write1 loop [13312.752004] snd_pcm_update_hw_ptr0 [13312.752013] snd_pcm_update_state [13312.755285] snd_pcm_lib_write1: end [13312.755293] snd_pcm_update_state [13312.755305] ALSA: null poll event, avail 265 avail_min 8192
I couldn't figure out who generates this null event, and even better it does not show in the report printed by my test app. I am somewhat lost here as to how snd_pcm_playback_poll works. - Pierre