DMA Engine development
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: linux-sound@vger.kernel.org, dmaengine@vger.kernel.org,
	alsa-devel@alsa-project.org, miquel.raynal@bootlin.com,
	perex@perex.cz, tiwai@suse.com, lars@metafoo.de,
	lgirdwood@gmail.com
Subject: Re: DMA Transfer Synchronization Issue in Out-of-Tree Sound Card Driver
Date: Tue, 21 May 2024 19:32:59 +0100	[thread overview]
Message-ID: <6e01c13f-2bc1-4e08-b50e-9f1307bda92d@sirena.org.uk> (raw)
In-Reply-To: <Zkxb0FTzW6wlnYYO@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 1375 bytes --]

On Tue, May 21, 2024 at 10:31:12AM +0200, Louis Chauvet wrote:

> To address this DMA issue, I have created a patch [1] that guarantees the 
> completion of the DMA transfer upon the return of xdma_synchronize. This 
> means xdma_synchronize now sleeps, but looking at other drivers around it 
> appears expected to be able to do so.

You need to set the nonatomic flag for the PCM to allow this, the
default is that triggers run in atomic context.

> 
> 		switch (command) {
> 		case SNDRV_PCM_TRIGGER_START:
> 			/* Synchronize on start, because the trigger stop is called from an IRQ	context	*/
> 			if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
> 				dmaengine_synchronize(my_dev->playback_dma_chan);

If any dmaengine work is needed put it in the generic dmaengine code and
allow it to be configured there (ideally through discovery through the
API).

> The problem might be related to the sound driver. Should I avoid manually 
> using dmaengine_synchronize? How to achieve the same effect in this case? 
> Perhaps there is a more traditional way to properly clean the stream in 
> the sound subsystem which I overlooked?

If there's no way of resetting things without blocking then I'm not sure
you can do much better though I might be forgetting something, it does
seem like disappointing hardware design and application behaviour.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2024-05-21 18:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21  8:31 DMA Transfer Synchronization Issue in Out-of-Tree Sound Card Driver Louis Chauvet
2024-05-21 18:32 ` Mark Brown [this message]
2024-05-22  5:52   ` Takashi Iwai
2024-05-24 16:13     ` Louis Chauvet

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=6e01c13f-2bc1-4e08-b50e-9f1307bda92d@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox