Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755404AbXKUTv5 (ORCPT ); Wed, 21 Nov 2007 14:51:57 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752607AbXKUTvq (ORCPT ); Wed, 21 Nov 2007 14:51:46 -0500 Received: from ogre.sisk.pl ([217.79.144.158]:50533 "EHLO ogre.sisk.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752521AbXKUTvp (ORCPT ); Wed, 21 Nov 2007 14:51:45 -0500 From: "Rafael J. Wysocki" To: "Huang, Ying" Subject: Re: [PATCH 3/3 -mm] kexec based hibernation -v6: kexec hibernate/resume Date: Wed, 21 Nov 2007 21:09:31 +0100 User-Agent: KMail/1.9.6 (enterprise 20070904.708012) Cc: "Eric W. Biederman" , Pavel Machek , nigel@nigel.suspend2.net, Andrew Morton , Jeremy Maitin-Shepard , linux-kernel@vger.kernel.org, linux-pm@lists.linux-foundation.org, Kexec Mailing List References: <1195455769.10291.26.camel@caritas-dev.intel.com> <200711210100.32631.rjw@sisk.pl> <1195632306.29280.7.camel@caritas-dev.intel.com> In-Reply-To: <1195632306.29280.7.camel@caritas-dev.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200711212109.32925.rjw@sisk.pl> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4765 Lines: 126 On Wednesday, 21 of November 2007, Huang, Ying wrote: > On Wed, 2007-11-21 at 01:00 +0100, Rafael J. Wysocki wrote: > > On Tuesday, 20 of November 2007, Huang, Ying wrote: > > > On Tue, 2007-11-20 at 03:24 +0100, Rafael J. Wysocki wrote: > > > > On Tuesday, 20 of November 2007, Huang, Ying wrote: > > > > > 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(). > > > > > > > > Hm, you need to call device_power_down(PMSG_SUSPEND) before > > > > hibernation_ops->enter(). > > > > > > > > Also, all of the ACPI global calls need to be carried out before that and the > > > > devices should be suspended rather than shut down in that case. > > > > > > > > That's why hibernation_platform_enter() has been introduced, BTW. > > > > > > Situation is a little different between u/swsusp and khiberantion. > > > > > > u/swsusp: > > > > > > platform_start(); > > > suspend console(); > > > device_suspend(PMSG_FREEZE); > > > platform_pre_snapshot(); > > > disable_nonboot_cpus(); > > > local_irq_disable(); > > > device_power_down(PMSG_FREEZE); > > > /* create snapshot */ > > > device_power_up(); > > > local_irq_enable(); > > > enable_nonboot_cpus(); > > > platform_finish(); > > > device_resume(); > > > resume_console(); > > > /* write the image out */ > > > hibernation_ops->start(); > > > suspend_console(); > > > device_suspend(PMSG_SUSPEND); > > > hibernation_ops->prepare(); > > > disable_nonboot_cpus(); > > > local_irq_disable(); > > > device_power_down(PMSG_SUSPEND); > > > hibernation_ops->enter(); > > > > > > khibernation: > > > > > > suspend_console(); > > > platform_start(); > > > device_suspend(PMSG_FREEZE); > > > platform_pre_snapshot(); > > > disable_nonboot_cpus(); > > > local_irq_disable(); > > > device_power_down(PMSG_FREEZE); > > > /* jump to kexeced (hibernating) kernel */ > > > /* in kexeced kernel */ > > > device_power_up(); > > > local_irq_eanble(); > > > enable_nonboot_cpus(); > > > > You should call platform_finish() here, or device_resume() will not work > > appropriately on some systems. > > > > However, after platform_finish() has been executed, the ACPI firmware will > > assume that the hibernation has been canceled, so you need to tell it that > > you'd like to go into the low power state after all. > > > > > device_resume(); > > > resume_console(); > > > /* write the image */ > > > > For this reason, you have to call hibernation_ops->start() once again > > and the other functions like in the swsusp case, in that order. > > > > > suspend_console(); > > > device_suspend(PMSG_FREEZE); > > > disable_nonboot_cpus(); > > > local_irq_disable(); > > > device_power_down(PMSG_FREEZE); > > > /* jump to original (hibernated) kernel */ > > > > This looks too fragile to my eyes. > > > > Why don't you call hibernation_ops->enter() directly from the "kexeced" kernel? > > I don't know whether there are ACPI global state inside Linux kernel. So > I restrict all ACPI method calling in original kernel. If the ACPI > global state in Linux kernel is not a issue, I can call > hibernation_ops->enter() directly in the "kexeced" kernel. Well, I can't say to what extent the Linux ACPI tracks the global state. Still, even if it does, you don't need to jump back to the hibernated kernel just to power off the system. Actually, if you really want to include ACPI into the picture, which I'm not sure is the best idea at this point, you should use all of the appropriate ACPI hooks in the kexeced kernel and you shouldn't get back to the hibernated kernel after you've saved the image. Regards, Rafael - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/