From patchwork Thu Mar 17 13:34:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Gondois X-Patchwork-Id: 552458 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF10CC433F5 for ; Thu, 17 Mar 2022 13:35:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229824AbiCQNhB (ORCPT ); Thu, 17 Mar 2022 09:37:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234630AbiCQNhB (ORCPT ); Thu, 17 Mar 2022 09:37:01 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 14B671DA8EF; Thu, 17 Mar 2022 06:35:45 -0700 (PDT) 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 C11F61570; Thu, 17 Mar 2022 06:35:44 -0700 (PDT) Received: from e126645.arm.com (unknown [10.57.41.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8E0083F766; Thu, 17 Mar 2022 06:35:40 -0700 (PDT) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Ionela.Voinescu@arm.com, Lukasz.Luba@arm.com, Morten.Rasmussen@arm.com, Dietmar.Eggemann@arm.com, mka@chromium.org, daniel.lezcano@linaro.org, Pierre Gondois , Catalin Marinas , Will Deacon , "Rafael J. Wysocki" , Viresh Kumar , Mark Rutland , Ard Biesheuvel , Fuad Tabba , Marc Zyngier , Valentin Schneider , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [PATCH v1 1/3] cpufreq: CPPC: Add cppc_cpufreq_search_cpu_data Date: Thu, 17 Mar 2022 14:34:15 +0100 Message-Id: <20220317133419.3901736-2-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220317133419.3901736-1-Pierre.Gondois@arm.com> References: <20220317133419.3901736-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org cppc_cpufreq_get_cpu_data() allocates a new struct cppc_cpudata for the input CPU at each call. To search the struct associated with a cpu without allocating a new one, add cppc_cpufreq_search_cpu_data(). Also add an early prototype. This will be used in a later patch, when generating artificial performance states to register an artificial Energy Model in the cppc_cpufreq driver and enable the Energy Aware Scheduler for ACPI based systems. Signed-off-by: Pierre Gondois --- drivers/cpufreq/cppc_cpufreq.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 82d370ae6a4a..8f950fe72765 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -41,6 +41,8 @@ */ static LIST_HEAD(cpu_data_list); +static struct cppc_cpudata *cppc_cpufreq_search_cpu_data(unsigned int cpu); + static bool boost_supported; struct cppc_workaround_oem_info { @@ -479,6 +481,19 @@ static void cppc_cpufreq_put_cpu_data(struct cpufreq_policy *policy) policy->driver_data = NULL; } +static inline struct cppc_cpudata * +cppc_cpufreq_search_cpu_data(unsigned int cpu) +{ + struct cppc_cpudata *iter, *tmp; + + list_for_each_entry_safe(iter, tmp, &cpu_data_list, node) { + if (cpumask_test_cpu(cpu, iter->shared_cpu_map)) + return iter; + } + + return NULL; +} + static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy) { unsigned int cpu = policy->cpu;