Skip to content

Commit 37137ec

Browse files
committed
ALSA: hda: Once again fix regression of page allocations with IOMMU
The last fix for trying to recover the regression on AMD platforms, unfortunately, leaded to yet another regression: it turned out that IOMMUs don't like the usage of raw page allocations. This is yet another attempt for addressing the log saga; at this time, we re-use the existing buffer allocation mechanism with SG-pages although we require only single pages. The SG buffer allocation itself was confirmed to work for stream buffers, so it's relatively easy to adapt for other places. The only problem is: although the HD-audio code is accessing the address directly via dmab->address field, SG-pages don't set up it. For the ease of adaption, we now set up the dmab->addr field from the address of the first page as default, so that it can run with the HD-audio driver code as-is without the excessive call of snd_sgbuf_get_addr() multiple times; that's the only change in the memalloc helper side. The rest is nothing but a flip of the dma_type field in the HD-audio side. Fixes: a8d302a ("ALSA: memalloc: Revive x86-specific WC page allocations again") Reported-by: Mikhail Gavrilov <[email protected]> Tested-by: Mikhail Gavrilov <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/CABXGCsO+kB2t5QyHY-rUe76npr1m0-5JOtt8g8SiHUo34ur7Ww@mail.gmail.com Link: https://bugzilla.kernel.org/show_bug.cgi?id=216112 Link: https://bugzilla.kernel.org/show_bug.cgi?id=216363 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent e53f47f commit 37137ec

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

sound/core/memalloc.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,10 +543,13 @@ static void *snd_dma_noncontig_alloc(struct snd_dma_buffer *dmab, size_t size)
543543
dmab->dev.need_sync = dma_need_sync(dmab->dev.dev,
544544
sg_dma_address(sgt->sgl));
545545
p = dma_vmap_noncontiguous(dmab->dev.dev, size, sgt);
546-
if (p)
546+
if (p) {
547547
dmab->private_data = sgt;
548-
else
548+
/* store the first page address for convenience */
549+
dmab->addr = snd_sgbuf_get_addr(dmab, 0);
550+
} else {
549551
dma_free_noncontiguous(dmab->dev.dev, size, sgt, dmab->dev.dir);
552+
}
550553
return p;
551554
}
552555

@@ -780,6 +783,8 @@ static void *snd_dma_sg_fallback_alloc(struct snd_dma_buffer *dmab, size_t size)
780783
if (!p)
781784
goto error;
782785
dmab->private_data = sgbuf;
786+
/* store the first page address for convenience */
787+
dmab->addr = snd_sgbuf_get_addr(dmab, 0);
783788
return p;
784789

785790
error:

sound/pci/hda/hda_intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,7 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci,
18171817

18181818
/* use the non-cached pages in non-snoop mode */
18191819
if (!azx_snoop(chip))
1820-
azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC;
1820+
azx_bus(chip)->dma_type = SNDRV_DMA_TYPE_DEV_WC_SG;
18211821

18221822
if (chip->driver_type == AZX_DRIVER_NVIDIA) {
18231823
dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n");

0 commit comments

Comments
 (0)