Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2488991ybv; Mon, 24 Feb 2020 06:13:29 -0800 (PST) X-Google-Smtp-Source: APXvYqyCCmsmvRkgtOeo7dVgI0b+1M+nuf1ZPxgu1QqGaWLKFe0esgYL2ufM0iuyLXHmWY2ZDhCi X-Received: by 2002:a05:6830:12d5:: with SMTP id a21mr41348459otq.296.1582553608994; Mon, 24 Feb 2020 06:13:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582553608; cv=none; d=google.com; s=arc-20160816; b=VtZMMOwa5HI+t6VBaZF3wJLHPbp2PEkhhVS18Ls+8E8eN8lzFpMdZ7dnKdHxf7H8j7 WKqWpMaHq5ez0FKX59Oj3loF87pl3awrHMsroVdc2529gUUw4dBVJQ0BWHHUiZeUkEk/ aTylWCKf+E+jIgS1tu4nYReUISly99UyasShwlLEh45uFWP30f2oeMlLkk9fONc4ey6C +PtYYk586GCvdkzYru0SV3lrDMlRnV7JovyUGN1tG4W5d2xLUZvJ1k2SMt8mwoJkuK56 ltGSLd0ISU8bOjgBgNslcPXf7rRGLwuCI0HM7sGgErHQAhL9BIGEFIuvB8EqnkyDx/AF UO9Q== 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=KZ1xwg1V88wevu0vfk1ket9/l10l476QppYcV8FElFU=; b=Z+7fuFyCwSoPVyCeYWEegKgwQoeP7yf6dbNYNTX3Ti67ynTfHFq01DQALqOAcwAGyS IFrbRAq314inriAW6uELPr4X9ngCSu0MWnEEWo+Tm6k2OOv1AdZeDDqK7XTTcy199AIn lyWhOUbZR7tUfyoEnpr4QI9MCTDp421gSDGqd7PeOh/I2m0wBjiCRVY/W+F3FcDkYiUY xXH+bo8nBo/8u9KJU9U82iD3q+3oyqNxyoBWn+Zxk2+MGipDJSxLlRlWiIw877AnPRsu isrwjdVttdFmIoaiYHyFGRvULCp/Nr8anhnY20kjdKs9j1rAgNcpjycqdNJ32+gK8BSx YKxw== 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 l14si5246449oii.37.2020.02.24.06.13.16; Mon, 24 Feb 2020 06:13:28 -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 S1727742AbgBXOMy (ORCPT + 99 others); Mon, 24 Feb 2020 09:12:54 -0500 Received: from foss.arm.com ([217.140.110.172]:37694 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727426AbgBXOMx (ORCPT ); Mon, 24 Feb 2020 09:12:53 -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 96E9531B; Mon, 24 Feb 2020 06:12:52 -0800 (PST) Received: from e108754-lin.cambridge.arm.com (unknown [10.1.198.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4CB963F534; Mon, 24 Feb 2020 06:12:50 -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, 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 v4 5/7] cpufreq: add function to get the hardware max frequency Date: Mon, 24 Feb 2020 14:11:40 +0000 Message-Id: <20200224141142.25445-6-ionela.voinescu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200224141142.25445-1-ionela.voinescu@arm.com> References: <20200224141142.25445-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 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