From patchwork Mon May 4 02:32:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 47986 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B9CA520553 for ; Mon, 4 May 2015 02:42:01 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf38927112lbb.0 for ; Sun, 03 May 2015 19:42:00 -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: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=eprhOQxZf+pERr95q+5uieUXnZvxixrZEg7ZAVmKiEc=; b=du+JLqVy1EOoRlUg6W6grOkbSJ9kUcb0B5sAjYOLJ7bWdEKrmZaqSjytSeYJ2W+yLU g3GPBg73E4Xh1gzQ889LtaUVW6sRoBIrOnh6Vsoe6w/LJRVKRKKodCqr83mARdTaei9Q 13fHNG1IRGrYX/Gfs1Fgltws+hj+1pPPgf4kKr8gN/LhUdfkVaYxp62rPnBvzhKP2DV8 0sQuDVayU82qunNlKKptWiocPgL9NofmofW/NXg9Gh1pmZfM1d4IyMRFPanMlshNtuRN whLQlohtpSkN4IaTNgxtThS3B03C28B/ZqwjOKdOEajj3qU+RxH5I0Q85gWfqNhjXuqK EeRQ== X-Gm-Message-State: ALoCoQnOKAqdB2gJIugqWrHs7NXWGgIu13d5gHzuLf1T3JcICO6yeteZeDNx1gheM7qcOA0RkFPd X-Received: by 10.180.88.226 with SMTP id bj2mr6946722wib.7.1430707320670; Sun, 03 May 2015 19:42:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.178.164 with SMTP id cz4ls736731lac.3.gmail; Sun, 03 May 2015 19:42:00 -0700 (PDT) X-Received: by 10.152.88.80 with SMTP id be16mr13370431lab.39.1430707320543; Sun, 03 May 2015 19:42:00 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id z9si9120780laj.152.2015.05.03.19.42.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 May 2015 19:42:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by laat2 with SMTP id t2so95444351laa.1 for ; Sun, 03 May 2015 19:42:00 -0700 (PDT) X-Received: by 10.112.29.36 with SMTP id g4mr18147422lbh.56.1430707320461; Sun, 03 May 2015 19:42:00 -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 l1csp1425038lbt; Sun, 3 May 2015 19:41:59 -0700 (PDT) X-Received: by 10.66.232.70 with SMTP id tm6mr26525462pac.77.1430706902609; Sun, 03 May 2015 19:35:02 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q9si17893553pds.196.2015.05.03.19.35.01; Sun, 03 May 2015 19:35:02 -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 S1752240AbbEDCfA (ORCPT + 2 others); Sun, 3 May 2015 22:35:00 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:27175 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752153AbbEDCen (ORCPT ); Sun, 3 May 2015 22:34:43 -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 t442Ygoe010042 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 4 May 2015 02:34:43 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t442Yg6N009887 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 4 May 2015 02:34:42 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t442YgV8007357; Mon, 4 May 2015 02:34:42 GMT Received: from lappy.hsd1.nh.comcast.net (/10.154.99.237) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 03 May 2015 19:34:42 -0700 From: Sasha Levin To: stable@vger.kernel.org, stable-commits@vger.kernel.org Subject: [PATCH 3.18 044/125] cpufreq: Schedule work for the first-online CPU on resume Date: Sun, 3 May 2015 22:32:54 -0400 Message-Id: <1430706855-4311-45-git-send-email-sasha.levin@oracle.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1430706855-4311-1-git-send-email-sasha.levin@oracle.com> References: <1430706855-4311-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.53 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 [ 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); } /**