diff options
author | Takashi Iwai <tiwai@suse.de> | 2020-11-23 09:53:28 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2020-11-23 15:14:44 +0100 |
commit | 96e221f379e887f58d29969f10ed330ae1be4d80 (patch) | |
tree | 97f8bcd1862e6c16f3b9ab9cedc2528dddbd4067 /sound/usb/usbaudio.h | |
parent | ALSA: usb-audio: Stop both endpoints properly at error (diff) | |
download | linux-96e221f379e887f58d29969f10ed330ae1be4d80.tar.xz linux-96e221f379e887f58d29969f10ed330ae1be4d80.zip |
ALSA: usb-audio: Set callbacks via snd_usb_endpoint_set_callback()
The prepare_data_urb and retire_data_urb fields of the endpoint object
are set dynamically at PCM trigger start/stop. Those are evaluated in
the endpoint handler, but there can be a race, especially if two
different PCM substreams are handling the same endpoint for the
implicit feedback case. Also, the data_subs field of the endpoint is
set and accessed dynamically, too, which has the same risk.
As a slight improvement for the concurrency, this patch introduces the
function to set the callbacks and the data in a shot with the memory
barrier. In the reader side, it's also fetched with the memory
barrier.
There is still a room of race if prepare and retire callbacks are set
during executing the URB completion. But such an inconsistency may
happen only for the implicit fb source, i.e. it's only about the
capture stream. And luckily, the capture stream never sets the
prepare callback, hence the problem doesn't happen practically.
Tested-by: Keith Milner <kamilner@superlative.org>
Tested-by: Dylan Robinson <dylan_robinson@motu.com>
Link: https://lore.kernel.org/r/20201123085347.19667-23-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/usbaudio.h')
0 files changed, 0 insertions, 0 deletions