Skip to content

RFC ALSA: Support for non-coherent and non-contiguous page allocation

Takashi Iwai alsa-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 RFC Latest4 patches 2 repliesIn review
  2. v1 RFC5 patches 0 repliesSuperseded

Changes in v2 from the cover letter

* Drop the optimization patch for embedding ops that turned out to be negligible but causing a trouble with the existing sgbuf.
* Minor code refactoring

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4ALSA: memalloc: Count continuous pages in vmalloc buffer handlersound/core/memalloc.c+21 -70 replies
2/4ALSA: pcm: Add SNDRV_PCM_INFO_EXPLICIT_SYNC flaginclude/uapi/sound/asound.h sound/core/pcm_native.c+10 -02 replies
3/4ALSA: memalloc: Support for non-contiguous page allocationinclude/sound/memalloc.h sound/core/memalloc.c sound/core/memalloc_local.h +4 more+161 -150 replies
4/4ALSA: memalloc: Support for non-coherent page allocationinclude/sound/memalloc.h sound/core/memalloc.c+44 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH RFC v2 0/4] ALSA: Support for non-coherent and non-contiguous page allocation

Hi,

this is a revised patchset to add the support for PCM buffers with non-coherent and non-contiguous pages, typically useful for non-x86 architectures. The first patch improves the SG-buffer handling, then add a new PCM info flag that disables the control and status mmap, and implements two new buffer types, SNDRV_DMA_TYPE_NONCONTIG and SNDRV_DMA_TYPE_NONCOHERENT. The former is the SG-buffer and the latter is the continuous page allocation, corresponding to SNDRV_DMA_TYPE_DEV_SG and SNDRV_DMA_TYPE_DEV on x86.

Unlike other page types, those are directional (that need the DMA direction at allocation time) and require the explicit sync of buffers around the data transfer (flushing, invalidating). The sync is implemented inside ALSA PCM core and automatically applied at updating the applptr and hwsync via SYNC_PTR ioctl, which should be issued during mmap operation, so it should work transparently as long as applications are running with alsa-lib. For tinyALSA, we might need to revisit the implementation.

This is currently an RFC -- more exactly, CALL FOR TESTERS, as I have no Arm machine with the sound device for now. The needed change for an existing driver is simple:

* Replace the buffer type from SNDRV_DMA_TYPE_DEV to SNDRV_DMA_TYPE_NONCOHERENT (or from SNDRV_DMA_TYPE_DEV_SG to SNDRV_DMA_TYPE_NONCONTIG), which is set up typically in snd_pcm_set_managed_buffer*() call.

* Add SNDRV_PCM_INFO_EXPLICIT_SYNC flag to the PCM runtime hardware.info field

It'd be greatly appreciated if anyone can test and try the changes, and help debugging. Again, the code is faily untested.

The latest code is found in topic/memalloc-noncontig branch of my sound git tree:
git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git

The patch set is based on for-next branch, i.e. changes for 5.15 are included.

thanks,

Takashi

===

v1: https://lore.kernel.org/r/[email protected]

v1->v2:
* Drop the optimization patch for embedding ops that turned out to be negligible but causing a trouble with the existing sgbuf.
* Minor code refactoring

===

Takashi Iwai (4):
ALSA: memalloc: Count continuous pages in vmalloc buffer handler
ALSA: pcm: Add SNDRV_PCM_INFO_EXPLICIT_SYNC flag
ALSA: memalloc: Support for non-contiguous page allocation
ALSA: memalloc: Support for non-coherent page allocation

 include/sound/memalloc.h    |  46 +++++++++-
 include/uapi/sound/asound.h |   1 +
 sound/core/memalloc.c       | 172 ++++++++++++++++++++++++++++++++----
 sound/core/memalloc_local.h |   1 +
 sound/core/pcm_lib.c        |   3 +
 sound/core/pcm_local.h      |   7 ++
 sound/core/pcm_memory.c     |  13 ++-
 sound/core/pcm_native.c     |  15 ++++
 8 files changed, 236 insertions(+), 22 deletions(-)
Signature · 1 line
2.26.2