Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp434021rdb; Thu, 30 Nov 2023 08:26:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IFugnbK90IwDTpkODe3AwvIP9L0Na1/gthI6eMGmkyeGzDACsvE2vfFaRljKkz81oG3+O33 X-Received: by 2002:a17:90b:1c8c:b0:280:c98f:2092 with SMTP id oo12-20020a17090b1c8c00b00280c98f2092mr22452317pjb.33.1701361573674; Thu, 30 Nov 2023 08:26:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701361573; cv=none; d=google.com; s=arc-20160816; b=xcj3nV6tSNOq2HAhqtg7rRtTEXsBSlW0FR3GKuPFfKvJ0u/CEjJZCAVr8vYYPLjKQs HOyeJQfuMEIgPMQCf6xMzaO4vdZZM0m1cuTv2oiZ3bTN/KCNwUxhtY6v+ItUInDeZ+Nu hlnpzC1J+fP9L7dA34ysGu8uuKJYguECi3LWPgxfGzs9Y3XMDUFGwJfhgukAu+/f8RNz OiAflmn73eIdHkqASCSrFUuqqBorBpf/ch3LxJy89GPpU/Af5+Pz/b6btF7+bfumIsoi URFCxLMmgiK3onwptYs7cq6jN5khygsqm3BJJYgbtLLBQSMncQZyhn3BWiEc9U7u+DtL I46g== 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=oUIgrCVRHDbKT5m6DfVKt7AJO1fBahgNWp++5Si9Qqw=; fh=eklqjAdhlKrrw5/bFT/WuYGvpfp2EHXDxAHVuR+/XKk=; b=dQlbbrmOwoH4bCbgY1UtdX7q4McWgoCT7TP2WXegKmCVNkbhJdrS2j/jrDLJSU1zMb YrjFt0YNdpU4BdNN/ejD0nPrJoWAWr6vupbwKvqCKctlKabTSQBliBU0L+hDoaO2OUvg DYBRyTUSBlsonP4XUy5p/M68xWT2VB7Ld0LYlBea3CDLzkNFdEJjFChWXqcJuL5ERpAR h3afi9XYR2nFD5nJ51yow7U94jxboT/+nsfjgt+W6+vLqWQJS2/fcJ5rLBwIqs9c1/wg LmkVXebHVv5gMUk9tG4eTNtTqmfyUy8YGkyR3wpJJBhXfu87V8UDCyRpOJ/U9iRRXCbn MgZw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id fu22-20020a17090ad19600b002859a8c63f4si3825532pjb.160.2023.11.30.08.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 08:26:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id DBABE82C401D; Thu, 30 Nov 2023 08:26:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232100AbjK3QZy (ORCPT + 99 others); Thu, 30 Nov 2023 11:25:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345452AbjK3QZn (ORCPT ); Thu, 30 Nov 2023 11:25:43 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7C8EE198; Thu, 30 Nov 2023 08:25:49 -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 EACC81042; Thu, 30 Nov 2023 08:26:35 -0800 (PST) Received: from pluto (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 11E1B3F6C4; Thu, 30 Nov 2023 08:25:46 -0800 (PST) Date: Thu, 30 Nov 2023 16:25:44 +0000 From: Cristian Marussi To: Sudeep Holla Cc: Sibi Sankar , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_mdtipton@quicinc.com, linux-arm-kernel@lists.infradead.org, quic_asartor@quicinc.com, quic_lingutla@quicinc.com Subject: Re: [PATCH 2/3] firmware: arm_scmi: Fix freq/power truncation in the perf protocol Message-ID: References: <20231129065748.19871-1-quic_sibis@quicinc.com> <20231129065748.19871-3-quic_sibis@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 pete.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 (pete.vger.email [0.0.0.0]); Thu, 30 Nov 2023 08:26:11 -0800 (PST) On Thu, Nov 30, 2023 at 01:56:56PM +0000, Sudeep Holla wrote: > On Thu, Nov 30, 2023 at 12:49:42PM +0000, Cristian Marussi wrote: > > On Thu, Nov 30, 2023 at 12:05:06PM +0000, Sudeep Holla wrote: > > > On Wed, Nov 29, 2023 at 12:27:47PM +0530, Sibi Sankar wrote: > > > > Fix frequency and power truncation seen in the performance protocol by > > > > casting it with the correct type. > > > > > > > > > > While I always remembered to handle this when reviewing the spec, seem to > > > have forgotten when it came to handling in the implementation :(. Thanks > > > for spotting this. > > > > > > However I don't like the ugly type casting. I think we can do better. Also > > > looking at the code around the recently added level index mode, I think we > > > can simplify things like below patch. > > > > > > Cristian, > > > What do you think ? > > > > > > > Hi > > > > the cleanup seems nice in general to compact the mult_factor multipliers > > in one place, and regarding addressing the problem of truncation without > > the need of the explicit casting, should not be enough to change to > > additionally also change mult_factor to be an u64 ? > > > > I started exactly with that, but when I completed the patch, there was no > explicit need for it, so dropped it again. I can bump mult_factor to be > u64 but do you see any other place that would need it apart from having > single statement that does multiplication and assignment ? I am exploiting > the conditional based on level_indexing_mode here but I agree it may help > in backporting if I make mult_factor u64. > Ah right freq *= dom->multi_fact; does the trick..but cannot this by itself (under unplausibl conds) overflow and does not fit into a u32 mult_factor ? dom_info->mult_factor = (dom_info->sustained_freq_khz * 1000UL) / dom_info->sustained_perf_level; Thanks, Cristian