ALSA: memalloc: Fix dma_need_sync() checks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Takashi Iwai <tiwai@xxxxxxx>

commit 8e1741c658996a16bd096e077dae0da2460a997f upstream.

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: a25684a95646 ("ALSA: memalloc: Support for non-contiguous page allocation")
Fixes: 73325f60e2ed ("ALSA: memalloc: Support for non-coherent page allocation")
Cc: <stable@xxxxxxxxxxxxxxx>
Reported-by: Ezequiel Garcia <ezequiel@xxxxxxxxxxxxxxxxxxxx>
Link: https://lore.kernel.org/r/20220210123344.8756-2-tiwai@xxxxxxx
Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 sound/core/memalloc.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

--- a/sound/core/memalloc.c
+++ b/sound/core/memalloc.c
@@ -511,7 +511,8 @@ static void *snd_dma_noncontig_alloc(str
 				      DEFAULT_GFP, 0);
 	if (!sgt)
 		return NULL;
-	dmab->dev.need_sync = dma_need_sync(dmab->dev.dev, dmab->dev.dir);
+	dmab->dev.need_sync = dma_need_sync(dmab->dev.dev,
+					    sg_dma_address(sgt->sgl));
 	p = dma_vmap_noncontiguous(dmab->dev.dev, size, sgt);
 	if (p)
 		dmab->private_data = sgt;
@@ -625,9 +626,13 @@ static const struct snd_malloc_ops snd_d
  */
 static void *snd_dma_noncoherent_alloc(struct snd_dma_buffer *dmab, size_t size)
 {
-	dmab->dev.need_sync = dma_need_sync(dmab->dev.dev, dmab->dev.dir);
-	return dma_alloc_noncoherent(dmab->dev.dev, size, &dmab->addr,
-				     dmab->dev.dir, DEFAULT_GFP);
+	void *p;
+
+	p = dma_alloc_noncoherent(dmab->dev.dev, size, &dmab->addr,
+				  dmab->dev.dir, DEFAULT_GFP);
+	if (p)
+		dmab->dev.need_sync = dma_need_sync(dmab->dev.dev, dmab->addr);
+	return p;
 }
 
 static void snd_dma_noncoherent_free(struct snd_dma_buffer *dmab)


Patches currently in stable-queue which might be from tiwai@xxxxxxx are

queue-5.16/alsa-memalloc-fix-dma_need_sync-checks.patch
queue-5.16/alsa-hda-fix-missing-codec-probe-on-shenker-dock-15.patch
queue-5.16/alsa-hda-realtek-add-quirk-for-legion-y9000x-2019.patch
queue-5.16/alsa-usb-audio-revert-to-implicit_fb_fixed_dev-for-m-audio-fasttrack-ultra.patch
queue-5.16/alsa-usb-audio-don-t-abort-resume-upon-errors.patch
queue-5.16/alsa-hda-fix-regression-on-forced-probe-mask-option.patch
queue-5.16/alsa-memalloc-invalidate-sg-pages-before-sync.patch
queue-5.16/alsa-hda-realtek-fix-deadlock-by-coef-mutex.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux