From patchwork Thu Apr 23 19:00:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 47475 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 8AB572121F for ; Thu, 23 Apr 2015 19:03:53 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf6535502lbb.0 for ; Thu, 23 Apr 2015 12:03:52 -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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=/ymmKg6pvDtUKH+yX/7UJy/LTPDlkkv+VX8sawWJMH4=; b=dU6RETm3XeNa84FFK2Dj9C14Fu+O20DrVPUeaU6IaMkE/r+a3mGj6WUKdQvw6XSFvh amyzIxPEi8C5pQbTYQZitC1zGLgVLoHZltJHGIPr/vaE0PJJQmnewo4TvsflRA9ynmuh HTTsLkF54ulBTPhV4GiAXuv/Aw1Nm6XAv4ctm7GeFn4kK40nAkEZm/zKqFwwdcj9WSfb O+arPtfCVkftBYWuj96s8VUmSKhDsdHI26YKah8TJkVxMaq2UdYBOuXsdLMrgyDtuw1V rpSTeRPmLncuk24AkkTvKkAN+4ooE6vf/TxGouwIweJsENKwrF/pZRBpKD2GTZjiJ62z GiAg== X-Gm-Message-State: ALoCoQmX8uoB5dO4x2CD3htCWFAFWvb7Y2QbYsgDAvNhcQTF3iB5DJW4CW8KGPWPMwv9hwy6NAn0 X-Received: by 10.112.46.172 with SMTP id w12mr2146180lbm.18.1429815832551; Thu, 23 Apr 2015 12:03:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.7 with SMTP id w7ls369793law.96.gmail; Thu, 23 Apr 2015 12:03:52 -0700 (PDT) X-Received: by 10.112.35.230 with SMTP id l6mr3759964lbj.5.1429815832439; Thu, 23 Apr 2015 12:03:52 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id qf3si6571183lbb.143.2015.04.23.12.03.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 12:03:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by lagv1 with SMTP id v1so19669507lag.3 for ; Thu, 23 Apr 2015 12:03:52 -0700 (PDT) X-Received: by 10.152.19.199 with SMTP id h7mr3904460lae.32.1429815832291; Thu, 23 Apr 2015 12:03:52 -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.67.65 with SMTP id l1csp755440lbt; Thu, 23 Apr 2015 12:03:51 -0700 (PDT) X-Received: by 10.70.49.229 with SMTP id x5mr7810455pdn.81.1429815807076; Thu, 23 Apr 2015 12:03:27 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ek14si11302185pac.239.2015.04.23.12.03.26; Thu, 23 Apr 2015 12:03:27 -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 S1030898AbbDWTCN (ORCPT + 2 others); Thu, 23 Apr 2015 15:02:13 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:39580 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030843AbbDWTCI (ORCPT ); Thu, 23 Apr 2015 15:02:08 -0400 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t3NJ26I8028384 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 23 Apr 2015 19:02:06 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t3NJ25Tf021128 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Thu, 23 Apr 2015 19:02:05 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t3NJ25tE014406; Thu, 23 Apr 2015 19:02:05 GMT Received: from lappy.hsd1.nh.comcast.net (/10.154.104.217) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 23 Apr 2015 12:02:04 -0700 From: Sasha Levin To: stable@vger.kernel.org, stable-commits@vger.kernel.org Cc: Viresh Kumar , "Rafael J. Wysocki" , Sasha Levin Subject: [added to the 3.18 stable tree] cpufreq: Schedule work for the first-online CPU on resume Date: Thu, 23 Apr 2015 15:00:18 -0400 Message-Id: <1429815663-25702-42-git-send-email-sasha.levin@oracle.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1429815663-25702-1-git-send-email-sasha.levin@oracle.com> References: <1429815663-25702-1-git-send-email-sasha.levin@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] 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: patch@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.44 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: , From: Viresh Kumar This patch has been added to the 3.18 stable tree. If you have any objections, please let us know. =============== [ Upstream commit c75de0ac0756d4b442f460e10461720c7c2412c2 ] 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") Reported-by: Saravana Kannan Signed-off-by: Viresh Kumar Acked-by: Saravana Kannan Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- 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 e3bf702..90e8deb 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1717,15 +1717,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); } /**