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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA216C433F5 for ; Sun, 5 Dec 2021 20:06:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238337AbhLEUJ1 (ORCPT ); Sun, 5 Dec 2021 15:09:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230035AbhLEUJ0 (ORCPT ); Sun, 5 Dec 2021 15:09:26 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 277AEC061714; Sun, 5 Dec 2021 12:05:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C5019B80ED8; Sun, 5 Dec 2021 20:05:57 +0000 (UTC) Received: from jic23-huawei (cpc108967-cmbg20-2-0-cust86.5-4.cable.virginm.net [81.101.6.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPSA id 2F563C00446; Sun, 5 Dec 2021 20:05:52 +0000 (UTC) Date: Sun, 5 Dec 2021 20:11:03 +0000 From: Jonathan Cameron To: Arnd Bergmann Cc: Iain Hunter , lothar.felten@gmail.com, iain@hunterembedded.co.uk, Lars-Peter Clausen , Alexandru Ardelean , Gwendal Grignou , Matt Ranostay , Thomas Gleixner , Zeng Tao , linux-iio@vger.kernel.org, Linux Kernel Mailing List Subject: Re: [PATCH v4] workaround regression in ina2xx introduced by cb47755725da("time: Prevent undefined behaviour in timespec64_to_ns()") Message-ID: <20211205201103.7e19d647@jic23-huawei> In-Reply-To: References: <20210930081025.366039-1-drhunter95@gmail.com> X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Thu, 30 Sep 2021 13:04:10 +0200 Arnd Bergmann wrote: > On Thu, Sep 30, 2021 at 10:10 AM Iain Hunter wrote: > > > > From: Iain Hunter > > > > 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 > > > > 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 Hi Iain, Are you planning to do a v5 with change log tidied up? In particularly the fixes tag? Sorry, I should have followed up on this earlier to find out your plans. Jonathan