Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2093708rdh; Tue, 26 Sep 2023 12:09:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGHtP8CzMsdQo6mEQJChAXPZ4hOtTHRLE/Q9JLFnv/svhyvtxcbFaF0yGJZKDZQxaGfwQhd X-Received: by 2002:a05:6a21:7989:b0:160:e394:ff79 with SMTP id bh9-20020a056a21798900b00160e394ff79mr2866229pzc.53.1695755382291; Tue, 26 Sep 2023 12:09:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695755382; cv=none; d=google.com; s=arc-20160816; b=RbQxnm0d6nn1vubDH+VPCZLJGtdA5RJ872HifBr6E7r6Mq54s/UcnPvoBrd8WjAnHk 4xxQfc9QSzSyO9MTVDqUVJzxNtKI0qjaXdydc9YxJfgI4J6HF8DFdPpgda6gXasIAC/h 6P95tR0WsimRd9L4d9aRyDwph7r9lFl5H8RFx0H5d2DRdRgmgdyMu0KqOSps8hKTGtD6 nTrs2euZGMUuSS/GU/OrvvNvd5oGV53BCsLlkKAW5Z2lY8sAq9a6LCOMHmw4fKMyrfHo 9sVzs3fUtIY31NBvB19Pz44Kqf+i5/NHfVRHS3UgHkimWzx7UXKT6btcUfTC2XwZUQcp 6Lfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=0K7k6Nzl8nTivtu9rEgAxF7z1StDs9iCVnXHjbTsqvI=; fh=O6YYF95gEoTquszwa1x1Mp3NZS9Am1klEUxdtkLeXmY=; b=VGoecUkQgbDFScnu+izQ7i8K78PenrKyO/lVZhkktt35ZvCbPK/JR/l2D3vfbtb+UL u35usGk4pxFem5GBCzIfroo3AXsLcQb53PDLNXKmHUvmRWj9U+fS5b0u7eNIR3PqmTuH Y3BpTeBL0y3PNaKQ3ivKx7qMnlj9jCuwyq0ZWRv0/Fyf5c3l3/LFYGwfI7bruKyALH/W t5OO2T2w79zVNnaYbRN/aikQAnCJbLsIYnSCj99VUECPxYxJ2+P3kSjrtniCaG/EZA6y OqrnmjGmnqLDknr+mQ1RPAXsCGadBi4XXl4TXysdcTIQ00k0vrTog+y7L0klnvNjZ3m7 Gwew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id e13-20020a170902cf4d00b001c339f83e8asi12818014plg.411.2023.09.26.12.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 12:09:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3E374832C35E; Tue, 26 Sep 2023 11:59:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235678AbjIZS7w convert rfc822-to-8bit (ORCPT + 99 others); Tue, 26 Sep 2023 14:59:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235680AbjIZS7u (ORCPT ); Tue, 26 Sep 2023 14:59:50 -0400 Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D9CE19F; Tue, 26 Sep 2023 11:59:43 -0700 (PDT) Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-57de3096e25so74902eaf.1; Tue, 26 Sep 2023 11:59:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695754783; x=1696359583; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CmWKOKQNOrostcE1rGyRT5Onp9uerQjKsYo9gD15hsI=; b=vjFATSqSkkJOYtThMKaVAveoqAIe54E/00/rGi3NM07By7PFXTDLJZ0EbCM0uZk6CC wYxQNGT37NXvo+P/gSboLLSZ55KB0pgUIaOR6vhqcHzeuY/kdXW3lihh7rNoMuPAi7gr Yrz6oTNuA4COKx+otDd7OvklXDUXjhz4fGOosfb+dfhknGDanujhMIy6cyne/lJCRDYk 4n1vf9Z93Jn8pAY+0IdnrJkc12zExrkTpN7G2UECKyv1+XJSVF5qhWACQWSi0WoXc3Bt HWb9STf+/Jz2eOZYPOkCKwEYT5c2t+OmQ7ov71lY+8ixcuYMv0v2JYv3bpr4XI8yuR6A r6jA== X-Gm-Message-State: AOJu0YwSEGmTNBOpsbKy664goIb7FLlfcuSxy18prfhNYO2cy8SZMaau VEiR6v/Di6+YF/0LdLCVYC+tf+7RZrYo7xMGEoA= X-Received: by 2002:a4a:de15:0:b0:57b:7804:9d72 with SMTP id y21-20020a4ade15000000b0057b78049d72mr9818067oot.1.1695754782938; Tue, 26 Sep 2023 11:59:42 -0700 (PDT) MIME-Version: 1.0 References: <20230925081139.1305766-1-lukasz.luba@arm.com> <20230925081139.1305766-9-lukasz.luba@arm.com> In-Reply-To: <20230925081139.1305766-9-lukasz.luba@arm.com> From: "Rafael J. Wysocki" Date: Tue, 26 Sep 2023 20:59:32 +0200 Message-ID: Subject: Re: [PATCH v4 08/18] PM: EM: Add update_power() callback for runtime modifications To: Lukasz Luba Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rafael@kernel.org, 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Tue, 26 Sep 2023 11:59:56 -0700 (PDT) On Mon, Sep 25, 2023 at 10:11 AM Lukasz Luba wrote: > > 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. > > Signed-off-by: Lukasz Luba > --- > include/linux/energy_model.h | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h > index d236e08e80dc..546dee90f716 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 The meaning of the above is unclear to me. > + * @dev : Device for which we do this operation (can be a CPU) It is unclear what "we" means in this context. Maybe say "Target device (can be a CPU)"? > + * @freq : Frequency at the performance state in kHz What performance state does this refer to? And the frequency of what? > + * @power : New power value at the performance state > + * (modified) Similarly unclear as the above. > + * @priv : Pointer to private data useful for tracking context > + * during runtime modifications of EM. Who's going to set this pointer and use this data? > + * > + * The update_power() is used by runtime modifiable EM. It aims to I would drop "The" from the above. > + * provide updated power value for a given frequency, which is stored > + * in the performance state. A given frequency of what and the performance state of what does this refer to? > + 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); > @@ -331,6 +352,7 @@ struct em_data_callback {}; > #define EM_ADV_DATA_CB(_active_power_cb, _cost_cb) { } > #define EM_DATA_CB(_active_power_cb) { } > #define EM_SET_ACTIVE_POWER_CB(em_cb, cb) do { } while (0) > +#define EM_UPDATE_CB(_update_cb) { } > > static inline > int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states, > --