Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1012079pxb; Wed, 6 Apr 2022 06:41:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPS2I91+W5/1+XPNwPoAqmvqsHkz9hueEZBxdPQYhecl6qQCrGzGenpKPNbCDZnrqUHjUF X-Received: by 2002:a17:903:230a:b0:156:9c66:5cd2 with SMTP id d10-20020a170903230a00b001569c665cd2mr8499360plh.57.1649252510699; Wed, 06 Apr 2022 06:41:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649252510; cv=none; d=google.com; s=arc-20160816; b=Fs2Q72/3YqJPyqAOw9CFxxcZoULbIPSVxdzEsK34WU+0hRqaKnuC0ehjtzQf+j0bNZ 2cK5kvAX8tmyeleRJPUk6575LtHgz1PXNwyzU96AZC1FD97j26x6o43qQwDZBPU6RIVx zBwt9C4H+2XBtTqiCSOs/3iLfWNfH35MS/2BctEXfANRRLEGbQSpBRmsdlBHJvl0LA7B vjXLeCisVMd/KlAcHnkKiAsDqNSdxBL+tnJfmldiy4NGFpRlZETZnQsfyN7UtanO7XPY Dks0uoC4DNIsDYXai0cNByifqlAFzNUzz4U3WJ4HTwLlgb20wBtWb30aVoaoK0BtbYGX PG/A== 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=KK0ZOOWmy3GQzr3NAb2fjr+Cp0elbd/g5HOWbCLiQmZmAwK2BFcaBLBfoLiJFp82md ApYMDm8iZ0DoTeAhPo6MS5jFqbJr9sbSoiKAiXy4hQ5Agt1JBvBU0qisYh7tduoXVgzr CxUeepkdkdCEt4nygjF9xuXHJEagvBY2cSsIj9KunjGLSnOuoCPUiXTDbyrqH+hp+u2F njDWBs9iGXVpMKJ0PTDi0ezY/AcHiGLDP2h2mutNQGSW6AXWn42L8kmkZ064vdH37Ak7 0wiRk8Usz/4n8iAic4rX8/IpANTdbYEdSuKfMBUBFLnEhHvZRMeNf7JN7nrz5IGR0ESQ cmhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Qw7GAi+E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d3-20020a636803000000b00381f044e11fsi517751pgc.550.2022.04.06.06.41.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:41:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Qw7GAi+E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 63C925F78B4; Wed, 6 Apr 2022 04:28:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1579607AbiDEXcE (ORCPT + 99 others); Tue, 5 Apr 2022 19:32:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349288AbiDEJtd (ORCPT ); Tue, 5 Apr 2022 05:49:33 -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 45AF810FDA; Tue, 5 Apr 2022 02:43:43 -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 F01BBB818F3; Tue, 5 Apr 2022 09:43:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D1CBC385A3; Tue, 5 Apr 2022 09:43:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151820; bh=K42QkayVvGfoqUO3AMD2fmm46tyYo/VhVx5kCxI5O6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qw7GAi+EhIpsWQWFKwAvNrqUGl146OHTkFru69AM7JXWxQZn1lf4WfazidhQIhWAJ O9AJnxlfdg/Dz51kCz7gxzhnuIzRv6Mr0G0Sb184gM+3XXv8TsoZB8Ijj/BZcmPluq ri7DreL5KtY5hs/eYqhZv/7FmdiOpjIFRh9YUr+A= 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.15 536/913] power: ab8500_chargalg: Use CLOCK_MONOTONIC Date: Tue, 5 Apr 2022 09:26:38 +0200 Message-Id: <20220405070355.916061620@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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 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