From: Jonathan Cameron <jic23@kernel.org>
To: Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com>
Cc: "Andy Shevchenko" <andriy.shevchenko@intel.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Jonathan Cameron" <jonathan.cameron@oss.qualcomm.com>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] iio: inv_sensors: fix estimated value larger than interrupt timestamp
Date: Mon, 31 Aug 2026 02:18:29 +0100 [thread overview]
Message-ID: <20260831021829.5240cba4@jic23-huawei> (raw)
In-Reply-To: <BE1P281MB142668824B5EB8067F8E1034CEAF2@BE1P281MB1426.DEUP281.PROD.OUTLOOK.COM>
On Tue, 25 Aug 2026 13:31:38 +0000
Jean-Baptiste Maneyrol <Jean-Baptiste.Maneyrol@tdk.com> wrote:
> >
> >
> >________________________________________
> >From: Andy Shevchenko <andriy.shevchenko@intel.com>
> >Sent: Monday, August 24, 2026 17:32
> >To: Jean-Baptiste Maneyrol
> >Cc: Jonathan Cameron; David Lechner; Nuno Sá; Andy Shevchenko; Jonathan Cameron; linux-iio@vger.kernel.org; linux-kernel@vger.kernel.org; stable@vger.kernel.org
> >Subject: Re: [PATCH] iio: inv_sensors: fix estimated value larger than interrupt timestamp
> >
> >On Mon, Aug 24, 2026 at 05: 16: 58PM +0200, Jean-Baptiste Maneyrol via B4 Relay wrote: > When interrupt timestamp interval is not valid, we use an estimated value > that can in rare case be bigger than the interrupt timestamp. This is >
> >ZjQcmQRYFpfptBannerStart
> >This Message Is From an External Sender
> >This message came from outside your organization.
> >
> >ZjQcmQRYFpfptBannerEnd
> >
> >On Mon, Aug 24, 2026 at 05:16:58PM +0200, Jean-Baptiste Maneyrol via B4 Relay wrote:
> >
> >> When interrupt timestamp interval is not valid, we use an estimated value
> >> that can in rare case be bigger than the interrupt timestamp. This is
> >> obviously wrong, so better use interrupt timestamp in this case.
> >
> >...
> >
> >> - ts->period = ts->mult * ts->chip_period.val;
> >> + ts->period = min(ts->mult * ts->chip_period.val, period);
> >
> >It's u32 * u32, how is this guaranteed to be always under the u32 result?
>
> Hello Andy,
>
> (ts->mult * ts->chip_period.val) is an estimation of the sampling period of
> the chip in ns. It is limited by maximum setting 8kHz (125000) and minimum
> setting 1.5625Hz (640000000), with a 2% margin. Meaning maximum value is
> 652800000, which is below the 32 bits limit.
>
> ts->chip_period.val is an estimation of the internal frequency which is 8kHz.
> It's value will always be around 125000, with a 2% margin. Maximum value
> being 127500.
>
> ts->mult will change from 8kHz setting (1) to 1.5625Hz setting (5120).
>
> Thanks,
> JB
Seems fine to me so applied to the fixes-togreg branch of iio.git
Thanks
Jonathan
>
> >
> >--
> >With Best Regards,
> >Andy Shevchenko
> >
> >
> >
>
prev parent reply other threads:[~2026-08-31 1:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 15:16 [PATCH] iio: inv_sensors: fix estimated value larger than interrupt timestamp Jean-Baptiste Maneyrol via B4 Relay
2026-08-24 15:32 ` Andy Shevchenko
2026-08-25 13:31 ` Jean-Baptiste Maneyrol
2026-08-31 1:18 ` Jonathan Cameron [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=20260831021829.5240cba4@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jean-Baptiste.Maneyrol@tdk.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jonathan.cameron@oss.qualcomm.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=stable@vger.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