mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Håvard Skinnemoen" <hskinnemoen@gmail.com>
To: "David Brownell" <david-b@pacbell.net>
Cc: "Haavard Skinnemoen" <hskinnemoen@atmel.com>,
	wux@landicorp.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] atmel_spi: Pass correct DMA address to controller
Date: Wed, 16 May 2007 23:14:18 +0200	[thread overview]
Message-ID: <1defaf580705161414i67e753d7x883a78da347f7d55@mail.gmail.com> (raw)
In-Reply-To: <200705161254.59308.david-b@pacbell.net>

On 5/16/07, David Brownell <david-b@pacbell.net> wrote:
> On Wednesday 16 May 2007, Haavard Skinnemoen wrote:
> > -     tx_dma = xfer->tx_dma;
> > -     rx_dma = xfer->rx_dma;
> > +     tx_dma = xfer->tx_dma + xfer->len - len;
> > +     rx_dma = xfer->rx_dma + xfer->len - len;
> >
> >       /* use scratch buffer only when rx or tx data is unspecified */
> > -     if (rx_dma == INVALID_DMA_ADDRESS) {
> > +     if (!xfer->rx_buf) {
>
> This test ...
>
> >               rx_dma = as->buffer_dma;
> >               if (len > BUFFER_SIZE)
> >                       len = BUFFER_SIZE;
> >       }
> > -     if (tx_dma == INVALID_DMA_ADDRESS) {
> > +     if (!xfer->tx_buf) {
>
> ... and this one must not assume that the relevant buffer
> is always NULL when the tx_dma has been set up.  Keep the
> test against INVALID_DMA_ADDRESS, but fetch the address
> from the spi_transfer.

No it doesn't -- it's the other way around. It assumes that if
xfer->tx_buf is NULL, the user didn't provide a buffer so it has to
use the scratch buffer instead. The driver never does PIO transfers,
so if tx_buf is valid, tx_dma ought to be valid  too. This is taken
care of elsewhere by calling dma_map_single() if the user provided a
virtual pointer but not a dma address.

Checking for an invalid cpu-virtual pointer really should be
equivalent to checking for an invalid DMA address at this point.

I could perhaps add else blocks to those two ifs and add the offset to
the respective dma addresses there instead if it makes it clearer. The
tests are supposed to be the same as before, but I had to change them
one way or another because of the added offset (which would make an
invalid dma address non-invalid.)

> It's legit to set up cpu-virtual (for PIO) and dma addresses
> for each buffer, since the upper layer driver has no way to
> know if the underlying controller driver is DMA-capable, or
> for that matter PIO-capable.

Yes, but are there any drivers that will provide a valid dma address
and a NULL cpu-virtual pointer? That would indeed break my
assumptions, but it would also break any PIO-only drivers, wouldn't
it?

Haavard

  reply	other threads:[~2007-05-16 21:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-16 10:19 Haavard Skinnemoen
2007-05-16 19:54 ` David Brownell
2007-05-16 21:14   ` Håvard Skinnemoen [this message]
2007-05-30 17:27     ` David Brownell

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=1defaf580705161414i67e753d7x883a78da347f7d55@mail.gmail.com \
    --to=hskinnemoen@gmail.com \
    --cc=david-b@pacbell.net \
    --cc=hskinnemoen@atmel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wux@landicorp.com \
    /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

all inboxes | Powered by JetHome®