From patchwork Thu Apr 2 04:51:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 46699 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 069922159A for ; Thu, 2 Apr 2015 04:51:55 +0000 (UTC) Received: by lbfb1 with SMTP id b1sf14732432lbf.2 for ; Wed, 01 Apr 2015 21:51:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=y6Pz26NMEkXYnRsycChat3JH7gDqlMEDLQSHzVMnNi0=; b=Qfe5WrtLEMVS6n647jt+a+SIuRiX0fp+sS37PXq9kEMQJaJeocsl8ZfNww9FPt/RKV Fc6OHA+goia3629h1oPbK7l1LrAKd5q68S6GAFdHLmn13lPTnByVt1tgTJmKO+hVuPdQ iFqVhwPMY3TZjzq5YK5FaNYyaEy5M/8S7zEy7zmyPS24/tIf17OLgI/uHHG9+gZiS001 6HPkGng+hLtTFjTyQKptajrZIK7dKrs+bRpo/1N6FQiBcuvdnQ/6n+XweamlTtGPEIoj crl6MPV5haMACZcGjlL9yD3UAkpK6sGu8YUdcGQjrXHUDKgbpz7kgcS0TxvEGY1tLi14 IH0A== X-Gm-Message-State: ALoCoQluhE5sDFk8DryPwQ79nP94+9QuHI8IOB0Qa6VOgdlZUG8dnAYMvkf6BfzEhZVljDcdVzHl X-Received: by 10.152.5.168 with SMTP id t8mr3153687lat.3.1427950313602; Wed, 01 Apr 2015 21:51:53 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.5.2 with SMTP id ci2ls146687lad.38.gmail; Wed, 01 Apr 2015 21:51:53 -0700 (PDT) X-Received: by 10.112.64.137 with SMTP id o9mr38739141lbs.15.1427950313382; Wed, 01 Apr 2015 21:51:53 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id yb1si3266492lbc.28.2015.04.01.21.51.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 21:51:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by labe2 with SMTP id e2so51910600lab.3 for ; Wed, 01 Apr 2015 21:51:53 -0700 (PDT) X-Received: by 10.112.46.74 with SMTP id t10mr12152044lbm.73.1427950313223; Wed, 01 Apr 2015 21:51:53 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.57.201 with SMTP id k9csp1091110lbq; Wed, 1 Apr 2015 21:51:52 -0700 (PDT) X-Received: by 10.68.253.226 with SMTP id ad2mr83065093pbd.98.1427950311133; Wed, 01 Apr 2015 21:51:51 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si5763478pap.185.2015.04.01.21.51.50; Wed, 01 Apr 2015 21:51:51 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751027AbbDBEvr (ORCPT + 1 other); Thu, 2 Apr 2015 00:51:47 -0400 Received: from mail-pd0-f179.google.com ([209.85.192.179]:35513 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750747AbbDBEvr (ORCPT ); Thu, 2 Apr 2015 00:51:47 -0400 Received: by pddn5 with SMTP id n5so77386506pdd.2 for ; Wed, 01 Apr 2015 21:51:46 -0700 (PDT) X-Received: by 10.68.238.200 with SMTP id vm8mr51386746pbc.15.1427950306695; Wed, 01 Apr 2015 21:51:46 -0700 (PDT) Received: from localhost ([122.167.118.120]) by mx.google.com with ESMTPSA id t5sm3747588pde.51.2015.04.01.21.51.45 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 01 Apr 2015 21:51:45 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, skannan@codeaurora.org, Viresh Kumar , "3.15+" Subject: [PATCH] cpufreq: Schedule work for the first-online CPU on resume Date: Thu, 2 Apr 2015 10:21:33 +0530 Message-Id: <9775122d957a0cd594cfc43b2d81ebbf78e6dc2f.1427950272.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.3.0.rc0.44.ga94655d Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , All CPUs leaving the first-online CPU are hotplugged out on suspend and and cpufreq core stops managing them. On resume, we need to call cpufreq_update_policy() for this CPU's policy to make sure its frequency is in sync with cpufreq's cached value, as it might have got updated by hardware during suspend/resume. The policies are always added to the top of the policy-list. So, in normal circumstances, CPU 0's policy will be the last one in the list. And so the code checks for the last policy. But there are cases where it will fail. Consider quad-core system, with policy-per core. If CPU0 is hotplugged out and added back again, the last policy will be on CPU1 :( To fix this in a proper way, always look for the policy of the first online CPU. That way we will be sure that we are calling cpufreq_update_policy() for the only CPU that wasn't hotplugged out. Cc: 3.15+ # 3.15+ Fixes: 2f0aea936360 ("cpufreq: suspend governors on system suspend/hibernate") Signed-off-by: Viresh Kumar Reported-by: Saravana Kannan --- drivers/cpufreq/cpufreq.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 28e59a48b35f..8ae655c364f4 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1698,15 +1698,18 @@ void cpufreq_resume(void) || __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS)) pr_err("%s: Failed to start governor for policy: %p\n", __func__, policy); - - /* - * schedule call cpufreq_update_policy() for boot CPU, i.e. last - * policy in list. It will verify that the current freq is in - * sync with what we believe it to be. - */ - if (list_is_last(&policy->policy_list, &cpufreq_policy_list)) - schedule_work(&policy->update); } + + /* + * schedule call cpufreq_update_policy() for first-online CPU, as that + * wouldn't be hotplugged-out on suspend. It will verify that the + * current freq is in sync with what we believe it to be. + */ + policy = cpufreq_cpu_get_raw(cpumask_first(cpu_online_mask)); + if (WARN_ON(!policy)) + return; + + schedule_work(&policy->update); } /**