From: Liam Beguin <liambeguin@gmail.com>
To: Peter Rosin <peda@axentia.se>
Cc: jic23@kernel.org, lars@metafoo.de, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
robh+dt@kernel.org
Subject: Re: [PATCH v9 00/14] iio: afe: add temperature rescaling support
Date: Tue, 30 Nov 2021 13:52:01 -0500 [thread overview]
Message-ID: <YaZy0Wk4Kzptt0SX@shaak> (raw)
In-Reply-To: <b9e1e804-fb59-660f-a9b8-ad6e20dd41aa@axentia.se>
Hi Peter,
On Sun, Nov 28, 2021 at 10:17:50AM +0100, Peter Rosin wrote:
> Hi!
>
> On 2021-11-27 21:27, Liam Beguin wrote:
> > Hi Peter,
> >
> > On Mon, Nov 22, 2021 at 01:53:44AM +0100, Peter Rosin wrote:
> >> Hi Liam!
> >>
> >> On 2021-11-15 04:43, Liam Beguin wrote:
> >>> Hi Jonathan, Peter,
>
> snip
>
> >>> - keep IIO_VAL_FRACTIONAL scale when possible, if not default to fixed
> >>> point
> >>
> >> This is not what is going on. Patch 9/14 will convert all fractional
> >> scales to fixed point. But I would really like if you in the "reduce
> >> risk of integer overflow" patch (8/14) would hold true to the above
> >> and keep the fractional scale when possible and only fall back to
> >> the less precise fractional-log case if any of the multiplications
> >> needed for an exact fractional scale causes overflow.
> >
> > Thanks for looking at these patches again.
> >
> >> The v8 discussion concluded that this was a valid approach, right?
> >
> > Yes, I remember you saying that you'd be more comfortable keeping the
> > IIO_VAL_FRACTIONAL.
> >
> >> I know you also said that the core exposes the scale with nano
> >> precision in sysfs anyway, but that is not true for in-kernel
> >> consumers. They have an easier time reading the "real" scale value
> >> compared to going via the string representation of fixed point
> >> returned from iio_format_value. At least the rescaler itself does so,
> >> which means that chaining rescalers might suffer needless accuracy
> >> degradation.
> >
> > Agreed, that makes total sense.
> >
> > If I'm not mistaken, the first condition in the case, if (!rem), will
> > return IIO_VAL_FRACTIONAL if the division is exact, keeping all the
> > precision. No?
>
> Only if the resulting scale fits in nine decimals. That's never the
> case if you have primes other than 2 and 5 in the denominator (after
> eliminating gcd of course). Which mean that if you chain one rescaler
> doing 1/3 and one doing 3/1, you would get a combined scale of
> 0.999999999 instead of 3/3 if we take the approach of these patches.
>
> So, what I'm after is that - for IIO_VAL_FRACTIONAL - not take the
> multiply-by-1e9 code path /unless/ the existing fractional approach
> overflows in either numerator or denominator (or both).
Understood, I'll update based on this.
> Side note: The same could be done for IIO_VAL_INT when the numerator
> overflows (since the denominator cannot overflow), but I guess that
> can be done later.
Agreed, I don't mind working on this later but I'd like to focus on
getting the current changes in first.
Thanks,
Liam
> Cheers,
> Peter
prev parent reply other threads:[~2021-11-30 18:52 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-15 3:43 [PATCH v9 00/14] iio: afe: add temperature rescaling support Liam Beguin
2021-11-15 3:43 ` [PATCH v9 01/14] iio: inkern: apply consumer scale on IIO_VAL_INT cases Liam Beguin
2021-11-15 3:43 ` [PATCH v9 02/14] iio: inkern: apply consumer scale when no channel scale is available Liam Beguin
2021-11-15 3:43 ` [PATCH v9 03/14] iio: inkern: make a best effort on offset calculation Liam Beguin
2021-11-15 3:43 ` [PATCH v9 04/14] iio: afe: rescale: expose scale processing function Liam Beguin
2021-11-15 3:43 ` [PATCH v9 05/14] iio: afe: rescale: add INT_PLUS_{MICRO,NANO} support Liam Beguin
2021-11-21 11:11 ` Jonathan Cameron
2021-11-15 3:43 ` [PATCH v9 06/14] iio: afe: rescale: add offset support Liam Beguin
2021-11-15 3:43 ` [PATCH v9 07/14] iio: afe: rescale: use s64 for temporary scale calculations Liam Beguin
2021-11-15 3:43 ` [PATCH v9 08/14] iio: afe: rescale: reduce risk of integer overflow Liam Beguin
2021-11-15 3:43 ` [PATCH v9 09/14] iio: afe: rescale: fix accuracy for small fractional scales Liam Beguin
2021-11-15 3:43 ` [PATCH v9 10/14] iio: test: add basic tests for the iio-rescale driver Liam Beguin
2021-11-17 15:03 ` kernel test robot
2021-11-21 11:19 ` Jonathan Cameron
2021-11-21 14:30 ` Peter Rosin
2021-11-21 17:00 ` Liam Beguin
2021-11-24 18:36 ` kernel test robot
2021-11-15 3:43 ` [PATCH v9 11/14] iio: afe: rescale: add RTD temperature sensor support Liam Beguin
2021-11-15 3:43 ` [PATCH v9 12/14] iio: afe: rescale: add temperature transducers Liam Beguin
2021-11-15 3:43 ` [PATCH v9 13/14] dt-bindings: iio: afe: add bindings for temperature-sense-rtd Liam Beguin
2021-11-15 3:43 ` [PATCH v9 14/14] dt-bindings: iio: afe: add bindings for temperature transducers Liam Beguin
2021-11-21 11:25 ` [PATCH v9 00/14] iio: afe: add temperature rescaling support Jonathan Cameron
2021-11-21 17:30 ` Liam Beguin
2021-11-22 0:53 ` Peter Rosin
2021-11-23 20:28 ` Jonathan Cameron
2021-11-27 20:27 ` Liam Beguin
2021-11-28 9:17 ` Peter Rosin
2021-11-30 18:52 ` Liam Beguin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YaZy0Wk4Kzptt0SX@shaak \
--to=liambeguin@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@axentia.se \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox