Re: [PATCH] driver for the ARM PL080/PL081 PrimeCells v5

From: Dan Williams
Date: Wed Sep 29 2010 - 17:16:10 EST


On Tue, Sep 28, 2010 at 6:57 AM, Linus Walleij
<linus.walleij@xxxxxxxxxxxxxx> wrote:
> This creates a DMAengine driver for the ARM PL080/PL081 PrimeCells
> based on the implementation earlier submitted by Peter Pearse.
> This is working like a charm for memcpy and slave DMA to the PL011
> PrimeCell on the PB11MPCore.
>
> This DMA controller is used in mostly unmodified form in the ARM
> RealView and Versatile platforms, in the ST-Ericsson Nomadik, and
> in the ST SPEAr platform.
>
> It has been converted to use the header from the Samsung PL080
> derivate instead of its own defintions. The Samsungs have a custom
> driver in their mach-* folders though, atleast we can share the
> register definitions.
>
> Cc: Peter Pearse <peter.pearse@xxxxxxx>
> Cc: Ben Dooks <ben-linux@xxxxxxxxx>
> Cc: Kukjin Kim <kgene.kim@xxxxxxxxxxx>
> Cc: Alessandro Rubini <rubini@xxxxxxxx>
> Acked-by: Viresh Kumar <viresh.kumar@xxxxxx>
> Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxxxxxx>
> ---
> Changes v4->v5:
> - Squashed in all the follow-up patches
> - Deny transfers at prep() time and hold a scary lock across to
>  tx_submit() time in order to avoid pending works being pulled out
>  by completed transfers before submitting
> - inline dummy filter function
>
> Notes: I had to keep the condition that slave prep() calls will
> bail out immediately and not queue up like memcpy calls do. The
> reason is that a memcpy will always proceed once there is a
> physical channel available, whereas a slave transfer also needs
> to mux in a signal after acquiring the physical channel, and this
> can fail, which would mean that jobs would have to fail
> asynchronously as well which seems a bit unsafe to me.
> Waiting for the muxing to be available is no alternative either
> since there is no guarantee this will ever happen resulting in
> serious starvation, better to fail at prep() time IMO.

Yes, let's go with the simpler / safe option now we can always get
fancier later.

> +/*
> + * Initialize a descriptor to be used by memcpy submit
> + */
> +static struct dma_async_tx_descriptor *pl08x_prep_dma_memcpy(
> +               struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
> +               size_t len, unsigned long flags)
> +{
> +       struct pl08x_dma_chan *plchan = to_pl08x_chan(chan);
> +       struct pl08x_driver_data *pl08x = plchan->host;
> +       struct pl08x_txd *txd;
> +       int ret;
> +
> +       txd = kzalloc(sizeof(struct pl08x_txd), GFP_KERNEL);
> +       if (!txd) {
> +               dev_err(&pl08x->adev->dev,
> +                       "%s no memory for descriptor\n", __func__);
> +               return NULL;
> +       }

With your acknowledgment I'll append a patch to convert this to
GFP_NOWAIT because device_prep_dma_memcpy() is meant to be callable
from atomic contexts.

--
Dan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/