From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2A921C4167B for ; Fri, 1 Dec 2023 16:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=285zf7+rUu8SN/9++Xi+AoHIe/hLVMwJ22g40OkxlNg=; b=hOq6pdtJid8Tdp SvSMNmQaxeyH4eUlqYZ2/XFwud49X/gEmC/DI4mln1cXCWMa1FeXfkbkgoACfYY1b/PRH9DHRtTLn Rb1MSuvlvedfhkjn1oZZFqJNhq0td9E5C/Xnu/Ts4E51BeRGNw54VerJT6g5QHJVI6Z9rUvSNufc2 xoO/bHvcV8uAPw+Ame5ZuXXw8lGHDcx3IGp8fsi8Vrjh0zkHEFTX31MVvKnAnMGxoj8SWnOFbTBJe b13W9j/jPrWgPqC8bTELfzi1+oun4PR3RqTVKONUPTnPu7i19hKYXBUOCGhZ4nsLBj1L/kLwKtdna Ni8W+fP7Da9sA5WJ3lLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r96JC-00EBAr-1t; Fri, 01 Dec 2023 16:24:06 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r96J9-00EBAP-2m for linux-arm-kernel@lists.infradead.org; Fri, 01 Dec 2023 16:24:05 +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 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-Disposition: inline In-Reply-To: <20231130204343.503076-2-sudeep.holla@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231201_082403_993626_48A02A5D X-CRM114-Status: GOOD ( 19.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel