mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: Linus Walleij <linus.walleij@stericsson.com>,
	yuanyabin1978@sina.com, Dan Williams <dan.j.williams@intel.com>,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/5] ARM: add PrimeCell generic DMA to PL022 v9
Date: Tue, 17 Aug 2010 09:56:04 +0100	[thread overview]
Message-ID: <20100817085603.GA20325@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20100817044834.GA27060@angua.secretlab.ca>

On Mon, Aug 16, 2010 at 10:48:34PM -0600, Grant Likely wrote:
> > +	/* Map DMA buffers */
> > +	sglen = dma_map_sg(&pl022->adev->dev, pl022->sgt_rx.sgl,
> > +			   pl022->sgt_rx.nents, DMA_FROM_DEVICE);
> > +	if (sglen != pages)
> > +		goto err_rx_sgmap;
> > +
> > +	sglen = dma_map_sg(&pl022->adev->dev, pl022->sgt_tx.sgl,
> > +			   pl022->sgt_tx.nents, DMA_TO_DEVICE);
> > +	if (sglen != pages)
> > +		goto err_tx_sgmap;
> > +
> > +	/* Synchronize the TX scatterlist, invalidate buffers, caches etc */
> > +	dma_sync_sg_for_device(&pl022->adev->dev,
> > +			       pl022->sgt_tx.sgl,
> > +			       pl022->sgt_tx.nents,
> > +			       DMA_TO_DEVICE);

This is wrong.  Mapping a scatterlist already makes it available for
the device to use.  There's no point re-doing that work by using
the sync API.

Let's go over the DMA API one more time.

	CPU owns buffer, device must not access

dma_map_xx		buffer ownership transitions from CPU to device

	device owns buffer, CPU must not access

dma_sync_xx_for_cpu	buffer ownership transitions from device to CPU

	CPU owns buffer, device must not access

dma_sync_xx_for_device	buffer ownership transitions from CPU to device

	device owns buffer, CPU must not access

dma_unmap_xx		buffer ownership transitions from device to CPU

	CPU owns buffer, device must not access

  reply	other threads:[~2010-08-17  8:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-06 11:50 Linus Walleij
2010-08-17  4:48 ` Grant Likely
2010-08-17  8:56   ` Russell King - ARM Linux [this message]
2010-08-18  4:34   ` Grant Likely
2010-08-18  9:18     ` Linus WALLEIJ
2010-08-18 13:39     ` Linus Walleij

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=20100817085603.GA20325@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=dan.j.williams@intel.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yuanyabin1978@sina.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®