linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rene Herman <rene.herman@gmail.com>
To: "David P. Reed" <dpreed@reed.com>, Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>, Pavel Machek <pavel@ucw.cz>
Subject: Re: [PATCH] x86_64: fix problems due to use of "outb" to port 80 on some AMD64x2 laptops, etc.
Date: Fri, 14 Dec 2007 10:45:57 +0100	[thread overview]
Message-ID: <476250D5.8000409@gmail.com> (raw)
In-Reply-To: <4761F193.7090400@reed.com>

[-- Attachment #1: Type: text/plain, Size: 2598 bytes --]

On 14-12-07 03:59, David P. Reed wrote:

> Replace use of outb to "unused" diagnostic port 0x80 for time delay
> with udelay based time delay on x86_64 architecture machines.  Fix for
> bugs 9511 and 6307 in bugzilla, plus bugs reported in
> bugzilla.redhat.com.
> 
> Derived from suggestion (that didn't compile) by Pavel Machek, and
> tested, also based on measurements of typical timings of out's
> collated by Rene Herman from many in the community.
> 
> This patch fixes a number of bugs known to cause problems on HP
> Pavilion dv9000z and dv6000z laptops - in the form of solid freezes
> when hwclock is used to show or set the time.  Also, it potentially
> improves bus utilization on SMP machines, by using a waiting process
> that doesn't tie up the ISA/LPC bus for 1 or 2 microseconds.
> 
> i386 family fixes (completely parallel) were not included, considering
> that such machines might involve more risk of problems on legacy machines.

Here's the corresponding 32-bit patch. Applies fine to (and works on) 
v2.6.23.x as well after un-uniting the paths...

I do believe it would be better to do both; x86-64 machines can run 32-bit 
kernels fine and might certainly in the form of generic (installer) kernels 
and the like so if it's a fix lets fix it across the board -- the 2 us delay 
is going to be enough for everything out there, certainly given that _0_ is 
normally enough. With the arches just merged, minimising diferences should 
be a goal in itself I guess.

One thing though -- I believe we want to adjust the loops_per_jiffy default 
to make sure this works, or would work, pre-calibration as well? Not really 
sure how needed it is, but bogomips is defined as

	bogomips = loops_per_jiffy / (500000 / HZ)
			<=>
	loops_per_jiffy = bogomips * (500000 / HZ)

which with assuming any machine above 1G isn't affected by any of this and 
bogomips coming out to 2 * MHz on anything I myself have run linux on might 
suggest that

	loops_per_jiffy = 2 * 1000 * (500000 / HZ) = 1000000000 / HZ

could possibly be a sane if very large default? Alan?

diff --git a/init/main.c b/init/main.c
index 9def935..6d41771 100644
--- a/init/main.c
+++ b/init/main.c
@@ -229,10 +229,9 @@ static int __init obsolete_checksetup(char *line)
  }

  /*
- * This should be approx 2 Bo*oMips to start (note initial shift), and will
- * still work even if initially too large, it will just take slightly longer
+ * Initial value roughly corresponds to a 1 GHz CPU
   */
-unsigned long loops_per_jiffy = (1<<12);
+unsigned long loops_per_jiffy = 1000000000 / HZ;

  EXPORT_SYMBOL(loops_per_jiffy);

[-- Attachment #2: v24-port80.diff --]
[-- Type: text/plain, Size: 1783 bytes --]

From: Pavel Machek <pavel@ucw.cz>

32-bit part of the port 0x80 delay replacement.

diff --git a/arch/x86/boot/compressed/misc_32.c b/arch/x86/boot/compressed/misc_32.c
index b74d60d..288e162 100644
--- a/arch/x86/boot/compressed/misc_32.c
+++ b/arch/x86/boot/compressed/misc_32.c
@@ -276,10 +276,10 @@ static void putstr(const char *s)
 	RM_SCREEN_INFO.orig_y = y;
 
 	pos = (x + cols * y) * 2;	/* Update cursor position */
-	outb_p(14, vidport);
-	outb_p(0xff & (pos >> 9), vidport+1);
-	outb_p(15, vidport);
-	outb_p(0xff & (pos >> 1), vidport+1);
+	outb(14, vidport);
+	outb(0xff & (pos >> 9), vidport+1);
+	outb(15, vidport);
+	outb(0xff & (pos >> 1), vidport+1);
 }
 
 static void* memset(void* s, int c, unsigned n)
diff --git a/include/asm-x86/io_32.h b/include/asm-x86/io_32.h
index fe881cd..9abc215 100644
--- a/include/asm-x86/io_32.h
+++ b/include/asm-x86/io_32.h
@@ -3,6 +3,7 @@
 
 #include <linux/string.h>
 #include <linux/compiler.h>
+#include <linux/delay.h>
 
 /*
  * This file contains the definitions for the x86 IO instructions
@@ -17,17 +18,6 @@
  * mistake somewhere.
  */
 
-/*
- * Thanks to James van Artsdalen for a better timing-fix than
- * the two short jumps: using outb's to a nonexistent port seems
- * to guarantee better timings even on fast machines.
- *
- * On the other hand, I'd like to be sure of a non-existent port:
- * I feel a bit unsafe about using 0x80 (should be safe, though)
- *
- *		Linus
- */
-
  /*
   *  Bit simplified and optimized by Jan Hubicka
   *  Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999.
@@ -252,7 +242,7 @@ static inline void flush_write_buffers(void)
 
 static inline void native_io_delay(void)
 {
-	asm volatile("outb %%al,$0x80" : : : "memory");
+	udelay(2);
 }
 
 #if defined(CONFIG_PARAVIRT)

  parent reply	other threads:[~2007-12-14  9:47 UTC|newest]

Thread overview: 184+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <466F0941.9060201@reed.com>
     [not found] ` <1181682498.8176.224.camel@chaos>
     [not found]   ` <469578CD.3080609@reed.com>
     [not found]     ` <1184216528.12353.203.camel@chaos>
     [not found]       ` <1184218962.12353.209.camel@chaos>
     [not found]         ` <46964352.7040301@reed.com>
     [not found]           ` <1184253339.12353.223.camel@chaos>
     [not found]             ` <469697C6.50903@reed.com>
     [not found]               ` <1184274754.12353.254.camel@chaos>
2007-11-12 16:55                 ` [PATCH] x86: fix locking and sync bugs in x86_64 RTC code in time_64.c David P. Reed
2007-11-14  7:49                   ` Thomas Gleixner
2007-11-14 13:10                     ` David P. Reed
2007-11-14 18:26                       ` Matt Mackall
2007-11-14 21:22                         ` David P. Reed
2007-11-12 17:02                 ` [PATCH] time: fix typo that makes sync_cmos_clock erratic David P. Reed
2007-11-14  7:57                   ` Thomas Gleixner
2007-11-12 19:19                 ` David P. Reed
2007-11-14 22:47                 ` [PATCH] x86: fix freeze in x86_64 RTC update code in time_64.c David P. Reed
2007-11-14 22:49                 ` [PATCH] time: fix typo that makes sync_cmos_clock erratic David P. Reed
2007-11-15  1:14                 ` [PATCH] x86: on x86_64, correct reading of PC RTC when update in progress in time_64.c David P. Reed
2007-11-15 19:33                   ` Thomas Gleixner
2007-11-15 20:31                     ` David P. Reed
2007-11-15 22:17                       ` Thomas Gleixner
2007-12-14  2:59                 ` [PATCH] x86_64: fix problems due to use of "outb" to port 80 on some AMD64x2 laptops, etc David P. Reed
2007-12-14  7:49                   ` Yinghai Lu
2007-12-14  9:45                   ` Rene Herman [this message]
2007-12-14 14:23                     ` Ingo Molnar
2007-12-14 14:36                       ` Rene Herman
2007-12-14 14:46                         ` Ingo Molnar
2007-12-14 14:56                           ` Rene Herman
2007-12-14 18:36                             ` Alan Cox
2007-12-14 18:48                               ` H. Peter Anvin
2007-12-14 21:05                               ` Pavel Machek
2007-12-15 22:59                       ` Pavel Machek
2007-12-14 10:51                   ` Andi Kleen
2007-12-14 11:11                     ` David P. Reed
2007-12-14 13:15                   ` Ingo Molnar
2007-12-14 13:24                     ` Ingo Molnar
2007-12-14 13:47                       ` Ingo Molnar
2007-12-14 14:41                         ` Ingo Molnar
2007-12-14 13:42                     ` Rene Herman
2007-12-14 14:03                       ` Ingo Molnar
2007-12-14 14:10                         ` Rene Herman
2007-12-14 14:21                           ` Ingo Molnar
2007-12-14 18:02                     ` H. Peter Anvin
2007-12-14 18:23                       ` Rene Herman
2007-12-14 21:06                       ` Pavel Machek
2007-12-14 22:13                         ` H. Peter Anvin
2007-12-14 23:29                           ` Alan Cox
2007-12-15  3:04                             ` David P. Reed
2007-12-15  5:45                               ` H. Peter Anvin
2007-12-15 17:17                                 ` David P. Reed
2007-12-15 17:46                                   ` Alan Cox
2007-12-17 22:50                                     ` Jan Engelhardt
2007-12-17 22:52                                       ` H. Peter Anvin
2007-12-15  8:08                             ` Paul Rolland
2007-12-15  8:13                               ` Rene Herman
2007-12-15 20:27                                 ` H. Peter Anvin
2007-12-15 23:26                                   ` [PATCH] x86: " Rene Herman
2007-12-15 23:51                                     ` H. Peter Anvin
2007-12-16  0:05                                       ` H. Peter Anvin
2007-12-16 13:15                                       ` [PATCH] x86: provide a DMI based port 0x80 I/O delay override Rene Herman
2007-12-16 15:22                                         ` Ingo Molnar
2007-12-17  1:43                                           ` Rene Herman
2007-12-17  2:05                                             ` H. Peter Anvin
2007-12-17  2:19                                               ` Rene Herman
2007-12-17  3:35                                                 ` H. Peter Anvin
2007-12-17 13:02                                                   ` Rene Herman
2007-12-17 17:14                                                     ` H. Peter Anvin
2007-12-17 19:43                                                       ` David P. Reed
2007-12-17 19:55                                                         ` H. Peter Anvin
2007-12-17 21:02                                                           ` David P. Reed
2007-12-17 21:17                                                             ` H. Peter Anvin
2007-12-17 21:25                                                         ` Alan Cox
2008-01-01 15:57                                                           ` David P. Reed
2008-01-01 21:16                                                             ` H. Peter Anvin
2008-01-01 15:59                                                           ` David P. Reed
2008-01-01 16:15                                                             ` Alan Cox
2008-01-01 16:43                                                               ` Ingo Molnar
2008-01-01 17:32                                                                 ` Alan Cox
2008-01-01 18:45                                                                   ` Ingo Molnar
2008-01-01 20:14                                                                     ` Christer Weinigel
2008-01-01 21:13                                                                       ` Alan Cox
2008-01-01 21:07                                                                     ` Alan Cox
2008-01-02 10:04                                                                       ` Ingo Molnar
2008-01-02 13:11                                                                         ` [linux-kernel] " David P. Reed
2008-01-02 13:21                                                                           ` Ingo Molnar
2008-01-02 13:47                                                                         ` Alan Cox
2008-01-02 15:35                                                                           ` Rene Herman
2008-01-02 15:50                                                                             ` Rene Herman
2008-01-01 17:32                                                                 ` Christer Weinigel
2008-01-01 18:46                                                                   ` Ingo Molnar
2008-01-01 19:35                                                                     ` Christer Weinigel
2008-01-01 19:59                                                                       ` Rene Herman
2008-01-01 20:55                                                                         ` Christer Weinigel
2008-01-01 21:24                                                                           ` H. Peter Anvin
2008-01-01 21:01                                                                       ` Ingo Molnar
2008-01-01 21:26                                                                         ` Alan Cox
2008-01-01 21:42                                                                         ` Christer Weinigel
2008-01-01 21:42                                                                           ` Rene Herman
2008-01-01 21:50                                                                           ` H. Peter Anvin
2008-01-01 21:21                                                                       ` H. Peter Anvin
2008-01-01 23:05                                                                         ` Christer Weinigel
2008-01-01 23:12                                                                           ` Alan Cox
2008-01-02  0:23                                                                             ` Christer Weinigel
2008-01-02 10:00                                                                         ` Ingo Molnar
2008-01-01 17:32                                                               ` David P. Reed
2008-01-01 17:38                                                                 ` Alan Cox
2008-01-01 21:15                                                               ` H. Peter Anvin
2008-01-01 21:35                                                                 ` Rene Herman
2008-01-01 21:44                                                                   ` H. Peter Anvin
2008-01-01 22:35                                                                     ` Rene Herman
2008-01-01 22:39                                                                       ` H. Peter Anvin
2008-01-01 23:11                                                                         ` Rene Herman
2008-01-02  0:25                                                                           ` Rene Herman
2008-01-02  0:55                                                                           ` Christer Weinigel
2008-01-02  1:00                                                                             ` Rene Herman
2008-01-02  2:27                                                                             ` H. Peter Anvin
2008-01-09 17:27                                                                     ` Maciej W. Rozycki
2008-01-09 18:18                                                                       ` H. Peter Anvin
2008-01-01 17:31                                                             ` Pavel Machek
2008-01-01 17:33                                                               ` David P. Reed
2007-12-17  4:09                                                 ` H. Peter Anvin
2007-12-17 10:57                                             ` Ingo Molnar
2007-12-17 11:29                                               ` Ingo Molnar
2007-12-17 13:34                                                 ` David P. Reed
2007-12-17 12:15                                               ` Rene Herman
2007-12-17 13:09                                                 ` Ingo Molnar
2007-12-17 13:22                                                   ` Rene Herman
2007-12-17 13:31                                                     ` Pavel Machek
2007-12-17 13:31                                                       ` Rene Herman
2007-12-17 13:32                                                     ` David P. Reed
2007-12-17 13:36                                                       ` Rene Herman
2007-12-17 14:39                                                       ` Ingo Molnar
2007-12-17 16:12                                                         ` Alan Cox
2007-12-17 16:48                                                           ` Ingo Molnar
2007-12-17 20:48                                                           ` Rene Herman
2007-12-17 20:57                                                             ` H. Peter Anvin
2007-12-17 21:33                                                               ` Rene Herman
2007-12-17 21:40                                                                 ` H. Peter Anvin
2007-12-17 21:46                                                                   ` Ingo Molnar
2007-12-17 21:50                                                                   ` Rene Herman
2007-12-17 21:41                                                             ` Ingo Molnar
2007-12-17 21:47                                                               ` Rene Herman
2007-12-17 21:56                                                                 ` Ingo Molnar
2007-12-17 22:01                                                                   ` Rene Herman
2007-12-17 22:18                                                                     ` David P. Reed
2007-12-17 19:38                                                         ` David P. Reed
2007-12-17 19:55                                                           ` H. Peter Anvin
2007-12-17 21:28                                                           ` Ingo Molnar
2007-12-16 21:42                                         ` H. Peter Anvin
2007-12-17  1:48                                           ` Rene Herman
2007-12-17  1:53                                             ` H. Peter Anvin
2007-12-16 23:12                                         ` David P. Reed
2007-12-17  1:56                                           ` Rene Herman
2007-12-17  2:04                                             ` H. Peter Anvin
2007-12-17  2:15                                               ` Rene Herman
2007-12-16  0:23                                     ` [PATCH] x86: fix problems due to use of "outb" to port 80 on some AMD64x2 laptops, etc David P. Reed
2007-12-15 20:26                               ` [PATCH] x86_64: " H. Peter Anvin
2007-12-15 22:55                                 ` Pavel Machek
2007-12-16  9:27                                 ` Ingo Molnar
2007-12-17 21:04                             ` Rene Herman
2007-12-17 23:20                               ` Pavel Machek
2007-12-18  0:06                                 ` Alan Cox
2007-12-18 15:49                                   ` Lennart Sorensen
2007-12-17 22:46                           ` Jan Engelhardt
2007-12-15  7:43                       ` Ingo Molnar
2007-12-15  7:58                         ` Rene Herman
2007-12-15 13:27                           ` Ingo Molnar
2007-12-15 14:01                             ` Rene Herman
2007-12-15 20:25                               ` H. Peter Anvin
2007-12-15 14:29                             ` Alan Cox
2007-12-15 16:19                               ` David P. Reed
2007-12-15 16:48                                 ` Mark Lord
2007-12-15 17:51                                 ` Alan Cox
2007-12-15 23:00                     ` Pavel Machek
2007-12-15 23:04                       ` H. Peter Anvin
2007-12-16  9:40                         ` Ingo Molnar
2007-12-16 21:43                           ` H. Peter Anvin
2007-12-16 23:06                             ` David P. Reed
2007-12-16 23:23                               ` Pavel Machek
2007-12-16 23:34                                 ` H. Peter Anvin
2007-12-26 20:49                                   ` Pavel Machek
2007-12-17  1:51                             ` Rene Herman
2007-12-14 16:08                   ` Avi Kivity
2007-12-15  2:13                     ` David P. Reed
2007-12-15  2:20                       ` H. Peter Anvin
2007-12-17 18:14                       ` linux-os (Dick Johnson)
2007-12-17 18:54                         ` Rene Herman
2007-12-19 15:03                       ` Avi Kivity
     [not found] <fa.SxdP/X04a85FM81xaEZMBrrv9i4@ifi.uio.no>
     [not found] ` <fa.tplCM7jT7JqanJcCtGK76o+Mdsw@ifi.uio.no>
     [not found]   ` <fa.lWVoQaFEkNNX7F+8WUJpMQjIODE@ifi.uio.no>
     [not found]     ` <fa.ng4A2MLKS/VR9lS0zt0LDJIDwi0@ifi.uio.no>
     [not found]       ` <fa.yZlGBJmYGGt3AQuIiiu7uMT3W9w@ifi.uio.no>
     [not found]         ` <fa.RR732o3u5kvPHNspJA9tM1WHlKI@ifi.uio.no>
2007-12-17  0:53           ` Robert Hancock
     [not found] <fa.F/CPALGk5eBe3QDRN7pjalMH5m4@ifi.uio.no>
     [not found] ` <fa.56LRmmk2ZdofP2s+juNK5l0iREQ@ifi.uio.no>
     [not found]   ` <fa.FRcgZwrZusfLF5d88S6yPr2bvYo@ifi.uio.no>
     [not found]     ` <fa.eZe9IlwlTeEF/5eA+8kKfNUncS4@ifi.uio.no>
     [not found]       ` <fa.EBJleK5JYl+P/h3+2m6zPq3PzDc@ifi.uio.no>
     [not found]         ` <fa.jU9nntHcOIpTOJuwui+u+/gya4Y@ifi.uio.no>
2007-12-17  0:57           ` Robert Hancock
2007-12-17 15:27             ` Ingo Molnar

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=476250D5.8000409@gmail.com \
    --to=rene.herman@gmail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=dpreed@reed.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pavel@ucw.cz \
    --cc=tglx@linutronix.de \
    /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).