From patchwork Thu Feb 8 11:55:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Luba X-Patchwork-Id: 198352 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp116000dyd; Thu, 8 Feb 2024 04:06:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IFY9Kd6IzK80XT7hxz4pKOZnek28vP0+QnzcihvKIH8rPse5amE3hsdHjdDb2i7AOWwRrj0 X-Received: by 2002:aa7:d902:0:b0:560:9277:80e5 with SMTP id a2-20020aa7d902000000b00560927780e5mr6064084edr.21.1707394012649; Thu, 08 Feb 2024 04:06:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707394012; cv=pass; d=google.com; s=arc-20160816; b=B6v70fK6DNwXLKAHoS1+0LRsjEX8ls9G+Db920CiB+2y4HlMWpqP0AUlpPQpp/AZgu LATRObw5Tu5ZLE7M+D1iaUx7TLB7TA86sVdCM6vmDkbEC9dLdeqtuIVWu33Yr0mmpO5n xZfXZ7QKhwtNqiqGo+c4mizVUlA3zx3hwLy298NAWoIg8xMytlApcOdAbbJltoi/F6L6 AJHUTO5OtF1le9LHbFvUtS+itD8xnTgF/MmNiuFeUgDpj3iUQQnrUvyJVn1nuZxKOc6e gKBFY9YjTE2Fh2Z2BI+gkGx3PKRoSXGNY0zjPbi3G+Wh/p8aGuU+e8zQJjOolJTPa48r DOTQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=SYWM+MbdENBgwwJMugawdJXQ8ceIiSWsGOLhNLQcIvU=; fh=UhFVAADUnwsQZOf4MtexnUD976ccA9p7xlp4kXvQPn8=; b=ZAW7sTmciC9YfvcQ6/Bhr0J/WkHPpto4IWyOyqOZgGVpVfcgzgN2qTI6hSUXIgM+jG wLYpzM+e2eWRCj3DMLOSZMj1g4aqzOBo0u+tGxHtb+H+dN7OiozFU8PnDsnweGtAuw0t fXXfcasRXyv1eA+O/ZomD42fLv3NVflgUzsC4UwnTyoMLvb4mzGwOXHqnoZH2CT6USG5 B8gEYCtbQ+7n+ddvoHaWJMzxVwbeWq5RNbahsuV1HAghoBTpSiAt4m8Hvs2klvUnwDmI MDtul4GqROUZtIC6BTRX26wOPsPLgFMOPu1QAM0e9XCn2u3TwVRjf0VIGEbIKyF2BCsm NLpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-58006-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58006-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCVJdGPzE/tVfBjGj6Uwke2YoDLrGLNTcwNSoFKpFE+BOrPePHc5+MdcGZeTZKMlaTKU04iV/e0hx7YkL1I5FoHVL5KDEA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dn9-20020a05640222e900b0055deaaf8b06si820164edb.346.2024.02.08.04.06.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 04:06:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58006-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-58006-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58006-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 63E6E1F2C52A for ; Thu, 8 Feb 2024 12:00:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9BDBD7318C; Thu, 8 Feb 2024 11:56:45 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F64D7AE62; Thu, 8 Feb 2024 11:56:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707393403; cv=none; b=Vq68Qmn7ROtnT37JJ9bUsp3bAU1RuHEv2f0nuHNNxVazEKrbEt77yZeDZe12l0emB18LsTBNxykzRQdnJNt2nTa7OrsgS66Kuh6zW5SYI7A2kzeEr+x3eRGB0BaL+OveS+W3xHJm7bcnnIMyZOVYJKk1kQGdR78rD5hlkoug6D8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707393403; c=relaxed/simple; bh=t1KyvAYlPGYt5k4QNfvPcCk4liGk3G3znjAuCwRkKtk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IlMawcnW0V2rpm9OHZbIXaSMDI5BXsm9YBynNnD1geIcME4RrafRyGimkB0lga63BI7jOq4bQwsorGFuvqOC/PNof1VLHNAScUPL3M2fznWYXOK4o5Xgt+c4ycWNrq5chVmV1IpHjReWUY8yFIz7d9vbRG+ghDXov3QZllc1OU8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 D937F1FB; Thu, 8 Feb 2024 03:57:23 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.8.23]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 055293F5A1; Thu, 8 Feb 2024 03:56:38 -0800 (PST) From: Lukasz Luba To: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org Cc: lukasz.luba@arm.com, dietmar.eggemann@arm.com, rui.zhang@intel.com, amit.kucheria@verdurent.com, amit.kachhap@gmail.com, daniel.lezcano@linaro.org, viresh.kumar@linaro.org, len.brown@intel.com, pavel@ucw.cz, mhiramat@kernel.org, qyousef@layalina.io, wvw@google.com, xuewen.yan94@gmail.com Subject: [PATCH v8 12/23] PM: EM: Add em_perf_state_from_pd() to get performance states table Date: Thu, 8 Feb 2024 11:55:46 +0000 Message-Id: <20240208115557.1273962-13-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240208115557.1273962-1-lukasz.luba@arm.com> References: <20240208115557.1273962-1-lukasz.luba@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790332384101841782 X-GMAIL-MSGID: 1790332384101841782 Introduce a wrapper to get the performance states table of the performance domain. The function should be called within the RCU read critical section. Reviewed-by: Dietmar Eggemann Tested-by: Dietmar Eggemann Signed-off-by: Lukasz Luba --- include/linux/energy_model.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h index 324a3a8e0a2d..158dad6ea313 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -338,6 +338,23 @@ static inline int em_pd_nr_perf_states(struct em_perf_domain *pd) return pd->nr_perf_states; } +/** + * em_perf_state_from_pd() - Get the performance states table of perf. + * domain + * @pd : performance domain for which this must be done + * + * To use this function the rcu_read_lock() should be hold. After the usage + * of the performance states table is finished, the rcu_read_unlock() should + * be called. + * + * Return: the pointer to performance states table of the performance domain + */ +static inline +struct em_perf_state *em_perf_state_from_pd(struct em_perf_domain *pd) +{ + return rcu_dereference(pd->em_table)->state; +} + #else struct em_data_callback {}; #define EM_ADV_DATA_CB(_active_power_cb, _cost_cb) { } @@ -384,6 +401,11 @@ int em_dev_update_perf_domain(struct device *dev, { return -EINVAL; } +static inline +struct em_perf_state *em_perf_state_from_pd(struct em_perf_domain *pd) +{ + return NULL; +} #endif #endif