[alsa-devel] problems writing pcm driver
tiwai at suse.de
Wed Aug 22 11:07:00 CEST 2007
At Tue, 21 Aug 2007 14:22:54 -0700 (PDT),
Trent Piepho wrote:
> On Tue, 21 Aug 2007, Takashi Iwai wrote:
> > At Mon, 20 Aug 2007 13:47:48 -0700 (PDT),
> > Trent Piepho wrote:
> > > Atomicity:
> > > trigger, pointer, and ack are atomic with respect to themselves. e.g., two
> > > copies of the trigger callback can't be running at the same time. That much
> > > is clear. But are they atomic with respect to each other? Can the trigger
> > > callback run at the same time as the pointer callback? How about the atomic
> > > callbacks with respect to the non-atomic ones? Can trigger run at the same
> > > time as prepare?
> > No, these callbacks are exclusive. In principle, they are called with
> > substream->lock spinlock already held by the PCM core, so they cannot
> > be called at the same time as long as belonging to the same PCM
> > substream instance.
> The driver writing howto says for hw_params, "is that this callback is
> non-atomic (schedulable)."
> If it's non-atomic, that would mean to me that it can be called multiple
> times at once, and at the same time as other callbacks. But, you're saying
> that's not the case?
No, in that context, non-atomic means schedulable. That is, the
function can get scheduled safely. It's outside the spinlock.
OTOH, the atomic callback cannot be scheduled. You cannot call
functions that might result in sleep, e.g. kmalloc with GFP_KERNEL.
Also, it implicitly means that you shouldn't take too long time in
About the concurrent access: since the PCM substream instance is
exclusive, all PCM callbacks are also basically exclusive. Even open
and close are already protected via mutex in PCM core. Thus they
cannot be called simultaneously for the same substream instance. (For
different substreams, they can be called.)
More information about the Alsa-devel