The Linux Kernel Mailing List
 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,
	sudeep.holla@arm.com, cristian.marussi@arm.com,
	Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH v1 1/1] firmware: arm_scmi: Lock powercap state updates
Date: Fri, 4 Dec 2026 13:33:40 +0000	[thread overview]
Message-ID: <axLBNKMFdiF8j7UZ@pluto> (raw)
In-Reply-To: <20261204111428.1004885-2-philip.radford@arm.com>

On Fri, Dec 04, 2026 at 11:14:28AM +0000, Philip Radford wrote:
> Add a per-domain mutex to prevent concurrent limit and enable writes
> leaving the cached state out of sync during CAP_SET operations.
> 

Hi Philip,

> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/bug/linux-1d52cced-b877-4a25-a7eb-fa3de15745f9
> Fixes: 758cd5fc13b2 ("firmware: arm_scmi: Add Powercap protocol enable support")
> Signed-off-by: Philip Radford <philip.radford@arm.com>
> ---
>  drivers/firmware/arm_scmi/powercap.c | 37 +++++++++++++++++++++++++---
>  1 file changed, 33 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/firmware/arm_scmi/powercap.c b/drivers/firmware/arm_scmi/powercap.c
> index e6dd18c6a154..144e6435869a 100644
> --- a/drivers/firmware/arm_scmi/powercap.c
> +++ b/drivers/firmware/arm_scmi/powercap.c
> @@ -10,6 +10,7 @@
>  #include <linux/bitfield.h>
>  #include <linux/io.h>
>  #include <linux/module.h>
> +#include <linux/mutex.h>
>  #include <linux/scmi_protocol.h>
>  
>  #include <trace/events/scmi.h>
> @@ -111,6 +112,8 @@ struct scmi_powercap_meas_changed_notify_payld {
>  };
>  
>  struct scmi_powercap_state {
> +	/* Lock protects enabled and last_pcap while changing a domain power cap */
> +	struct mutex lock;
>  	bool enabled;
>  	u32 last_pcap;
>  	bool meas_notif_enabled;
> @@ -444,6 +447,7 @@ static int scmi_powercap_cap_set(const struct scmi_protocol_handle *ph,
>  				 bool ignore_dresp)
>  {
>  	struct powercap_info *pi = ph->get_priv(ph);
> +	int ret;
>  
>  	/*
>  	 * Disallow zero as a possible explicitly requested powercap:
> @@ -457,10 +461,18 @@ static int scmi_powercap_cap_set(const struct scmi_protocol_handle *ph,
>  		if (!scmi_powercap_dom_info_get(ph, domain_id))
>  			return -EINVAL;
>  
> +		mutex_lock(&pi->states[domain_id].lock);
> +
>  		if (!pi->states[domain_id].enabled) {
>  			pi->states[domain_id].last_pcap = power_cap;
> -			return 0;
> +			ret = 0;

Use cleanup handlers all over this series and it should be much more clean.

Just this.

Thanks,
Cristian

  reply	other threads:[~2026-12-04 13:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 11:14 [PATCH v1 0/1] firmware: arm_scmi: Lock powercap state updates Philip Radford
2026-12-04 11:14 ` [PATCH v1 1/1] " Philip Radford
2026-12-04 13:33   ` Cristian Marussi [this message]
2026-12-04 11:39 ` [PATCH v1 0/1] " Cristian Marussi

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=axLBNKMFdiF8j7UZ@pluto \
    --to=cristian.marussi@arm.com \
    --cc=arm-scmi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=philip.radford@arm.com \
    --cc=sashiko-bot@kernel.org \
    --cc=sudeep.holla@arm.com \
    /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