All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gerhard Pircher" <gerhard_pircher@gmx.net>
To: Andrew Lewis <andrew-lewis@netspace.net.au>, linuxppc-dev@ozlabs.org
Cc: paulus@samba.org
Subject: Re: [PATCH/RFC] powerpc: prevent memory corruption due to cache invalidation of unaligned DMA buffer
Date: Thu, 26 Jun 2008 12:32:15 +0200	[thread overview]
Message-ID: <20080626103215.170810@gmx.net> (raw)
In-Reply-To: <48636161.6080603@netspace.net.au>


-------- Original-Nachricht --------
> Datum: Thu, 26 Jun 2008 17:29:05 +0800
> Von: Andrew Lewis <andrew-lewis@netspace.net.au>
> An: linuxppc-dev@ozlabs.org
> CC: \'Andrew Lewis\' <andrew-lewis@netspace.net.au>, paulus@samba.org
> Betreff: [PATCH/RFC] powerpc: prevent memory corruption due to cache	invalidation of unaligned DMA buffer

> On PowerPC processors with non-coherent cache architectures the DMA
> subsystem calls invalidate_dcache_range() before performing a DMA read
> operation.  If the address and length of the DMA buffer are not aligned
> to a cache-line boundary this can result in memory outside of the DMA
> buffer being invalidated in the cache.  If this memory has an
> uncommitted store then the data will be lost and a subsequent read of
> that address will result in an old value being returned from main memory.
> 
> Only when the DMA buffer starts on a cache-line boundary and is an exact
> mutiple of the cache-line size can invalidate_dcache_range() be called,
> otherwise flush_dcache_range() must be called.  flush_dcache_range()
> will first flush uncommitted writes, and then invalidate the cache.
I have a similar problem, but with a network driver (which uses cacheable
skbuffers as DMA memory). The SLUB allocator should return cache line
aligned memory, but that doesn't prevent data corruption. I fixed it by
setting NET_SKB_PAD (default 16)  to L1_CACHE_BYTES (32 on my 7455
non coherent DMA system).
It looks like your patch could solve my problem without changing
NET_SKB_PAD. I'll have to try that out.

regards,

Gerhard
-- 
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser

  reply	other threads:[~2008-06-26 11:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-26  9:29 [PATCH/RFC] powerpc: prevent memory corruption due to cache invalidation of unaligned DMA buffer Andrew Lewis
2008-06-26 10:32 ` Gerhard Pircher [this message]
2008-06-26 10:55 ` Benjamin Herrenschmidt

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=20080626103215.170810@gmx.net \
    --to=gerhard_pircher@gmx.net \
    --cc=andrew-lewis@netspace.net.au \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.