linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Andre Schwarz <andre.schwarz@matrix-vision.de>
To: David Laight <David.Laight@ACULAB.COM>
Cc: LinuxPPC List <linuxppc-dev@ozlabs.org>,
	"Ira W. Snyder" <iws@ovro.caltech.edu>
Subject: Re: PCI DMA to user mem on mpc83xx
Date: Tue, 24 May 2011 12:02:48 +0200	[thread overview]
Message-ID: <4DDB8248.8010406@matrix-vision.de> (raw)
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6D8AD4B@saturn3.aculab.com>

David,

>> we have a pretty old PCI device driver here that needs some
>> basic rework running on 2.6.27 on several MPC83xx.
>> It's a simple char-device with "give me some data" implemented
>> using read() resulting in zero-copy DMA to user mem.
>>
>> There's get_user_pages() working under the hood along with
>> SetPageDirty() and page_cache_release().
> Does that dma use the userspace virtual address, or the
> physical address - or are you remapping the user memory into
> kernel address space.

no mapping at all AFAIK.

I'm using get_user_pages() followed by allocation of a struct 
scatterlist being filled with sg_set_page().
After the transfer the pages are marked dirty using SetPageDirty().

> If the memory is remapped into the kernel address space, the
> cost of the mmu and tlb operations (especially on MP systems)
> is such that a dma to kernel memory followed by copyout/copytouser
> may well be faster!
no mapping.

> That may even be the case even if the dma is writing to the
> user virtual (or physical) addresses when it is only
> necessary to ensure the memory page is resident and that
> the caches are coherent.
All I need is physical addresses of user mem.
Since the allocating user driver is using mlock() and there's no swap I 
expect to be safe ... is this a stupid assumption ?
> In any case the second copy is probably far faster than the
> PCI one!
huh - I observed memcpy() to be very expensive (at least on 83xx PowerPC).
> I've recently written driver that supports a pread/pwrite interface
> to the memory windows on a PCIe card. It was important to use
> dma for the PCIe transfers (to get a sensible transfer size).
> I overlapped the copyin/copyout with the next dma transfer.
> The dma's are fast enough that it is worth spinning waiting
> for completion - but slow enough to make the overlapped
> operation worthwhile (same speed as a single word pio transfer).


Thanks for your feedback.


Cheers,
André


MATRIX VISION GmbH, Talstrasse 16, DE-71570 Oppenweiler
Registergericht: Amtsgericht Stuttgart, HRB 271090
Geschaeftsfuehrer: Gerhard Thullner, Werner Armingeon, Uwe Furtner

      reply	other threads:[~2011-05-24 10:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-23  9:12 PCI DMA to user mem on mpc83xx Andre Schwarz
2011-05-23 17:27 ` Ira W. Snyder
2011-05-24  9:47   ` Andre Schwarz
2011-05-24  8:15 ` David Laight
2011-05-24 10:02   ` Andre Schwarz [this message]

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=4DDB8248.8010406@matrix-vision.de \
    --to=andre.schwarz@matrix-vision.de \
    --cc=David.Laight@ACULAB.COM \
    --cc=iws@ovro.caltech.edu \
    --cc=linuxppc-dev@ozlabs.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;
as well as URLs for NNTP newsgroup(s).