ALSA: pcm: Use SG-buffer only when direct DMA is available
authorTakashi Iwai <tiwai@suse.de>
Mon, 15 Jun 2020 16:00:45 +0000 (18:00 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 15 Jun 2020 16:02:03 +0000 (18:02 +0200)
commit3ad796cbc36a7bc8bfd4de191d791b9490bc112b
tree1b161051729cab91b5c9dc6755cc7f5d421dde12
parent2a1f3368bff609504cdc984cdb7cef467bb0b2b0
ALSA: pcm: Use SG-buffer only when direct DMA is available

The DMA-coherent SG-buffer is tricky to use, as it does need the
mapping.  It used to work stably on x86 over years (and that's why we
had enabled SG-buffer on solely x86) with the default mmap handler and
vmap(), but our luck seems no forever success.  The chance of breakage
is high when the special DMA handling is introduced in the arch side.

In this patch, we change the buffer allocation to use the SG-buffer
only when the device in question is with the direct DMA.  It's a bit
hackish, but it's currently the only condition that may work (more or
less) reliably with the default mmap and vmap() for mapping the pages
that are deduced via virt_to_page().

In theory, we can apply the similar hack in the sound/core memory
allocation helper, too; but it's used by SOF for allocating SG pages
without re-mapping via vmap() or mmap, and it's fine to use it in that
way, so let's keep it and adds the workaround in PCM side.

Link: https://lore.kernel.org/r/20200615160045.2703-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/pcm_memory.c