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 51DD2C433EF for ; Fri, 25 Mar 2022 11:42:28 +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=olb4cBVIg467yN5pIXsW4M/UqHml9Jc5SQPFjxKf8J0=; b=P2RL43ANmAZ5q3 LedAUNpVGlkq3+1zg2G0Z+r0EOpu8LjfCGcpTCISKMyYtdRadT+oY9VQs96D/IC8agarqHWenoN8I Wku48KTUNAX8uLsTC5J5P9ehnE23J8MsjziikTNN6L39WAYhqolfjKfQGq2YIRgbPPJR/oVYr3nwp AhMIc2vjxVtbXb9/+dLVIL+u0MQwU95iyH2UvEuXLTPo3a+fVAoRA2asJpfC/nnU6VCLT6+amAkiB jCos5O4OTrha5UK9JClz2qj4fvgHK24yynDEU5q1wJ/IydQsK/cag55qfGjc+YsYf8XbxG3w1ZjUJ ML4n9CJ1aHpa9R2OdbTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXiJY-001wD3-Sk; Fri, 25 Mar 2022 11:41:08 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nXiJV-001wCV-4f for linux-arm-kernel@lists.infradead.org; Fri, 25 Mar 2022 11:41:06 +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 114FB12FC; Fri, 25 Mar 2022 04:41:03 -0700 (PDT) Received: from e120937-lin (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 180C93F73B; Fri, 25 Mar 2022 04:41:01 -0700 (PDT) Date: Fri, 25 Mar 2022 11:41:00 +0000 From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, f.fainelli@gmail.com, souvik.chakravarty@arm.com, nicola.mazzucato@arm.com, cristian.marussi@arm.com Subject: Re: [RFC PATCH 0/2] Sensor readings fixes Message-ID: References: <20211220174155.40239-1-cristian.marussi@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211220174155.40239-1-cristian.marussi@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220325_044105_253105_C60E2F58 X-CRM114-Status: GOOD ( 25.54 ) 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 Mon, Dec 20, 2021 at 05:41:53PM +0000, Cristian Marussi wrote: > Hi, > > this was supposed to be an easy fix on how sensor readings are handled > across different FW versions while maintaining backward compatibility, > but the solution raised for me more questions than the issue itself... > ...so I posted as an RFC. > > In a nutshell, since SCMI FWv3.0 spec, sensors SCMI_READING_GET command > can report axis and timestamps too, beside readings, so a brand new > scmi_reading_get_timestamped protocol operation was exposed (used by IIO) > while the old scmi_reading_get was kept as it was, already used by HWMON > subsystem for other classes of sensors. > > Unfortunately, also the flavour of reported values changed from unsigned > to signed with v3.0, so if you end-up on a system running against an SCMI > v3.0 FW platform you could end up reading a negative value and interpreting > it as a big positive since scmi_reading_get reports only u64. > > 01/02 simply takes care, when a FW >= 3.0 is detected, to return an error > to any scmi_reading_get request if that would result in tryinh to carry > a negative value into an u64. > > So this should rectify the API exposed by SCMI sensor and make it > consistent in general, in such a way that a user calling it won't risk to > receive a false big-positive which was indeed a 2-complement negative from > the perpective of the SCMI fw. > > So far so good...sort of...since, to make things more dire, the HWMON > interface, which is the only current upstream user of scmi_reading_get > DOES allow indeed to report to the HWMON core negative values, so it was > just that we were silently interpreting u64 as s64 :P ... > > ...as a consequence the fix above to the SCMI API will potentially break > this undocumented behaviour of our only scmi_reading_get user. > > Additionally, while looking at this, I realized that for similar reasons > even on systems running the current SCMI stack API and an old FW <=2.0 > the current HWMON read is potentially broken, since when the FW reports > a very big and real positive number we'll report it as a signed long to > the HWMON core, so turning it wrongly into a negative report: for this > reason 02/02 adds a check inside scmi-hwmon to filter out, reporting > errors, any result reported by scmi_reading_get so big as to be considered > a negative in 2-complement... > > ...and this will probably break even more the undocumented behaviours... > > Any feedback welcome ! Hi, any feedback on this ? (...before I forgot again :D) Thanks, Cristian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel