diff options
author | Rene Herman <rene.herman@gmail.com> | 2008-01-30 07:30:05 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:30:05 -0500 |
commit | b02aae9cf52956dfe1bec73f77f81a3d05d3902b (patch) | |
tree | ce715a107c853960cc9541377aeae0ff31ac25f7 /arch/x86/kernel/io_delay.c | |
parent | 4c6b8b4d62fb4cb843c32db71e0a8301039908f3 (diff) |
x86: provide a DMI based port 0x80 I/O delay override.
x86: provide a DMI based port 0x80 I/O delay override.
Certain (HP) laptops experience trouble from our port 0x80 I/O delay
writes. This patch provides for a DMI based switch to the "alternate
diagnostic port" 0xed (as used by some BIOSes as well) for these.
David P. Reed confirmed that port 0xed works for him and provides a
proper delay. The symptoms of _not_ working are a hanging machine,
with "hwclock" use being a direct trigger.
Earlier versions of this attempted to simply use udelay(2), with the
2 being a value tested to be a nicely conservative upper-bound with
help from many on the linux-kernel mailinglist but that approach has
two problems.
First, pre-loops_per_jiffy calibration (which is post PIT init while
some implementations of the PIT are actually one of the historically
problematic devices that need the delay) udelay() isn't particularly
well-defined. We could initialise loops_per_jiffy conservatively (and
based on CPU family so as to not unduly delay old machines) which
would sort of work, but...
Second, delaying isn't the only effect that a write to port 0x80 has.
It's also a PCI posting barrier which some devices may be explicitly
or implicitly relying on. Alan Cox did a survey and found evidence
that additionally some drivers may be racy on SMP without the bus
locking outb.
Switching to an inb() makes the timing too unpredictable and as such,
this DMI based switch should be the safest approach for now. Any more
invasive changes should get more rigid testing first. It's moreover
only very few machines with the problem and a DMI based hack seems
to fit that situation.
This also introduces a command-line parameter "io_delay" to override
the DMI based choice again:
io_delay=<standard|alternate>
where "standard" means using the standard port 0x80 and "alternate"
port 0xed.
This retains the udelay method as a config (CONFIG_UDELAY_IO_DELAY) and
command-line ("io_delay=udelay") choice for testing purposes as well.
This does not change the io_delay() in the boot code which is using
the same port 0x80 I/O delay but those do not appear to be a problem
as David P. Reed reported the problem was already gone after using the
udelay version. He moreover reported that booting with "acpi=off" also
fixed things and seeing as how ACPI isn't touched until after this DMI
based I/O port switch I believe it's safe to leave the ones in the boot
code be.
The DMI strings from David's HP Pavilion dv9000z are in there already
and we need to get/verify the DMI info from other machines with the
problem, notably the HP Pavilion dv6000z.
This patch is partly based on earlier patches from Pavel Machek and
David P. Reed.
Signed-off-by: Rene Herman <rene.herman@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/io_delay.c')
-rw-r--r-- | arch/x86/kernel/io_delay.c | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c new file mode 100644 index 000000000000..4d955e74b974 --- /dev/null +++ b/arch/x86/kernel/io_delay.c | |||
@@ -0,0 +1,106 @@ | |||
1 | /* | ||
2 | * I/O delay strategies for inb_p/outb_p | ||
3 | */ | ||
4 | #include <linux/kernel.h> | ||
5 | #include <linux/module.h> | ||
6 | #include <linux/init.h> | ||
7 | #include <linux/delay.h> | ||
8 | #include <linux/dmi.h> | ||
9 | #include <asm/io.h> | ||
10 | |||
11 | /* | ||
12 | * Allow for a DMI based override of port 0x80 needed for certain HP laptops | ||
13 | */ | ||
14 | #define IO_DELAY_PORT_STD 0x80 | ||
15 | #define IO_DELAY_PORT_ALT 0xed | ||
16 | |||
17 | static void standard_io_delay(void) | ||
18 | { | ||
19 | asm volatile ("outb %%al, %0" : : "N" (IO_DELAY_PORT_STD)); | ||
20 | } | ||
21 | |||
22 | static void alternate_io_delay(void) | ||
23 | { | ||
24 | asm volatile ("outb %%al, %0" : : "N" (IO_DELAY_PORT_ALT)); | ||
25 | } | ||
26 | |||
27 | /* | ||
28 | * 2 usecs is an upper-bound for the outb delay but note that udelay doesn't | ||
29 | * have the bus-level side-effects that outb does | ||
30 | */ | ||
31 | #define IO_DELAY_USECS 2 | ||
32 | |||
33 | /* | ||
34 | * High on a hill was a lonely goatherd | ||
35 | */ | ||
36 | static void udelay_io_delay(void) | ||
37 | { | ||
38 | udelay(IO_DELAY_USECS); | ||
39 | } | ||
40 | |||
41 | #ifndef CONFIG_UDELAY_IO_DELAY | ||
42 | static void (*io_delay)(void) = standard_io_delay; | ||
43 | #else | ||
44 | static void (*io_delay)(void) = udelay_io_delay; | ||
45 | #endif | ||
46 | |||
47 | /* | ||
48 | * Paravirt wants native_io_delay to be a constant. | ||
49 | */ | ||
50 | void native_io_delay(void) | ||
51 | { | ||
52 | io_delay(); | ||
53 | } | ||
54 | EXPORT_SYMBOL(native_io_delay); | ||
55 | |||
56 | #ifndef CONFIG_UDELAY_IO_DELAY | ||
57 | static int __init dmi_alternate_io_delay_port(const struct dmi_system_id *id) | ||
58 | { | ||
59 | printk(KERN_NOTICE "%s: using alternate I/O delay port\n", id->ident); | ||
60 | io_delay = alternate_io_delay; | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | static struct dmi_system_id __initdata alternate_io_delay_port_dmi_table[] = { | ||
65 | { | ||
66 | .callback = dmi_alternate_io_delay_port, | ||
67 | .ident = "HP Pavilion dv9000z", | ||
68 | .matches = { | ||
69 | DMI_MATCH(DMI_BOARD_VENDOR, "Quanta"), | ||
70 | DMI_MATCH(DMI_BOARD_NAME, "30B9") | ||
71 | } | ||
72 | }, | ||
73 | { | ||
74 | } | ||
75 | }; | ||
76 | |||
77 | static int __initdata io_delay_override; | ||
78 | |||
79 | void __init io_delay_init(void) | ||
80 | { | ||
81 | if (!io_delay_override) | ||
82 | dmi_check_system(alternate_io_delay_port_dmi_table); | ||
83 | } | ||
84 | #endif | ||
85 | |||
86 | static int __init io_delay_param(char *s) | ||
87 | { | ||
88 | if (!s) | ||
89 | return -EINVAL; | ||
90 | |||
91 | if (!strcmp(s, "standard")) | ||
92 | io_delay = standard_io_delay; | ||
93 | else if (!strcmp(s, "alternate")) | ||
94 | io_delay = alternate_io_delay; | ||
95 | else if (!strcmp(s, "udelay")) | ||
96 | io_delay = udelay_io_delay; | ||
97 | else | ||
98 | return -EINVAL; | ||
99 | |||
100 | #ifndef CONFIG_UDELAY_IO_DELAY | ||
101 | io_delay_override = 1; | ||
102 | #endif | ||
103 | return 0; | ||
104 | } | ||
105 | |||
106 | early_param("io_delay", io_delay_param); | ||