Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp722463pxb; Tue, 5 Apr 2022 20:21:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhxVWrklfgZZ7M0MVHaYMX4dMdtpRYw8L6LUgrEo9uovzytu8qcCEAY3OOtX20NJkg3fZJ X-Received: by 2002:a17:90a:f189:b0:1ca:c279:1bdf with SMTP id bv9-20020a17090af18900b001cac2791bdfmr7624299pjb.185.1649215276155; Tue, 05 Apr 2022 20:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649215276; cv=none; d=google.com; s=arc-20160816; b=qbDIKMHzkIVNq6ioaxGzKbBdsEpdtYaiWq88EwJUY78W7FA4phYxg8eFCqV4sZg8sj +b3wqIuFyk7l6sDXIl92N4DFKZZOke4aUM7g0pqzRZmdWzPSv0TMcqgqEArvCF84WoOl 8qqSjjbmnyjZWhXZJR6buvmDdlLiVfpBiVBaYTalcQfvuAzlehTElMmIuvOGckRQBpF/ NS7/8gkF/pD77kOPBoKK4jDrKWJizIwGGqs6VKl+j0jqbaSwQoCFZKtZZ6XWhNlMhidc GGaWOL7eBK9yI51QNCSB129o6yqt88c52PT1F8mkv4Av95AGP7L/j7OxWgV1YQa9eMqW y17g== 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=39WXONccaXYKTJU15q58JRVZIhsoe8uYuC1bChCQr2A=; b=Cr2xqXq1HMLcY5wqgalQbMZrrR4rSYFEUfYa0bewrV+3KyqyOezPnyUdsCy/XPv0DN 9YNen6IS8rP01BSBaxe2w/rYt4V/GoaAhB4ErOUKa/j/HlWHoummEcUYgBXRdyb5PKEd 2fH2NEOm9wiSd+tR9AmEJn1kN2ZLwBvH0jHUKBoXD5StEmxtrdu/9ZK5PkG92PTFYNak Xob0Lh8YDVaGZNTT+pX6qQnoV2iIKh8RSuGQrVabG+CG3ypb4X+CWmS5i79KOx++hlId zBris6a+BxTlSSYAtFCdNNdDOIsBdUUZQde7GHeQ0elwL/V56mRV1/mq3TwZx4IDuoLe 1T+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1mbU8ruu; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id pj9-20020a17090b4f4900b001ca996be6d9si4065854pjb.133.2022.04.05.20.21.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 20:21:16 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1mbU8ruu; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6F9D5309716; Tue, 5 Apr 2022 19:55:33 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240515AbiDEJGJ (ORCPT + 99 others); Tue, 5 Apr 2022 05:06:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238477AbiDEITI (ORCPT ); Tue, 5 Apr 2022 04:19:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9246DDF0B; Tue, 5 Apr 2022 01:09:00 -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 F2B0EB81A37; Tue, 5 Apr 2022 08:08:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52D37C385A2; Tue, 5 Apr 2022 08:08:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649146137; bh=Mrz80BjJ2Jh+RPjc7Mig+slCavA5b7jhX6T0oLaoi4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1mbU8ruuAhLaNIk1dBLpXVCzJC2rKkhV2tIfyf21nn/Z0p9RtmT9xm0Jj/BKR8+xn 7YCWP9RGQ18x+ZL+oWkwNP8T/lN43VDoNN4Dkoq/fAxVFhQXCOCSERnQ5CibfhAPG/ wtjj1dJyLRbV8vVzYnSzvuoG5v19QCXQuOxbECho= 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.17 0656/1126] power: ab8500_chargalg: Use CLOCK_MONOTONIC Date: Tue, 5 Apr 2022 09:23:23 +0200 Message-Id: <20220405070426.885662479@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 bcf85ae6828e..da490e090ce4 100644 --- a/drivers/power/supply/ab8500_chargalg.c +++ b/drivers/power/supply/ab8500_chargalg.c @@ -2020,11 +2020,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