public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: "David Xiao" <dxiao@broadcom.com>
To: "Laurent Pinchart" <laurent.pinchart@ideasonboard.com>
Cc: "Steven Walter" <stevenrwalter@gmail.com>,
	"Russell King - ARM Linux" <linux@arm.linux.org.uk>,
	"Ben Dooks" <ben-linux@fluff.org>,
	"Hugh Dickins" <hugh.dickins@tiscali.co.uk>,
	"Robin Holt" <holt@sgi.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	v4l2_linux <linux-media@vger.kernel.org>,
	"linux-arm-kernel@lists.arm.linux.org.uk"
	<linux-arm-kernel@lists.arm.linux.org.uk>
Subject: Re: How to efficiently handle DMA and cache on ARMv7 ? (was "Is get_user_pages() enough to prevent pages from being swapped out ?")
Date: Wed, 26 Aug 2009 10:22:11 -0700	[thread overview]
Message-ID: <1251307331.9535.16.camel@david-laptop> (raw)
In-Reply-To: <200908260117.27180.laurent.pinchart@ideasonboard.com>

On Tue, 2009-08-25 at 16:17 -0700, Laurent Pinchart wrote:
> On Wednesday 26 August 2009 00:02:48 David Xiao wrote:
> > On Tue, 2009-08-25 at 05:53 -0700, Steven Walter wrote:
> > > On Thu, Aug 6, 2009 at 6:25 PM, Russell King - ARM
> > > Linux<linux@arm.linux.org.uk> wrote:
> > > [...]
> > >
> > > > As far as userspace DMA coherency, the only way you could do it with
> > > > current kernel APIs is by using get_user_pages(), creating a
> > > > scatterlist from those, and then passing it to dma_map_sg().  While the
> > > > device has ownership of the SG, userspace must _not_ touch the buffer
> > > > until after DMA has completed.
> > >
> > > [...]
> > >
> > > Would that work on a processor with VIVT caches?  It seems not.  In
> > > particular, dma_map_page uses page_address to get a virtual address to
> > > pass to map_single().  map_single() in turn uses this address to
> > > perform cache maintenance.  Since page_address() returns the kernel
> > > virtual address, I don't see how any cache-lines for the userspace
> > > virtual address would get invalidated (for the DMA_FROM_DEVICE case).
> > >
> > > If that's true, then what is the correct way to allow DMA to/from a
> > > userspace buffer with a VIVT cache?  If not true, what am I missing?
> >
> > page_address() is basically returning page->virtual, which records the
> > virtual/physical mapping for both user/kernel space; and what only
> > matters there is highmem or not.
> 
> I'm not sure to get it. Are you implying that a physical page will then be 
> mapped to the same address in all contexts (kernelspace and userspace 
> processes) ? Is that even possible ? And if not, how could page->virtual store 
> both the initial kernel map and all the userspace mappings ?
> 
Sorry for the confusion, page_address() indeed only returns kernel
virtual address; and in order to support VIVT cache maintenance for the
user space mappings, the dma_map_sg/dma_map_page() functions or even the
struct scatterlist do seem to have to be modified to pass in virtual
address, I think.

David



  reply	other threads:[~2009-08-26 17:22 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-06 10:08 How to efficiently handle DMA and cache on ARMv7 ? (was "Is get_user_pages() enough to prevent pages from being swapped out ?") Laurent Pinchart
2009-08-06 11:46 ` Ben Dooks
2009-08-06 13:06   ` Laurent Pinchart
2009-08-06 18:46     ` David Xiao
2009-08-06 19:16       ` Chetan.Loke
2009-08-06 20:15       ` Jamie Lokier
2009-08-06 22:25       ` Russell King - ARM Linux
2009-08-07  5:59         ` David Xiao
2009-08-07  7:58           ` Laurent Pinchart
2009-08-07  8:10             ` Russell King - ARM Linux
2009-08-07  9:54               ` Jamie Lokier
2009-08-07  9:59                 ` Russell King - ARM Linux
2009-08-07 12:07                 ` Laurent Desnogues
2009-08-07 13:15                   ` Robin Holt
2009-08-07 19:01                     ` Russell King - ARM Linux
2009-08-07 20:11                       ` Laurent Pinchart
2009-08-07 20:28                         ` Russell King - ARM Linux
2009-08-07 22:25                           ` David Xiao
2009-08-10 13:49                           ` Laurent Pinchart
2009-08-07  8:08           ` Russell King - ARM Linux
2009-08-07 10:23           ` Jamie Lokier
2009-08-07 19:03             ` Russell King - ARM Linux
2009-08-11  9:31           ` Catalin Marinas
2009-08-11 18:23             ` David Xiao
2009-08-07  7:48         ` Laurent Pinchart
2009-08-25 12:53         ` Steven Walter
2009-08-25 22:02           ` David Xiao
2009-08-25 23:17             ` Laurent Pinchart
2009-08-26 17:22               ` David Xiao [this message]
2009-09-01 13:31                 ` Russell King - ARM Linux
2009-09-01 18:08                   ` David Xiao
2009-09-01 13:28           ` Russell King - ARM Linux
2009-09-01 13:43             ` Laurent Pinchart
2009-09-01 14:18               ` Russell King - ARM Linux
2009-09-01 16:53                 ` Hugh Dickins
2009-09-02 15:10               ` Imre Deak
2009-09-03  7:31                 ` Imre Deak
2009-09-03  8:36                 ` Russell King - ARM Linux
2009-09-08 13:05                   ` Steven Walter
2009-08-07  7:29       ` Laurent Pinchart
2009-08-07  8:12         ` Matthieu CASTET
2009-08-07 10:13           ` How to efficiently handle DMA and cache on ARMv7 ? (was " Is " Laurent Pinchart

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=1251307331.9535.16.camel@david-laptop \
    --to=dxiao@broadcom.com \
    --cc=ben-linux@fluff.org \
    --cc=holt@sgi.com \
    --cc=hugh.dickins@tiscali.co.uk \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=stevenrwalter@gmail.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