staging: bcm2835-audio: Operate non-atomic PCM ops
authorTakashi Iwai <tiwai@suse.de>
Tue, 4 Sep 2018 15:58:49 +0000 (17:58 +0200)
committerpopcornmix <popcornmix@gmail.com>
Mon, 13 May 2019 23:08:30 +0000 (00:08 +0100)
commitbcc5def6f0e80412edc624649c11e6f4dcf6643c
tree3b78dc8f02b63b98b1fd8d420529869ed34dd337
parent8901c568c574328414de4c8a852d35707e50b044
staging: bcm2835-audio: Operate non-atomic PCM ops

commit 5c7883e5f27e829f3f3a2ba174d4a724bfd5f026 upstream.

This is the most significant part in the patch series.

The bcm2835-audio driver used to queue the commands to vc04 core via
workqueue, but basically the whole accesses to vc04 core are done in
the sleepable context, including the callback calls.  In such a case,
rewriting the code using non-atomic PCM ops will simplify the logic a
lot.

This patch does it: all workqueue are gone and each former-work
implementation is now directly called from PCM ops like trigger and
write transfer.

Along with it, the DMA position updater, bcm2835_playback_fifo(), was
also rewritten to use a simpler logic.  Now it handles the XRUN and
draining properly by calling snd_pcm_stop() conditionally.

The current position is kept in atomic_t value so that it can be read
concurrently from the pointer callback.

Also, the bcm2835_audio_instance object is allocated at the beginning
of bcm2835_audio_open().  This makes the resource management clearer.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
drivers/staging/vc04_services/bcm2835-audio/bcm2835.h