From patchwork Thu Dec 26 01:05:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 3405731 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D9F309F169 for ; Thu, 26 Dec 2013 00:52:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F1B9A2013A for ; Thu, 26 Dec 2013 00:52:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 96A5E2012E for ; Thu, 26 Dec 2013 00:52:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752465Ab3LZAwU (ORCPT ); Wed, 25 Dec 2013 19:52:20 -0500 Received: from v094114.home.net.pl ([79.96.170.134]:64650 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752442Ab3LZAwU convert rfc822-to-8bit (ORCPT ); Wed, 25 Dec 2013 19:52:20 -0500 Received: from afnb86.neoplus.adsl.tpnet.pl [178.42.79.86] (HELO vostro.rjw.lan) by serwer1319399.home.pl [79.96.170.134] with SMTP (IdeaSmtpServer v0.80) id 4e5974dfb94d5727; Thu, 26 Dec 2013 01:52:18 +0100 From: "Rafael J. Wysocki" To: Viresh Kumar , bjorn@mork.no Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] cpufreq: try to resume policies which failed on last resume Date: Thu, 26 Dec 2013 02:05:50 +0100 Message-ID: <5562479.pVWRuDL0y6@vostro.rjw.lan> User-Agent: KMail/4.10.5 (Linux/3.12.0-rc6+; KDE/4.10.5; x86_64; ; ) In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.5 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 using ClamSMTP On Tuesday, December 24, 2013 07:11:00 AM Viresh Kumar wrote: > __cpufreq_add_dev() can fail sometimes while we are resuming our system. > Currently we are clearing all sysfs nodes for cpufreq's failed policy as that > could make userspace unstable. But if we suspend/resume again, we should atleast > try to bring back those policies. > > This patch fixes this issue by clearing fallback data on failure and trying to > allocate a new struct cpufreq_policy on second resume. > > Reported-and-tested-by: Bjørn Mork > Signed-off-by: Viresh Kumar Well, while I appreciate the work done here, I don't like the changelog, I don't really like the way the code is written and I don't like the comments. Sorry about that. Bjorn, can you please test the patch below instead along with the [2/2] from this series (on top of linux-pm.git/pm-cpufreq)? Rafael Acked-by: Viresh Kumar --- From: Rafael J. Wysocki Subject: cpufreq: Clean up after a failing light-weight initialization If cpufreq_policy_restore() returns NULL during system resume, __cpufreq_add_dev() should just fall back to the full initialization instead of returning an error, because that may actually make things work. Moreover, it should not leave stale fallback data behind after it has failed to restore a previously existing policy. This change is based on Viresh Kumar's work. Reported-by: Bjørn Mork Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-pm/drivers/cpufreq/cpufreq.c =================================================================== --- linux-pm.orig/drivers/cpufreq/cpufreq.c +++ linux-pm/drivers/cpufreq/cpufreq.c @@ -1016,15 +1016,17 @@ static int __cpufreq_add_dev(struct devi read_unlock_irqrestore(&cpufreq_driver_lock, flags); #endif - if (frozen) - /* Restore the saved policy when doing light-weight init */ - policy = cpufreq_policy_restore(cpu); - else + /* + * Restore the saved policy when doing light-weight init and fall back + * to the full init if that fails. + */ + policy = frozen ? cpufreq_policy_restore(cpu) : NULL; + if (!policy) { + frozen = false; policy = cpufreq_policy_alloc(); - - if (!policy) - goto nomem_out; - + if (!policy) + goto nomem_out; + } /* * In the resume path, since we restore a saved policy, the assignment @@ -1118,8 +1120,11 @@ err_get_freq: if (cpufreq_driver->exit) cpufreq_driver->exit(policy); err_set_policy_cpu: - if (frozen) + if (frozen) { + /* Do not leave stale fallback data behind. */ + per_cpu(cpufreq_cpu_data_fallback, cpu) = NULL; cpufreq_policy_put_kobj(policy); + } cpufreq_policy_free(policy); nomem_out: