This is a note to let you know that I've just added the patch titled ALSA: memalloc: Try dma_alloc_noncontiguous() at first to the 6.0-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-memalloc-try-dma_alloc_noncontiguous-at-first.patch and it can be found in the queue-6.0 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 9d8e536d36e75e76614fe09ffab9a1df95b8b666 Mon Sep 17 00:00:00 2001 From: Takashi Iwai <tiwai@xxxxxxx> Date: Sat, 12 Nov 2022 09:47:18 +0100 Subject: ALSA: memalloc: Try dma_alloc_noncontiguous() at first From: Takashi Iwai <tiwai@xxxxxxx> commit 9d8e536d36e75e76614fe09ffab9a1df95b8b666 upstream. The latest fix for the non-contiguous memalloc helper changed the allocation method for a non-IOMMU system to use only the fallback allocator. This should have worked, but it caused a problem sometimes when too many non-contiguous pages are allocated that can't be treated by HD-audio controller. As a quirk workaround, go back to the original strategy: use dma_alloc_noncontiguous() at first, and apply the fallback only when it fails, but only for non-IOMMU case. We'll need a better fix in the fallback code as well, but this workaround should paper over most cases. Fixes: 9736a325137b ("ALSA: memalloc: Don't fall back for SG-buffer with IOMMU") Reported-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Link: https://lore.kernel.org/r/CAHk-=wgSH5ubdvt76gNwa004ooZAEJL_1Q-Fyw5M2FDdqL==dg@xxxxxxxxxxxxxx Link: https://lore.kernel.org/r/20221112084718.3305-1-tiwai@xxxxxxx Signed-off-by: Takashi Iwai <tiwai@xxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- sound/core/memalloc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -527,8 +527,10 @@ static void *snd_dma_noncontig_alloc(str struct sg_table *sgt; void *p; + sgt = dma_alloc_noncontiguous(dmab->dev.dev, size, dmab->dev.dir, + DEFAULT_GFP, 0); #ifdef CONFIG_SND_DMA_SGBUF - if (!get_dma_ops(dmab->dev.dev)) { + if (!sgt && !get_dma_ops(dmab->dev.dev)) { if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_WC_SG) dmab->dev.type = SNDRV_DMA_TYPE_DEV_WC_SG_FALLBACK; else @@ -536,9 +538,6 @@ static void *snd_dma_noncontig_alloc(str return snd_dma_sg_fallback_alloc(dmab, size); } #endif - - sgt = dma_alloc_noncontiguous(dmab->dev.dev, size, dmab->dev.dir, - DEFAULT_GFP, 0); if (!sgt) return NULL; Patches currently in stable-queue which might be from tiwai@xxxxxxx are queue-6.0/alsa-usb-audio-yet-more-regression-for-for-the-delayed-card-registration.patch queue-6.0/alsa-hda-realtek-add-quirk-for-asus-zenbook-using-cs35l41.patch queue-6.0/alsa-usb-audio-add-dsd-support-for-accuphase-dac-60.patch queue-6.0/alsa-memalloc-try-dma_alloc_noncontiguous-at-first.patch queue-6.0/alsa-hda-fix-potential-memleak-in-add_widget_node.patch queue-6.0/alsa-hda-hdmi-enable-runtime-pm-for-more-amd-display-audio.patch queue-6.0/alsa-hda-ca0132-add-quirk-for-evga-z390-dark.patch queue-6.0/alsa-hda-realtek-add-positivo-c6300-model-quirk.patch queue-6.0/alsa-memalloc-don-t-fall-back-for-sg-buffer-with-iom.patch queue-6.0/alsa-arm-pxa-pxa2xx-ac97-lib-fix-return-value-check-.patch queue-6.0/alsa-usb-audio-add-quirk-entry-for-m-audio-micro.patch