linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-arch@vger.kernel.org, linux-parisc@vger.kernel.org
Subject: Re: [PATCH 1/6] mm: add coherence API for DMA to vmalloc/vmap areas
Date: Wed, 18 Nov 2009 10:13:37 -0500	[thread overview]
Message-ID: <1258557217.2540.12.camel@mulgrave.site> (raw)
In-Reply-To: <20091118143815.GA17146@linux-mips.org>

On Wed, 2009-11-18 at 15:38 +0100, Ralf Baechle wrote:
> On Tue, Nov 17, 2009 at 11:03:47AM -0600, James Bottomley wrote:
> 
> > On Virtually Indexed architectures (which don't do automatic alias
> > resolution in their caches), we have to flush via the correct
> > virtual address to prepare pages for DMA.  On some architectures
> > (like arm) we cannot prevent the CPU from doing data movein along
> > the alias (and thus giving stale read data), so we not only have to
> > introduce a flush API to push dirty cache lines out, but also an invalidate
> > API to kill inconsistent cache lines that may have moved in before
> > DMA changed the data
> 
> The API looks right for MIPS and trivial to implement based on existing
> code, so feel free to throw in my Ack on the generic parts.
> 
> The new APIs deserve documentation in Documentation/cachetlb.txt.

True (mutter, hate doing docs, mutter).

How about this?

James

---

diff --git a/Documentation/cachetlb.txt b/Documentation/cachetlb.txt
index da42ab4..7d1055c 100644
--- a/Documentation/cachetlb.txt
+++ b/Documentation/cachetlb.txt
@@ -377,3 +377,27 @@ maps this page at its virtual address.
 	All the functionality of flush_icache_page can be implemented in
 	flush_dcache_page and update_mmu_cache. In 2.7 the hope is to
 	remove this interface completely.
+
+For machines where aliasing can be a problem, there exist two
+additional APIs to handle I/O to vmap/vmalloc areas within the
+kernel. These are areas that have two kernel mappings, one the regular
+page offset map through which the page has likely been previously
+accessed and the other, the new contiguous map in the kernel virtual
+map area.  This dual mapping sets up aliasing within the kernel and,
+in particular since all kernel flushing goes through the offset map,
+must be handled separately for I/O.  to declare your architecture as
+needing to use these functions, you must define
+ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE in asm/cacheflush.h and add two API
+helpers (usually as static inlines in cacheflush.h).  The two new APIs
+are:
+
+  void flush_kernel_dcache_addr(void *addr)
+       Flush a single page through the vmap alias for addr.  This is
+       usually executed prior to performing I/O on the page to make
+       sure the underlying physical page is up to date.
+
+  void invalidate_kernel_dcache_addr(void *addr)
+       Invalidate the page after I/O has completed.  This is necessary
+       on machines whose cache mechanisms might trigger cache movein
+       during I/O.  If you can ensure architecturally that this movein
+       never occurs, this function can be empty on your architecture.

  parent reply	other threads:[~2009-11-18 15:13 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-17 17:03 [PATCH 0/6] fix xfs by making I/O to vmap/vmalloc areas work James Bottomley
2009-11-17 17:03 ` James Bottomley
2009-11-17 17:03 ` [PATCH 1/6] mm: add coherence API for DMA to vmalloc/vmap areas James Bottomley
2009-11-17 17:03   ` James Bottomley
2009-11-17 17:03   ` [PATCH 2/6] parisc: add mm " James Bottomley
2009-11-17 17:03     ` [PATCH 3/6] arm: " James Bottomley
2009-11-17 17:03       ` James Bottomley
2009-11-17 17:03       ` [PATCH 4/6] sh: " James Bottomley
2009-11-17 17:03         ` James Bottomley
2009-11-17 17:03         ` [PATCH 5/6] block: permit I/O to vmalloc/vmap kernel pages James Bottomley
2009-11-17 17:03           ` [PATCH 6/6] xfs: fix xfs to work with Virtually Indexed architectures James Bottomley
2009-11-18 10:10           ` [PATCH 5/6] block: permit I/O to vmalloc/vmap kernel pages FUJITA Tomonori
2009-11-18 13:50             ` James Bottomley
2009-11-18 13:50               ` James Bottomley
2009-11-18 14:15               ` FUJITA Tomonori
2009-11-18 14:15                 ` FUJITA Tomonori
2009-11-18 14:21                 ` James Bottomley
2009-11-18 14:21                   ` James Bottomley
2009-11-18 14:38   ` [PATCH 1/6] mm: add coherence API for DMA to vmalloc/vmap areas Ralf Baechle
2009-11-18 14:38     ` Ralf Baechle
2009-11-18 15:13     ` James Bottomley [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-09-17 23:06 [PATCH 0/6] fix xfs by making I/O to vmap/vmalloc areas work James Bottomley
2009-09-17 23:06 ` [PATCH 1/6] mm: add coherence API for DMA to vmalloc/vmap areas James Bottomley
2009-09-17 23:06   ` James Bottomley
2009-09-09 15:52 [PATCH 0/6] fix xfs by making I/O to vmap/vmalloc areas work James Bottomley
2009-09-09 15:52 ` [PATCH 1/6] mm: add coherence API for DMA to vmalloc/vmap areas James Bottomley

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=1258557217.2540.12.camel@mulgrave.site \
    --to=james.bottomley@hansenpartnership.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=ralf@linux-mips.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).