Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5328611ybv; Tue, 11 Feb 2020 13:36:53 -0800 (PST) X-Google-Smtp-Source: APXvYqwuoH8DZO+MU9vznd4QNUcH17FzKmGYKDujB9AceDNE3yOzygsGh9TchHrY23GcxIu4x12S X-Received: by 2002:a05:6830:1251:: with SMTP id s17mr6750800otp.108.1581457013817; Tue, 11 Feb 2020 13:36:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581457013; cv=none; d=google.com; s=arc-20160816; b=h1U3fI8DNKPHSb49dwfpoVr/NjaVfIP+6UIQUgY4JJDkJ1Rpct+wT+V6xbGFh0bfLB U2d+K4DXFzmryX1z7o10FLxKdrBg3qnwmvl2/VfoZZ/qe0mRpflERsLjqW9crAUVj2TS f5EjiXjI6qViOp3G6bgoOSDXVZt0pu4zA7FzSPlrXK0BnNWkc4yIRPI/1+NNhcMt211G zJii8CNKo7ovD6aISYLlBrANnhwTCmA+qsBHisKS9kHtqtsMhukPirYxS1yyqIdbtqD0 aFaCLyb3DdFKyv9NwbiVxIH73YzWTrc3XQ5pzfUTGLU154VYHsQMz8pVPlgnm7jjyvZg webA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=+wXhzUWHOptbbYFBFTb59KlzaMvKl9wiec3u7JC1R5Q=; b=cygPUREh4Z2yiMfNbGgnVtCiS0rXHkWKKl2HUKY28g7AT/LKmyxajfuMgMzMzCWY7v xv+t/DEH2dvKEcLR2hT//2RwGJQ22HVlTVB1ekRKem3SqedT1Dkm0CZ6DpJzoI/uwQIC 4D6QSuIn2I6W4AVl2Tu9+i5EAXQibrtcX/Q94uziIWWtiQugNb/Q4B7jTMuAxCN5HFdq 8ZRi7n/AukE/QN/kmm4Zwvfx7XIbZVxOpid3h4OoU/sWoj+s0Ege2SdMk21mzXqJ5gJw McKRAtWe49X549gP3tnUZF2K3ch/2AtaBskFqcZTkspOmoi6XCe6QIs/FHskQEoiVqWW QsvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p19si2630692otk.251.2020.02.11.13.36.41; Tue, 11 Feb 2020 13:36:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731505AbgBKSqi (ORCPT + 99 others); Tue, 11 Feb 2020 13:46:38 -0500 Received: from foss.arm.com ([217.140.110.172]:52406 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727958AbgBKSqh (ORCPT ); Tue, 11 Feb 2020 13:46:37 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D37FB30E; Tue, 11 Feb 2020 10:46:36 -0800 (PST) Received: from e108754-lin.cambridge.arm.com (e108754-lin.cambridge.arm.com [10.1.198.52]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A4BC73F68F; Tue, 11 Feb 2020 10:46:34 -0800 (PST) From: Ionela Voinescu To: catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, maz@kernel.org, suzuki.poulose@arm.com, sudeep.holla@arm.com, lukasz.luba@arm.com, valentin.schneider@arm.com, rjw@rjwysocki.net, ionela.voinescu@arm.com Cc: peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, viresh.kumar@linaro.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH v3 5/7] cpufreq: add function to get the hardware max frequency Date: Tue, 11 Feb 2020 18:45:40 +0000 Message-Id: <20200211184542.29585-6-ionela.voinescu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200211184542.29585-1-ionela.voinescu@arm.com> References: <20200211184542.29585-1-ionela.voinescu@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add weak function to return the hardware maximum frequency of a CPU, with the default implementation returning cpuinfo.max_freq. The default can be overwritten by a strong function in platforms that want to provide an alternative implementation. Signed-off-by: Ionela Voinescu Cc: Rafael J. Wysocki Cc: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 20 ++++++++++++++++++++ include/linux/cpufreq.h | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 77114a3897fb..d2ff3018861d 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1733,6 +1733,26 @@ unsigned int cpufreq_quick_get_max(unsigned int cpu) } EXPORT_SYMBOL(cpufreq_quick_get_max); +/** + * cpufreq_get_hw_max_freq - get the max hardware frequency of the CPU + * @cpu: CPU number + * + * The default return value is the max_freq field of cpuinfo. + */ +__weak unsigned int cpufreq_get_hw_max_freq(unsigned int cpu) +{ + struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); + unsigned int ret_freq = 0; + + if (policy) { + ret_freq = policy->cpuinfo.max_freq; + cpufreq_cpu_put(policy); + } + + return ret_freq; +} +EXPORT_SYMBOL(cpufreq_get_hw_max_freq); + static unsigned int __cpufreq_get(struct cpufreq_policy *policy) { if (unlikely(policy_is_inactive(policy))) diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 31b1b0e03df8..b4423ff619f4 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -194,6 +194,7 @@ extern struct kobject *cpufreq_global_kobject; unsigned int cpufreq_get(unsigned int cpu); unsigned int cpufreq_quick_get(unsigned int cpu); unsigned int cpufreq_quick_get_max(unsigned int cpu); +unsigned int cpufreq_get_hw_max_freq(unsigned int cpu); void disable_cpufreq(void); u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy); @@ -223,6 +224,10 @@ static inline unsigned int cpufreq_quick_get_max(unsigned int cpu) { return 0; } +static inline unsigned int cpufreq_get_hw_max_freq(unsigned int cpu) +{ + return 0; +} static inline void disable_cpufreq(void) { } #endif -- 2.17.1