From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] Update imx-sdma cyclic handling to report residue
Date: Sat, 28 Jun 2014 23:03:22 +0800 [thread overview]
Message-ID: <20140628150320.GC7869@dragon> (raw)
In-Reply-To: <20140625120032.GI32514@n2100.arm.linux.org.uk>
On Wed, Jun 25, 2014 at 01:00:33PM +0100, Russell King - ARM Linux wrote:
> I received a report this morning from one of the Novena developers that
> the behaviour of the iMX6 ASoC codec driver (using imx-pcm-dma.c) was
> sub-optimal under high system load.
>
> While there are issues relating to system load remaining, upon reviewing
> the ASoC imx-pcm-dma.c driver, it was noticed that it not using the
> residue support, because SDMA doesn't support it. This has the effect
> that SDMA has to make multiple calls into the ASoC and ALSA code, one
> for each period.
>
> Since ALSA's snd_pcm_elapsed() does not need to be called multiple times
> and it is entirely sufficient to call it once to update ALSA with the
> current buffer position via the pointer method, we can do better here.
> We can also avoid stopping the DMA entirely, just like real cyclic DMA
> implementations behave. While this means that we replay some old samples,
> this is a nicer behaviour than having audio stop and restart.
>
> The changes to achieve this are relatively minor - imx-sdma.c can track
> where the DMA is to the nearest descriptor boundary - it does this
> already when deciding how many callbacks to issue. In doing this,
> buf_tail always points at the descriptor which will complete next.
>
> The residue is defined by the bytes remaining to the end of the buffer,
> when the buffer is viewed as a single block of memory [start...end].
> So, when we start out, there's a full buffer worth of residue, and this
> counts down as we approach the end of the buffer, eventually becoming
> zero at the end, before returning to the full buffer worth when we
> wrap back to the start.
>
> Moving the walking of the descriptors into the interrupt handler means
> that we can update the BD_DONE flag at interrupt time, thus avoiding
> a delayed tasklet stopping the cyclic DMA.
>
> This means that the residue can be calculated from (total descriptors -
> buf_tail) * descriptor size. This is what the change below does. We
> update imx-pcm-dma.c to remove the NO_RESIDUE flag since we now provide
> the residue.
>
> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
For all the audio test cases I usually run, nothing breaks, so
Tested-by: Shawn Guo <shawn.guo@linaro.org>
next prev parent reply other threads:[~2014-06-28 15:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-25 12:00 [PATCH] Update imx-sdma cyclic handling to report residue Russell King - ARM Linux
2014-06-28 15:03 ` Shawn Guo [this message]
2014-07-01 6:55 ` Vinod Koul
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=20140628150320.GC7869@dragon \
--to=shawn.guo@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).