public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Opinion on ordering of writel vs. stores to RAM
@ 2006-09-09  2:03 Paul Mackerras
  2006-09-09  2:42 ` Linus Torvalds
  2006-09-09 15:06 ` Alan Cox
  0 siblings, 2 replies; 59+ messages in thread
From: Paul Mackerras @ 2006-09-09  2:03 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel, benh, akpm, segher, davem

Linus,

An issue has come up in the tg3 ethernet driver, where we are seeing
data corruption on ppc64 machines that is attributable to a lack of
ordering between writes to normal RAM and writes to an MMIO register.
Basically the driver does writes to RAM and then a writel to an MMIO
register to trigger DMA, and occasionally the device then reads old
values from memory.

Do you have an opinion about whether the MMIO write in writel() should
be ordered with respect to preceding writes to normal memory?

Currently we have a sync instruction after the store in writel() but
not one before.  The sync after is to keep the writel inside
spinlocked regions and to ensure that the store is ordered with
respect to the load in readl() and friends.

Paul.

^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: Opinion on ordering of writel vs. stores to RAM
@ 2006-09-11  5:03 Michael Chan
  2006-09-11  5:21 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 59+ messages in thread
From: Michael Chan @ 2006-09-11  5:03 UTC (permalink / raw)
  To: benh; +Cc: linux-kernel

Benjamin Herrenschmidt wrote:
> > The tg3 bug actually seems not to be because of the missing wmb()'s,
> > [the driver and all net traffic survive just fine in the case of
non- 
> > TSO],
> > but just because of a plain-and-simple programming bug in the
driver.
> > I'll run some tests tomorrow to confirm.  If I'm right, this fix
should
> > go into .18 and into .17-stable at least.
> 
> Interesting :) I didn't actually verify the barrier problem theory
> (though the driver does indeed seem to lack them, so there _is_ a
> problem there too), I trusted Michael Chan who seemed to know about
the
> bug :) 

It definitely is caused by lack of memory barriers before the writel().
IBM, Anton, and all of us know about this.  TSO probably makes it more
susceptible because you write to many buffer descriptors before you
issue one writel() to DMA all the descriptors.  The large number of
TSO descriptors makes re-ordering more likely.


^ permalink raw reply	[flat|nested] 59+ messages in thread
* Re: Opinion on ordering of writel vs. stores to RAM
@ 2006-09-12  4:30 Albert Cahalan
  2006-09-12  5:30 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 59+ messages in thread
From: Albert Cahalan @ 2006-09-12  4:30 UTC (permalink / raw)
  To: benh, jbarnes, alan, davem, jeff, paulus, torvalds, linux-kernel,
	akpm, segher

Benjamin Herrenschmidt writes:
> On Mon, 2006-09-11 at 11:08 -0700, Jesse Barnes wrote:

>> Ok, that's fine, though I think you'd only want the very weak
>> semantics (as provided by your __raw* routines) on write
>> combined memory typically?
>
> Well, that and memory with no side effects (like frame buffers)

Oh no, it's great for regular device driver work. I used this
type of system all the time on a different PowerPC OS.

Suppose you need to set up a piece of hardware. Assume that the
hardware isn't across some nasty bridge. You do this:

hw->x = 42;
hw->y = 19;
eieio();
hw->p = 11;
hw->q = 233;
hw->r = 87;
eieio()
hw->n = 101;
hw->m = 5;
eieio()

In that ficticious example, I get 7 writes to the hardware device
with only 3 "eieio" operations. It's not hard at all. Sometimes
a "sync" is used instead, also explicitly.

To get even more speed, you can mark memory as non-coherent.
You can even do this for RAM. There are cache control instructions
to take care of any problems; simply ask the CPU to write things
out as needed.

Linux should probably do this:

Plain stuff is like x86. If you want the performance of loose
ordering, ask for it when you get the mapping and use read/write
functions that have a "_" prefix. If you mix the "_" versions
with a plain x86-like mapping or the other way, the behavior you
get will be an arch-specific middle ground.

^ permalink raw reply	[flat|nested] 59+ messages in thread

end of thread, other threads:[~2006-09-12 16:47 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-09  2:03 Opinion on ordering of writel vs. stores to RAM Paul Mackerras
2006-09-09  2:42 ` Linus Torvalds
2006-09-09  3:02   ` Paul Mackerras
2006-09-09  3:54     ` Linus Torvalds
2006-09-09  7:24     ` Benjamin Herrenschmidt
2006-09-09  9:34     ` David Miller
2006-09-09  9:55       ` Jeff Garzik
2006-09-09 10:08         ` David Miller
2006-09-10 17:18           ` Jesse Barnes
2006-09-10 19:35             ` Alan Cox
2006-09-10 21:25               ` Benjamin Herrenschmidt
2006-09-10 22:23                 ` Alan Cox
2006-09-10 22:18                   ` Benjamin Herrenschmidt
2006-09-11 13:19                     ` Jes Sorensen
2006-09-10 23:35                 ` Segher Boessenkool
2006-09-11  0:12                   ` Benjamin Herrenschmidt
2006-09-11  0:34                     ` Jesse Barnes
2006-09-11  1:04                       ` Benjamin Herrenschmidt
2006-09-11  1:13                       ` Segher Boessenkool
2006-09-11  1:35                         ` Benjamin Herrenschmidt
2006-09-11  9:02                     ` Alan Cox
2006-09-11  9:23                       ` Benjamin Herrenschmidt
2006-09-11  0:25                 ` Jesse Barnes
2006-09-11  0:54                   ` Segher Boessenkool
2006-09-11  1:10                     ` Benjamin Herrenschmidt
2006-09-11  1:48                       ` Segher Boessenkool
2006-09-11  3:53                         ` Benjamin Herrenschmidt
2006-09-11 18:12                     ` Jesse Barnes
2006-09-11  1:00                   ` Benjamin Herrenschmidt
2006-09-11 18:08                     ` Jesse Barnes
2006-09-11 21:32                       ` Benjamin Herrenschmidt
2006-09-10 20:01             ` Segher Boessenkool
2006-09-11 13:21               ` David Miller
2006-09-11 14:17                 ` Segher Boessenkool
2006-09-12  0:32                   ` David Miller
2006-09-12  0:49                     ` Benjamin Herrenschmidt
2006-09-12 16:47                       ` Segher Boessenkool
2006-09-12  0:54                     ` Roland Dreier
2006-09-09 11:16       ` Paul Mackerras
2006-09-09  7:23   ` Benjamin Herrenschmidt
2006-09-09  9:38     ` David Miller
2006-09-09 15:09     ` Alan Cox
2006-09-10 17:19       ` Jesse Barnes
2006-09-10 17:35         ` Michael Buesch
2006-09-10 17:49           ` Linus Torvalds
2006-09-10 18:02             ` Michael Buesch
2006-09-09 15:08   ` Alan Cox
2006-09-09 18:34   ` Auke Kok
2006-09-09 19:10     ` Patrick McFarland
2006-09-09 15:06 ` Alan Cox
  -- strict thread matches above, loose matches on Subject: below --
2006-09-11  5:03 Michael Chan
2006-09-11  5:21 ` Benjamin Herrenschmidt
2006-09-12  4:30 Albert Cahalan
2006-09-12  5:30 ` Benjamin Herrenschmidt
2006-09-12  6:04   ` Albert Cahalan
2006-09-12  6:12     ` Benjamin Herrenschmidt
2006-09-12  7:09       ` Albert Cahalan
2006-09-12  7:17         ` Benjamin Herrenschmidt
2006-09-12  7:21           ` Albert Cahalan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox