From patchwork Mon Apr 17 06:01:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 97500 Delivered-To: patch@linaro.org Received: by 10.140.109.52 with SMTP id k49csp1212659qgf; Sun, 16 Apr 2017 23:03:32 -0700 (PDT) X-Received: by 10.84.225.129 with SMTP id u1mr13572160plj.123.1492409011972; Sun, 16 Apr 2017 23:03:31 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5si10024993plt.253.2017.04.16.23.03.31; Sun, 16 Apr 2017 23:03:31 -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 S932968AbdDQGDZ (ORCPT + 12 others); Mon, 17 Apr 2017 02:03:25 -0400 Received: from mail-pg0-f48.google.com ([74.125.83.48]:33752 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932961AbdDQGDW (ORCPT ); Mon, 17 Apr 2017 02:03:22 -0400 Received: by mail-pg0-f48.google.com with SMTP id 63so7465797pgh.0 for ; Sun, 16 Apr 2017 23:03:21 -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=uTyV3zKwtfiKGloebR8qhIzsNQawmYQUjzmaGDwWons=; b=AOwH7qvAGvhD/+M6X3z8Xzvu21TH26aejQMXut/Qx+vgQoTcDL0SOwO6HanWdevwwf 061CIPrkBuHVk9GYC1zm666aakD3x06FgIPqUnBntAgBluAVa44fFvDClHMrJ9l0ZbcU nG4MDLaLeFnfNEx9BOPk/QkH6LmJWzOpux8l8= 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=uTyV3zKwtfiKGloebR8qhIzsNQawmYQUjzmaGDwWons=; b=mwYb+WV0ZvvE4blESV00n2qP1tlMX4RxDQB4nTkQF/FCGEGrEaqDmg0RXQ/TPlDxj8 QpaV38LpU9LVpByr7SNexsEMZexM8/rXxHKiwMRZUchpaJn3KhYUDlrbayq5Az0U6zYc Mbbu7ZJFuzOVEAYgaiOTIht8GVLxyTSOrNJ+dds+n3QZLW3QOiGd7HtQFfnHP8SbNK7f 6d/VJ2AjPCOcIAk7RwZKxVxsg/ukq5AagbKlyMzsrAsucAO92Mg2qR7+pGISr0q5u5B0 VCoyHhNfu9hJR+M+iyTClJUJypZ+xDtI7JR+gHrXFKPTmtvBqR+RackEX9gqilmhgfin lLwg== X-Gm-Message-State: AN3rC/4BO/34evgaVU2+KG3XcnlqpUT4M8Tx9onfTricGPw/4lFUGY3d 204mvf4Hof3hWqqe X-Received: by 10.98.42.14 with SMTP id q14mr9905392pfq.229.1492408996426; Sun, 16 Apr 2017 23:03:16 -0700 (PDT) Received: from localhost ([122.172.121.5]) by smtp.gmail.com with ESMTPSA id o1sm15268691pfb.122.2017.04.16.23.03.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Apr 2017 23:03:15 -0700 (PDT) From: Viresh Kumar To: Javi Merino , Zhang Rui , Eduardo Valentin , 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 Subject: [PATCH V2 10/17] thermal: cpu_cooling: OPPs are registered for all CPUs Date: Mon, 17 Apr 2017 11:31:55 +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 --- 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 bc018c628c93..3c6b63e7a257 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;