From patchwork Tue Dec 3 11:14:32 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: 3275331 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 67A97C0D4A for ; Tue, 3 Dec 2013 11:15:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9A48920373 for ; Tue, 3 Dec 2013 11:15:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7AD4320364 for ; Tue, 3 Dec 2013 11:15:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753554Ab3LCLPN (ORCPT ); Tue, 3 Dec 2013 06:15:13 -0500 Received: from canardo.mork.no ([148.122.252.1]:60678 "EHLO canardo.mork.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752726Ab3LCLPJ (ORCPT ); Tue, 3 Dec 2013 06:15:09 -0500 Received: from nemi.mork.no (ip6-localhost [IPv6:::1]) by canardo.mork.no (8.14.4/8.14.4) with ESMTP id rB3BEnSL014813 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Tue, 3 Dec 2013 12:14:50 +0100 Received: from bjorn by nemi.mork.no with local (Exim 4.80) (envelope-from ) id 1Vnnw2-0002Pi-A1; Tue, 03 Dec 2013 12:14:34 +0100 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= To: cpufreq@vger.kernel.org Cc: linux-pm@vger.kernel.org, "Srivatsa S. Bhat" , Viresh Kumar , "Rafael J. Wysocki" , =?UTF-8?q?Bj=C3=B8rn=20Mork?= Subject: [PATCH] cpufreq: fix garbage kobj on errors during suspend/resume Date: Tue, 3 Dec 2013 12:14:32 +0100 Message-Id: <1386069272-9250-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 This is effectively a revert of commit 5302c3fb2e62 ("cpufreq: Perform light-weight init/teardown during suspend/resume"), which enabled suspend/resume optimizations leaving the sysfs files in place. Errors during suspend/resume are not handled properly, leaving dead sysfs attributes in case of failures. There are are number of functions with special code for the "frozen" case, and all these need to also have special error handling. The problem is easy to demonstrate by making cpufreq_driver->init() or cpufreq_driver->get() fail during resume. The code is too complex for a simple fix, with split code paths in multiple blocks within a number of functions. It is therefore best to revert the patch enabling this code until the error handling is in place. Examples of problems resulting from resume errors: Dec 2 09:54:38 nemi kernel: [ 930.162476] ------------[ cut here ]------------ Dec 2 09:54:38 nemi kernel: [ 930.162489] WARNING: CPU: 0 PID: 6055 at fs/sysfs/file.c:343 sysfs_open_file+0x77/0x212() Dec 2 09:54:38 nemi kernel: [ 930.162493] missing sysfs attribute operations for kobject: (null) Dec 2 09:54:38 nemi kernel: [ 930.162495] Modules linked in: [stripped as irrelevant] Dec 2 09:54:38 nemi kernel: [ 930.162662] CPU: 0 PID: 6055 Comm: grep Tainted: G D 3.13.0-rc2 #153 Dec 2 09:54:38 nemi kernel: [ 930.162665] Hardware name: LENOVO 2776LEG/2776LEG, BIOS 6EET55WW (3.15 ) 12/19/2011 Dec 2 09:54:38 nemi kernel: [ 930.162668] 0000000000000009 ffff8802327ebb78 ffffffff81380b0e 0000000000000006 Dec 2 09:54:38 nemi kernel: [ 930.162676] ffff8802327ebbc8 ffff8802327ebbb8 ffffffff81038635 0000000000000000 Dec 2 09:54:38 nemi kernel: [ 930.162682] ffffffff811823c7 ffff88021a19e688 ffff88021a19e688 ffff8802302f9310 Dec 2 09:54:38 nemi kernel: [ 930.162690] Call Trace: Dec 2 09:54:38 nemi kernel: [ 930.162698] [] dump_stack+0x55/0x76 Dec 2 09:54:38 nemi kernel: [ 930.162705] [] warn_slowpath_common+0x7c/0x96 Dec 2 09:54:38 nemi kernel: [ 930.162710] [] ? sysfs_open_file+0x77/0x212 Dec 2 09:54:38 nemi kernel: [ 930.162715] [] warn_slowpath_fmt+0x41/0x43 Dec 2 09:54:38 nemi kernel: [ 930.162720] [] ? sysfs_get_active+0x6b/0x82 Dec 2 09:54:38 nemi kernel: [ 930.162725] [] ? sysfs_open_file+0x32/0x212 Dec 2 09:54:38 nemi kernel: [ 930.162730] [] sysfs_open_file+0x77/0x212 Dec 2 09:54:38 nemi kernel: [ 930.162736] [] ? sysfs_schedule_callback+0x1ac/0x1ac Dec 2 09:54:38 nemi kernel: [ 930.162742] [] do_dentry_open+0x17c/0x257 Dec 2 09:54:38 nemi kernel: [ 930.162748] [] finish_open+0x41/0x4f Dec 2 09:54:38 nemi kernel: [ 930.162754] [] do_last+0x80c/0x9ba Dec 2 09:54:38 nemi kernel: [ 930.162759] [] ? inode_permission+0x40/0x42 Dec 2 09:54:38 nemi kernel: [ 930.162764] [] path_openat+0x233/0x4a1 Dec 2 09:54:38 nemi kernel: [ 930.162770] [] do_filp_open+0x35/0x85 Dec 2 09:54:38 nemi kernel: [ 930.162776] [] ? __alloc_fd+0x172/0x184 Dec 2 09:54:38 nemi kernel: [ 930.162782] [] do_sys_open+0x6b/0xfa Dec 2 09:54:38 nemi kernel: [ 930.162787] [] SyS_openat+0xf/0x11 Dec 2 09:54:38 nemi kernel: [ 930.162794] [] system_call_fastpath+0x16/0x1b Dec 2 09:54:38 nemi kernel: [ 930.162798] ---[ end trace 48ce7fe74a95d4be ]--- The failure to restore cpufreq devices on cancelled hibernation is not a new bug. It is caused by the ACPI _PPC call failing unless the hibernate is completed. This makes the acpi_cpufreq driver fail its init. Previously, the cpufreq device could be restored by offlining the cpu temporarily. And as a complete hibernation cycle would do this, it would be automatically restored most of the time. But after commit 5302c3fb2e62 the leftover sysfs attributes will block any device add action. Therefore offlining and onlining CPU 1 will no longer restore the cpufreq object, and a complete suspend/resume cycle will replace it with garbage. Fixes: 5302c3fb2e62 ("cpufreq: Perform light-weight init/teardown during suspend/resume") Cc: # v3.12 Signed-off-by: Bjørn Mork --- drivers/cpufreq/cpufreq.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 02d534da22dd..b7c3b877da44 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2076,9 +2076,6 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb, dev = get_cpu_device(cpu); if (dev) { - if (action & CPU_TASKS_FROZEN) - frozen = true; - switch (action & ~CPU_TASKS_FROZEN) { case CPU_ONLINE: __cpufreq_add_dev(dev, NULL, frozen);