Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10042637rwr; Fri, 12 May 2023 03:02:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fOIaRGacihl6zwpZOi0iF9gUb3dDINUwen72A2nqhU7iJXC63Ytyi/LPDiGNL2C0MuMIs X-Received: by 2002:a17:90b:1d87:b0:24d:fb82:71ab with SMTP id pf7-20020a17090b1d8700b0024dfb8271abmr24765440pjb.26.1683885729129; Fri, 12 May 2023 03:02:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683885729; cv=none; d=google.com; s=arc-20160816; b=m6UBAJL7iofmC4FVhWEZE1PCc+PLUKQeE/1RDlrHrwFusgzkiij2JRjn4Fu7Nyx0bv ncbttBPkUl2Kt4ZFARcf/YTBSp3wWjN9YkKmHGY5QYE8C0Yk/3uwun9DQr6j96VpCwvx V0sfaDFWca/LyTpaItM3CVNENilVQaT4jFXSxjQCT9e6QMTu5v3x8mwWRoQJKsNl3Gr0 SPTeIRq/KiNTp2sWrpi2vO5uvMSJTpRufcTiP7hqLj61RB6s0eNF7CbQwW1Se8Hwm9xw yCNJ1Atvy37ZCe5h5KwQ2zH4Njp5q837IdSRkVx8e2QzWSdZ/A3DMBZ8UdJ6FEfNvR0C JDJA== 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=xJvDFnbW8Z+tP3Sxw/naBBQGZ3enQ3TCHSsB0ixo5o0=; b=Xm6PU55kys0wwfIy1kxyVGYPADedJGpNKtHUf3GaDpHQHQWa/vgoGrO5flK7XaqYtc Pm8CIY86Hok1Ba5CMFV+ngNZHKFePadpCBsLJkzugV01JDzmw2OyHqR9ioF9P0Lw3Qo7 1zHkGFbeHCSAOxGPkIL0TkNNKHS79CMqWk+qvCt2bSSkZAOSVdp15+/oJRPIXwqyu/cu BIitWsrHWhSNnl0Jl/QSfQfNP/JimIZmwa/+rOBUKbqSgWwBwkCHQRg89yKKSbao0f1d PW59Y5b1kX1E+MzMk1KbrBWcMb9Ejq4GfQG9HIyig4CYwOa7HN2ApGtueSc8GcdKhByz QewA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mw14-20020a17090b4d0e00b002467eaf62e0si22631625pjb.178.2023.05.12.03.01.54; Fri, 12 May 2023 03:02:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240721AbjELKAU (ORCPT + 99 others); Fri, 12 May 2023 06:00:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240751AbjELJ7u (ORCPT ); Fri, 12 May 2023 05:59:50 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 09ABB12E90; Fri, 12 May 2023 02:59:10 -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 27D9B16F2; Fri, 12 May 2023 02:59:33 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.22.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DEB273F5A1; Fri, 12 May 2023 02:58:45 -0700 (PDT) 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, Pierre.Gondois@arm.com, ionela.voinescu@arm.com, rostedt@goodmis.org, mhiramat@kernel.org Subject: [PATCH v2 17/17] Documentation: EM: Describe the API of runtime modifications Date: Fri, 12 May 2023 10:57:43 +0100 Message-Id: <20230512095743.3393563-18-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230512095743.3393563-1-lukasz.luba@arm.com> References: <20230512095743.3393563-1-lukasz.luba@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Describe the Energy Model runtime modification API and how it can be used. Signed-off-by: Lukasz Luba --- Documentation/power/energy-model.rst | 31 ++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/Documentation/power/energy-model.rst b/Documentation/power/energy-model.rst index a6ceeeb72868..2fd6e82a8124 100644 --- a/Documentation/power/energy-model.rst +++ b/Documentation/power/energy-model.rst @@ -213,10 +213,37 @@ CPUfreq governor is in use in case of CPU device. Currently this calculation is not provided for other type of devices. More details about the above APIs can be found in ```` -or in Section 3.4 +or in Section 3.5 -3.4 Description details of this API +3.4 Runtime modifications +^^^^^^^^^^^^^^^^^^^^^^^^^ + +Drivers willing to modify the EM at runtime should use the following API:: + + + int em_dev_update_perf_domain(struct device *dev, + struct em_data_callback *cb, void *priv); + +Drivers must provide a callback .update_power() returning power value for each +performance state. The callback function provided by the driver is free +to fetch data from any relevant location (DT, firmware, ...) or sensor. +The .update_power() callback is called by the EM for each performance state to +provide new power value. In the Section 4.2 there is an example driver +which shows simple implementation of this mechanism. The callback can be +declared with EM_UPDATE_CB() macro. The caller of that callback also passes +a private void pointer back to the driver which tries to update EM. +It is useful and helps to maintain the consistent context for all performance +state calls for a given EM. +The artificial EM also supports runtime modifications. For this type of EM +there is a need to provide one more callback: .get_cost(). The .get_cost() +returns the cost value for each performance state, which better reflects the +efficiency of the CPUs which use artificial EM. Those two callbacks: +.update_power() and get .get_cost() can be declared with one macro +EM_ADV_UPDATE_CB() and then passed to the em_dev_update_perf_domain(). + + +3.5 Description details of this API ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. kernel-doc:: include/linux/energy_model.h :internal: -- 2.25.1