2010/9/23 Dan Williams <dan.j.williams@intel.com>:
I was sort of suspecting a discussion around this...
Background: the PL081 that I'm testing on only has *two* physical
channels, they can be used for memcpy, slave transfers (RX/TX).
My first option was to set one channel aside for memcpy and
one for dev xfers and be done with it.
But that would be devastating if
I was only using them for memcpy or only devxfer, since it would
slash performance in half. So I decided to let memcpy and
dev xfers battle for the channels with oversubscription and exposing
two virtual memcpy channels.
Whereas the slave drivers I've written are prepared to handle the
case where a transfer fails gracefully (and not treat it as an error)
and fall back to IRQ/PIO mode, the memcpy tests in
drivers/dma/dmatest.c does treat a failure to prep() or submit()
as an error.
So for this reason I'm queueing memcpy requests until
there is a channel ready.
Are you suggesting I should rewrite the memcpy tests instead
so they gracefully handle a failed prep() call, not treat it as an
error and either:
- retry or
- copy with a regular klibc memcpy() call?
It is possible to do this at prep() time. However that assumes that every
device transfer has code that executes this sequence:
.device_prep_slave_sg()
.tx_submit()
.device_issue_pending()
In direct succession. If there is an arbitrary delay between prep()
and submit() (where I currently fail xfers) the physical channels
may starve if prep() allocates them.
If I can safely assume that prep() and .tx_submit() are in quick
succession, I can reserve the physical channel at prep() time.
This seems to be the case in current code where only quick
things like setting a callback etc is done between prep() and
.tx_submit().
So I'll spin the PL08x around to reserve channels on
prep() instead.
(By the way: we should rename .tx_submit() to just .submit()
since in device context this can just as well be RX!)
OK I've implemented failure path for tx_submit() in all my
drivers but I also have it for prep() of course. I hope I can keep
that code... I'll take out the comments about allocation failure
and move them to the prep() calls though.
Yours,
Linus Walleij
--