Re: [PATCH] atmel_spi: fix dma addr calculation for len >BUFFER_SIZE

From: Haavard Skinnemoen
Date: Mon Sep 28 2009 - 03:13:44 EST


Ben Nizette <bn@xxxxxxxxxxxxxxx> wrote:
> If len > BUFFER_LEN and !xfer->rx_buf we end up calculating the tx
> buffer address as
>
> *tx_dma = xfer->tx_dma + xfer->len - BUFFER_SIZE;
>
> which is constant; i.e. we just send the last BUFFER_SIZE data over
> again until we've reached the right number of bytes.
>
> This patch gets around this by using the /requested/ length when
> calculating addresses.
>
> Note there's no way len != *plen when we calculate the rx buffer address
> but conceptually we should be using *plen and I don't want someone to
> come through later, see the calculations for rx and tx are different and
> "clean up" back to what we had.
>
> Signed-off-by: Ben Nizette <bn@xxxxxxxxxxxxxxx>

Wow, that is subtle. I had to stare at it for a long while before I
understood what's going on, but I believe you're right.

Acked-by: Haavard Skinnemoen <haavard.skinnemoen@xxxxxxxxx>

While you're at it, could you send another patch renaming 'len' to
'next_len'? I think that would make it a bit more obvious why your
patch is correct and prevent similar mistakes in the future.

Haavard
--
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/