Re: [PATCH 07/11] spi/pxa2xx: add support for DMA engine

From: Mika Westerberg
Date: Thu Jan 17 2013 - 05:35:13 EST


On Thu, Jan 17, 2013 at 10:48:15AM +0100, Linus Walleij wrote:
> On Mon, Jan 7, 2013 at 11:44 AM, Mika Westerberg
> <mika.westerberg@xxxxxxxxxxxxxxx> wrote:
>
> > In order to use DMA with this driver on non-PXA platforms we implement support
> > for the generic DMA engine API. This allows to use different DMA engines with
> > little or no modification to the driver.
> >
> > Request lines and channel numbers can be passed to the driver from the
> > platform specific data.
> >
> > Signed-off-by: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>
> > ---
> > drivers/spi/spi-pxa2xx.c | 351 +++++++++++++++++++++++++++++++++++++++-
> > include/linux/spi/pxa2xx_spi.h | 6 +
>
> So if the other DMA implementation could go into spi-pxa2xx-pxadma.c
> this could be spi-pxa2xx-dma.c and they could use the common header
> file spi-pxa2xx-dma.h and then Kconfig select which one to compile.
>
> Just a suggestion to get the driver more readable.

Yes, it makes perfect sense. I'll do that in the next version.

> > + /*
> > + * Some DMA controllers have problems transferring buffers that are
> > + * not multiple of 4 bytes. So we truncate the transfer so that it
> > + * is suitable for such controllers, and handle the trailing bytes
> > + * manually after the DMA completes.
> > + */
> > + len = ALIGN(drv_data->len, 4);
>
> This is actually a property of the DMA controller.

Right and this is not the proper place for this but I wasn't sure where to
put this information...

> struct dma_device already has this:
>
> * @copy_align: alignment shift for memcpy operations
> * @xor_align: alignment shift for xor operations
> * @pq_align: alignment shift for pq operations
> * @fill_align: alignment shift for memset operations
> (...)
> u8 copy_align;
> u8 xor_align;
> u8 pq_align;
> u8 fill_align;
>
> To align memcpy's on 4 bytes you can e.g. set .copy_align
> to 2.
>
> So the syntax is number of shifts 1 << 2 = 4.
>
> If slave transfers can expose the same type of property we should
> maybe introdyce .slave_align in the same manner so you don't have
> to assume the worst in the driver.

... so this sounds good to me.
--
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/