From: Yinghai Lu <yinghai@kernel.org>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Ingo Molnar <mingo@redhat.com>, "Rafael J. Wysocki" <rjw@sisk.pl>,
Michael Leun <lkml20101129@newton.leun.net>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Greg Kroah-Hartman <gregkh@suse.de>,
Mike Pagano <mpagano@gentoo.org>
Subject: Re: 2.6.38.2 breaks suspend to disk
Date: Fri, 01 Apr 2011 16:04:40 -0700 [thread overview]
Message-ID: <4D965A08.2080203@kernel.org> (raw)
In-Reply-To: <4D9646C6.7060301@zytor.com>
On 04/01/2011 02:42 PM, H. Peter Anvin wrote:
>
> And why on Earth is it worth saving a couple of instructions (and
> introducing code ugliness and a more complex testing matrix) in the case
> when it is not?
Please check this one, it moves storing mmu_cr4 to arch_prepare_suspend.
Thanks
Yinghai
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
[PATCH -v5] x86: Save cr4 to mmu_cr4_features at boot time
Save cr4 to mmu_cr4_features at boot time
Michael reported 2.6.38.2 hibernation is broken by one backported patch.
it cause a freeze when resuming from hibernation
| "x86: Cleanup highmap after brk is concluded"
| commit id e5f15b45ddf3afa2bbbb10c7ea34fb32b6de0a0e.
it turns out the mmu_cr4 save it lost somehow.
-v3: read back cr4 for 32bit too according to HPA
-v4: use cpuid_level to check if we can read cr4 according to HPA
don't touch mmu_cr4_features if CONFIG_HIBERNATION is defined from Yinghai
-v5: reduce the using of CONFIG_HIBERNATION
Bisected-and-tested-by: Michael Leun <lkml20101129@newton.leun.net>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
arch/x86/include/asm/processor.h | 2 --
arch/x86/include/asm/suspend_32.h | 2 +-
arch/x86/include/asm/suspend_64.h | 5 +----
arch/x86/kernel/setup.c | 16 +++++++++++++++-
4 files changed, 17 insertions(+), 8 deletions(-)
Index: linux-2.6/arch/x86/kernel/setup.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/setup.c
+++ linux-2.6/arch/x86/kernel/setup.c
@@ -212,12 +212,26 @@ struct cpuinfo_x86 boot_cpu_data __read_
EXPORT_SYMBOL(boot_cpu_data);
#endif
-
+/*
+ * mmu_cr4_features has two purposes:
+ * a. head_32.S will access cr4 according if X86_CR4_PAE is set in it.
+ * b. store read back cr4 for hibernation
+ */
#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
unsigned long mmu_cr4_features;
#else
unsigned long mmu_cr4_features = X86_CR4_PAE;
#endif
+#ifdef CONFIG_HIBERNATION
+int arch_prepare_suspend(void)
+{
+ /* a CPU has CR4 iff it has CPUID --- hpa */
+ if (boot_cpu_data.cpuid_level >= 0)
+ mmu_cr4_features = read_cr4();
+
+ return 0;
+}
+#endif
/* Boot loader ID and version as integers, for the benefit of proc_dointvec */
int bootloader_type, bootloader_version;
Index: linux-2.6/arch/x86/include/asm/processor.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/processor.h
+++ linux-2.6/arch/x86/include/asm/processor.h
@@ -601,7 +601,6 @@ static inline void set_in_cr4(unsigned l
{
unsigned long cr4;
- mmu_cr4_features |= mask;
cr4 = read_cr4();
cr4 |= mask;
write_cr4(cr4);
@@ -611,7 +610,6 @@ static inline void clear_in_cr4(unsigned
{
unsigned long cr4;
- mmu_cr4_features &= ~mask;
cr4 = read_cr4();
cr4 &= ~mask;
write_cr4(cr4);
Index: linux-2.6/arch/x86/include/asm/suspend_32.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/suspend_32.h
+++ linux-2.6/arch/x86/include/asm/suspend_32.h
@@ -9,7 +9,7 @@
#include <asm/desc.h>
#include <asm/i387.h>
-static inline int arch_prepare_suspend(void) { return 0; }
+int arch_prepare_suspend(void);
/* image of the saved processor state */
struct saved_context {
Index: linux-2.6/arch/x86/include/asm/suspend_64.h
===================================================================
--- linux-2.6.orig/arch/x86/include/asm/suspend_64.h
+++ linux-2.6/arch/x86/include/asm/suspend_64.h
@@ -9,10 +9,7 @@
#include <asm/desc.h>
#include <asm/i387.h>
-static inline int arch_prepare_suspend(void)
-{
- return 0;
-}
+int arch_prepare_suspend(void);
/*
* Image of the saved processor state, used by the low level ACPI suspend to
next prev parent reply other threads:[~2011-04-01 23:05 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-30 18:32 2.6.38.2 breaks suspend to disk Michael Leun
2011-03-31 5:14 ` Yinghai Lu
2011-03-31 7:05 ` Michael Leun
2011-03-31 14:48 ` Stefano Stabellini
2011-03-31 15:53 ` Michael Leun
2011-03-31 21:48 ` Rafael J. Wysocki
2011-03-31 22:20 ` Yinghai Lu
2011-04-01 11:32 ` Stefano Stabellini
2011-04-01 16:06 ` Yinghai Lu
2011-04-01 16:22 ` H. Peter Anvin
2011-04-01 17:14 ` Yinghai Lu
2011-04-01 18:15 ` Stefano Stabellini
2011-04-01 18:14 ` Stefano Stabellini
2011-04-01 18:55 ` H. Peter Anvin
2011-04-01 19:32 ` Yinghai Lu
2011-04-01 19:36 ` H. Peter Anvin
2011-04-01 19:54 ` Yinghai Lu
2011-04-01 20:21 ` H. Peter Anvin
2011-04-01 21:24 ` Yinghai Lu
2011-04-01 21:30 ` H. Peter Anvin
2011-04-01 21:37 ` Yinghai Lu
2011-04-01 21:42 ` H. Peter Anvin
2011-04-01 23:04 ` Yinghai Lu [this message]
2011-04-01 23:12 ` H. Peter Anvin
2011-04-02 0:10 ` Yinghai Lu
2011-04-01 23:54 ` Rafael J. Wysocki
2011-04-06 20:28 ` [tip:x86/urgent] x86, hibernate: Initialize mmu_cr4_features during boot tip-bot for H. Peter Anvin
2011-04-01 6:15 ` 2.6.38.2 breaks suspend to disk 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=4D965A08.2080203@kernel.org \
--to=yinghai@kernel.org \
--cc=gregkh@suse.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkml20101129@newton.leun.net \
--cc=mingo@redhat.com \
--cc=mpagano@gentoo.org \
--cc=rjw@sisk.pl \
--cc=stefano.stabellini@eu.citrix.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.