From patchwork Thu Mar 16 05:29:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 95386 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp661236qgd; Wed, 15 Mar 2017 22:32:31 -0700 (PDT) X-Received: by 10.98.72.88 with SMTP id v85mr7920099pfa.99.1489642350940; Wed, 15 Mar 2017 22:32:30 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k80si2958658pfk.272.2017.03.15.22.32.30; Wed, 15 Mar 2017 22:32:30 -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 S1751667AbdCPFak (ORCPT + 13 others); Thu, 16 Mar 2017 01:30:40 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:35907 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751638AbdCPFaf (ORCPT ); Thu, 16 Mar 2017 01:30:35 -0400 Received: by mail-pf0-f172.google.com with SMTP id o126so18994103pfb.3 for ; Wed, 15 Mar 2017 22:30:34 -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=W4mXduu0wjv/eACg7byHuaSvBsKv+IC/7961nKcsOFk=; b=Cm7ixbPHscQQ3m6r0jtzaVamO1Js6ORicDIqpyEPjAUwvTjjOus1BznGOXWToJdtj0 PYUqYsEYj8F5RIcpzogsxcIwjYG0VZqLVDNTgowhB+I0ehsjebj1oAid1IBWKZ8JnpTu O7IkaM2qynJgRGrqHYLjuKKfJFW1UpYip1bHU= 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=W4mXduu0wjv/eACg7byHuaSvBsKv+IC/7961nKcsOFk=; b=EX5SO7YEGbRCH22LfpSr6DlWNKArEQoGIBZ8wSCQZTEZgnjgA7F0as+t74B6uYQXc+ ao0N+CLTrUOGhc8zVVPTc196pfDB3hCTYi93HeIwtPjAnakeP+Adr8jQdvv5mKOZ4OrA 2YJXhu9HwL3CV/nDE8fJ8qb/+nTThZihXqFEJ3UNjdsPqiIH2Mc6UxaqpVt67O/vHicp NkkvoH2lhlvifD5wbTsP2qudEjBJF5Sae9oj1/tVohB25QJOjCH6rkNywFb4/A9zryFS kl27vS8KJIOiNdAEIu1c2QGvdAOJ3M/+DMciiwBzx7aUJNyu1AynXiyLrS8M5XSif/sM OkuQ== X-Gm-Message-State: AFeK/H0B6Gbq1t0daoZuTdnmNM/TFZFWBvrXWCsStiRkw/HhyiSUNVNkcAdGbxMIz/G8wgzt X-Received: by 10.98.103.146 with SMTP id t18mr8173273pfj.135.1489642229029; Wed, 15 Mar 2017 22:30:29 -0700 (PDT) Received: from localhost ([122.171.239.200]) by smtp.gmail.com with ESMTPSA id b8sm7500214pgn.6.2017.03.15.22.30.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 22:30:28 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Javi Merino , Zhang Rui , Eduardo Valentin , Amit Daniel Kachhap , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot Subject: [PATCH 10/17] thermal: cpu_cooling: OPPs are registered for all CPUs Date: Thu, 16 Mar 2017 10:59:45 +0530 Message-Id: <7a99a212c7c7b4a0b8ce9cc723bb2f16b7ef0962.1489640000.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b 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.7.1.410.g6faf27b diff --git a/drivers/thermal/cpu_cooling.c b/drivers/thermal/cpu_cooling.c index 7590279bf1de..1df6c9039e45 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 @@ -208,24 +208,20 @@ static int build_dyn_power_table(struct cpufreq_cooling_device *cpufreq_dev, 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_dev->policy->cpu, i, ret = 0; unsigned long freq; - for_each_cpu(cpu, &cpufreq_dev->allowed_cpus) { - dev = get_cpu_device(cpu); - if (!dev) { - dev_warn(&cpufreq_dev->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_dev->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;