This is a note to let you know that I've just added the patch titled ALSA: usb-audio: Switch back to non-latency mode at a later point to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: alsa-usb-audio-switch-back-to-non-latency-mode-at-a-later-point.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From eee5d6f1356a016105a974fb176b491288439efa Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@xxxxxxx> Date: Fri, 19 Nov 2021 11:24:59 +0100 Subject: ALSA: usb-audio: Switch back to non-latency mode at a later point From: Takashi Iwai <tiwai@xxxxxxx> commit eee5d6f1356a016105a974fb176b491288439efa upstream. The recent regression report revealed that the judgment of the low-latency playback mode based on the runtime->stop_threshold cannot work reliably at the prepare stage, as sw_params call may happen at any time, and PCM dmix actually sets it up after the prepare call. This ended up with the stall of the stream as PCM ack won't be issued at all. For addressing this, check the free-wheeling mode again at the PCM trigger right before starting the stream again, and allow switching to the non-LL mode at a late stage. Fixes: d5f871f89e21 ("ALSA: usb-audio: Improved lowlatency playback support") Reported-and-tested-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> Link: https://lore.kernel.org/r/20211117161855.m45mxcqszkfcetai@xxxxxxxxxxxxxxxxx Link: https://lore.kernel.org/r/20211119102459.7055-1-tiwai@xxxxxxx Signed-off-by: Takashi Iwai <tiwai@xxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- sound/usb/pcm.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -581,6 +581,12 @@ static int snd_usb_hw_free(struct snd_pc return 0; } +/* free-wheeling mode? (e.g. dmix) */ +static int in_free_wheeling_mode(struct snd_pcm_runtime *runtime) +{ + return runtime->stop_threshold > runtime->buffer_size; +} + /* check whether early start is needed for playback stream */ static int lowlatency_playback_available(struct snd_pcm_runtime *runtime, struct snd_usb_substream *subs) @@ -592,8 +598,7 @@ static int lowlatency_playback_available /* disabled via module option? */ if (!chip->lowlatency) return false; - /* free-wheeling mode? (e.g. dmix) */ - if (runtime->stop_threshold > runtime->buffer_size) + if (in_free_wheeling_mode(runtime)) return false; /* implicit feedback mode has own operation mode */ if (snd_usb_endpoint_implicit_feedback_sink(subs->data_endpoint)) @@ -1545,6 +1550,8 @@ static int snd_usb_substream_playback_tr subs); if (subs->lowlatency_playback && cmd == SNDRV_PCM_TRIGGER_START) { + if (in_free_wheeling_mode(substream->runtime)) + subs->lowlatency_playback = false; err = start_endpoints(subs); if (err < 0) { snd_usb_endpoint_set_callback(subs->data_endpoint, Patches currently in stable-queue which might be from tiwai@xxxxxxx are queue-5.15/alsa-usb-audio-rename-early_playback_start-flag-with-lowlatency_playback.patch queue-5.15/alsa-usb-audio-disable-low-latency-playback-for-free-wheel-mode.patch queue-5.15/alsa-usb-audio-avoid-killing-in-flight-urbs-during-draining.patch queue-5.15/alsa-usb-audio-less-restriction-for-low-latency-playback-mode.patch queue-5.15/alsa-usb-audio-improved-lowlatency-playback-support.patch queue-5.15/alsa-usb-audio-check-available-frames-for-the-next-packet-size.patch queue-5.15/alsa-usb-audio-switch-back-to-non-latency-mode-at-a-later-point.patch queue-5.15/alsa-usb-audio-fix-packet-size-calculation-regression.patch queue-5.15/alsa-usb-audio-don-t-start-stream-for-capture-at-prepare.patch queue-5.15/alsa-usb-audio-disable-low-latency-mode-for-implicit-feedback-sync.patch queue-5.15/alsa-usb-audio-add-spinlock-to-stop_urbs.patch queue-5.15/alsa-usb-audio-restrict-rates-for-the-shared-clocks.patch