From: Greg Kroah-Hartman Date: Mon, 14 Nov 2022 11:32:44 +0000 (+0100) Subject: 6.0-stable patches X-Git-Tag: v5.10.155~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=08bb77130f2a19a5da53eb4152e8e15247669da8;p=thirdparty%2Fkernel%2Fstable-queue.git 6.0-stable patches added patches: alsa-memalloc-try-dma_alloc_noncontiguous-at-first.patch drm-amdkfd-migrate-in-cpu-page-fault-use-current-mm.patch --- diff --git a/queue-6.0/alsa-memalloc-try-dma_alloc_noncontiguous-at-first.patch b/queue-6.0/alsa-memalloc-try-dma_alloc_noncontiguous-at-first.patch new file mode 100644 index 00000000000..8d1cd7e4849 --- /dev/null +++ b/queue-6.0/alsa-memalloc-try-dma_alloc_noncontiguous-at-first.patch @@ -0,0 +1,56 @@ +From 9d8e536d36e75e76614fe09ffab9a1df95b8b666 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +Date: Sat, 12 Nov 2022 09:47:18 +0100 +Subject: ALSA: memalloc: Try dma_alloc_noncontiguous() at first + +From: Takashi Iwai + +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 +Link: https://lore.kernel.org/r/CAHk-=wgSH5ubdvt76gNwa004ooZAEJL_1Q-Fyw5M2FDdqL==dg@mail.gmail.com +Link: https://lore.kernel.org/r/20221112084718.3305-1-tiwai@suse.de +Signed-off-by: Takashi Iwai +Signed-off-by: Greg Kroah-Hartman +--- + 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; + diff --git a/queue-6.0/drm-amdkfd-migrate-in-cpu-page-fault-use-current-mm.patch b/queue-6.0/drm-amdkfd-migrate-in-cpu-page-fault-use-current-mm.patch new file mode 100644 index 00000000000..3646eefdbcc --- /dev/null +++ b/queue-6.0/drm-amdkfd-migrate-in-cpu-page-fault-use-current-mm.patch @@ -0,0 +1,45 @@ +From 3a876060892ba52dd67d197c78b955e62657d906 Mon Sep 17 00:00:00 2001 +From: Philip Yang +Date: Thu, 8 Sep 2022 17:56:09 -0400 +Subject: drm/amdkfd: Migrate in CPU page fault use current mm + +From: Philip Yang + +commit 3a876060892ba52dd67d197c78b955e62657d906 upstream. + +migrate_vma_setup shows below warning because we don't hold another +process mm mmap_lock. We should use current vmf->vma->vm_mm instead, the +caller already hold current mmap lock inside CPU page fault handler. + + WARNING: CPU: 10 PID: 3054 at include/linux/mmap_lock.h:155 find_vma + Call Trace: + walk_page_range+0x76/0x150 + migrate_vma_setup+0x18a/0x640 + svm_migrate_vram_to_ram+0x245/0xa10 [amdgpu] + svm_migrate_to_ram+0x36f/0x470 [amdgpu] + do_swap_page+0xcfe/0xec0 + __handle_mm_fault+0x96b/0x15e0 + handle_mm_fault+0x13f/0x3e0 + do_user_addr_fault+0x1e7/0x690 + +Fixes: e1f84eef313f ("drm/amdkfd: handle CPU fault on COW mapping") +Signed-off-by: Philip Yang +Reviewed-by: Felix Kuehling +Signed-off-by: Alex Deucher +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +@@ -951,7 +951,8 @@ static vm_fault_t svm_migrate_to_ram(str + goto out_unlock_prange; + } + +- r = svm_migrate_vram_to_ram(prange, mm, KFD_MIGRATE_TRIGGER_PAGEFAULT_CPU); ++ r = svm_migrate_vram_to_ram(prange, vmf->vma->vm_mm, ++ KFD_MIGRATE_TRIGGER_PAGEFAULT_CPU); + if (r) + pr_debug("failed %d migrate svms 0x%p range 0x%p [0x%lx 0x%lx]\n", + r, prange->svms, prange, prange->start, prange->last); diff --git a/queue-6.0/series b/queue-6.0/series index bc85bfc71c3..c992057a356 100644 --- a/queue-6.0/series +++ b/queue-6.0/series @@ -186,3 +186,5 @@ dmaengine-at_hdmac-fix-completion-of-unissued-descriptor-in-case-of-errors.patch dmaengine-at_hdmac-don-t-allow-cpu-to-reorder-channel-enable.patch dmaengine-at_hdmac-fix-impossible-condition.patch dmaengine-at_hdmac-check-return-code-of-dma_async_device_register.patch +drm-amdkfd-migrate-in-cpu-page-fault-use-current-mm.patch +alsa-memalloc-try-dma_alloc_noncontiguous-at-first.patch