Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1158468rdb; Fri, 1 Dec 2023 08:24:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5EHR8qIvKA+7fYdeN79VnBgE8fmCfcTyEemM+QugNQQth/Irgr/WMdU7Vvly0utgoWvSH X-Received: by 2002:a05:6e02:c8a:b0:35d:4efa:e8eb with SMTP id b10-20020a056e020c8a00b0035d4efae8ebmr2859550ile.7.1701447864600; Fri, 01 Dec 2023 08:24:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701447864; cv=none; d=google.com; s=arc-20160816; b=VPZnhPIcbG1jAjoPlEO5hvPOFzcwKx4MRe2NGwPBKbyaDDzX2YL2wVvKJwVju0RQSO p54NM+ETm7sDoYPFpOKQcFOhpi5uvz52x6af1PnqLPkPVCQo/TUZ7BS82H3Qz8c4CcYO M5+w36lWLSQpCSZ5YWnmLfDRuo4PRol8bisJHm6M/zxjr4W1DVk1Hn1QLvWp5jGa3Kmh CjbHZUV/MOUAaF/qUUJ2w2LE2+eN//11d+CLsWFBagGVpfSxfxytgpCeruNFUjtaGF5O nFQkIQb7VnK58+klBQdP4mnkD6p1dcsULF0JPS52DTVtOo0i+1gnM4MKr0Jb1NvxoQIw dBAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=JZzo3Yska4/YKTFXTc6z0iZoKVcLMuEPG9R+UHIwY1Q=; fh=M0L2O/dAzErEPhmdqQLe0e8L9u5AdcJ3puKPlkOLPfM=; b=BwLUwFEov2vAehrmvUZzkfBy2DUtu3umGxDt0Yg4VKY1NfZlIaHc2cO+pZ3bRZTGLs E0DcYM2HOC7xgnEvArBwDvQCKOrpqrVg+5sjPW0lEag8DxdD4a/ihZfexJKEwy7LEd81 CZrl77pWDIW11o95ePR6loQAqqnoYOmf1ugDKq5S8MCj4jO0nHV6MzsxxMVBF7VtIDaF G0ldWXDV8WDdP1kA+jawg4/jdDrKai9ufS++Pat76PTIGVxlM+9MxTgxl+IFF92dGyeB gRE79P0i4IpBf+LBj4iGDaFx+i10BMu4UKnk7CZa21P+d8/iw/R1NMTKmgwBcLSorzRd OVXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id u1-20020a6540c1000000b005b882238681si3596775pgp.620.2023.12.01.08.24.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 08:24:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8DFA7810498C; Fri, 1 Dec 2023 08:24:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229674AbjLAQX7 (ORCPT + 99 others); Fri, 1 Dec 2023 11:23:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbjLAQX5 (ORCPT ); Fri, 1 Dec 2023 11:23:57 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0FD1095; Fri, 1 Dec 2023 08:24:03 -0800 (PST) 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 2CC601007; Fri, 1 Dec 2023 08:24:49 -0800 (PST) Received: from pluto (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8EF1F3F6C4; Fri, 1 Dec 2023 08:24:01 -0800 (PST) Date: Fri, 1 Dec 2023 16:23:58 +0000 From: Cristian Marussi To: Sudeep Holla Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, quic_mdtipton@quicinc.com, quic_asartor@quicinc.com, quic_lingutla@quicinc.com, Sibi Sankar , linux-arm-msm@vger.kernel.org Subject: Re: [PATCH 2/2] firmware: arm_scmi: Fix possible frequency truncation when using level indexing mode Message-ID: References: <20231130204343.503076-1-sudeep.holla@arm.com> <20231130204343.503076-2-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231130204343.503076-2-sudeep.holla@arm.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 01 Dec 2023 08:24:13 -0800 (PST) On Thu, Nov 30, 2023 at 08:43:43PM +0000, Sudeep Holla wrote: > The multiplier is already promoted to u64, however the frequency > calculations done when using level indexing mode doesn't use the > multiplier computed. It instead hardcodes the multiplier value of 1000 > at all the usage sites. > > Clean that up by assigning the multiplier value of 1000 when using > the perf level indexing mode and upadte the frequency calculations to ^update > use the multiplier instead. It should fix the possible frequency > truncation for all the values greater than or equal to 4GHz. > > Fixes: 31c7c1397a33 ("firmware: arm_scmi: Add v3.2 perf level indexing mode support") > Reported-by: Sibi Sankar > Closes: https://lore.kernel.org/all/20231129065748.19871-3-quic_sibis@quicinc.com/ > Cc: Cristian Marussi > Signed-off-by: Sudeep Holla > --- Other than the typo, LGTM. Reviewed-by: Cristian Marussi Thanks, Cristian > drivers/firmware/arm_scmi/perf.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c > index 8ce449922e55..875dcb71bb65 100644 > --- a/drivers/firmware/arm_scmi/perf.c > +++ b/drivers/firmware/arm_scmi/perf.c > @@ -268,7 +268,8 @@ scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph, > dom_info->sustained_perf_level = > le32_to_cpu(attr->sustained_perf_level); > if (!dom_info->sustained_freq_khz || > - !dom_info->sustained_perf_level) > + !dom_info->sustained_perf_level || > + dom_info->level_indexing_mode) > /* CPUFreq converts to kHz, hence default 1000 */ > dom_info->mult_factor = 1000; > else > @@ -806,7 +807,7 @@ static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph, > if (!dom->level_indexing_mode) > freq = dom->opp[idx].perf * dom->mult_factor; > else > - freq = dom->opp[idx].indicative_freq * 1000; > + freq = dom->opp[idx].indicative_freq * dom->mult_factor; > > data.level = dom->opp[idx].perf; > data.freq = freq; > @@ -853,7 +854,8 @@ static int scmi_dvfs_freq_set(const struct scmi_protocol_handle *ph, u32 domain, > } else { > struct scmi_opp *opp; > > - opp = LOOKUP_BY_FREQ(dom->opps_by_freq, freq / 1000); > + opp = LOOKUP_BY_FREQ(dom->opps_by_freq, > + freq / dom->mult_factor); > if (!opp) > return -EIO; > > @@ -887,7 +889,7 @@ static int scmi_dvfs_freq_get(const struct scmi_protocol_handle *ph, u32 domain, > if (!opp) > return -EIO; > > - *freq = opp->indicative_freq * 1000; > + *freq = opp->indicative_freq * dom->mult_factor; > } > > return ret; > @@ -910,7 +912,7 @@ static int scmi_dvfs_est_power_get(const struct scmi_protocol_handle *ph, > if (!dom->level_indexing_mode) > opp_freq = opp->perf * dom->mult_factor; > else > - opp_freq = opp->indicative_freq * 1000; > + opp_freq = opp->indicative_freq * dom->mult_factor; > > if (opp_freq < *freq) > continue; > -- > 2.43.0 >