public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Cristian Marussi <cristian.marussi@arm.com>
To: Philip Radford <philip.radford@arm.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, arm-scmi@vger.kernel.org,
	linux-pm@vger.kernel.org, sudeep.holla@arm.com,
	james.quinlan@broadcom.com, f.fainelli@gmail.com,
	vincent.guittot@linaro.org, etienne.carriere@st.com,
	peng.fan@oss.nxp.com, michal.simek@amd.com,
	quic_sibis@quicinc.com, dan.carpenter@linaro.org, d-gole@ti.com,
	souvik.chakravarty@arm.com, cristian.marussi@arm.com
Subject: Re: [PATCH v5 06/12] firmware: arm_scmi: Extend powercap report to include MAI
Date: Tue, 5 May 2026 21:13:32 +0100	[thread overview]
Message-ID: <afpPbHkvNE0ijM9n@pluto> (raw)
In-Reply-To: <20260428090922.346069-7-philip.radford@arm.com>

On Tue, Apr 28, 2026 at 10:09:15AM +0100, Philip Radford wrote:
> Extend scmi_powercap_meas_changed_report to include MAI change
> notifications.
> 

Hi

> Signed-off-by: Philip Radford <philip.radford@arm.com>
> ---
>  drivers/firmware/arm_scmi/powercap.c | 20 ++++++++++++--------
>  include/linux/scmi_protocol.h        |  1 +
>  2 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/firmware/arm_scmi/powercap.c b/drivers/firmware/arm_scmi/powercap.c
> index 1d1188e98d49..b9d50f4e8ae5 100644
> --- a/drivers/firmware/arm_scmi/powercap.c
> +++ b/drivers/firmware/arm_scmi/powercap.c
> @@ -11,6 +11,7 @@
>  #include <linux/io.h>
>  #include <linux/module.h>
>  #include <linux/scmi_protocol.h>
> +#include <linux/stddef.h>
>  
>  #include <trace/events/scmi.h>
>  
> @@ -164,6 +165,7 @@ struct scmi_powercap_meas_changed_notify_payld {
>  	__le32 agent_id;
>  	__le32 domain_id;
>  	__le32 power;
> +	__le32 mai;
>  };
>  
>  struct scmi_msg_powercap_cpc {
> @@ -1212,13 +1214,6 @@ static int scmi_powercap_notify(const struct scmi_protocol_handle *ph,
>  		if (ret)
>  			return ret;
>  
> -		if (enable && !low && !high) {
> -			dev_err(ph->dev,
> -				"Invalid Measurements Notify thresholds: %u/%u\n",
> -				low, high);
> -			return -EINVAL;
> -		}
> -

Ok so you removed this check because now that a notification can be
emitted even only to notify a MAI change, it is possible that the
thresholds are zero and the notification will be emitted anyway due to
a MAI change....BUT you have to review or completely remove the comment
block that precedes this that says:

   /*                                                               
    * Note that we have to pick the most recently configured        
    * thresholds to build a proper POWERCAP_MEASUREMENTS_NOTIFY     
    * enable request and we fail, complaining, if no thresholds     
    * were ever set, since this is an indication the API has been   
    * used wrongly.                                                 
    */                                                              

...becasue NOW is no more true and misleading, since you just removed the
fail and complain part...

It would be good to shortly explain in a comment the new possible
scenarios in which notification can be enabled...

>  		ret = ph->xops->xfer_get_init(ph, message_id,
>  					      sizeof(*notify), 0, &t);
>  		if (ret)
> @@ -1333,14 +1328,23 @@ scmi_powercap_fill_custom_report(const struct scmi_protocol_handle *ph,
>  	{
>  		const struct scmi_powercap_meas_changed_notify_payld *p = payld;
>  		struct scmi_powercap_meas_changed_report *r = report;
> +		const size_t sz_v2 = offsetofend(struct scmi_powercap_meas_changed_notify_payld,
> +						 power);
> +		const size_t sz_v3 = sizeof(*p);

While this is a valid and nice construct, I think is overkill here since
these offsets/sizes will never change at runtime....

...you can just define above a couples of DEFINE that hardcodes the
sizes of the v2 and v3 by using the

	#define SZ_V2 	(sizeof(struct scmi_powercap_meas_changed_notify_payld))

and
	#define SZ_V3   (SZ_V2 - sizeof(__le32))

>  
> -		if (sizeof(*p) != payld_sz)
> +		if (payld_sz != sz_v2 && payld_sz != sz_v3)
>  			break;
>  
>  		r->timestamp = timestamp;
>  		r->agent_id = le32_to_cpu(p->agent_id);
>  		r->domain_id = le32_to_cpu(p->domain_id);
>  		r->power = le32_to_cpu(p->power);

maybe more clear to simply:
		
		r->mai = 0;
		if (payld_sz == SZ_V3 && PROTOCOL_REV_MAJOR(ph->version) >= 0x3)
			r->mai = le32_to_cpu(p->mai);

		
> +
> +		if (payld_sz == sz_v3 && PROTOCOL_REV_MAJOR(ph->version) >= 0x3)
> +			r->mai = le32_to_cpu(p->mai);
> +		else
> +			r->mai = 0;
> +
>  		*src_id = r->domain_id;

Thanks,
Cristian

  reply	other threads:[~2026-05-05 20:13 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-28  9:09 [PATCH v5 00/12] Add support for SCMIv4.0 Powercap Extensions Philip Radford
2026-04-28  9:09 ` [PATCH v5 01/12] firmware: arm_scmi: Add an optional custom parameter to fastchannel helpers Philip Radford
2026-04-28  9:09 ` [PATCH v5 02/12] firmware: arm_scmi: Refactor powercap domain layout Philip Radford
2026-04-28  9:09 ` [PATCH v5 03/12] firmware: arm_scmi: Add SCMIv4.0 Powercap basic support Philip Radford
2026-04-28  9:09 ` [PATCH v5 04/12] firmware: arm_scmi: Add SCMIv4.0 Powercap FCs support Philip Radford
2026-04-28  9:09 ` [PATCH v5 05/12] firmware: arm_scmi: Add SCMIV4.0 Powercap notifications support Philip Radford
2026-04-28  9:09 ` [PATCH v5 06/12] firmware: arm_scmi: Extend powercap report to include MAI Philip Radford
2026-05-05 20:13   ` Cristian Marussi [this message]
2026-05-05 21:21     ` Philip Radford
2026-04-28  9:09 ` [PATCH v5 07/12] include: trace: Add new parameter to trace_scmi_fc_call Philip Radford
2026-04-28  9:09 ` [PATCH v5 08/12] powercap: arm_scmi: Enable multiple constraints support Philip Radford
2026-04-28  9:09 ` [PATCH v5 09/12] firmware: arm_scmi: add Powercap MAI get/set support Philip Radford
2026-05-05 20:36   ` Cristian Marussi
2026-05-05 21:44     ` Philip Radford
2026-05-05 22:09       ` Cristian Marussi
2026-04-28  9:09 ` [PATCH v5 10/12] powercap: arm_scmi: Create synthetic parent node for multi-instance Philip Radford
2026-05-05 22:03   ` Cristian Marussi
2026-05-06 10:35     ` Philip Radford
2026-04-28  9:09 ` [PATCH v5 11/12] powercap: arm_scmi: Add get_power_uw to synthetic node Philip Radford
2026-05-05 22:13   ` Cristian Marussi
2026-05-06 10:37     ` Philip Radford
2026-04-28  9:09 ` [PATCH v5 12/12] powercap: arm_scmi: Synthetic zone enable/disable Philip Radford
2026-05-05 22:28   ` Cristian Marussi
2026-05-06 10:51     ` Philip Radford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=afpPbHkvNE0ijM9n@pluto \
    --to=cristian.marussi@arm.com \
    --cc=arm-scmi@vger.kernel.org \
    --cc=d-gole@ti.com \
    --cc=dan.carpenter@linaro.org \
    --cc=etienne.carriere@st.com \
    --cc=f.fainelli@gmail.com \
    --cc=james.quinlan@broadcom.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=michal.simek@amd.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=philip.radford@arm.com \
    --cc=quic_sibis@quicinc.com \
    --cc=souvik.chakravarty@arm.com \
    --cc=sudeep.holla@arm.com \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox