Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp94921rwo; Fri, 21 Jul 2023 09:01:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlE2K6nlQ6OE70wmmQ3NxTJQfLgwDjBdk23ufsyyrxAKc0BTwpJjhRLE/TtxXrtTMpexUzSk X-Received: by 2002:a05:6a20:748b:b0:134:e14c:851b with SMTP id p11-20020a056a20748b00b00134e14c851bmr2223034pzd.23.1689955298263; Fri, 21 Jul 2023 09:01:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689955298; cv=none; d=google.com; s=arc-20160816; b=Xe/3uXqjc1jmZKfdo2Jl24l31in7D5Yie3cBC44hh3iGeoVJsUSlRz6sAOs63BLLjF 4zr5kci4sBY9iBgtMNku0qSPIw/GqG4XJHGYxrMBV8i9sZniThxd4OGLjakz1sEvEaIr 34HFOf4Tdf1afZ7liB8kwCVDUuQ1eu5xso3FM0a14Lbsv/MWQZKQiUav8trREB+fiSMh Dlbezh5TFZERcxXPgXmX0l0W8iYRpAED/Hm3G1KM1+TDrQcYcAee+yjQGPSu9Qa9VZC2 y/mmkz3/LohvcZ7G73S1dz4CZ/AlhiHn8hh0qKRJUOef9kmys4jGSr0vVYC5sfbBF3E4 PYew== 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=6FrMZ5Er5ZT5LZgHsl2G0iQzN86RWOHn/IsyaH7AYqU=; fh=X59gKo2bTEq2VHcwIFizOsXoeGl1m0HuKLr4L9qvQjg=; b=POCY46LJl/d68kphIOuous+ECxmy1gflDOGZ1ewaPpApGzEtuodEbnvn/uQ9lwe3nx 2DpAaqfsbxoLRMdRfJukvPpd0N6oM7TbhJrmkBC9JEcFNj5YFMLjFu9PCCg2ogew96+k vxutYLckBgtiJ00yT2aZ+O1t/xDvuXXwTwuh52z+DKXYRbxT5/AxRV7wIdTHTiF3u3j6 wxcMLAc3aRvBP+xd8WG9yp5JpuJBRSCAOaDR9Lpjuz297K7ApSywUEOHbeoi2C0M+vtA o5wELK0Vp8WhqAiVtQHy4P6GDZEZLSczQCy10b9Hij5sp3ji7+8DIk1IqoV38MQTp5sr NurQ== 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 r20-20020a6560d4000000b00563571a8d0asi2967280pgv.852.2023.07.21.09.01.16; Fri, 21 Jul 2023 09:01:38 -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 S232340AbjGUPuw (ORCPT + 99 others); Fri, 21 Jul 2023 11:50:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232338AbjGUPug (ORCPT ); Fri, 21 Jul 2023 11:50:36 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 59E8E3AB5; Fri, 21 Jul 2023 08:50:22 -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 1FB562F4; Fri, 21 Jul 2023 08:51:05 -0700 (PDT) Received: from e129166.arm.com (unknown [10.57.0.79]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E903E3F738; Fri, 21 Jul 2023 08:50:18 -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, mhiramat@kernel.org Subject: [PATCH v3 07/12] PM: EM: Add update_power() callback for runtime modifications Date: Fri, 21 Jul 2023 16:50:17 +0100 Message-Id: <20230721155022.2339982-8-lukasz.luba@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230721155022.2339982-1-lukasz.luba@arm.com> References: <20230721155022.2339982-1-lukasz.luba@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,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 90c0822b664b..9b67f54ddcf0 100644 --- a/include/linux/energy_model.h +++ b/include/linux/energy_model.h @@ -168,6 +168,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) \ @@ -175,6 +195,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