Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4494629rdh; Wed, 29 Nov 2023 03:10:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEtxXCg+nHdJa1ILmEx5f3h8x6M7aFDdrbvgiqbGfEgFSp6Uy7XmN/MHrf9vij+bMACyRWI X-Received: by 2002:a05:6a20:1388:b0:187:e1cc:8cfc with SMTP id hn8-20020a056a20138800b00187e1cc8cfcmr14720454pzc.35.1701256205169; Wed, 29 Nov 2023 03:10:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701256205; cv=none; d=google.com; s=arc-20160816; b=P2S/52wi7zH7KyJ8zqK1hj351H5bPkXSWFwL/KQniNAqwOZtF3TqIqp80ATvGTOLhK aRDgrf++uyTBHX+ry60hA7He6Zlwy2ztr9ddMFOHU0Y/v5f371INeqGZbQKAoE0Koi8L ba8hvSBWbn81Hlq2h/siqAVddSE5clcnyaYw8pZdxMejUCZL5nbo5ZAjYYEawcdZbnFU dwnqCKvxkmvdCkgILJ58jGBUUqY4PgSvThAjibCEPPzAC43RAMy2FSzeIrHaB+P9ukm0 N5+E4MA3m7bzHxN4PKSlSE3HwNhp0ZzKRUNZmmVvoPTQzzM7UXY+igQHF6WfJW8u+ufd ZTZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QwE0v4XQ4uCtto4wLo2xPdjsPNwymenAafjnZOkg4Co=; fh=jF+j1UEDAwnYbShW3HmO1TshMsWh36Jt7pSLTP62NeE=; b=ILivpuphV7Smz7ryj9nCmRDVbKJQMPkr2WTASRdtfj6QpeYISK6qepms+YrhRqNQFX DfIH/0v654z2BPKPQch+URwBhE7DJJ47XRjac/I+qXXBm6SzDNRb7ZeozWKOjz178iYz ++ixZb942kSwWuP6Ur6kGk7ABcbvu1fkLxjPqNT8E+dIdARlPaCRIMIXlkVGUazvezSW WW2R2Xq+gCEfTu7rWsMxAkjMJgHGCbjhihGxowOESBmJ6IJBl4wKldkyMLl2W/UWgepp tn/WJhHE+DxO6+S9m2gYJXEPWhEg27ZdlFW2wCkj3k7e3I5efxfg9qB7RDgUQ6e6ITai 5Xcg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id m12-20020a170902768c00b001d002eeb4a1si2593531pll.15.2023.11.29.03.10.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 03:10:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id B64448049D6A; Wed, 29 Nov 2023 03:09:59 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232929AbjK2LJX (ORCPT + 99 others); Wed, 29 Nov 2023 06:09:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231793AbjK2LIu (ORCPT ); Wed, 29 Nov 2023 06:08:50 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 59BA02127; Wed, 29 Nov 2023 03:08:34 -0800 (PST) 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 45CA22F4; Wed, 29 Nov 2023 03:09:21 -0800 (PST) Received: from e129166.arm.com (unknown [10.57.4.241]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id ADF103F5A1; Wed, 29 Nov 2023 03:08:31 -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 v5 12/23] PM: EM: Add helpers to read under RCU lock the EM table Date: Wed, 29 Nov 2023 11:08:42 +0000 Message-Id: <20231129110853.94344-13-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231129110853.94344-1-lukasz.luba@arm.com> References: <20231129110853.94344-1-lukasz.luba@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 29 Nov 2023 03:10:00 -0800 (PST) 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 520a8c8ad849..ae3ccc8b9f44 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -341,6 +341,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 *runtime_table; + + rcu_read_lock(); + runtime_table = rcu_dereference(pd->runtime_table); + return runtime_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) { } @@ -387,6 +401,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