ALSA: memalloc: Don't fall back for SG-buffer with IOMMU
authorTakashi Iwai <tiwai@suse.de>
Thu, 10 Nov 2022 13:22:16 +0000 (14:22 +0100)
committerTakashi Iwai <tiwai@suse.de>
Thu, 10 Nov 2022 13:23:03 +0000 (14:23 +0100)
commit9736a325137b62499d2b4be3fc2d742b131f75da
treef8e1db0661d499b9ea02473688ef19cc8463acb3
parentbf990c10231937c0f51e5da5558e08cf5adc6a78
ALSA: memalloc: Don't fall back for SG-buffer with IOMMU

When the non-contiguous page allocation for SG buffer allocation
fails, the memalloc helper tries to fall back to the old page
allocation methods.  This would, however, result in the bogus page
addresses when IOMMU is enabled.  Usually in such a case, the fallback
allocation should fail as well, but occasionally it succeeds and
hitting a bad access.

The fallback was thought for non-IOMMU case, and as the error from
dma_alloc_noncontiguous() with IOMMU essentially implies a fatal
memory allocation error, we should return the error straightforwardly
without fallback.  This avoids the corner case like the above.

The patch also renames the local variable "dma_ops" with snd_ prefix
for avoiding the name conflict.

Fixes: a8d302a0b770 ("ALSA: memalloc: Revive x86-specific WC page allocations again")
Reported-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://lore.kernel.org/r/alpine.DEB.2.22.394.2211041541090.3532114@eliteleevi.tm.intel.com
Link: https://lore.kernel.org/r/20221110132216.30605-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/memalloc.c