Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp750527pxu; Wed, 6 Jan 2021 03:29:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwgpI8Wz/tDeS9GUmE4bQ6I8vb8YKlv0po0vOqvHXagy4AAtk6jqZgI+lSA9xl1gM7K73AN X-Received: by 2002:a17:906:3101:: with SMTP id 1mr2593892ejx.115.1609932553620; Wed, 06 Jan 2021 03:29:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609932553; cv=none; d=google.com; s=arc-20160816; b=WZdgAbjF7kwFTzKA5cxOJ7OtyXQ5VzewUXq66pZxq5bn0PGIYBRDt+p8P0Mwc3Ztn3 FPoWzR2g5CskxBdCB7DFIg3NdbNYrC2uZCnkq5CzKPCQVwmLPMdmwER9HUlIfYloxc2L ijd6fa14oCb6OB6bwqcc1v3rEvM8W4SJEYArFRYSd036FSQy8ByfVJeY6uXgYcGQNL4n eoI0H/lRNnu/PS5lDniZaOlob6EnpHf60lKeF30n2GMgU/N3PwKIDDxHjxPDMkGAAQFl pSa5x7kxd5SR85Q9J/ptY3J3BYSLI8/4UQJffurrRTpod4MjD1yQYyQetDsKD4tfMVD8 bsdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=WaaustMF60swBpMZHKlmRk8G4WbaUDog0R4P/QvN/yk=; b=AQeW6NgfwGyN3drIl44tOInp+32RNc1PGXtFUMPIvryQ7s6KiHZxkClSfmjXEUdEek 7gn3P3z2r3xOMmP6cmDBi67qqeaz4R4rgy+/JOteivNWfyZGco1FSVIyjT3r5I2A6bso GjPjmD0aldBlmsXWHLzRXHjDM62uaNBLRAWnnKPJIZEWNHp/Jo3BfJ3HISg4XAoSmPcD yUqk27yCFnzpy/9CpRUCCFLyOerolwvcF1KxtHe25N36y+L54YcO3mCRaa6T2AQW1qmu MBDLSAQNQq4quDXHVUFbAQIti2gKor2pI05heVAhqNXe4kE3ez1TP2sw/1UbmvIF9puK S9kQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q8si792176ejj.24.2021.01.06.03.28.49; Wed, 06 Jan 2021 03:29:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725903AbhAFL1v (ORCPT + 99 others); Wed, 6 Jan 2021 06:27:51 -0500 Received: from foss.arm.com ([217.140.110.172]:39588 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725877AbhAFL1v (ORCPT ); Wed, 6 Jan 2021 06:27:51 -0500 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 26B88D6E; Wed, 6 Jan 2021 03:27:05 -0800 (PST) Received: from e120937-lin (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7E2E03F719; Wed, 6 Jan 2021 03:27:02 -0800 (PST) Date: Wed, 6 Jan 2021 11:26:59 +0000 From: Cristian Marussi To: Jonathan Cameron Cc: Jyoti Bhayana , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Mauro Carvalho Chehab , "David S. Miller" , Rob Herring , Lukas Bulwahn , linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, sudeep.holla@arm.com, egranata@google.com, mikhail.golubev@opensynergy.com, Igor.Skalkin@opensynergy.com, Peter.hilber@opensynergy.com, ankitarora@google.com Subject: Re: Reply to [RFC PATCH v2 0/1] Adding support for IIO SCMI based sensors Message-ID: <20210106112659.GA9138@e120937-lin> References: <20201230123748.4e969f82@archlinux> <20210105230920.769144-1-jbhayana@google.com> <20210106102917.0000332c@Huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210106102917.0000332c@Huawei.com> User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi On Wed, Jan 06, 2021 at 10:29:17AM +0000, Jonathan Cameron wrote: > On Tue, 5 Jan 2021 23:09:20 +0000 > Jyoti Bhayana wrote: > > > Hi Jonathan, > > > > > So, sensor_max_range can effectively be exposed as a combination of > > > scale and the *_raw_avail for a raw read (via the read_avail callback in IIO). > > > We'll ignore the fact the interface assumes a single value (so I assume symmetric?) > > > > Based on the SCMI specification the sensor min range and max range are 64 bits signed number. > > > > looks like IIO_AVAIL_RANGE can only take the following > > types of data which all looks like 32 bit. IIO_VAL_FRACTIONAL > > also takes two int type numbers. > > How can I send 64 bit sensor range using this and read_avail callback? > > > > #define IIO_VAL_INT 1 > > #define IIO_VAL_INT_PLUS_MICRO 2 > > #define IIO_VAL_INT_PLUS_NANO 3 > > #define IIO_VAL_INT_PLUS_MICRO_DB 4 > > #define IIO_VAL_INT_MULTIPLE 5 > > #define IIO_VAL_FRACTIONAL 10 > > #define IIO_VAL_FRACTIONAL_LOG2 11 > > #define IIO_VAL_CHAR 12 > > Hmm It is a bit unfortunate that SCMI decided to pretend that real sensor resolutions were > greater than 32 bits. I doubt they will ever actually be any (as such accurate measurements > are completely pointless) and they aren't anywhere near that today. Only way it might end > up looking a bit like that would be result of a highly non linear sensor being shoved through > an interface that pretends it isn't (goody). > We shared this info internally to involve our architects about this. > Having said that, specifications are what they are and we have to cope with that. > > There is no real problem with defining a new value type except for the fact that any > legacy userspace won't necessarily expect to see values that large. Given we need the full > 64 bits it would have to be something like > IIO_VAL_INT_H32_L32 with the 64 bit values split up appropriately and put back together > at time of formatting. Not particularly pretty but I'm not keep to put that much effort > in to support something like this for one driver (so not interesting in changing that > the read_raw_* interfaces) > Regarding the current spec and this IIODEV limit to 32bit, I was thinking about the following horrid thing (:D) as a solution: given that as of now no sensor exist in real life reporting bigger than 32bits values, instead of adding new defines in IIODEV framework to support 64bit that no userspace is expecting and no sensor will really emit ever in the foreseable future, couldn't this SCMI IIODEV driver simply: - truncate silently straight away 64bit vals into 32bit when detects that he upper MSB 32bit are unused (zeros or sign-extension) and in fact the values fits into 32bits - WARN and do not truncate if the upper MSB 32bit are in fact valid because such a 64bit capable sensor was indeed used finally (at that point in time IIODEV driver and framework will need a 64bit update) Or I am missing something ? Feel free to insult me about this hack ... :D Thanks Cristian > Jonathan > > > > > > > > > > Thanks, > > Jyoti > > >