From patchwork Wed Mar 11 17:53:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kapileshwar Singh X-Patchwork-Id: 5988081 X-Patchwork-Delegate: eduardo.valentin@ti.com 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2AE32BF910 for ; Wed, 11 Mar 2015 17:53:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6AC5B20395 for ; Wed, 11 Mar 2015 17:53:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 78F70203B0 for ; Wed, 11 Mar 2015 17:53:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752039AbbCKRxs (ORCPT ); Wed, 11 Mar 2015 13:53:48 -0400 Received: from service87.mimecast.com ([91.220.42.44]:37281 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751639AbbCKRxr (ORCPT ); Wed, 11 Mar 2015 13:53:47 -0400 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by service87.mimecast.com; Wed, 11 Mar 2015 17:53:45 +0000 Received: from e105702-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 11 Mar 2015 17:53:43 +0000 From: Kapileshwar Singh To: linux-pm@vger.kernel.org Cc: edubezval@gmail.com, rui.zhang@intel.com, Javi.Merino@arm.com, Punit.Agrawal@arm.com, kapileshwar.singh@arm.com Subject: [PATCH 2/2] thermal: cpu_cooling: Fix power calculation when CPUs are offline Date: Wed, 11 Mar 2015 17:53:37 +0000 Message-Id: <1426096417-27522-3-git-send-email-kapileshwar.singh@arm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1426096417-27522-1-git-send-email-kapileshwar.singh@arm.com> References: <1426096417-27522-1-git-send-email-kapileshwar.singh@arm.com> X-OriginalArrivalTime: 11 Mar 2015 17:53:43.0966 (UTC) FILETIME=[50E753E0:01D05C24] X-MC-Unique: 115031117534509801 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 Ensure that the CPU for which the frequency is being requested is online. If none of the CPUs are online the requested power is returned as 0. Acked-by: Javi Merino Signed-off-by: Kapileshwar Singh --- drivers/thermal/cpu_cooling.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 2e15133b4793..07a9629edf4b 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -555,7 +555,18 @@ static int cpufreq_get_requested_power(struct thermal_cooling_device *cdev, struct cpufreq_cooling_device *cpufreq_device = cdev->devdata; u32 *load_cpu = NULL; - freq = cpufreq_quick_get(cpumask_any(&cpufreq_device->allowed_cpus)); + cpu = cpumask_any_and(&cpufreq_device->allowed_cpus, cpu_online_mask); + + /* + * All the CPUs are offline, thus the requested power by + * the cdev is 0 + */ + if (cpu >= nr_cpu_ids) { + *power = 0; + return 0; + } + + freq = cpufreq_quick_get(cpu); if (trace_thermal_power_cpu_get_power_enabled()) { u32 ncpus = cpumask_weight(&cpufreq_device->allowed_cpus);