lkml.org 
[lkml]   [2021]   [Sep]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v4] workaround regression in ina2xx introduced by cb47755725da("time: Prevent undefined behaviour in timespec64_to_ns()")
On Thu, Sep 30, 2021 at 10:10 AM Iain Hunter <drhunter95@gmail.com> wrote:
>
> From: Iain Hunter <iain@hunterembedded.co.uk>
>
> That change adds an error check to avoid saturation during multiplication
> to calculate nano seconds in timespec64_to_ns().
> In ina2xx_capture_thread() a timespec64 structure is used to calculate
> the delta time until the next sample time. This delta can be negative if
> the next sample time was in the past. In the -1 case timespec64_to_ns()
> now clamps the -1 second value to KTIME_MAX. This essentially puts ina2xx
> thread to sleep forever.
> Proposed patch is to:
> 1 change from timespec64_XXX() to standard raw ktime_XXX() APIs to remove
> non-standard timespec64 calls.
> 2 split the functionality in the loop into two parts:
> - do while loop only does the test to see if the next sample time is in the
> future or in the past and so will be skipped and the sample time
> incremented until it is in the future. This test is done with a simple
> signed comparison as we are only interested in the sign being positive or
> negative.
> - after do while loop we know that next is later than now and so delay is
> positive and ksub_sub() can be used to get the delay which is positive.
>
> Signed-off-by: Iain Hunter <iain@hunterembedded.co.uk>
>
> Fixes: cb47755725da("time: Prevent undef$

The changelog text could be improved to more closely follow the
style described in Documentation/process/submitting-patches.rst,
but the important information is here and the changes look good
to me.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

\
 
 \ /
  Last update: 2021-09-30 13:05    [W:0.052 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site