From patchwork Thu Apr 7 08:16:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Gondois X-Patchwork-Id: 12804790 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85CA6C4332F for ; Thu, 7 Apr 2022 08:49:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=N4UdCVaM66zymbOwn8zY+iKSOh+1WkRTCbN7sg2+Fco=; b=Lh/SNdWWRDZFMF fJmkCN9QMvalTVCpBUPukkEOP7f57ReLGkTvWYfMfqOaulSa5+n/sd0ANifGrnIgnolzRDaUUTXQG uoGnFKgvElOHnMRs/vady8UVzSPLy3L0zhylApPg6VcyYCWPm9J9rDvMD5ZVpxKasCm9V1LdKaNbZ xmfba/ew8SPuZfUme4EZqU2CIe6ls7SC7bZ+ls25cKamJjxOlYsO49kYVhfanrDnntbTe6sDmhU7P IKSbv8AfvMa4q7UnmCz2HWLshQJ3YG0RunUFwMJHfEcQEwrMiK8Gw2fzdS+BQa+xeGN1xUh1WNtbo yzRdhDlPBul85OCCKGZw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncNot-00AZ83-Ka; Thu, 07 Apr 2022 08:48:48 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncNLY-00AK8J-SP for linux-arm-kernel@lists.infradead.org; Thu, 07 Apr 2022 08:18:32 +0000 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 03E31139F; Thu, 7 Apr 2022 01:18:28 -0700 (PDT) Received: from e126645.nice.arm.com (e126645.nice.arm.com [10.34.129.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1563B3F5A1; Thu, 7 Apr 2022 01:18:23 -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, maz@kernel.org, Pierre Gondois , Catalin Marinas , Will Deacon , "Rafael J. Wysocki" , Viresh Kumar , Mark Rutland , Ard Biesheuvel , Fuad Tabba , Valentin Schneider , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: [PATCH v2 1/3] cpufreq: CPPC: Add cppc_cpufreq_search_cpu_data Date: Thu, 7 Apr 2022 10:16:16 +0200 Message-Id: <20220407081620.1662192-2-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220407081620.1662192-1-pierre.gondois@arm.com> References: <20220407081620.1662192-1-pierre.gondois@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_011829_024692_3F2FDCEA X-CRM114-Status: GOOD ( 11.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Pierre Gondois 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..ffcd9704add2 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 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;