From patchwork Tue Apr 25 10:27:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 98197 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp1880763qgf; Tue, 25 Apr 2017 03:31:16 -0700 (PDT) X-Received: by 10.98.155.20 with SMTP id r20mr27851597pfd.198.1493116276557; Tue, 25 Apr 2017 03:31:16 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y12si21872879pgo.307.2017.04.25.03.31.16; Tue, 25 Apr 2017 03:31:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1428604AbdDYKbO (ORCPT + 14 others); Tue, 25 Apr 2017 06:31:14 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:35628 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1429564AbdDYK2E (ORCPT ); Tue, 25 Apr 2017 06:28:04 -0400 Received: by mail-pf0-f177.google.com with SMTP id v14so21410948pfd.2 for ; Tue, 25 Apr 2017 03:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=dNgIS0Kcp4AyWfJv7xC3w5iEImDBYg2CvLszWr7+iUQ=; b=ijAIjlHkDEB5lo/mM24N5V1hmOCFNkVFDRYSZ8m3ojKt//5rq4sz7rydQPjz1ZXAAF smwOGPqpTSqSbZdaazas9VdR0EI9f07E0JTMwBI/sULLWnfCtVlUKcy/yKNScm8Gg7P3 33yKZQ6OYQEd/kqI2YF633qDcRXqMMF1djAkc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=dNgIS0Kcp4AyWfJv7xC3w5iEImDBYg2CvLszWr7+iUQ=; b=Eh5/R+y7Bh9eDY3NQSGnpD/bXu6ql5wLlBgx9mqRLDcaNe024bvmVYTGYW2EnX10Gl 34i6FV1nMxj6Z6k0CxyW9Bn3hy/oHrPUuZlbrh5ss/ivk3xF2anp/Yykh3m2FE6u0g4C SeV1+HMe6kz7WsptSdnodakXyna245Ufj52q54gBmbBUvgtU4XbRZP7h53vZ0GAnyKvP ivLPUJQAmc0jl/zztlI74PyM1nrpT2C5a5s4nU5/oKuMyXiwXY07cWRZ6SkrWnjMqp1r WSnHYfxo6fCeuTCEKKnbB0IWA+Md1EqdOtu2eOhGNcEuh3p5tBKhljPwAa7mExKvnUmN /XJQ== X-Gm-Message-State: AN3rC/54qvYyoS9HEFgrE8TINfoT59k0wmQRrISLups2PgyTFLo4URaH H5uYK0WMZds4fkJ4 X-Received: by 10.98.84.194 with SMTP id i185mr28858892pfb.234.1493116082960; Tue, 25 Apr 2017 03:28:02 -0700 (PDT) Received: from localhost ([122.172.121.5]) by smtp.gmail.com with ESMTPSA id a77sm35757457pfe.33.2017.04.25.03.28.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Apr 2017 03:28:02 -0700 (PDT) From: Viresh Kumar To: Javi Merino , Zhang Rui , Eduardo Valentin , Lukasz Luba , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, Rafael Wysocki , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , Punit Agrawal Subject: [PATCH V4 10/17] thermal: cpu_cooling: OPPs are registered for all CPUs Date: Tue, 25 Apr 2017 15:57:17 +0530 Message-Id: X-Mailer: git-send-email 2.12.0.432.g71c3a4f4ba37 In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The OPPs are registered for all CPUs of a cpufreq policy now and we don't need to run the loop in build_dyn_power_table(). Just check for the policy->cpu and we should be fine. Signed-off-by: Viresh Kumar Tested-by: Lukasz Luba --- drivers/thermal/cpu_cooling.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) -- 2.12.0.432.g71c3a4f4ba37 diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 7dddc7443f5d..ce387f62c93e 100644 --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -83,7 +83,7 @@ struct power_table { * @dyn_power_table: array of struct power_table for frequency to power * conversion, sorted in ascending order. * @dyn_power_table_entries: number of entries in the @dyn_power_table array - * @cpu_dev: the first cpu_device from @allowed_cpus that has OPPs registered + * @cpu_dev: the cpu_device of policy->cpu. * @plat_get_static_power: callback to calculate the static power * * This structure is required for keeping information of each registered @@ -207,24 +207,20 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_cdev, struct power_table *power_table; struct dev_pm_opp *opp; struct device *dev = NULL; - int num_opps = 0, cpu, i, ret = 0; + int num_opps = 0, cpu = cpufreq_cdev->policy->cpu, i, ret = 0; unsigned long freq; - for_each_cpu(cpu, &cpufreq_cdev->allowed_cpus) { - dev = get_cpu_device(cpu); - if (!dev) { - dev_warn(&cpufreq_cdev->cdev->device, - "No cpu device for cpu %d\n", cpu); - continue; - } - - num_opps = dev_pm_opp_get_opp_count(dev); - if (num_opps > 0) - break; - else if (num_opps < 0) - return num_opps; + dev = get_cpu_device(cpu); + if (unlikely(!dev)) { + dev_warn(&cpufreq_cdev->cdev->device, + "No cpu device for cpu %d\n", cpu); + return -ENODEV; } + num_opps = dev_pm_opp_get_opp_count(dev); + if (num_opps < 0) + return num_opps; + if (num_opps == 0) return -EINVAL;