linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Ayman El-Khashab <ayman@elkhashab.com>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: How to handle cache when I allocate phys memory?
Date: Fri, 14 Oct 2011 09:39:51 +0200	[thread overview]
Message-ID: <1318577991.29415.514.camel@pasglop> (raw)
In-Reply-To: <20111012210816.GA17878@crust.elkhashab.com>

On Wed, 2011-10-12 at 16:08 -0500, Ayman El-Khashab wrote:
> I'm using the 460sx (440 core) so no snooping here.  What
> I've done is reserved the top of memory for my driver.  My
> driver can read/write the memory and I can mmap it just
> fine.  The problem is I want to enable caching on the mmap
> for performance but I don't know / can't figure out how to
> tell the kernel to sync the cache after it gets dma data
> from the device or after i put data into it from user space.
> I know how to do it from regular devices, but not when I've
> allocated the physical memory myself.  I suppose what I am
> looking for is something akin to dma_sync_single cpu/device.
> 
> In my device driver, I am allocating the memory like this, 
> in this case the buffer is about 512MB.
> 
>  vma->vm_flags |= VM_LOCKED | VM_RESERVED;
> 
>  /* map the physical area into one buffer */
>  rc = remap_pfn_range(vma, vma->vm_start, 
>                          (PHYS_MEM_ADDR)>>PAGE_SHIFT, 
>                          len, vma->vm_page_prot);
> 
> Is this going to give me the best performance, or is there
> something more I can do?
> 
> Failing that, what is the best way to do this (i need a very
> large contiguous buffer).  it runs in batch mode, so it
> DMAs, stops, cpu reads, cpu writes, repeat ...

Did you try looking at what the dma_* functions do under the hood and
call it directly (or reproducing it) ?

Basically it boils down to using dcbf instructions to flush dirty data
or dcbi to invalidate cache lines.

Cheers,
Ben.

  reply	other threads:[~2011-10-14  7:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-12 21:08 How to handle cache when I allocate phys memory? Ayman El-Khashab
2011-10-14  7:39 ` Benjamin Herrenschmidt [this message]
2012-02-23 23:13   ` Ayman El-Khashab

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=1318577991.29415.514.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=ayman@elkhashab.com \
    --cc=linuxppc-dev@lists.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).