Skip to content

Commit 478689b

Browse files
committed
ALSA: hda: Conditionally use snooping for AMD HDMI
The recent regression report revealed that the use of WC pages for AMD HDMI device together with AMD IOMMU leads to unexpected truncation or noises. The issue seems triggered by the change in the kernel core memory allocation that enables IOMMU driver to use always S/G buffers. Meanwhile, the use of WC pages has been a workaround for the similar issue with standard pages in the past. So, now we need to apply the workaround conditionally, namely, only when IOMMU isn't in place. This patch modifies the workaround code to check the DMA ops at first and apply the snoop-off only when needed. Fixes: f5ff79f ("dma-mapping: remove CONFIG_DMA_REMAP") Link: https://bugzilla.kernel.org/show_bug.cgi?id=219087 Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent b7b7e1a commit 478689b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

sound/pci/hda/hda_controller.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#else
2929
#define AZX_DCAPS_I915_COMPONENT 0 /* NOP */
3030
#endif
31-
/* 14 unused */
31+
#define AZX_DCAPS_AMD_ALLOC_FIX (1 << 14) /* AMD allocation workaround */
3232
#define AZX_DCAPS_CTX_WORKAROUND (1 << 15) /* X-Fi workaround */
3333
#define AZX_DCAPS_POSFIX_LPIB (1 << 16) /* Use LPIB as default */
3434
#define AZX_DCAPS_AMD_WORKAROUND (1 << 17) /* AMD-specific workaround */

sound/pci/hda/hda_intel.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
#ifdef CONFIG_X86
4242
/* for snoop control */
43+
#include <linux/dma-map-ops.h>
4344
#include <asm/set_memory.h>
4445
#include <asm/cpufeature.h>
4546
#endif
@@ -306,7 +307,7 @@ enum {
306307

307308
/* quirks for ATI HDMI with snoop off */
308309
#define AZX_DCAPS_PRESET_ATI_HDMI_NS \
309-
(AZX_DCAPS_PRESET_ATI_HDMI | AZX_DCAPS_SNOOP_OFF)
310+
(AZX_DCAPS_PRESET_ATI_HDMI | AZX_DCAPS_AMD_ALLOC_FIX)
310311

311312
/* quirks for AMD SB */
312313
#define AZX_DCAPS_PRESET_AMD_SB \
@@ -1702,6 +1703,13 @@ static void azx_check_snoop_available(struct azx *chip)
17021703
if (chip->driver_caps & AZX_DCAPS_SNOOP_OFF)
17031704
snoop = false;
17041705

1706+
#ifdef CONFIG_X86
1707+
/* check the presence of DMA ops (i.e. IOMMU), disable snoop conditionally */
1708+
if ((chip->driver_caps & AZX_DCAPS_AMD_ALLOC_FIX) &&
1709+
!get_dma_ops(chip->card->dev))
1710+
snoop = false;
1711+
#endif
1712+
17051713
chip->snoop = snoop;
17061714
if (!snoop) {
17071715
dev_info(chip->card->dev, "Force to non-snoop mode\n");

0 commit comments

Comments
 (0)