Skip to contentSkip to conversation

Enable A20 using KBC for some MSI laptops to fix S3 resume

PATCH In review Ondrej Zary 3 participants 10 messages Oct 26, 2012 – Dec 11, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Enable A20 using KBC for some MSI laptops to fix S3 resume

Some MSI laptop BIOSes are broken - INT 15h code uses port 92h to enable A20 line but resume code assumes that KBC was used.
The laptop will not resume from S3 otherwise but powers off after a while and then powers on again stuck with a blank screen.

Fix it by enabling A20 using KBC. Affected laptop list and DMI data are from bug reports at Ubuntu Launchpad.

Also add kernel parameter to easily activate this quirk on any system.

Only compile tested. The original patch was tested with EX600 and PR200.

Fixes https://bugzilla.kernel.org/show_bug.cgi?id=12878

---
 Documentation/kernel-parameters.txt |    6 ++
 arch/x86/kernel/acpi/boot.c         |  122 +++++++++++++++++++++++++++++++++++
 2 files changed, 128 insertions(+), 0 deletions(-)
Documentation/kernel-parameters.txt +6 -0
index 9776f06..eb3d6a4 100644
@@ -153,6 +153,12 @@ multipliers 'Kilo', 'Mega', and 'Giga', equalling 2^10, 2^20, and 2^30
 bytes respectively. Such letter suffixes can also be entirely omitted.
 
 
+	a20_enable_kbc	[ACPI,X86]
+			Enable A20 line using KBC even if it's already
+			enabled using other method.
+			This is needed for some MSI laptops to resume from
+			S3.
+
 	acpi=		[HW,ACPI,X86]
 			Advanced Configuration and Power Interface
 			Format: { force | off | strict | noirq | rsdt }
arch/x86/kernel/acpi/boot.c +122 -0

140 lines not on this page · raw message

Signature · 1 line
Ondrej Zary
#1 lore raw
Quoted 5 lines · On Friday 26 October 2012 10:56:44 Ondrej Zary wrote:

Some MSI laptop BIOSes are broken - INT 15h code uses port 92h to enable A20 line but resume code assumes that KBC was used.
The laptop will not resume from S3 otherwise but powers off after a while and then powers on again stuck with a blank screen.

Quoted 8 lines

Fix it by enabling A20 using KBC. Affected laptop list and DMI data are from bug reports at Ubuntu Launchpad.

Also add kernel parameter to easily activate this quirk on any system.

Only compile tested. The original patch was tested with EX600 and PR200.

Fixes https://bugzilla.kernel.org/show_bug.cgi?id=12878

The bug was marked as RESOLVED CODE_FIX but I wonder what happened to this patch. Was it applied? Or is someone working on a better way to fix this problem?

Signature · 1 line
Ondrej Zary
#2 lore raw
Quoted 11 lines · Ondrej Zary
Quoted 10 lines · On Friday 26 October 2012 10:56:44 Ondrej Zary wrote:

Some MSI laptop BIOSes are broken - INT 15h code uses port 92h to enable A20 line but resume code assumes that KBC was used.
The laptop will not resume from S3 otherwise but powers off after a while and then powers on again stuck with a blank screen.

Fix it by enabling A20 using KBC. Affected laptop list and DMI data are from bug reports at Ubuntu Launchpad.

Also add kernel parameter to easily activate this quirk on any system.

Quoted 8 lines
Quoted 3 lines

Only compile tested. The original patch was tested with EX600 and PR200.

Fixes https://bugzilla.kernel.org/show_bug.cgi?id=12878

The bug was marked as RESOLVED CODE_FIX but I wonder what happened to this patch. Was it applied? Or is someone working on a better way to fix this problem?

Sorry, I managed to forget about this.

Is there any way you could test this patch by any chance?

I would be a lot happier if this works as a general solution rather than relying on a quirk...

-hpa

Quoted 1 line

From 5513340abd845eaa28fe2394f7e0296599f2d9e7 Mon Sep 17 00:00:00 2001

From: "H. Peter Anvin" <[email protected]>
Date: Mon, 10 Dec 2012 13:17:48 -0800
Subject: [PATCH] x86, suspend: Run A20 test on resume

If A20 is disabled on resume, we may have to explicitly enable it. Rather than creating a bunch of ad hoc code, use the same code we would on system startup.

Note: the startup code implicitly assumes BIOS, specifically that int $0x15 is enabled. However, for non-BIOS platforms to have A20 closed on resume seems extremely unlikely, since pretty much all non-BIOS firmware run in 32- or 64-bit mode.

---
 arch/x86/realmode/rm/Makefile   | 2 +-
 arch/x86/realmode/rm/a20.c      | 1 +
 arch/x86/realmode/rm/wakemain.c | 3 +++
 3 files changed, 5 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/realmode/rm/a20.c
arch/x86/realmode/rm/Makefile +1 -1
index 8869287..7e2ff68 100644
@@ -10,7 +10,7 @@
 always := realmode.bin realmode.relocs
 
 wakeup-objs	:= wakeup_asm.o wakemain.o video-mode.o
-wakeup-objs	+= copy.o bioscall.o regs.o
+wakeup-objs	+= copy.o bioscall.o regs.o a20.o
 # The link order of the video-*.o modules can matter.  In particular,
 # video-vga.o *must* be listed first, followed by video-vesa.o.
 # Hardware-specific drivers should follow in the order they should be
arch/x86/realmode/rm/a20.c new file +1 -0
new file mode 100644
index 0000000..e71d518
@@ -0,0 +1 @@
+#include "../../boot/a20.c"
arch/x86/realmode/rm/wakemain.c +3 -0
index 91405d5..6e0d548 100644
@@ -79,4 +79,7 @@ void main(void)
 		probe_cards(0);
 		set_mode(wakeup_header.video_mode);
 	}
+
+	/* If A20 is closed, fix now */
+	enable_a20();
 }
Signature · 1 line
1.7.11.7
#3 lore raw
Quoted 20 lines · On Monday 10 December 2012 22:26:18 H. Peter Anvin wrote:
Quoted 11 lines · Ondrej Zary
Quoted 10 lines · On Friday 26 October 2012 10:56:44 Ondrej Zary wrote:

Some MSI laptop BIOSes are broken - INT 15h code uses port 92h to enable A20 line but resume code assumes that KBC was used.
The laptop will not resume from S3 otherwise but powers off after a while and then powers on again stuck with a blank screen.

Fix it by enabling A20 using KBC. Affected laptop list and DMI data are from bug reports at Ubuntu Launchpad.

Also add kernel parameter to easily activate this quirk on any system.

Quoted 7 lines
Quoted 3 lines

Only compile tested. The original patch was tested with EX600 and PR200.

Fixes https://bugzilla.kernel.org/show_bug.cgi?id=12878

The bug was marked as RESOLVED CODE_FIX but I wonder what happened to this patch. Was it applied? Or is someone working on a better way to fix this problem?

Quoted 6 lines

Sorry, I managed to forget about this.

Is there any way you could test this patch by any chance?

I would be a lot happier if this works as a general solution rather than relying on a quirk...

I have a PR200 laptop for a while now so I'll try to test this patch.

Signature · 1 line
Ondrej Zary
#4 lore raw
In reply to H. Peter Anvin
Quoted 16 lines · On Monday 10 December 2012 22:26:18 H. Peter Anvin wrote:
Quoted 15 lines · Ondrej Zary
Quoted 13 lines · On Friday 26 October 2012 10:56:44 Ondrej Zary wrote:

Some MSI laptop BIOSes are broken - INT 15h code uses port 92h to enable A20 line but resume code assumes that KBC was used.
The laptop will not resume from S3 otherwise but powers off after a while and then powers on again stuck with a blank screen.

Fix it by enabling A20 using KBC. Affected laptop list and DMI data are from bug reports at Ubuntu Launchpad.

Also add kernel parameter to easily activate this quirk on any system.

Only compile tested. The original patch was tested with EX600 and PR200.

Fixes https://bugzilla.kernel.org/show_bug.cgi?id=12878

Quoted 7 lines
Quoted 3 lines

The bug was marked as RESOLVED CODE_FIX but I wonder what happened to this patch. Was it applied? Or is someone working on a better way to fix this problem?

Sorry, I managed to forget about this.

Is there any way you could test this patch by any chance?

I've just tested the patch and it does not work (no change in behavior).

Quoted 2 lines

I would be a lot happier if this works as a general solution rather than relying on a quirk...

As I said before, the BIOS probably breaks on resume before any Linux code is executed. So any fix must be done before suspending.

I hate quirks too. A general solution would be to always enable A20 using KBC (if KBC is present) but that's probably not acceptable.

Signature · 1 line
Ondrej Zary
#5 lore raw
Quoted 4 lines · Ondrej Zary

As I said before, the BIOS probably breaks on resume before any Linux code is executed. So any fix must be done before suspending.

Well, that code should be independent of A20, being in low memory, but if the BIOS itself crashes, then that's... yeah.

Quoted 2 lines

I hate quirks too. A general solution would be to always enable A20 using KBC (if KBC is present) but that's probably not acceptable.

I don't see why not. If so we could just do it as part of the initialization of the i8042 driver.

-hpa

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.
#6 lore raw
Quoted 4 lines · On Tuesday 11 December 2012 20:07:50 H. Peter Anvin wrote:
Quoted 2 lines · Ondrej Zary

As I said before, the BIOS probably breaks on resume before any Linux code is executed. So any fix must be done before suspending.

Quoted 8 lines

Well, that code should be independent of A20, being in low memory, but if the BIOS itself crashes, then that's... yeah.

Quoted 2 lines

I hate quirks too. A general solution would be to always enable A20 using KBC (if KBC is present) but that's probably not acceptable.

I don't see why not. If so we could just do it as part of the initialization of the i8042 driver.

Something like this? (It works.)

drivers/input/serio/i8042-x86ia64io.h +8 -0
index d6cc77a..0807ac7 100644
@@ -921,6 +921,7 @@ static int __init i8042_platform_init(void)
 	int retval;
 
 #ifdef CONFIG_X86
+	u8 a20_on = 0xdf;
 	/* Just return if pre-detection shows no i8042 controller exist */
 	if (!x86_platform.i8042_detect())
 		return -ENODEV;
@@ -960,6 +961,13 @@ static int __init i8042_platform_init(void)
 
 	if (dmi_check_system(i8042_dmi_dritek_table))
 		i8042_dritek = true;
+
+	/*
+	 * A20 was already enabled during early kernel init. But some buggy
+	 * BIOSes (in MSI Laptops) require A20 to be enabled using 8042 to
+	 * resume from S3. So we do it here and hope that nothing breaks.
+	 */
+	i8042_command(&a20_on, 0x10d1);
 #endif /* CONFIG_X86 */
 
 	return retval;
Signature · 1 line
Ondrej Zary
#7 lore raw
Quoted 3 lines · Ondrej Zary

Something like this? (It works.)

Something like that. We need to make sure we send the proper sequence, though, or it might break some SMM firmware...

Quoted 27 lines
drivers/input/serio/i8042-x86ia64io.h +8 -0
index d6cc77a..0807ac7 100644
@@ -921,6 +921,7 @@ static int __init i8042_platform_init(void)
 	int retval;
 
 #ifdef CONFIG_X86
+	u8 a20_on = 0xdf;
 	/* Just return if pre-detection shows no i8042 controller exist */
 	if (!x86_platform.i8042_detect())
 		return -ENODEV;
@@ -960,6 +961,13 @@ static int __init i8042_platform_init(void)
 
 	if (dmi_check_system(i8042_dmi_dritek_table))
 		i8042_dritek = true;
+
+	/*
+	 * A20 was already enabled during early kernel init. But some buggy
+	 * BIOSes (in MSI Laptops) require A20 to be enabled using 8042 to
+	 * resume from S3. So we do it here and hope that nothing breaks.
+	 */
+	i8042_command(&a20_on, 0x10d1);
 #endif /* CONFIG_X86 */
 
 	return retval;
#8 lore raw
Quoted 5 lines · On Tuesday 11 December 2012 21:36:46 H. Peter Anvin wrote:
Quoted 1 line · Ondrej Zary

Something like this? (It works.)

Something like that. We need to make sure we send the proper sequence, though, or it might break some SMM firmware...

Could you please create proper patch? You're the x86 expert (and I'm not).

I've read that 0xd1 command with 0xdf data is often used to enable A20. But I don't know when this must be done or what else needs to be done for the SMM to not break.

Quoted 26 lines
Quoted 26 lines
(quoted diff) +0 -0

b/drivers/input/serio/i8042-x86ia64io.h index d6cc77a..0807ac7 100644

drivers/input/serio/i8042-x86ia64io.h +8 -0
@@ -921,6 +921,7 @@ static int __init i8042_platform_init(void)
 	int retval;
 
 #ifdef CONFIG_X86
+	u8 a20_on = 0xdf;
 	/* Just return if pre-detection shows no i8042 controller exist */
 	if (!x86_platform.i8042_detect())
 		return -ENODEV;
@@ -960,6 +961,13 @@ static int __init i8042_platform_init(void)
 
 	if (dmi_check_system(i8042_dmi_dritek_table))
 		i8042_dritek = true;
+
+	/*
+	 * A20 was already enabled during early kernel init. But some buggy
+	 * BIOSes (in MSI Laptops) require A20 to be enabled using 8042 to
+	 * resume from S3. So we do it here and hope that nothing breaks.
+	 */
+	i8042_command(&a20_on, 0x10d1);
 #endif /* CONFIG_X86 */
 
 	return retval;
Signature · 1 line
Ondrej Zary
#9 lore raw
Quoted 4 lines · Ondrej Zary
Quoted 3 lines · On Tuesday 11 December 2012 21:36:46 H. Peter Anvin wrote:
Quoted 1 line · Ondrej Zary

Something like this? (It works.)

Quoted 9 lines
Quoted 2 lines

Something like that. We need to make sure we send the proper sequence, though, or it might break some SMM firmware...

Could you please create proper patch? You're the x86 expert (and I'm not).

I've read that 0xd1 command with 0xdf data is often used to enable A20. But I don't know when this must be done or what else needs to be done for the SMM to not break.

You need to send an FF dummy command afterwards, that's all.

Signature · 2 lines
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.