mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Andy Gross <agross@codeaurora.org>
Cc: Mark Brown <broonie@kernel.org>,
	Bjorn Andersson <bjorn.andersson@sonymobile.com>,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-spi@vger.kernel.org,
	Daniel Sneddon <dsneddon@codeaurora.org>,
	"Ivan T. Ivanov" <iivanov@mm-sol.com>,
	Sagar Dharia <sdharia@codeaurora.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] spi: qup: Add DMA capabilities
Date: Fri, 27 Jun 2014 17:24:11 +0100	[thread overview]
Message-ID: <20140627162411.GO32514@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <20140627155422.GA13621@qualcomm.com>

On Fri, Jun 27, 2014 at 10:54:22AM -0500, Andy Gross wrote:
> On Fri, Jun 27, 2014 at 11:50:57AM +0100, Mark Brown wrote:
> > On Thu, Jun 26, 2014 at 04:06:21PM -0500, Andy Gross wrote:
> > 
> > > +	if (xfer->rx_buf) {
> > > +		rx_dma = dma_map_single(controller->dev, xfer->rx_buf,
> > > +			xfer->len, DMA_FROM_DEVICE);
> > 
> > It would be better to use the core DMA mapping code rather than open
> > coding.  This code won't work for vmalloc()ed addresses, or physically
> > non-contiguous addresses unless there's an IOMMU fixing things up.
> 
> Ah, ok.  So I just need a to setup the scatter gather page list and then do a
> dma_map_sg.  I'll resend once I have this in place.

Note that DMA from vmalloc'd memory is non-coherent on some platforms,
even if you use the DMA API.

The only thing that the DMA API guarantees is that the kernel mapping
will be made coherent for DMA purposes.  No other mapping has this
guarantee.

Consider a VIVT cache (like the older ARMs).  For this cache, you need
to find every alias of a physical page and flush it.  The DMA API doesn't
have that information - it can only deal with the kernel's lowmem mapping.

We have introduced a couple of helpers recently to solve the problem of
vmalloc() (since a number of filesystems now do this trick) but the
vmalloc() user has to deal with the problem:

	flush_kernel_vmap_range()
	invalidate_kernel_vmap_range()

See the bottom of Documentation/cachetlb.txt for details.

The long and the short of it is that it's better if vmalloc()'d memory
is avoided where possible.  It's also loads better if subsystems pass
physical references to memory for IO purposes where possible like our
block layer does (iow, struct page + offset, length) rather than
using randomly mapped virtual addresses, where the driver may not
know where the memory has come from.

-- 
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly
improving, and getting towards what was expected from it.

  reply	other threads:[~2014-06-27 16:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-26 21:06 Andy Gross
2014-06-27 10:50 ` Mark Brown
2014-06-27 15:54   ` Andy Gross
2014-06-27 16:24     ` Russell King - ARM Linux [this message]
2014-06-27 18:58       ` Andy Gross
2014-07-02 14:26 ` Ivan T. Ivanov

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=20140627162411.GO32514@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=agross@codeaurora.org \
    --cc=bjorn.andersson@sonymobile.com \
    --cc=broonie@kernel.org \
    --cc=dsneddon@codeaurora.org \
    --cc=iivanov@mm-sol.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=sdharia@codeaurora.org \
    /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®