From: Ben Nizette <bn@niasdigital.com>
To: hskinnemoen@atmel.com
Cc: spi-devel-general@lists.sourceforge.net,
Linux Kernel list <linux-kernel@vger.kernel.org>,
kernel <kernel@avr32linux.org>,
dbrownell@users.sourceforge.net
Subject: [PATCH] atmel_spi: fix dma addr calculation for len > BUFFER_SIZE
Date: Sun, 27 Sep 2009 15:26:27 +1000 [thread overview]
Message-ID: <1254029187.7587.146.camel@ben-desktop> (raw)
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@niasdigital.com>
---
drivers/spi/atmel_spi.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c
index f5b3fdb..8ce70cb 100644
--- a/drivers/spi/atmel_spi.c
+++ b/drivers/spi/atmel_spi.c
@@ -189,14 +189,14 @@ static void atmel_spi_next_xfer_data(struct spi_master *master,
/* use scratch buffer only when rx or tx data is unspecified */
if (xfer->rx_buf)
- *rx_dma = xfer->rx_dma + xfer->len - len;
+ *rx_dma = xfer->rx_dma + xfer->len - *plen;
else {
*rx_dma = as->buffer_dma;
if (len > BUFFER_SIZE)
len = BUFFER_SIZE;
}
if (xfer->tx_buf)
- *tx_dma = xfer->tx_dma + xfer->len - len;
+ *tx_dma = xfer->tx_dma + xfer->len - *plen;
else {
*tx_dma = as->buffer_dma;
if (len > BUFFER_SIZE)
--
1.6.0.4
next reply other threads:[~2009-09-27 5:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-27 5:26 Ben Nizette [this message]
2009-09-28 7:12 ` [PATCH] atmel_spi: fix dma addr calculation for len > BUFFER_SIZE Haavard Skinnemoen
2009-09-29 0:55 ` Ben Nizette
2009-09-29 6:57 ` Haavard Skinnemoen
2009-09-29 6:57 ` Haavard Skinnemoen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1254029187.7587.146.camel@ben-desktop \
--to=bn@niasdigital.com \
--cc=dbrownell@users.sourceforge.net \
--cc=hskinnemoen@atmel.com \
--cc=kernel@avr32linux.org \
--cc=linux-kernel@vger.kernel.org \
--cc=spi-devel-general@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.