linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roland Dreier <rdreier@cisco.com>
To: "Robert P. J. Day" <rpjday@crashcourse.ca>
Cc: Hitoshi Mitake <h.mitake@gmail.com>, Ingo Molnar <mingo@elte.hu>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: arch/x86/Kconfig selects invalid HAVE_READQ, HAVE_WRITEQ vars
Date: Sun, 19 Apr 2009 14:12:07 -0700	[thread overview]
Message-ID: <adaab6c1h7c.fsf@cisco.com> (raw)
In-Reply-To: <alpine.LFD.2.00.0904191543530.11789@localhost.localdomain> (Robert P. J. Day's message of "Sun, 19 Apr 2009 15:45:02 -0400 (EDT)")

 > from arch/x86/Kconfig:
 > 	...
 >         select HAVE_READQ
 >         select HAVE_WRITEQ
 > 	...
 > 
 > yet there are no such defined Kconfig vars anywhere.  thoughts?

git blame shows that this came in from 2c5643b1 ("x86: provide
readq()/writeq() on 32-bit too").  And that commit looks very dubious
indeed to me -- it defines readq() and writeq() in a way that is not
atomic and probably won't generate single 64-bit bus cycles.

Now, many drivers do "#ifndef readq <define my own implementation> #endif"
but exactly what is required is very hardware-dependent, and accessing
32-bit halves in the wrong order may lead to very subtle bugs.  For
example, the changelog for e23a59e1 ("niu: Fix readq implementation when
architecture does not provide one.") says:

    In particular one of the issues is whether the top 32-bits
    or the bottom 32-bits of the 64-bit register should be read
    first.  There could be side effects, and in fact that is
    exactly the problem here.

By coincidence, the 32-bit x86 implementation is actually OK for niu,
but I didn't audit every similar driver, and I don't think any
implementation of readq()/writeq() that generates multiple bus cycles is
suitable in general -- it doesn't meet the requirements of the API.

So I would strongly suggest reverting 2c5643b1 since as far as I can
tell it just sets a trap for subtle bugs that only show up on 32-bit
x86 -- any portable driver still needs to provide readq()/writeq() for
other 32-bit architectures, so it doesn't really help anyone.

 - R.

  reply	other threads:[~2009-04-19 21:12 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-19 19:45 arch/x86/Kconfig selects invalid HAVE_READQ, HAVE_WRITEQ vars Robert P. J. Day
2009-04-19 21:12 ` Roland Dreier [this message]
2009-04-19 21:46   ` Ingo Molnar
2009-04-19 22:02     ` H. Peter Anvin
2009-04-19 22:35       ` Ingo Molnar
2009-04-20  0:56         ` Roland Dreier
2009-04-20  2:08           ` Robert Hancock
2009-04-20  0:53     ` Roland Dreier
2009-04-20  1:20       ` H. Peter Anvin
2009-04-20 10:53         ` Ingo Molnar
2009-04-20 14:47           ` Hitoshi Mitake
2009-04-20 16:03             ` Ingo Molnar
2009-04-21  8:33               ` Hitoshi Mitake
2009-04-21  8:45                 ` Ingo Molnar
2009-04-21  8:57                   ` Hitoshi Mitake
2009-04-21 15:44                 ` H. Peter Anvin
2009-04-21 17:07                   ` Roland Dreier
2009-04-21 17:19                     ` H. Peter Anvin
2009-04-21 17:23                       ` Roland Dreier
2009-04-21 19:09                         ` H. Peter Anvin
2009-04-21 21:11                           ` Roland Dreier
2009-04-21 21:16                             ` H. Peter Anvin
2009-04-22  0:31                               ` David Miller
2009-04-28 19:05                                 ` [PATCH] x86: Remove readq()/writeq() on 32-bit Roland Dreier
2009-04-29  5:12                                   ` David Miller
2009-04-29 11:56                                     ` Ingo Molnar
2009-04-29 12:10                                       ` Jeff Garzik
2009-04-29 17:25                                         ` Roland Dreier
2009-04-29 19:59                                           ` Jeff Garzik
2009-05-13  5:32                                             ` Hitoshi Mitake
2009-05-13 20:19                                               ` H. Peter Anvin
2009-05-13 22:39                                                 ` Jeff Garzik
2009-05-13 23:39                                                   ` H. Peter Anvin
2009-05-14  0:49                                                     ` Jeff Garzik
2009-05-14  7:19                                                       ` Hitoshi Mitake
2009-05-15 23:44                                                         ` Jeff Garzik
2009-05-17  7:12                                                           ` Hitoshi Mitake
2009-05-17  8:06                                                             ` Jeff Garzik
2009-05-21 11:35                                                               ` Hitoshi Mitake
2009-05-21 11:49                                                                 ` Hitoshi Mitake
2009-05-13 20:42                                               ` Jeff Garzik
2009-05-13 21:05                                                 ` H. Peter Anvin
2009-05-13 21:30                                                   ` Jeff Garzik
2009-05-13 21:31                                                     ` Jeff Garzik
2009-05-13 21:54                                                     ` H. Peter Anvin
2009-05-13 22:06                                                 ` Roland Dreier
2009-05-13 22:29                                                   ` Jeff Garzik
2009-04-29 17:21                                       ` Roland Dreier
2009-04-22  0:27                           ` arch/x86/Kconfig selects invalid HAVE_READQ, HAVE_WRITEQ vars David Miller
2009-04-22  0:25                     ` David Miller

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=adaab6c1h7c.fsf@cisco.com \
    --to=rdreier@cisco.com \
    --cc=h.mitake@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rpjday@crashcourse.ca \
    /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).