ALSA: memalloc: invalidate SG pages before sync
authorTakashi Iwai <tiwai@suse.de>
Thu, 10 Feb 2022 12:33:44 +0000 (13:33 +0100)
committerTakashi Iwai <tiwai@suse.de>
Thu, 10 Feb 2022 12:36:53 +0000 (13:36 +0100)
It seems that calling invalidate_kernel_vmap_range() is more correct
to be called before dma_sync_*(), judging from the other thread:
  https://lore.kernel.org/all/20220111085958.GA22795@lst.de/
Although this won't matter much in practice, let's fix the call order
for consistency.

Fixes: a25684a95646 ("ALSA: memalloc: Support for non-contiguous page allocation")
Reported-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220210123344.8756-3-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/memalloc.c

index f98f694..6fd763d 100644 (file)
@@ -541,9 +541,9 @@ static void snd_dma_noncontig_sync(struct snd_dma_buffer *dmab,
        if (mode == SNDRV_DMA_SYNC_CPU) {
                if (dmab->dev.dir == DMA_TO_DEVICE)
                        return;
+               invalidate_kernel_vmap_range(dmab->area, dmab->bytes);
                dma_sync_sgtable_for_cpu(dmab->dev.dev, dmab->private_data,
                                         dmab->dev.dir);
-               invalidate_kernel_vmap_range(dmab->area, dmab->bytes);
        } else {
                if (dmab->dev.dir == DMA_FROM_DEVICE)
                        return;