Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5461369ybf; Thu, 5 Mar 2020 01:09:01 -0800 (PST) X-Google-Smtp-Source: ADFU+vswf3FUqHhNV7F1MPwyborb3f+kyFxUbL9cBoOM6vk9DsCfZDMy6tqxY3kKiCoccZuHhB13 X-Received: by 2002:a9d:7617:: with SMTP id k23mr5551346otl.329.1583399340926; Thu, 05 Mar 2020 01:09:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583399340; cv=none; d=google.com; s=arc-20160816; b=OUjPo0XXxDG5u045YOvUuDVNQevFGSQCyt2SSjLsNH9O/Fa30NGZ/tifc9sEfntzDC u20yJm0nsX9JiVchZyCXlnLBF1HbyJaMT9MZxocxez8WDDFnVj7+P8QBa4DRqMGDNz2f CwjotUdTJ2yX9pY4GtvLlsMEE9LnmvCGgLmEYALXn63aeHl2RxfR40EP2F/A1RmGR8LI zS3zzWbOpCMO4LGUMln/BNQrmFS832znLafsGV95aWuCldMkEne4/tSP64Q9vayS+Vzw JSdV0t2Bp97nGXSs591L8TRQP1cvXFarh84IWnRIFUFqrZIDJeaevdK6eYB/qY4ruJcw fr/Q== 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=0A0UNKAR4JNz/57XVifCKG/fRkfA+4HWRIv0G1T1zLc=; b=J3RzCON3237uEXasiJR47vvYLJZircGWoe/JIafPvN5G6jY1jhv4Lp9g1Vx3TIRoSP YKZeqFKyJFwb3Z7IAY4fCy101TIh3v3E6URYLkeTpkOjj7+aHgyipoi4SvdFLU/09KH9 uMQrcQedZ01tPu+Kt9RKiXLchhjyz58CVBQhv0SWt59EZGXnGW+Zd5kLumsx7a5Rk/PV enQo/QTTHUrxpyz4MmypvQl742rtfMUKArwgUWeBfnEQ30eXteFCTeKWECGbn0PJM/a0 42kk5KpoP9Lzz0VIh02yjgdVZVox5ULXaZjZriz8ooBw6Tqak21fjBcGeUqUh3uprk42 pAvg== 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 s64si3096221oig.147.2020.03.05.01.08.49; Thu, 05 Mar 2020 01:09:00 -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 S1727067AbgCEJHN (ORCPT + 99 others); Thu, 5 Mar 2020 04:07:13 -0500 Received: from foss.arm.com ([217.140.110.172]:45200 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725880AbgCEJHM (ORCPT ); Thu, 5 Mar 2020 04:07:12 -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 C65C04B2; Thu, 5 Mar 2020 01:07:11 -0800 (PST) Received: from e108754-lin.cambridge.arm.com (e108754-lin.cambridge.arm.com [10.1.198.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 325343F534; Thu, 5 Mar 2020 01:07:09 -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, dietmar.eggemann@arm.com, rjw@rjwysocki.net, pkondeti@codeaurora.org, 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 v6 5/7] cpufreq: add function to get the hardware max frequency Date: Thu, 5 Mar 2020 09:06:25 +0000 Message-Id: <20200305090627.31908-6-ionela.voinescu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200305090627.31908-1-ionela.voinescu@arm.com> References: <20200305090627.31908-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, which is the best information we can generically get from the cpufreq framework. The default can be overwritten by a strong function in platforms that want to provide an alternative implementation, with more accurate information, obtained either from hardware or firmware. Signed-off-by: Ionela Voinescu Acked-by: Viresh Kumar Reviewed-by: Valentin Schneider 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 cbe6c94bf158..985228aee46f 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1725,6 +1725,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 0fb561d1b524..f7240251a949 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -205,6 +205,7 @@ static inline bool policy_is_shared(struct cpufreq_policy *policy) 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); @@ -232,6 +233,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