From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EA67606A339 for ; Fri, 4 Dec 2026 13:34:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=sGDgBofA; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=TD8LBtnT DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=I1N/s+Xt+Q4PkVPRK+bhNf/juJwizsMWP4pUYLaaj8U=; b=sGDgBofAkgQrHcsUe1H2JmRcrn QSURR/4h8kvJ5wZ2pZrXJTqkupQrdap+LtyhamzJnq9/HVSC39PfPLMpkkwfR8Lzlzy3s8DsaDX3Q 10x2cb8uesX91W3UGSA9qkCz1xoUnYTY1DnZ/E/rAjQbSfF8UgKebKDhbW+pXmQvPy8hOmQ2Wxbzw HVgwKGDg9JS96CMsxATpm1a4MC2ScfWVXyXxFe5svNcQWDiiZE5VINjuaC2UMYUCHjKkG6qOIOKKH Bin0a/m+79+Qjbyfpiy/yjpyJf32MNC3pa4g1TnH+4G2PiNEGQyJh9q9+EC+hQrlVQlvH1JdD4VNe IMNRRIjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZTQ7-00000000Q98-2T6K; Fri, 04 Dec 2026 13:33:51 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZTQ3-00000000Q6V-0RJI for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2026 13:33:49 +0000 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 1A70014BF; Fri, 4 Dec 2026 05:33:43 -0800 (PST) Received: from pluto (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 158A93F632; Fri, 4 Dec 2026 05:33:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796391225; bh=0dNSCW3mwJMSPxs0EY6EbwjXAHhzUSuh5DdYeacGwYI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TD8LBtnTORuErp9eMjpFrLeHiRMJC+vcYq2KEwbtkCO4A80X59aYxmhnORRLHCepA U3k2XNwxSRhcNpqr98a1aBOtnawJZGwTNhb7fhpYmJnnH81gt6rK+78J6qpcBVFEVF rHYcNmmpBaQfUY3cQN/ui2CCs0mFK3Rg2CSf85zc= Date: Fri, 4 Dec 2026 13:33:40 +0000 From: Cristian Marussi To: Philip Radford 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 Subject: Re: [PATCH v1 1/1] firmware: arm_scmi: Lock powercap state updates Message-ID: References: <20261204111428.1004885-1-philip.radford@arm.com> <20261204111428.1004885-2-philip.radford@arm.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261204111428.1004885-2-philip.radford@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261204_053347_262425_45809F15 X-CRM114-Status: GOOD ( 17.12 ) X-Spam-Score: -4.4 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-16.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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 > 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 > --- > 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 > #include > #include > +#include > #include > > #include > @@ -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