Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1171550rdb; Fri, 1 Dec 2023 08:43:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEF2qZH3v4qIFeL/cdpT8Px7XrR+TgUlgNQtQ+gpXcqhyFxFR4Nv8r44MwI2VsXdLjp9ToO X-Received: by 2002:a17:902:9042:b0:1cc:379b:3505 with SMTP id w2-20020a170902904200b001cc379b3505mr22726611plz.49.1701448998416; Fri, 01 Dec 2023 08:43:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701448998; cv=none; d=google.com; s=arc-20160816; b=O0xAQi375B0w3SeU5JcM+ST/MONY6T7GMp8qAWn1sTFGMQv82TaO5T1gNv+uQrnhSC vSLCme/7/bqMS5fGhQgU121cVMrAVBAJb85xRJgpmg9eMccVWq0Zh6zIS2BPaVWEjr0D dnxCbBQB45/vaAS9hqRjKogswsLBDL9X8vnrxZECl5NVTj7LXUWJXm9NQjRTW8vVfujV E0SOPsj7V8oBrTLiVqQ3e+tr1eo2azHifTLY47EApkw49TxlXGy+DtbfTB+vMfde9rkB bflwPAVxce9kQSpk9f8tkJ+dq7qlIdASFpFtEsdg0V6JuSw71FMLiZ4HjSb/I9OMxF/U qS5Q== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=9T+uomzN+dkzWbAFRnQQIJWeUSpWmU1ByqNPd/nfb9w=; fh=3fpC9MaHkZZbhpQ9+r/FXZpLVi70h5mRZrKxUCeO+nI=; b=vfUadWFGbP6/xcYWJfiG/zxeFaUGK19Ofv2jeAPw8V4HAnnFZk4tQba7dE0EyNRPOv ua+QjKTs+QNl94PmoRw20bLicFHJg1V1yBmimR+7WqgkSjl62Ll4b87WXFXTMJsHniIC YvL6VPK2w/boNqkZbiWxo6skrq3WjpRvfGxqznXv7nhlZGLrX0r1yvjz2H+9F4IebOYn U0u0ALCcwj2SKNNdRVkpZUvV4C40GkhY6vUkYfiY7Xh12jFZU1PjTB6vvKLWCEcu92kD fQ1xnlmTP/VvdsxXnKfLCxrEb5xSTscdatqZSXyEaZty8xzIJOvP+VKlHHnDYXO6uhGm Z/cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id 12-20020a170902c20c00b001cfb967b763si3456884pll.32.2023.12.01.08.43.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 08:43:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 576D8819CC2E; Fri, 1 Dec 2023 08:43:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229533AbjLAQnA (ORCPT + 99 others); Fri, 1 Dec 2023 11:43:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbjLAQm7 (ORCPT ); Fri, 1 Dec 2023 11:42:59 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 31F20A6; Fri, 1 Dec 2023 08:43:06 -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 5371C1007; Fri, 1 Dec 2023 08:43:52 -0800 (PST) Received: from bogus (unknown [10.57.42.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 199DB3F6C4; Fri, 1 Dec 2023 08:43:03 -0800 (PST) Date: Fri, 1 Dec 2023 16:41:02 +0000 From: Sudeep Holla To: Cristian Marussi 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 1/2] firmware: arm_scmi: Fix frequency truncation by promoting multiplier to u64 Message-ID: <20231201164102.lb2o3mgdgjmtfknk@bogus> References: <20231130204343.503076-1-sudeep.holla@arm.com> <20231201143935.be6wzjzxmyl5vpz6@bogus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 01 Dec 2023 08:43:15 -0800 (PST) On Fri, Dec 01, 2023 at 04:17:56PM +0000, Cristian Marussi wrote: > On Fri, Dec 01, 2023 at 02:39:35PM +0000, Sudeep Holla wrote: > > On Thu, Nov 30, 2023 at 08:43:42PM +0000, Sudeep Holla wrote: > > > Fix the frequency truncation for all values equal to or greater 4GHz by > > > updating the multiplier 'mult_factor' to u64 type. It is also possible > > > that the multiplier itself can be greater than or equal to 2^32. So we need > > > to also fix the equation computing the value of the multiplier. > > > > > > Fixes: a9e3fbfaa0ff ("firmware: arm_scmi: add initial support for performance protocol") > > > 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 > > > --- > > > drivers/firmware/arm_scmi/perf.c | 6 +++--- > > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > > > diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c > > > index 81dd5c5e5533..8ce449922e55 100644 > > > --- a/drivers/firmware/arm_scmi/perf.c > > > +++ b/drivers/firmware/arm_scmi/perf.c > > > @@ -152,7 +152,7 @@ struct perf_dom_info { > > > u32 opp_count; > > > u32 sustained_freq_khz; > > > u32 sustained_perf_level; > > > - u32 mult_factor; > > > + u64 mult_factor; > > > > I have now changed this to unsigned long instead of u64 to fix the 32-bit > > build failure[1]. > > Right, I was caught a few times too by this kind of failures on v7 :D > ???? > ... but this 32bit issue makes me wonder what to do in such a case... > Same here, but the frequency calculations are also unsigned long in higher layers, so I don't see any point in making it u64(also 32-bit doesn't support 32bit value to be divided by a 64bit value which adds unnecessary complications here). > ...I mean, on 32bit if the calculated freq oveflows, there is just > nothing we can do on v7 without overcomplicating the code...but I suppose > it is unplausible to have such high freq on a v7... Yes this is exactly the argument I made myself and got convinced to keep it unsigned long(KISS approach) unless we need it on v7. > as a palliative I can only think of some sort of overflow check (only on v7) > that could trigger a warning ... but it is hardly worth the effort > probably.. > Not sure myself. -- Regards, Sudeep