Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7844701rdb; Thu, 4 Jan 2024 09:19:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRE6AjRSJ19AIbQ/lcynPoQAZJeAZlsN4actNnCqb5t/6X1lOvyVkOJeJ21wefzd4PvBCu X-Received: by 2002:aa7:80c7:0:b0:6da:b302:d5f8 with SMTP id a7-20020aa780c7000000b006dab302d5f8mr653588pfn.35.1704388776581; Thu, 04 Jan 2024 09:19:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704388776; cv=none; d=google.com; s=arc-20160816; b=S1bx6W4vGVMIUd0Rtn3WCsuJwb9N2cyxEsvLShoqEtj9JJZeK6KtQoGZTVCVz960aP NlHR7UUYJY71N1+mOcIebSLFZIfYAMfwZznlEYCGHM0ebqscQ/zzKSgTwtLi7uWL8zkC qoWALXoterONc/v50n5TVx3srtKhNoqsDJQGZiOiihdpnpr4elm323/2ZoJVj26BwIAV fmONw9cSwdVDv8PrelHLKEZgGp8vJgXDPiKgW86kl55M0unv64dH1umYGOg1jdBwy4OW 8+OzykWax3napgvMO8uBYPdt/rH5AGrvCfT3u6a79x2yznZmMOaf564Q4Q6n8DO+HWQl qVVg== ARC-Message-Signature: i=1; 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=AwIdrfrsN6FU1d3SnWby5u6EgblUdTBHu8gsXIjugcc=; fh=jF+j1UEDAwnYbShW3HmO1TshMsWh36Jt7pSLTP62NeE=; b=i8kODrOhjkgtADLimT6aHFYDf+xv4Jg190wbLTQ85sVMbVZqUg8ar6jDwHvCsyLGOI iNfXzx2I4loadXEl4+VtPUOTt8ZGEYzXqbioFic9/62u29JfDNEVu7B3CFZqmK/IJGw+ 5A7fWsRFAlQ/U7aK/BE132aWVgped3zN4AzEi4GpCKWaS/z94N7Z94dowrn9tW4vPbPk nzFqrNGkmbI9kk0nNJvGKSrfnePtpt/ukjzuVTXq7hdvaTqgU0zaYe2b/JSf1Zlr4WdU PXqBKeMpMYs8AXDh06d0S/bHi8/ZcRdo5bcTCo1HjmQByQRNL6KuONDEBoK363vs2qZ+ c9pg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17016-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f14-20020a056a00228e00b006d9e3783cf4si15677049pfe.52.2024.01.04.09.19.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 09:19:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-17016-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17016-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 17F722884B6 for ; Thu, 4 Jan 2024 17:19:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EA5972E648; Thu, 4 Jan 2024 17:15:25 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A41DE2E629; Thu, 4 Jan 2024 17:15:23 +0000 (UTC) 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 3D0271007; Thu, 4 Jan 2024 09:16:09 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.88.128]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BDE523F64C; Thu, 4 Jan 2024 09:15:20 -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 Subject: [PATCH v6 12/23] PM: EM: Add helpers to read under RCU lock the EM table Date: Thu, 4 Jan 2024 17:15:42 +0000 Message-Id: <20240104171553.2080674-13-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240104171553.2080674-1-lukasz.luba@arm.com> References: <20240104171553.2080674-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 Content-Transfer-Encoding: 8bit To use the runtime modifiable EM table there is a need to use RCU read locking properly. Add helper functions for the device drivers and frameworks to make sure it's done properly. Signed-off-by: Lukasz Luba --- include/linux/energy_model.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h index f33257ed83fd..cfaf5d8b1aad 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -338,6 +338,20 @@ static inline int em_pd_nr_perf_states(struct em_perf_domain *pd) return pd->nr_perf_states; } +static inline struct em_perf_state *em_get_table(struct em_perf_domain *pd) +{ + struct em_perf_table __rcu *table; + + rcu_read_lock(); + table = rcu_dereference(pd->em_table); + return table->state; +} + +static inline void em_put_table(void) +{ + rcu_read_unlock(); +} + #else struct em_data_callback {}; #define EM_ADV_DATA_CB(_active_power_cb, _cost_cb) { } @@ -384,6 +398,11 @@ int em_dev_update_perf_domain(struct device *dev, { return -EINVAL; } +static inline struct em_perf_state *em_get_table(struct em_perf_domain *pd) +{ + return NULL; +} +static inline void em_put_table(void) {} #endif #endif -- 2.25.1