linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hitoshi Mitake <h.mitake@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>,
	Matthew Wilcox <matthew.r.wilcox@intel.com>,
	Roland Dreier <roland@purestorage.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	James Bottomley <James.Bottomley@parallels.com>,
	linux-kernel@vger.kernel.org, hpa@linux.intel.com
Subject: Re: [PATCH] NVMe: Fix compilation on architecturs without readq/writeq
Date: Sun, 5 Feb 2012 00:24:48 +0900	[thread overview]
Message-ID: <CAMO-S2gjOL_kv1Lka_tJw5yB-LrPG-4hiJ0EKpaFzVAgRGs59A@mail.gmail.com> (raw)
In-Reply-To: <CA+55aFyxbieV2-WpFNrEtwQ6gXbW7y_X9oW5N6FcEcxmQKA38g@mail.gmail.com>

On Tue, Jan 31, 2012 at 12:03, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
> On Sun, Jan 29, 2012 at 12:02 AM, Hitoshi Mitake <h.mitake@gmail.com> wrote:
>>
>> I don't know about the minor architectures, but some of them,
>> like alpha, seems to do reordering of memory access agressively.
>>
>> Is the reordering is applied to io rw?
>> Should memory barriers be placed between two readl/writel?
>
> No need to place barriers - the "readl/writel()" functions are ordered
> in themselves. There are non-ordered versions in theory
> ("writel_relaxed()") for things like frame buffers etc that actively
> want the ordering, but that's a separate issue entirely.
>
> You do want to make sure that they aren't in the same C expression, so
> that the compiler doesn't re-order the expression. IOW, if you just do
>
>  return (readl(addr+4) << 32) | readl(addr);
>
> then that doesn't have any ordering at all simply because there is
> none at the C level. But
>
>  u64 val;
>  val = readl(addr);
>  val |= readl(addr+4) << 32;
>
> is well-defined and must read the low word first - both at the C level
> *and* at the CPU level. Anything else would be a bug in the
> architecture "readl()" implementation or the hardware.
>
> (On x86, for example, a "readl()" is just a memory access, but while
> x86 can re-order reads to regular memory in hardware, that is *not*
> true of IO memory accesses. On architectures like POWER, 'readl()'
> implies synchronization instructions)
>
>                   Linus

Thanks for your description.
Now I can understand the semantics of readl/writel of the kernel.

-- 
Hitoshi Mitake
h.mitake@gmail.com

      parent reply	other threads:[~2012-02-04 15:24 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-20  1:01 [PATCH] NVMe: Fix compilation on architecturs without readq/writeq Matthew Wilcox
2012-01-20  1:21 ` Linus Torvalds
2012-01-20 17:43   ` Wilcox, Matthew R
2012-01-21  8:28   ` Ingo Molnar
2012-01-21 15:54     ` Hitoshi Mitake
2012-01-21 16:58       ` Ingo Molnar
2012-01-23 16:05         ` Hitoshi Mitake
2012-01-23 16:57           ` Linus Torvalds
2012-01-23 23:04             ` H. Peter Anvin
2012-01-29  8:02             ` Hitoshi Mitake
2012-01-31  3:03               ` Linus Torvalds
2012-01-31  3:05                 ` Linus Torvalds
2012-02-04 15:25                   ` Hitoshi Mitake
2012-01-31 11:58                 ` Alan Cox
2012-01-31 12:09                   ` Ingo Molnar
2012-01-31 12:18                     ` Alan Cox
2012-01-31 12:23                       ` Ingo Molnar
2012-02-01 23:35                         ` Linus Torvalds
2012-02-02  1:05                           ` James Bottomley
2012-02-02  1:15                             ` Linus Torvalds
2012-02-02 15:05                             ` H. Peter Anvin
2012-02-04 15:39                               ` Hitoshi Mitake
2012-02-05  6:53                                 ` Geert Uytterhoeven
2012-02-05  7:01                                   ` Hitoshi Mitake
2012-02-04 15:34                             ` Hitoshi Mitake
2012-02-07  2:48                               ` Hitoshi Mitake
2012-02-04 15:24                 ` Hitoshi Mitake [this message]

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=CAMO-S2gjOL_kv1Lka_tJw5yB-LrPG-4hiJ0EKpaFzVAgRGs59A@mail.gmail.com \
    --to=h.mitake@gmail.com \
    --cc=James.Bottomley@parallels.com \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.r.wilcox@intel.com \
    --cc=mingo@elte.hu \
    --cc=roland@purestorage.com \
    --cc=torvalds@linux-foundation.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).