From 7599acb7b9a1e33a410e33f13791647fba94e84f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 4 Nov 2021 19:08:46 +0100 Subject: Revert "ALSA: memalloc: Convert x86 SG-buffer handling with non-contiguous type" This reverts commit 2d9ea39917a4e4293bc2caea902c7059a330b611. We've got a regression report showing that the audio got broken the device over AMD IOMMU. The conversion assumed the wrong pointer / page mapping for the indirect mapping case, and we need to correct this urgently, so let's revert it for now. Fixes: 2d9ea39917a4 ("ALSA: memalloc: Convert x86 SG-buffer handling with non-contiguous type") Reported-and-tested-by: Alex Xu (Hello71) Link: https://lore.kernel.org/r/20211104180846.16340-1-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/core/memalloc.c | 51 ++++----------------------------------------------- 1 file changed, 4 insertions(+), 47 deletions(-) (limited to 'sound/core/memalloc.c') diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c index 99cd0f67daa1..ea778f868cf3 100644 --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -560,50 +560,6 @@ static const struct snd_malloc_ops snd_dma_noncontig_ops = { .get_chunk_size = snd_dma_vmalloc_get_chunk_size, }; -/* x86-specific SG-buffer with WC pages */ -#ifdef CONFIG_SND_DMA_SGBUF -#define vmalloc_to_virt(v) (unsigned long)page_to_virt(vmalloc_to_page(v)) - -static void *snd_dma_sg_wc_alloc(struct snd_dma_buffer *dmab, size_t size) -{ - void *p = snd_dma_noncontig_alloc(dmab, size); - size_t ofs; - - if (!p) - return NULL; - for (ofs = 0; ofs < size; ofs += PAGE_SIZE) - set_memory_uc(vmalloc_to_virt(p + ofs), 1); - return p; -} - -static void snd_dma_sg_wc_free(struct snd_dma_buffer *dmab) -{ - size_t ofs; - - for (ofs = 0; ofs < dmab->bytes; ofs += PAGE_SIZE) - set_memory_wb(vmalloc_to_virt(dmab->area + ofs), 1); - snd_dma_noncontig_free(dmab); -} - -static int snd_dma_sg_wc_mmap(struct snd_dma_buffer *dmab, - struct vm_area_struct *area) -{ - area->vm_page_prot = pgprot_writecombine(area->vm_page_prot); - /* FIXME: dma_mmap_noncontiguous() works? */ - return -ENOENT; /* continue with the default mmap handler */ -} - -const struct snd_malloc_ops snd_dma_sg_wc_ops = { - .alloc = snd_dma_sg_wc_alloc, - .free = snd_dma_sg_wc_free, - .mmap = snd_dma_sg_wc_mmap, - .sync = snd_dma_noncontig_sync, - .get_addr = snd_dma_vmalloc_get_addr, - .get_page = snd_dma_vmalloc_get_page, - .get_chunk_size = snd_dma_vmalloc_get_chunk_size, -}; -#endif /* CONFIG_SND_DMA_SGBUF */ - /* * Non-coherent pages allocator */ @@ -663,13 +619,14 @@ static const struct snd_malloc_ops *dma_ops[] = { [SNDRV_DMA_TYPE_DEV_WC] = &snd_dma_wc_ops, [SNDRV_DMA_TYPE_NONCONTIG] = &snd_dma_noncontig_ops, [SNDRV_DMA_TYPE_NONCOHERENT] = &snd_dma_noncoherent_ops, -#ifdef CONFIG_SND_DMA_SGBUF - [SNDRV_DMA_TYPE_DEV_WC_SG] = &snd_dma_sg_wc_ops, -#endif #ifdef CONFIG_GENERIC_ALLOCATOR [SNDRV_DMA_TYPE_DEV_IRAM] = &snd_dma_iram_ops, #endif /* CONFIG_GENERIC_ALLOCATOR */ #endif /* CONFIG_HAS_DMA */ +#ifdef CONFIG_SND_DMA_SGBUF + [SNDRV_DMA_TYPE_DEV_SG] = &snd_dma_sg_ops, + [SNDRV_DMA_TYPE_DEV_WC_SG] = &snd_dma_sg_ops, +#endif }; static const struct snd_malloc_ops *snd_dma_get_ops(struct snd_dma_buffer *dmab) -- cgit v1.2.3