linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
To: Ben Nizette <bn@niasdigital.com>
Cc: hskinnemoen@atmel.com, spi-devel-general@lists.sourceforge.net,
	Linux Kernel list <linux-kernel@vger.kernel.org>,
	kernel <kernel@avr32linux.org>,
	dbrownell@users.sourceforge.net
Subject: Re: [PATCH] atmel_spi: fix dma addr calculation for len > BUFFER_SIZE
Date: Mon, 28 Sep 2009 09:12:59 +0200	[thread overview]
Message-ID: <20090928091259.27485716@hskinnemoen-d830> (raw)
In-Reply-To: <1254029187.7587.146.camel@ben-desktop>

Ben Nizette <bn@niasdigital.com> 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@niasdigital.com>

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@atmel.com>

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

  reply	other threads:[~2009-09-28  7:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-27  5:26 [PATCH] atmel_spi: fix dma addr calculation for len > BUFFER_SIZE Ben Nizette
2009-09-28  7:12 ` Haavard Skinnemoen [this message]
2009-09-29  0:55   ` Ben Nizette
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=20090928091259.27485716@hskinnemoen-d830 \
    --to=haavard.skinnemoen@atmel.com \
    --cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).