Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10054185rwr; Fri, 12 May 2023 03:10:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7d6DxhXWrvPZynMpIi9xFf6tPIReedOeZyjKYs8w+TOuawTowHN2vXNGpSe/Ni86ooS/lB X-Received: by 2002:a17:902:e751:b0:1a9:a408:a52f with SMTP id p17-20020a170902e75100b001a9a408a52fmr33835939plf.24.1683886256664; Fri, 12 May 2023 03:10:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683886256; cv=none; d=google.com; s=arc-20160816; b=VcXLM3ew2NWm80DkffokSyRE1dQ/cClGnRFFfMQ0rUJI3Di20+cUY4Cu/7UXHAKkbo WXSGwfuFInZH0Y6D5+zJaPyb8vAKq+YqYk0xMbXAbPzqwcfLLA7D8otLiouepjyMQvMW v9M9TKnfl9st+QX6uWT599MZuoZcjBzo91y2T+LuvwPHrMuAnSrMhh/Gtzpx4uT6EJ9l 9kiZqSnTrnyqAPuJPVWLR0QJybrju9GRdqXQT58rQFUZQhpMpw1XsXYC2gLs9C6XxcU/ wnN9l9F6fTV+EnG4SSnrhJIVEs6tDK/eM8nNXS1onk8GaVr+cUH9bzPxHyV1AobuczNX l5QA== 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=NTRuhr/lqT5WOL9niJWL5/o/B0yNXIb/4HueHfVYLro=; b=pdjjCy9HoOThXfJWzGF5/SzVTCTh+jVzH5zExDLL/aX/TsNSo8F7RGTqoZgoQFknYP LbH+eFhQW9kxocaTMLz0wh0YUZqe8ROK4wNB602/0xEwS0HVr7nmnW13R5JEUAkkCLYc sl1HYAX94lf0LiWP/QJJ2Ynk1O3vYhX2uCkIgPAopHfRDpcntzezhKGM18DZfW7yt+WG T1EJQwmpq9KPMJtGJBkcM0bXhMtl4y/+JxwyET4C3ZYG4HIQQZTOTN0pnokuFp/uQfJD fQ094O93aPBrC37hx27ATGv71zO6p+CuE0+SYMNYJHN2azAzV5GzvGlLeYUN51jMvK7v 0WpA== 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 e63-20020a636942000000b0051b13a071a8si8669972pgc.575.2023.05.12.03.10.42; Fri, 12 May 2023 03:10:56 -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 S240681AbjELJ7E (ORCPT + 99 others); Fri, 12 May 2023 05:59:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240658AbjELJ6o (ORCPT ); Fri, 12 May 2023 05:58:44 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0A1411249D; Fri, 12 May 2023 02:58:16 -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 2C9D1168F; Fri, 12 May 2023 02:59:00 -0700 (PDT) Received: from e123648.arm.com (unknown [10.57.22.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E05573F5A1; Fri, 12 May 2023 02:58:12 -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 06/17] PM: EM: Add update_power() callback for runtime modifications Date: Fri, 12 May 2023 10:57:32 +0100 Message-Id: <20230512095743.3393563-7-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 The Energy Model (EM) is going to support runtime modifications. This new callback would be used in the upcoming EM changes. The drivers or frameworks which want to modify the EM have to implement the update_power() callback and provide it via EM API em_dev_update_perf_domain(). The callback is then used by the EM framework to get new power values for each frequency in existing EM. Signed-off-by: Lukasz Luba --- include/linux/energy_model.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h index 8069f526c9d8..cc2bf607191e 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -158,6 +158,26 @@ struct em_data_callback { */ int (*get_cost)(struct device *dev, unsigned long freq, unsigned long *cost); + + /** + * update_power() - Provide new power at the given performance state of + * a device + * @dev : Device for which we do this operation (can be a CPU) + * @freq : Frequency at the performance state in kHz + * @power : New power value at the performance state + * (modified) + * @priv : Pointer to private data useful for tracking context + * during run-time modifications of EM. + * + * The update_power() is used by run-time modifiable EM. It aims to + * provide updated power value for a given frequency, which is stored + * in the performance state. The power value provided by this callback + * should fit in the [0, EM_MAX_POWER] range. + * + * Return 0 on success, or appropriate error value in case of failure. + */ + int (*update_power)(struct device *dev, unsigned long freq, + unsigned long *power, void *priv); }; #define EM_SET_ACTIVE_POWER_CB(em_cb, cb) ((em_cb).active_power = cb) #define EM_ADV_DATA_CB(_active_power_cb, _cost_cb) \ @@ -165,6 +185,7 @@ struct em_data_callback { .get_cost = _cost_cb } #define EM_DATA_CB(_active_power_cb) \ EM_ADV_DATA_CB(_active_power_cb, NULL) +#define EM_UPDATE_CB(_update_power_cb) { .update_power = &_update_power_cb } struct em_perf_domain *em_cpu_get(int cpu); struct em_perf_domain *em_pd_get(struct device *dev); -- 2.25.1