From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Shaohua Li <shaohua.li@intel.com>
Cc: pm list <linux-pm@lists.linux-foundation.org>,
linux acpi <linux-acpi@vger.kernel.org>,
Len Brown <lenb@kernel.org>, Pavel Machek <pavel@suse.cz>
Subject: Re: [patch] hibernation: utilize ACPI hardware signature
Date: Fri, 11 Jan 2008 18:20:47 +0100 [thread overview]
Message-ID: <200801111820.48462.rjw@sisk.pl> (raw)
In-Reply-To: <1200013632.21533.1.camel@sli10-desk.sh.intel.com>
On Friday, 11 of January 2008, Shaohua Li wrote:
>
> On Fri, 2008-01-11 at 07:39 +0800, Rafael J. Wysocki wrote:
> > On Monday, 7 of January 2008, Shaohua Li wrote:
> > >
> > > On Sat, 2008-01-05 at 04:44 +0800, Rafael J. Wysocki wrote:
> > > > On Friday, 4 of January 2008, Shaohua Li wrote:
> > > > >
> > > > > On Fri, 2008-01-04 at 01:04 +0800, Rafael J. Wysocki wrote:
> > > > > > On Thursday, 3 of January 2008, Shaohua Li wrote:
> > > > > > >
> > > > > > > On Wed, 2008-01-02 at 22:05 +0800, Rafael J. Wysocki wrote:
> > > > > > > > On Wednesday, 2 of January 2008, Shaohua Li wrote:
> > > > > > > > > ACPI defines a hardware signature. BIOS calculates the
> > > > signature
> > > > > > > > > according to hardware configure, if hardware changes,
> > the
> > > > > > signature
> > > > > > > > will
> > > > > > > > > change, in this case, S4 resume should fail.
> > > > > > > >
> > > > > > > > The idea is fine, but I'd prefer to do that in a more
> > > > > > straightforward
> > > > > > > > way.
> > > > > > > > Namely, we can just:
> > > > > > > > * write the signature into a variable in, for example,
> > > > > > > > acpi_hibernation_prepare() (then, the "old" signature
> > value
> > > > will
> > > > > > be
> > > > > > > > automatically saved in the image)
> > > > > > > > * compare it with a the "new" value read from the BIOS in
> > > > > > > > acpi_hibernation_leave() and panic if there's a mismatch
> > > > > > > > * add a configuration option to disable this behavior
> > (just in
> > > > > > case)
> > > > > > > > This way we can avoid modifying the entire generic
> > interface
> > > > to
> > > > > > add
> > > > > > > > the feature
> > > > > > > > specific to ACPI.
> > > > > > > it would be better we do the check in boot kernel.
> > > > > > Franky, I think we should also check in the image kernel, in
> > case
> > > > the
> > > > > > boot
> > > > > > one doesn't support ACPI as I said.
> > > > > Ok, makes sense. I changed to check the signature
> > > > in .higberation_leave
> > > >
> > > > Thanks, comments below.
> > > >
> > > > > Signed-off-by: Shaohua Li <shaohua.li@intel.com>
> > > > > ---
> > > > > drivers/acpi/sleep/main.c | 20 ++++++++++++++++++++
> > > > > 1 file changed, 20 insertions(+)
> > > > >
> > > > > Index: linux/drivers/acpi/sleep/main.c
> > > > >
> > ===================================================================
> > > > > --- linux.orig/drivers/acpi/sleep/main.c 2008-01-03
> > > > 13:37:08.000000000 +0800
> > > > > +++ linux/drivers/acpi/sleep/main.c 2008-01-04
> > 13:36:10.000000000
> > > > +0800
> > > > > @@ -256,6 +256,17 @@ static int acpi_hibernation_enter(void)
> > > > > return ACPI_SUCCESS(status) ? 0 : -EFAULT;
> > > > > }
> > > > >
> > > > > +static unsigned long s4_hardware_signature;
> > > > > +static struct acpi_table_facs *facs;
> > > > > +static int nosigcheck;
> > > >
> > > > Use bool perhaps?
> > > >
> > > > > +
> > > > > +static int __init acpi_s4_nosigcheck(char *str)
> > > > > +{
> > > > > + nosigcheck = 1;
> > > >
> > > > And "true" here?
> > > >
> > > > > + return 1;
> > > > > +}
> > > > > +__setup("acpi_s4_nosigcheck", acpi_s4_nosigcheck);
> > > > > +
> > > >
> > > > Please put this function at the end of the file. Also, I'd call
> > it
> > > > "acpi_s4_nosig", but whatever.
> > > Fixed all except this one, the routine is defined with HIBERATION
> > > configed.
> >
> > I've just realized that we're not doing the right thing here ...
> >
> > > Signed-off-by: Shaohua Li <shaohua.li@intel.com>
> > > ---
> > > drivers/acpi/sleep/main.c | 22 ++++++++++++++++++++++
> > > 1 file changed, 22 insertions(+)
> > >
> > > Index: linux/drivers/acpi/sleep/main.c
> > > ===================================================================
> > > --- linux.orig/drivers/acpi/sleep/main.c 2008-01-04
> > 13:44:40.000000000 +0800
> > > +++ linux/drivers/acpi/sleep/main.c 2008-01-07 09:31:42.000000000
> > +0800
> > > @@ -256,6 +256,17 @@ static int acpi_hibernation_enter(void)
> > > return ACPI_SUCCESS(status) ? 0 : -EFAULT;
> > > }
> > >
> > > +static unsigned long s4_hardware_signature;
> > > +static struct acpi_table_facs *facs;
> > > +static bool nosigcheck;
> > > +
> > > +static int __init acpi_s4_nosigcheck(char *str)
> > > +{
> > > + nosigcheck = true;
> > > + return 1;
> > > +}
> > > +__setup("acpi_s4_nosigcheck", acpi_s4_nosigcheck);
> > > +
> > > static void acpi_hibernation_leave(void)
> > > {
> > > /*
> > > @@ -263,6 +274,10 @@ static void acpi_hibernation_leave(void)
> > > * enable it here.
> > > */
> > > acpi_enable();
> > > + if (facs && s4_hardware_signature != facs->hardware_signature)
> > {
> >
> > ... because we should read the signature from the hardware here, while
> > we're
> > comparing two values read from memory. They will always be equal. :-)
> No, facs isn't a copy of ACPI FACS table (imagine how we sets
> facs->waking_vector). It's mapped to BIOS table.
Ah, ok. Thanks for the clarification.
I'll rebase your patch on top of the suspend branch.
Greetings,
Rafael
prev parent reply other threads:[~2008-01-11 17:18 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-02 6:59 [patch] hibernation: utilize ACPI hardware signature Shaohua Li
2008-01-02 7:37 ` [linux-pm] " Maxim Levitsky
2008-01-02 9:29 ` Johannes Berg
2008-01-03 1:52 ` Shaohua Li
2008-01-02 10:08 ` Erik Andrén
2008-01-02 14:12 ` Rafael J. Wysocki
2008-01-02 21:25 ` [linux-pm] " Nigel Cunningham
2008-01-02 22:18 ` Rafael J. Wysocki
2008-01-03 8:26 ` Nigel Cunningham
2008-01-02 14:05 ` Rafael J. Wysocki
2008-01-02 21:26 ` [linux-pm] " Nigel Cunningham
2008-01-02 22:01 ` Rafael J. Wysocki
2008-01-03 8:31 ` Nigel Cunningham
2008-01-03 16:58 ` Rafael J. Wysocki
2008-01-03 22:10 ` Nigel Cunningham
2008-01-03 5:36 ` Shaohua Li
2008-01-03 17:04 ` Rafael J. Wysocki
2008-01-04 5:41 ` Shaohua Li
2008-01-04 20:44 ` Rafael J. Wysocki
2008-01-07 1:46 ` Shaohua Li
2008-01-10 23:39 ` Rafael J. Wysocki
2008-01-11 1:07 ` Shaohua Li
2008-01-11 17:20 ` Rafael J. Wysocki [this message]
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=200801111820.48462.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=pavel@suse.cz \
--cc=shaohua.li@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox