All of lore.kernel.org
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v6 01/15] ARM: mxs: Add core definitions
Date: Wed, 15 Dec 2010 23:26:38 +0100	[thread overview]
Message-ID: <201012152326.39191.arnd@arndb.de> (raw)
In-Reply-To: <20101215172754.GI9937@n2100.arm.linux.org.uk>

On Wednesday 15 December 2010, Russell King - ARM Linux wrote:
> > * be synchronized with spinlocks
> 
> Err.  Even readl/writel are not synchronized with spinlocks.  See
> Documentation/memory-barriers.txt:

readl is synchronized, writel by itself is never synchronized with
spinlocks if it is posted.

> | Under certain circumstances (especially involving NUMA), I/O accesses within
> | two spinlocked sections on two different CPUs may be seen as interleaved by the
> | PCI bridge, because the PCI bridge does not necessarily participate in the
> | cache-coherence protocol, and is therefore incapable of issuing the required
> | read memory barriers.
> |
> | For example:
> |
> |       CPU 1                           CPU 2
> |       =============================== ===============================
> |       spin_lock(Q)
> |       writel(0, ADDR)
> |       writel(1, DATA);
> |       spin_unlock(Q);
> |                                       spin_lock(Q);
> |                                       writel(4, ADDR);
> |                                       writel(5, DATA);
> |                                       spin_unlock(Q);
> |
> | may be seen by the PCI bridge as follows:
> |
> |       STORE *ADDR = 0, STORE *ADDR = 4, STORE *DATA = 1, STORE *DATA = 5
> |
> | which would probably cause the hardware to malfunction.

I was simplifying. To be more specific, __raw_readl/__raw_writel
makes no explicit guarantees regarding ordering with spinlocks.
I could argue that it also makes no guarantees about ordering between
writes, although for all practical purposes they are ordered
as long as you have sane buses underneath.

The ordering of readl/writel is defined to be at least as strict
as what x86 gets you on PCI. This means fully ordered for readl
and writel. In theory, writel is only ordered wrt spinlocks in
combination with mmiowb() as you mentioned, but hardly anyone uses
that correctly, so all sane architectures define mmiowb as a NOP
anyway, except when it's an extremely expensive operation and there
are only a handful of drivers that are actually being used and
they can be audited. I'm not crazy enough to ask anyone to
understand and use mmiowb() correctly ;-)

Russell, from previous discussions I had the impression that you did
not actually want __raw_readl/writel to be used for random platform
drivers, although you might not bother to complain about it either.
When I first complained about readl() being used for non-PCI drivers,
I got the reply that it's actually the right thing to do on ARM, so
I started telling people about that in reviews. My current mental
matrix of the various I/O so far accessors is:

readl: 		anywhere, except PCI I/O space, little-endian
inl: 		PCI I/O space, little-endian
readl_relaxed:	SoC components only, little-endian
ioread32:	anywhere, little-endian
ioread32be:	anywhere, big-endian
pointer dereference: definitely nowhere, native-endian
__raw_readl:	almost nowhere, native-endian

You apparently disagree on the last one, which is fine. Just tell
me what you want and I can make sure I'll look out for any
misuse of the rules in future reviews but don't complain about
correct uses.

	Arnd

  reply	other threads:[~2010-12-15 22:26 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-13 12:54 [PATCH v6 00/15] ARM: mxs: Add initial support for MX23 and MX28 Shawn Guo
2010-12-13 12:54 ` [PATCH v6 01/15] ARM: mxs: Add core definitions Shawn Guo
2010-12-15 16:22   ` Arnd Bergmann
2010-12-15 16:40     ` Uwe Kleine-König
2010-12-15 16:58       ` Arnd Bergmann
2010-12-15 17:06         ` Uwe Kleine-König
2010-12-15 17:17           ` Arnd Bergmann
2010-12-15 17:27             ` Russell King - ARM Linux
2010-12-15 22:26               ` Arnd Bergmann [this message]
2010-12-15 18:49             ` Uwe Kleine-König
2010-12-16  1:37           ` Shawn Guo
2010-12-15 16:47     ` Russell King - ARM Linux
2010-12-15 17:08       ` Arnd Bergmann
2010-12-15 17:23         ` Russell King - ARM Linux
2010-12-15 17:51           ` Arnd Bergmann
2010-12-13 12:54 ` [PATCH v6 03/15] ARM: mxs: Add reset routines Shawn Guo
2010-12-13 12:55 ` [PATCH v6 06/15] ARM: mxs: Add timer support Shawn Guo
2010-12-13 13:53   ` Russell King - ARM Linux
2010-12-13 12:55 ` [PATCH v6 07/15] ARM: mxs: Add gpio support Shawn Guo
2010-12-13 12:55 ` [PATCH v6 08/15] ARM: mxs: Add iomux support Shawn Guo
2010-12-16  9:51   ` Uwe Kleine-König
2010-12-16 10:26     ` Shawn Guo
2010-12-13 12:55 ` [PATCH v6 15/15] ARM: mxs: Add build configuration for mxs Shawn Guo
2010-12-13 14:20 ` [PATCH v6 00/15] ARM: mxs: Add initial support for MX23 and MX28 Uwe Kleine-König
2010-12-14  8:31   ` [PATCH v6 00/15] ARM: mxs: Add initial support for MX23 andMX28 Shawn Guo
2010-12-14 13:00     ` Shawn Guo
2010-12-15 16:24 ` [PATCH v6 00/15] ARM: mxs: Add initial support for MX23 and MX28 Arnd Bergmann
2010-12-15 16:34   ` Uwe Kleine-König

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=201012152326.39191.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=linux-arm-kernel@lists.infradead.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.