Skip to content

Commit 8e1741c

Browse files
committed
ALSA: memalloc: Fix dma_need_sync() checks
dma_need_sync() checks each DMA address. Fix the incorrect usages for non-contiguous and non-coherent page allocations. Fortunately, there are no actual call sites that need manual syncs yet. Fixes: a25684a ("ALSA: memalloc: Support for non-contiguous page allocation") Fixes: 73325f6 ("ALSA: memalloc: Support for non-coherent page allocation") Cc: <stable@vger.kernel.org> Reported-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar> Link: https://lore.kernel.org/r/20220210123344.8756-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 52517d9 commit 8e1741c

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

sound/core/memalloc.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,8 @@ static void *snd_dma_noncontig_alloc(struct snd_dma_buffer *dmab, size_t size)
511511
DEFAULT_GFP, 0);
512512
if (!sgt)
513513
return NULL;
514-
dmab->dev.need_sync = dma_need_sync(dmab->dev.dev, dmab->dev.dir);
514+
dmab->dev.need_sync = dma_need_sync(dmab->dev.dev,
515+
sg_dma_address(sgt->sgl));
515516
p = dma_vmap_noncontiguous(dmab->dev.dev, size, sgt);
516517
if (p)
517518
dmab->private_data = sgt;
@@ -671,9 +672,13 @@ static const struct snd_malloc_ops snd_dma_sg_wc_ops = {
671672
*/
672673
static void *snd_dma_noncoherent_alloc(struct snd_dma_buffer *dmab, size_t size)
673674
{
674-
dmab->dev.need_sync = dma_need_sync(dmab->dev.dev, dmab->dev.dir);
675-
return dma_alloc_noncoherent(dmab->dev.dev, size, &dmab->addr,
676-
dmab->dev.dir, DEFAULT_GFP);
675+
void *p;
676+
677+
p = dma_alloc_noncoherent(dmab->dev.dev, size, &dmab->addr,
678+
dmab->dev.dir, DEFAULT_GFP);
679+
if (p)
680+
dmab->dev.need_sync = dma_need_sync(dmab->dev.dev, dmab->addr);
681+
return p;
677682
}
678683

679684
static void snd_dma_noncoherent_free(struct snd_dma_buffer *dmab)

0 commit comments

Comments
 (0)