Re: [PATCH 07/11] spi/pxa2xx: add support for DMA engine
From: Linus Walleij
Date: Thu Jan 17 2013 - 04:48:04 EST
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.
> + /*
> + * 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.
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.
Vinod/Dan? What do you say about this?
Yours,
Linus Walleij
--
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/