public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Huang, Ying" <ying.huang@intel.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	Pavel Machek <pavel@ucw.cz>,
	nigel@nigel.suspend2.net,
	Andrew Morton <akpm@linux-foundation.org>,
	Jeremy Maitin-Shepard <jbms@cmu.edu>,
	linux-kernel@vger.kernel.org,
	linux-pm@lists.linux-foundation.org,
	Kexec Mailing List <kexec@lists.infradead.org>
Subject: Re: [PATCH 3/3 -mm] kexec based hibernation -v6: kexec hibernate/resume
Date: Tue, 20 Nov 2007 09:56:48 +0800	[thread overview]
Message-ID: <1195523808.11955.27.camel@caritas-dev.intel.com> (raw)
In-Reply-To: <200711191922.44008.rjw@sisk.pl>

On Mon, 2007-11-19 at 19:22 +0100, Rafael J. Wysocki wrote:
> > +#ifdef CONFIG_KEXEC
> > +static void kexec_hibernate_power_down(void)
> > +{
> > +	switch (hibernation_mode) {
> > +	case HIBERNATION_TEST:
> > +	case HIBERNATION_TESTPROC:
> > +		break;
> > +	case HIBERNATION_REBOOT:
> > +		machine_restart(NULL);
> > +		break;
> > +	case HIBERNATION_PLATFORM:
> > +		if (!hibernation_ops)
> > +			break;
> > +		hibernation_ops->enter();
> 
> hibernation_platform_enter() should be used here (as of the current mainline).

The power_down will be called with interrupt disabled, device suspended,
non-boot CPU disabled. But the latest hibernate_platform_enter calls the
device_suspend, disable_nonboot_cpus etc function. So, I use
hibernation_ops->enter() directly instead of
hibernation_platform_enter().

> > +		/* We should never get here */
> > +		while (1);
> > +		break;
> > +	case HIBERNATION_SHUTDOWN:
> > +		machine_power_off();
> > +		break;
> > +	}
> > +	machine_halt();
> > +	/*
> > +	 * Valid image is on the disk, if we continue we risk serious data
> > +	 * corruption after resume.
> > +	 */
> > +	printk(KERN_CRIT "Please power me down manually\n");
> > +	while (1);
> > +}
> 
> Hm, what's the difference between the above function and power_down(),
> actually?

Same as above.

> > +
> > +int kexec_hibernate(struct kimage *image)
> > +{
> > +	int error;
> > +	int platform_mode = (hibernation_mode == HIBERNATION_PLATFORM);
> > +	unsigned long cmd_ret;
> > +
> > +	mutex_lock(&pm_mutex);
> > +
> > +	pm_prepare_console();
> > +	suspend_console();
> > +
> > +	error = pm_notifier_call_chain(PM_HIBERNATION_PREPARE);
> > +	if (error)
> > +		goto Resume_console;
> > +
> > +	error = platform_start(platform_mode);
> > +	if (error)
> > +		goto Resume_console;
> > +
> > +	error = device_suspend(PMSG_FREEZE);
> > +	if (error)
> > +		goto Resume_console;
> > +
> > +	error = platform_pre_snapshot(platform_mode);
> > +	if (error)
> > +		goto Resume_devices;
> > +
> > +	error = disable_nonboot_cpus();
> > +	if (error)
> > +		goto Resume_devices;
> 
> I wonder if it's viable to merge the above with hibernate() and
> hibernation_snapshot() somehow, to avoid code duplication?

Yes. Most code are duplicated. But there is one advantage not to merge
them: power_down can called with IRQ disabled to make it possible to
eliminate the freezer.

I think it is possible to merge the two implementation. I will try to do
it.

> Apart from the above, there's some new debug code to be added to disk.c
> in 2.6.25.  It's in the ACPI test tree right now and you can get it as
> individual patches from:
> http://www.sisk.pl/kernel/hibernation_and_suspend/2.6.24-rc2/patches/
> (patches 10-12).
> 
> Please base your changes on top of that.

OK, I will do it.

Best Regards,
Huang Ying

  reply	other threads:[~2007-11-20  2:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-19  7:02 [PATCH 3/3 -mm] kexec based hibernation -v6: kexec hibernate/resume Huang, Ying
2007-11-19 18:22 ` Rafael J. Wysocki
2007-11-20  1:56   ` Huang, Ying [this message]
2007-11-20  2:24     ` Rafael J. Wysocki
2007-11-20  2:50       ` Huang, Ying
2007-11-20 14:58         ` [linux-pm] " Alan Stern
2007-11-21  0:00           ` Rafael J. Wysocki
2007-11-21  0:00         ` Rafael J. Wysocki
2007-11-21  8:05           ` Huang, Ying
2007-11-21 20:09             ` Rafael J. Wysocki

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=1195523808.11955.27.camel@caritas-dev.intel.com \
    --to=ying.huang@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=jbms@cmu.edu \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=nigel@nigel.suspend2.net \
    --cc=pavel@ucw.cz \
    --cc=rjw@sisk.pl \
    /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