From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Vinod Koul <vinod.koul@intel.com>,
Kuninori Morimoto <kuninori.morimoto.gx@gmail.com>,
dmaengine@vger.kernel.org, linux-sh@vger.kernel.org,
Magnus Damm <magnus.damm@gmail.com>,
Linux-ALSA <alsa-devel@alsa-project.org>,
linux-arm-kernel@lists.infradead.org,
Maxime Ripard <maxime.ripard@free-electrons.com>
Subject: Re: DMA engine API issue
Date: Mon, 04 Aug 2014 18:32:25 +0000 [thread overview]
Message-ID: <20140804183225.GJ30282@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <53DFCB01.5050703@metafoo.de>
On Mon, Aug 04, 2014 at 08:03:45PM +0200, Lars-Peter Clausen wrote:
> If the hardware has scatter gather support it allows the driver to chain
> the descriptors before submitting them, which reduces the latency between
> the transfers as well as the IO over overhead.
While partially true, that's not the full story...
BTW, you're talking about stuff in DMA engine not being clear, but you're
using confusing terminology. Descriptors vs transactions. The prepare
functions return a transaction. Descriptors are the hardware data
structures which describe the transaction. I'll take what you're talking
about above as "chain the previous transaction descriptors to the next
transaction descriptors".
> The flaw with the current
> implementation is that there is only one global chain per channel instead
> of e.g. having the possibility to build up a chain in a driver and then
> submit and start the chain. Some drivers have virtual channels where each
> channel basically acts as the chain and once issue pending is called it
> is the chain is mapped to a real channel which then executes it.
Most DMA engines are unable to program anything except the parameters for
the next stage of the transfer. In order to switch between "channels",
many DMA engine implementations need the help of the CPU to reprogram the
physical channel configuration. Chaining two different channels which
may ultimately end up on the same physical channel would be a bug in that
case.
Where the real flaw exists is the way that a lot of people write their
DMA engine drivers - in particular how they deal with the end of a
transfer.
Many driver implementations receive an interrupt from the DMA controller,
and either queue a tasklet, or they check the existing transfer, mark it
as completed in some way, and queue a tasklet.
When the tasklet runs, they then look to see if there's another transfer
which they can start, and they then start it.
That is horribly inefficient - it is much better to do all the DMA
manipulation in IRQ context. So, when the channel completes the
existing transfer, you move the transaction to the queue of completed
transfers and queue the tasklet, check whether there's a transaction for
the same channel pending, and if so, start it immediately.
This means that your inter-transfer gap is reduced down from the
interrupt latency plus tasklet latency, to just the interrupt latency.
Controllers such as OMAP (if their hardware scatter chains were used)
do have the ability to reprogram the entire channel configuration from
an appropriate transaction, and so /could/ start the next transfer
entirely automatically - but I never added support for the hardware
scatterlists as I have been told that TI measurements indicated that
it did not gain any performance to use them. Had this been implemented,
it would mean that OMAP would only need to issue an interrupt to notify
completion of a transfer (so the driver would only have to work out
how many dma transactions had been completed.)
In this case, it is important that we do batch up the entries (since
an already in progress descriptor should not be modified), but I
suspect in the case of slave DMA, it is rarely the case that there
is more than one or two descriptors queued at any moment.
--
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
according to speedtest.net.
next prev parent reply other threads:[~2014-08-04 18:32 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-22 12:33 [PATCH/RFC 0/5] R-Car Gen2 DMAC hardware descriptor list support Laurent Pinchart
2014-07-23 2:17 ` Kuninori Morimoto
2014-07-23 10:28 ` Laurent Pinchart
2014-07-23 11:07 ` DMA engine API issue (was: [PATCH/RFC 0/5] R-Car Gen2 DMAC hardware descriptor list support) Laurent Pinchart
2014-07-24 0:46 ` Kuninori Morimoto
2014-07-24 1:35 ` Kuninori Morimoto
2014-07-24 4:59 ` Vinod Koul
2014-07-24 4:58 ` Vinod Koul
2014-08-01 8:51 ` Laurent Pinchart
2014-08-01 14:30 ` Russell King - ARM Linux
2014-08-01 17:21 ` Vinod Koul
2014-08-04 13:47 ` Geert Uytterhoeven
2014-08-04 17:00 ` Laurent Pinchart
2014-08-04 17:54 ` Russell King - ARM Linux
2014-08-05 23:19 ` Laurent Pinchart
2014-08-06 7:17 ` Geert Uytterhoeven
2014-08-06 11:04 ` Arnd Bergmann
2014-08-01 17:19 ` Vinod Koul
2014-08-04 16:50 ` Laurent Pinchart
2014-08-04 18:03 ` DMA engine API issue Lars-Peter Clausen
2014-08-04 18:32 ` Russell King - ARM Linux [this message]
2014-08-04 23:12 ` Laurent Pinchart
2014-08-05 17:08 ` DMA engine API issue (was: [PATCH/RFC 0/5] R-Car Gen2 DMAC hardware descriptor list support) Vinod Koul
2014-07-24 12:29 ` [alsa-devel] DMA engine API issue Lars-Peter Clausen
2014-07-24 12:51 ` DMA engine API issue (was: [PATCH/RFC 0/5] R-Car Gen2 DMAC hardware descriptor list support) Russell King - ARM Linux
2014-08-01 9:24 ` Laurent Pinchart
2014-07-23 9:48 ` [PATCH/RFC 0/5] R-Car Gen2 DMAC hardware descriptor list support Laurent Pinchart
2014-07-23 23:56 ` Kuninori Morimoto
2014-07-24 0:12 ` Laurent Pinchart
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=20140804183225.GJ30282@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=alsa-devel@alsa-project.org \
--cc=dmaengine@vger.kernel.org \
--cc=kuninori.morimoto.gx@gmail.com \
--cc=lars@metafoo.de \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-sh@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=maxime.ripard@free-electrons.com \
--cc=vinod.koul@intel.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;
as well as URLs for NNTP newsgroup(s).