From: Dan Malek <dan@embeddededge.com>
To: Brad Parker <brad@parker.boston.ma.us>
Cc: David Gibson <david@gibson.dropbear.id.au>,
linuxppc-embedded@lists.linuxppc.org
Subject: Re: Workaround for USB DMA bugs
Date: Thu, 04 Apr 2002 09:12:47 -0500 [thread overview]
Message-ID: <3CAC5F5F.9000602@embeddededge.com> (raw)
In-Reply-To: 200204041235.g34CZDw22993@p2.parker.boston.ma.us
Brad Parker wrote:
> Maybe I need to go drink some coffee, but I'm confused by this thread.
I'll try to explain it in more detail.
> The real problem, as I recall, was that cache invalidate routine one
> in the 405 port didn't respect the addresses handed to it and instead
> invalidated the entire cache line, even if it went beyond the address
> range provided.
You can't invalidate, flush, manage anything less than a cache line.
The problem is the same on all processors, it doesn't matter how the
DMA object is allocated either. Suppose you have a processor with
something larger than an 8 byte cache line. Suppose you have some DMA buffer
(kmalloc'ed or just static declared), that is only 8 bytes for example,
and it starts at memory location 0x1000. Suppose the processor (or
another DMA) had some data that starts at location 0x1008. The logically
correct thing to do for an incoming DMA is to first invalidate the
cache line, then do the DMA, then when the processor accesses the
DMA buffer it will re-load the cache line. In this example, if the
processor writes some variable at location 0x1008, the invalidate
will also invalide this processor data, which is wrong. The next
access by the processor to this variable will read some old piece
of data, not the last thing it wrote to memory.
So, the solution was to first flush this line, then invalidate it.
Well, that works better but still isn't correct. If the processor
accesses the memory at location 0x1008 before the DMA is complete,
then the cache line is filled with the old stale DMA buffer, and
when the processor accesses the DMA buffer you don't get the
data that is the result of the DMA.
The only reason this patch appears to work is because we are lucky,
and the processor doesn't access anything in the cache line prior
to the DMA completion.
It's the same for all incoherent processors. Memory is accessed
in cache line chunks, you can't invalidate, flush or otherwise
manage part of a cache line. The stack is a weird place to put
a DMA buffer, but that has nothing to do with this problem.
-- Dan
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
next prev parent reply other threads:[~2002-04-04 14:12 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-03 2:43 Workaround for USB DMA bugs David Gibson
2002-04-03 8:17 ` Armin
2002-04-03 17:39 ` Frank Rowand
2002-04-03 17:49 ` Dan Malek
2002-04-03 20:43 ` David Blythe
2002-04-03 23:34 ` David Gibson
2002-04-03 9:45 ` "David Müller (ELSOFT AG)"
2002-04-03 23:35 ` David Gibson
2002-04-03 17:42 ` Dan Malek
2002-04-03 23:40 ` David Gibson
2002-04-04 2:54 ` Dan Malek
2002-04-04 3:48 ` David Gibson
2002-04-04 4:09 ` Dan Malek
2002-04-04 5:23 ` David Gibson
2002-04-04 6:08 ` Dan Malek
2002-04-04 6:30 ` David Gibson
2002-04-04 20:21 ` David Blythe
2002-04-04 12:35 ` Brad Parker
2002-04-04 14:12 ` Dan Malek [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-04-04 4:19 Jeremy Rosen
2002-04-04 6:16 ` Dan Malek
2002-04-04 6:32 ` David Gibson
2002-04-04 6:40 Rosen Jeremy
2002-04-04 6:52 ` David Gibson
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=3CAC5F5F.9000602@embeddededge.com \
--to=dan@embeddededge.com \
--cc=brad@parker.boston.ma.us \
--cc=david@gibson.dropbear.id.au \
--cc=linuxppc-embedded@lists.linuxppc.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).