mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@samba.org>
To: Linus Torvalds <torvalds@osdl.org>
Cc: linux-kernel@vger.kernel.org, benh@kernel.crashing.org,
	akpm@osdl.org, segher@kernel.crashing.org, davem@davemloft.net
Subject: Re: Opinion on ordering of writel vs. stores to RAM
Date: Sat, 9 Sep 2006 13:02:27 +1000	[thread overview]
Message-ID: <17666.11971.416250.857749@cargo.ozlabs.ibm.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0609081928570.27779@g5.osdl.org>

Linus Torvalds writes:

> I don't think anyting but a few SCSI drivers that are used on some ia64 
> boxes use mmiowb(). And it's currently a no-op not only on x86 but also on 

The examples in Documentation/memory-barriers.txt and
Documentation/DocBook/deviceiobook.tmpl only seem to say that mmiowb
is needed between a writel and a spin_unlock.

> powerpc. Probably because it's defined to be a barrier between _two_ MMIO 
> operations, while we should probably have things like
> 
>  a)
> 	.. regular mem store ..
> 	mem_to_io_barrier();
> 	.. IOMEM store ..
> 
>  b)
> 	.. IOMEM store ..
> 	io_to_mem_barrier();
> 	.. regular mem store ..
> 
> although it's quite possible that (a) never makes any sense at all.

Do you mean (b) never makes sense?  (a) is the classic scenario for a
device doing DMA to read a descriptor we've just constructed.

> That said, it's also entirely possible that what you _should_ do is to 
> just make sure that the	"sync" is always _before_ the IO op. But that 
> would require that you have one before an IO load too. Do you? I'm too 
> lazy to check.

Not at present; readX() have no barrier before the load.  They have a
barrier after the load that waits for the data to arrive before
allowing any following instructions to execute.

> (Keeping it inside a spinlock, I don't know. Spinlocks aren't _supposed_ 
> to order IO, so I don't _think_ that's necessarily an argument for doing 
> so. So your rationale seems strange. Even on x86, a spinlock release by 
> _no_ means would mean that an IO write would be "done").

Well, it's about ordering between multiple CPUs rather than the write
being "done".  I think the powerpc readX/writeX got to their current
form before the ia64 guys invented mmiowb().

I suspect the best thing at this point is to move the sync in writeX()
before the store, as you suggest, and add an "eieio" before the load
in readX().  That does mean that we are then relying on driver writers
putting in the mmiowb() between a writeX() and a spin_unlock, but at
least that is documented.

Paul.

  reply	other threads:[~2006-09-09  3:02 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-09  2:03 Paul Mackerras
2006-09-09  2:42 ` Linus Torvalds
2006-09-09  3:02   ` Paul Mackerras [this message]
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
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

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=17666.11971.416250.857749@cargo.ozlabs.ibm.com \
    --to=paulus@samba.org \
    --cc=akpm@osdl.org \
    --cc=benh@kernel.crashing.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=segher@kernel.crashing.org \
    --cc=torvalds@osdl.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

all inboxes | Powered by JetHome®