ALSA: usb-audio: Fix possible stall of implicit fb packet ring-buffer
authorTakashi Iwai <tiwai@suse.de>
Mon, 23 Nov 2020 08:53:32 +0000 (09:53 +0100)
committerTakashi Iwai <tiwai@suse.de>
Mon, 23 Nov 2020 14:15:26 +0000 (15:15 +0100)
commitc15871e17fc6efb98176b92b4152019876dbec24
tree23798581450b05f5f8b4dcd311cc67f9b203ed9f
parentbf6313a0ff766925462e97b4e733d5952de02367
ALSA: usb-audio: Fix possible stall of implicit fb packet ring-buffer

The implicit feedback mode uses a ring buffer for storing the received
packet sizes from the feedback source, and the code has a slight flaw;
when a playback stream stalls by some reason and the URBs aren't
processed, the next_packet FIFO might become empty, but the driver
can't distinguish whether it's empty or full because it's managed with
read_poss and write_pos.

This patch addresses those by changing the next_packet array
management.  Instead of keeping read and write positions, now the head
position and the queued amount are kept.  It's easier to understand
about the emptiness.  Also, the URB active flag is now cleared before
calling queue_pending_output_urbs() for avoiding (theoretically)
possible inconsistency.

Tested-by: Keith Milner <kamilner@superlative.org>
Tested-by: Dylan Robinson <dylan_robinson@motu.com>
Link: https://lore.kernel.org/r/20201123085347.19667-27-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/card.h
sound/usb/endpoint.c