From patchwork Tue Mar 14 10:33:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Luba X-Patchwork-Id: 69486 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1678835wrd; Tue, 14 Mar 2023 03:39:28 -0700 (PDT) X-Google-Smtp-Source: AK7set8rqGUDelYsCrn+NRJd8J1TRQ5aS96ee3gzwFcQZ6N1jpZ1FUT9cflkTPV2/bil00/IqCOW X-Received: by 2002:a17:90b:3881:b0:234:b082:48a2 with SMTP id mu1-20020a17090b388100b00234b08248a2mr38799503pjb.28.1678790368718; Tue, 14 Mar 2023 03:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678790368; cv=none; d=google.com; s=arc-20160816; b=n1AddBHqSoIFqccqzMMeZbLZiATnbVdlIcFvxTUTiTDIAqrpoq50wnBrp8ILu5KtAe itvnJiV6qe47Uq9mYxVe2vE+L6atcgCp6udnLHD9QZuOjRLHm9xBuqebs6FDNmFD84Eb t7btIO55+GyaS+L1NoMFHOkDXawAD9mQO/8Jy16g16hivV+DRZ2D/08bwECbgjBaatQ5 GZugQBqWVCF7agV3rzxYgP2UgOoxbFZlaN6YBVa/ihaGkHgTdjmNja0iHEjI8cHbyXen fvVFGOidWfg+SJ4+U4w67E6GGony5MZh5jLbJ0UDIGU+yjMxtiRPa1GGwuGsmspFmO1v Rd8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=mkQ0Vzv4K08WTljXAtqXXMEGMsKQdPZsNZYBMjKkoSE=; b=a7CgrUt7viGbbc/Bj5D9Vw77u2zDHbC5M5FGQQ7mZcootkaZCMOUlzQSInQRtmYse3 YMdpnc0E84Lf1+FakWW27PA7/3w1j8tfePN96+/4iyRcmsoF9sV3YTs8GileHM627Lhw 3WH+WXj4j/DGjPB7R5FK22s4s3ar+22jfCeIBSz8kVL/6i5+hac81STLmp9oeaEgsbtr eC1x0/lwagUh30NQ4iDzPJK8GL2/f17w+j7YVInfSTBrxrd1DXHVn/f5G3pyYfuHitxK m15zALrxMjig/PI1fBm6spOXUBY+3QSgX08mKR05zn+3ugtWIk2TtdVET+5UO1hvRf0n eIwg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ci18-20020a17090afc9200b00228e80888c9si2183558pjb.14.2023.03.14.03.39.16; Tue, 14 Mar 2023 03:39:28 -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 S231382AbjCNKhM (ORCPT + 99 others); Tue, 14 Mar 2023 06:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231365AbjCNKgT (ORCPT ); Tue, 14 Mar 2023 06:36:19 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A4A169C9B1; Tue, 14 Mar 2023 03:35:50 -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 01CFD1BB2; Tue, 14 Mar 2023 03:35:51 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.19.101]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 719423F71A; Tue, 14 Mar 2023 03:35:04 -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 17/17] Documentation: EM: Describe the API of runtime modifications Date: Tue, 14 Mar 2023 10:33:57 +0000 Message-Id: <20230314103357.26010-18-lukasz.luba@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230314103357.26010-1-lukasz.luba@arm.com> References: <20230314103357.26010-1-lukasz.luba@arm.com> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760339289349445174?= X-GMAIL-MSGID: =?utf-8?q?1760339289349445174?= 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: