On Tue, Mar 06, 2012 at 12:06:47PM +0000, Mark Brown wrote:
On Tue, Mar 06, 2012 at 10:40:15AM +0000, Russell King - ARM Linux wrote:
On Mon, Mar 05, 2012 at 12:26:36AM +0000, Mark Brown wrote:
On Mon, Mar 05, 2012 at 12:13:52AM +0000, Tabi Timur-B04825 wrote:
To answer your question: I was lead to believe that the individual ALSA callback functions are atomic. So one thread should not be trying to start playback while another thread is simultaneously trying to stop it.
That's correct, there's ALSA level locking.
Please explain which lock prevents the capture substream trigger callback occuring simultaneously with a playback substream trigger callback on a SMP system.
Oh, bother - that one is per substream not per stream. Which isn't terribly helpful.
It's actually entirely right that the core shouldn't take care of this: it's entirely possible that drivers do not have any dependencies between the two substreams and so they should not be exposed to enforced exclusivity between the actions of two substreams in multiprocessor systems.
Please also note that in ALSA documentation, an 'atomic' callback means little with respect to race conditions. All it means is that the callback is called from a context where sleeping in the callback is not permitted. The documentation does not say what is protected by the ALSA spinlocks and mutexes, so without reviewing the ALSA code, driver writters have little idea whether they need their own locks or not.