From patchwork Wed Dec 4 15:06:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 3282891 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4CA45C0D4A for ; Wed, 4 Dec 2013 15:07:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 204DB204D6 for ; Wed, 4 Dec 2013 15:07:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B3CC22041D for ; Wed, 4 Dec 2013 15:07:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932472Ab3LDPHo (ORCPT ); Wed, 4 Dec 2013 10:07:44 -0500 Received: from canardo.mork.no ([148.122.252.1]:54396 "EHLO canardo.mork.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932178Ab3LDPHo (ORCPT ); Wed, 4 Dec 2013 10:07:44 -0500 Received: from nemi.mork.no (ip6-localhost [IPv6:::1]) by canardo.mork.no (8.14.4/8.14.4) with ESMTP id rB4F7VIH000502 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Wed, 4 Dec 2013 16:07:32 +0100 Received: from bjorn by nemi.mork.no with local (Exim 4.80) (envelope-from ) id 1VoE2Y-0001g1-3Z; Wed, 04 Dec 2013 16:07:02 +0100 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= To: linux-pm@vger.kernel.org Cc: Pavel Machek , "Rafael J. Wysocki" , cpufreq@vger.kernel.org, =?UTF-8?q?Bj=C3=B8rn=20Mork?= Subject: [RFC] PM / hibernate: Call platform_leave in suspend path too Date: Wed, 4 Dec 2013 16:06:58 +0100 Message-Id: <1386169618-6417-1-git-send-email-bjorn@mork.no> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: clamav-milter 0.97.8 at canardo X-Virus-Status: Clean Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The system can continue running after the image is created, for example because userspace cancelled the hibernation or only saved the image for a dual mode disk + ram suspend. We must restore the platform to the pre_snapshot state in this case. This fixes a long standing bug in the acpi_cpufreq driver which would fail after a cancelled hibernate because the system then was running with the EC blocked: cpufreq: adding CPU 1 acpi_cpufreq_cpu_init cpufreq: FREQ: 1401000 - CPU: 0 ACPI Exception: AE_BAD_PARAMETER, Returned by Handler for [EmbeddedControl] (20130725/evregion-287) ACPI Error: Method parse/execution failed [\_SB_.PCI0.LPC_.EC__.LPMD] (Node ffff88023249ab28), AE_BAD_PARAMETER (20130725/psparse-536) ACPI Error: Method parse/execution failed [\_PR_.CPU0._PPC] (Node ffff88023270e3f8), AE_BAD_PARAMETER (20130725/psparse-536) ACPI Error: Method parse/execution failed [\_PR_.CPU1._PPC] (Node ffff88023270e290), AE_BAD_PARAMETER (20130725/psparse-536) ACPI Exception: AE_BAD_PARAMETER, Evaluating _PPC (20130725/processor_perflib-140) cpufreq: initialization failed CPU1 is up Signed-off-by: Bjørn Mork --- This is posted as RFC because I am unsure whether this is the correct way to fix the problem. We definitely need to undo some of the pre_snapshot work to have a fully functional system when create_image returns, but I guess there can be unwanted side effects of unconditionally calling platform_leave() like this. FWIW, this works for me. Testing and verifying the original acpi_cpufreq problem should be easy on any system using that driver and having an EC, which should include most laptops: - Start a userspace hibernation and cancel it, for example by using s2disk from uswsusp and pressing backspace. The cpufreq device will disappear from all non-boot cores, and the above ACPI exceptions will be logged. Comments and/or alternative solutions are appreciated. Note that the final solution to this problem should be backported to all maintained stable kernels. I've verified that the problem exists and that this proposed patch applies to 3.2, 3.4, 3.10 and 3.12 Bjørn kernel/power/hibernate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 0121dab83f43..59fb7e82f818 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -293,10 +293,10 @@ static int create_image(int platform_mode) error); /* Restore control flow magically appears here */ restore_processor_state(); - if (!in_suspend) { + if (!in_suspend) events_check_enabled = false; - platform_leave(platform_mode); - } + + platform_leave(platform_mode); Power_up: syscore_resume();