Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp701368pxb; Tue, 5 Apr 2022 19:24:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzP0UgUZqSmQvhrh/f9/ohGosxs96mm3y+nzQSxh8rFFP6YROfmEGeWmiU+Dg3GFJbLum7v X-Received: by 2002:a17:902:a510:b0:156:6cf9:9a7c with SMTP id s16-20020a170902a51000b001566cf99a7cmr6569591plq.151.1649211840555; Tue, 05 Apr 2022 19:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649211840; cv=none; d=google.com; s=arc-20160816; b=Lq5SP20HRcBOxrkU/uattDaimqexqG0sSD4SysHk6jcN96MUwv3g49weDSJZ6xGo96 y3g3RwfonCpe7Aj0OWgCV26V6TAxaNrzDMLkcZl9D89vU1Kmig4ZL33wQdOKvwNZMLSH 625eYzZMibeXbHpQ4gNFiZ4gzgfq7J5p+ynXw0z6lk8RmrUpXdjiTZxE3PJxq2M1qyN0 xSHmOK3eY5mdET8N6VbeiapnpV7Lg3f9wbWbhZfmtAPCAmhmTUX2GVRGzKdSzXL9XgVs JKIsWPkt2Lp+L588NwK8syc/1WhF9Zd/ihb/PGbLFh485npw8+fR5HGabO9rYbC9F+Vh tEgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=G0SBEysBYd/5uCtLWkE6Qa+k2qxShHuWw2jutbqptvU=; b=jdGcKRGyJ3cnuj+nHOXuXd52YXR3FhCCprgWiCdf3j6P6f90i0IgbipXmkLZmJXJ5R ZqgPiIA0ck18KJ/q8stNhEGDuuB8bwGOwPpZr0aGMBc00HORD5Rt9DGBn0DvRV3fHq2Z 1VUHBauLmLJ/hW9A3QYnovwejslRWvcGvmEEYtXJJRpcrdqqoAKl21TZZxYQ4iTtw9jv bJQjZ3jvDet4Xe7m/s7A8iXfbSIYwmEZUAnvm9g+3D0qQlcTElChO67DsyZOWXn7iC8G 3OA5fm/91qwhakF++fKBi/VVzKmTZAv2FifF8P6//g7AqFbwsskDglrqgYyQSZ56F/oU Rd+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BgEeJxrr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q32-20020a63f960000000b003816043ee5csi13888837pgk.81.2022.04.05.19.23.41; Tue, 05 Apr 2022 19:24:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BgEeJxrr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378833AbiDEMwy (ORCPT + 99 others); Tue, 5 Apr 2022 08:52:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245431AbiDEJLt (ORCPT ); Tue, 5 Apr 2022 05:11:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C50472DA98; Tue, 5 Apr 2022 02:00:07 -0700 (PDT) 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 7A42EB81BBF; Tue, 5 Apr 2022 09:00:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5AD7C385A1; Tue, 5 Apr 2022 09:00:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149205; bh=K42QkayVvGfoqUO3AMD2fmm46tyYo/VhVx5kCxI5O6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BgEeJxrrZIMg05Xw/GTuYpdq4LEZOYsWv7rMnVlOAETVZ7GJMCsJ/2EkKNOis6YwX LlCopsMzzeUUfSvNIdrZ7Oe66sBpndEJqrIGBVLShuRSYKDZRsHLvsVp9DmZRzXpeC ybP6y77YWTk95s7gRIdsxFOBKy2bAOWzaHMSi32k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lee Jones , Matti Vaittinen , Linus Walleij , Matti Vaittinen , Sebastian Reichel , Sasha Levin Subject: [PATCH 5.16 0595/1017] power: ab8500_chargalg: Use CLOCK_MONOTONIC Date: Tue, 5 Apr 2022 09:25:08 +0200 Message-Id: <20220405070411.939121688@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Walleij [ Upstream commit c22fca40522e2be8af168f3087d87d85e404ea72 ] The HRTimer in the AB8500 charging code is using CLOCK_REALTIME to set an alarm some hours forward in time +/- 5 min for a safety timer. I have observed that this will sometimes fire sporadically early when charging a battery with the result that charging stops. As CLOCK_REALTIME can be subject to adjustments of time from sources such as NTP, this cannot be trusted and will likely for example fire events if the clock is set forward some hours by say NTP. Use CLOCK_MONOTONIC as indicated in other instances and the problem goes away. Also initialize the timer to REL mode as this is what will be used later. Fixes: 257107ae6b9b ("ab8500-chargalg: Use hrtimer") Cc: Lee Jones Suggested-by: Matti Vaittinen Signed-off-by: Linus Walleij Reviewed-by: Matti Vaittinen Signed-off-by: Sebastian Reichel Signed-off-by: Sasha Levin --- drivers/power/supply/ab8500_chargalg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/ab8500_chargalg.c b/drivers/power/supply/ab8500_chargalg.c index ff4b26b1ceca..b809fa5abbba 100644 --- a/drivers/power/supply/ab8500_chargalg.c +++ b/drivers/power/supply/ab8500_chargalg.c @@ -2019,11 +2019,11 @@ static int ab8500_chargalg_probe(struct platform_device *pdev) psy_cfg.drv_data = di; /* Initilialize safety timer */ - hrtimer_init(&di->safety_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS); + hrtimer_init(&di->safety_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); di->safety_timer.function = ab8500_chargalg_safety_timer_expired; /* Initilialize maintenance timer */ - hrtimer_init(&di->maintenance_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS); + hrtimer_init(&di->maintenance_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); di->maintenance_timer.function = ab8500_chargalg_maintenance_timer_expired; -- 2.34.1