From: Jerry Van Baren <gerald.vanbaren@ge.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] PPC sync/eieio (was cfi_flash.c and lost volatile qualifier)
Date: Wed, 30 Apr 2008 11:35:41 -0400 [thread overview]
Message-ID: <481891CD.7010907@ge.com> (raw)
In-Reply-To: <1209568270.16926.32.camel@gentoo-jocke.transmode.se>
Joakim Tjernlund wrote:
>> [1] Sync is a big hammer, eieio is a medium size hammer. Don't use
>> both, PPC people will know you don't know what you are doing. ;-)
>
> Yet the in_bex()/out_bex() functions in PowerPC linux uses sync and all
> SOC drivers are encouraged to use them. What a waste :(
>
> Jocke
Well, I was a little terse because I was cross-applying PPC instructions
in a ARM discussion. Personally, I prefer to use sync vs. eieio. The
size of the hammer isn't that different, I don't believe. The advantage
of sync is that it flushes the read/write operation out on the bus
*now*. When I'm writing to hardware to control the hardware, *now* is
what I want.
The eieio merely guarantees the preceding operations will go out on the
bus before following bus operations. The preceding operations could be
hung up in the bus interface unit *indefinitely* if no "following" bus
operations occur. This is an unlikely occurrence, but could be the
result of running out of cache in a tight loop.
For instance, if you do a write to a hardware register, a eieio, and
then wait in a tight loop until time goes by (reading the decrementer
register) followed by another write, the write1/delay/write2 sequence
could actually be delay/write1/write2. Note that the order of the
writes on the bus is correct per the eieio, but it isn't what the
hardware *needed*.
Illustration - what you did in code and intended to occur:
write1 (eieio)
delay
write2 (eieio)
What actually may happen on the bus:
delay
write1 (eieio)
write2 (eieio)
By using a sync, you guarantee the write isn't delayed:
write1 (sync)
delay
write2 (sync)
Disclaimer: the above explanation is from my fertile imagination. It
may or may not happen and *will* happen differently on different PPC
processors. For instance, the eieio instruction is actually a NOP in
the 603e core because it doesn't reorder bus operations, but it *does*
have a BIU that can buffer and delay the bus operations, causing the
above timing problem.
I contend using the "sync" instruction will always work correctly and
the "eieio" instruction is at best a false economy and at worst a lot of
very difficult, mysterious bugs to find, so I'm in agreement with the
linux in_bex/out_bex recommendation.
Side note: I don't know if I communicated it properly, but when you see
"eieio ; sync" or "sync ; eieio", you know the author of that code
doesn't understand sync and eieio. "isync ; sync" is occasionally a
valid combination, but I don't believe it is necessary other than when
called for by the Users Manual in conjunction with writing to special
purpose registers.
Best regards,
gvb
next prev parent reply other threads:[~2008-04-30 15:35 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-08 14:32 [U-Boot-Users] drivers MMCplus for at91sam9x Pierre Savary
2008-04-09 17:49 ` Jean-Christophe PLAGNIOL-VILLARD
2008-04-10 10:32 ` Pierre Savary
2008-04-10 22:31 ` Ken.Fuchs at bench.com
2008-04-11 8:26 ` Pierre Savary
2008-04-11 15:48 ` Pierre Ossman
2008-04-11 18:54 ` Ken.Fuchs at bench.com
2008-04-12 9:28 ` Pierre Ossman
2008-04-15 10:18 ` Pierre Savary
2008-04-15 16:51 ` Ken.Fuchs at bench.com
[not found] ` <-6021840981243159212@unknownmsgid>
2008-04-15 19:25 ` Andy Fleming
2008-04-16 8:55 ` Pierre Savary
2008-04-16 23:30 ` Ken.Fuchs at bench.com
2008-04-22 11:55 ` Pierre Savary
2008-04-22 15:07 ` [U-Boot-Users] [PATCH] Add eSDHC driver Andy Fleming
2008-04-22 16:53 ` Anton Vorontsov
2008-04-23 19:23 ` Ken.Fuchs at bench.com
2008-04-24 6:24 ` Pierre Savary
2008-04-29 19:45 ` [U-Boot-Users] drivers MMCplus for at91sam9x Ken.Fuchs at bench.com
2008-04-29 20:20 ` [U-Boot-Users] cfi_flash.c and lost volatile qualifier Adrian Filipi
2008-04-29 20:43 ` Wolfgang Denk
2008-04-29 21:10 ` Adrian Filipi
2008-04-29 21:16 ` Jerry Van Baren
[not found] ` <alpine.DEB.1.10.0804300949360.13610@pmy.adscville>
2008-04-30 14:43 ` Jerry Van Baren
2008-04-30 15:11 ` Joakim Tjernlund
2008-04-30 15:21 ` Scott Wood
2008-04-30 15:34 ` Joakim Tjernlund
2008-04-30 15:41 ` Wolfgang Denk
2008-04-30 16:02 ` Scott Wood
2008-04-30 16:11 ` Joakim Tjernlund
2008-04-30 15:35 ` Jerry Van Baren [this message]
2008-04-30 15:38 ` Wolfgang Denk
2008-04-30 15:51 ` Jerry Van Baren
2008-05-08 11:17 ` Haavard Skinnemoen
2008-05-08 14:05 ` Adrian Filipi
2008-05-08 16:27 ` Haavard Skinnemoen
2008-04-30 14:20 ` [U-Boot-Users] drivers MMCplus for at91sam9x Pierre Savary
2008-04-30 16:25 ` Ken.Fuchs at bench.com
2008-04-30 20:31 ` Ken.Fuchs at bench.com
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=481891CD.7010907@ge.com \
--to=gerald.vanbaren@ge.com \
--cc=u-boot@lists.denx.de \
/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