]> git.baikalelectronics.ru Git - kernel.git/commit
ALSA: memalloc: Workaround for Xen PV
authorTakashi Iwai <tiwai@suse.de>
Wed, 25 Jan 2023 15:31:04 +0000 (16:31 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Feb 2023 10:28:02 +0000 (11:28 +0100)
commite1f8bbcd523b95e7bf7dc2edfeb80802d65ce08d
treea01ef0ba98213694851b079d4641cbbded1705d6
parentc5c8ad9e0aa3e9d092ad551e301860f43c374e6d
ALSA: memalloc: Workaround for Xen PV

[ Upstream commit 11c3fc59ab2767476582cd0d65a6d8bcfbf4636a ]

We change recently the memalloc helper to use
dma_alloc_noncontiguous() and the fallback to get_pages().  Although
lots of issues with IOMMU (or non-IOMMU) have been addressed, but
there seems still a regression on Xen PV.  Interestingly, the only
proper way to work is use dma_alloc_coherent().  The use of
dma_alloc_coherent() for SG buffer was dropped as it's problematic on
IOMMU systems.  OTOH, Xen PV has a different way, and it's fine to use
the dma_alloc_coherent().

This patch is a workaround for Xen PV.  It consists of the following
changes:
- For Xen PV, use only the fallback allocation without
  dma_alloc_noncontiguous()
- In the fallback allocation, use dma_alloc_coherent();
  the DMA address from dma_alloc_coherent() is returned in get_addr
  ops
- The DMA addresses are stored in an array; the first entry stores the
  number of allocated pages in lower bits, which are referred at
  releasing pages again

Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Tested-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Fixes: b04e1237923a ("ALSA: memalloc: Revive x86-specific WC page allocations again")
Fixes: 236e5cf26a73 ("ALSA: memalloc: Don't fall back for SG-buffer with IOMMU")
Link: https://lore.kernel.org/r/87tu256lqs.wl-tiwai@suse.de
Link: https://lore.kernel.org/r/20230125153104.5527-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/core/memalloc.c