From patchwork Thu Jul 21 21:23:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 72589 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp663376qga; Thu, 21 Jul 2016 14:23:41 -0700 (PDT) X-Received: by 10.98.12.18 with SMTP id u18mr534624pfi.89.1469136221694; Thu, 21 Jul 2016 14:23:41 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u3si11728116pab.162.2016.07.21.14.23.41; Thu, 21 Jul 2016 14:23:41 -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=neutral (body hash did not verify) 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=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754724AbcGUVXj (ORCPT + 14 others); Thu, 21 Jul 2016 17:23:39 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:34206 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754415AbcGUVXi (ORCPT ); Thu, 21 Jul 2016 17:23:38 -0400 Received: by mail-pa0-f52.google.com with SMTP id fi15so32520529pac.1 for ; Thu, 21 Jul 2016 14:23:38 -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; bh=ZvfNfbWsSltNH3Txp8GzaXy36/zm4HK04M9M/ZfkoXI=; b=Jysd4YNbrdDDDFKkMi+omp8sLTLmA2/Hm8YxE13mjQ/q5c918rGiNYVAsNCU0Vo8oe 2zRNUzHkGJj0XrphOgRJ4Ev8l41CQmV1u/om7BalpC7CiCyvnT7RZa6OYVJ5lUP1cbaZ RVOyCjOdxkBobxUb0BbcU9yyrS4MbT6OaXhwE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZvfNfbWsSltNH3Txp8GzaXy36/zm4HK04M9M/ZfkoXI=; b=g9EDKitSlOUhRQZIGYiQmXr6oIsEYqs49Xa2QSuQblL9OToT5X1I1hB0mDg3NsbMMp 7vIgqEeWy4si7zAicC3CWbNZ0QLHIfQFNjuHg2XLXqrePzEHI5phK5aPhNAS/pXaHt7f gEaret2xQRV5ojhVpsuHnTWVbgtsUziXeqMPH/Qhc+WPy4X1ae3AU6HdDkEN+/inRCRn GLKN1aSBNXlHVo1VeR7QJRWEmoS2f6ZSlxkRYOC1LpBoS3UwIBr8G6/54SLfa2QeexRm 1z9RqBmxJQsH2NuKfR2+Qnzmi9jYwNFRJlplt5TK2LavDZD7+rxjm69pw8ob7kNpiOwH p7Vw== X-Gm-Message-State: AEkoouuwUD8BdCP7UFiRtihWL+zU7cuUQuIbnx7lKi/WhXnIC1gYLMGPR5hX19P61mmCAjwX X-Received: by 10.66.7.199 with SMTP id l7mr555679paa.136.1469136217689; Thu, 21 Jul 2016 14:23:37 -0700 (PDT) Received: from localhost ([104.132.1.108]) by smtp.gmail.com with ESMTPSA id u1sm14469310pfu.12.2016.07.21.14.23.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jul 2016 14:23:36 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, steve.muckle@linaro.org, peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, morten.rasmussen@arm.com, dietmar.eggemann@arm.com, Juri.Lelli@arm.com, patrick.bellasi@arm.com Subject: [PATCH] cpufreq: Disallow ->resolve_freq() for drivers providing ->target_index() Date: Thu, 21 Jul 2016 14:23:30 -0700 Message-Id: X-Mailer: git-send-email 2.7.4 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The handlers provided by cpufreq core are sufficient for resolving the frequency for drivers providing ->target_index(), as the core already has the frequency table and so ->resolve_freq() isn't required for such platforms. This patch disallows drivers with ->target_index() callback to use the ->resolve_freq() callback. Also, it fixes a potential kernel crash for drivers providing ->target() but no ->resolve_freq(). Fixes: e3c062360870 ("cpufreq: add cpufreq_driver_resolve_freq()") Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index b696baeb249d..342bbee8d0e1 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -507,12 +507,20 @@ unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy, { target_freq = clamp_val(target_freq, policy->min, policy->max); policy->cached_target_freq = target_freq; + + if (cpufreq_driver->target_index) { + int idx; + + idx = cpufreq_frequency_table_target(policy, target_freq, + CPUFREQ_RELATION_L); + policy->cached_resolved_idx = idx; + return policy->freq_table[idx].frequency; + } + if (cpufreq_driver->resolve_freq) return cpufreq_driver->resolve_freq(policy, target_freq); - policy->cached_resolved_idx = - cpufreq_frequency_table_target(policy, target_freq, - CPUFREQ_RELATION_L); - return policy->freq_table[policy->cached_resolved_idx].frequency; + + return UINT_MAX; } /*********************************************************************