All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH RFC v2 0/4] ALSA: Support for non-coherent and non-contiguous page allocation
Date: Thu, 12 Aug 2021 13:38:14 +0200	[thread overview]
Message-ID: <20210812113818.6479-1-tiwai@suse.de> (raw)

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/20210810122200.971-1-tiwai@suse.de

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(-)

-- 
2.26.2


             reply	other threads:[~2021-08-12 11:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12 11:38 Takashi Iwai [this message]
2021-08-12 11:38 ` [PATCH RFC v2 1/4] ALSA: memalloc: Count continuous pages in vmalloc buffer handler Takashi Iwai
2021-08-12 11:38 ` [PATCH RFC v2 2/4] ALSA: pcm: Add SNDRV_PCM_INFO_EXPLICIT_SYNC flag Takashi Iwai
2021-08-12 18:37   ` Pierre-Louis Bossart
2021-08-13  6:03     ` Takashi Iwai
2021-08-12 11:38 ` [PATCH RFC v2 3/4] ALSA: memalloc: Support for non-contiguous page allocation Takashi Iwai
2021-08-12 11:38 ` [PATCH RFC v2 4/4] ALSA: memalloc: Support for non-coherent " Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210812113818.6479-1-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --subject='Re: [PATCH RFC v2 0/4] ALSA: Support for non-coherent and non-contiguous page allocation' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.