From patchwork Wed Feb 22 19:15:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 60659 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp765392wrd; Wed, 22 Feb 2023 11:21:33 -0800 (PST) X-Google-Smtp-Source: AK7set+6yaSV3GfVKsagcrhYQW4dHYIs/i9LaZ9wZhpbIqf9/2QXvWSgX9seVou/5Ri5SbzyHWqN X-Received: by 2002:adf:cd12:0:b0:2c6:5972:cd0d with SMTP id w18-20020adfcd12000000b002c65972cd0dmr8086113wrm.3.1677093691295; Wed, 22 Feb 2023 11:21:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677093691; cv=none; d=google.com; s=arc-20160816; b=VOR/NIks1rnxMaAaylv3DuULDqVxgeQ8lwA8yopqe71jFNnHn2UD1qUQOhRATX5cKI 5AOOp0yUhKlCHUEwJ0qhbdo8kiu05rVBE1Q1Kmm5xYytlD9Q3IyUwds0ISuYtA7AkHmK KUuVi9kMY7rxV2cmRTLj7nQZUpsu6XypzbfadoxJvgCX1M3opWShgPL4ZuyRM+08qcrZ yHPu0kdwHgntgO4L8x6PMw+DCHUjtu9eKgfqQ12RdNToCymxGFrLODlH2M6o5Hg6ZvMS sIfH0sXyjzIpDOXP54b3ur7C16z+pQMHXkPQ99N39pQD23MkWy8iLl7gkesNjF75vjyD ofMg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=I2c3lg+eD0Vch4RpQWqcPIBMzqi7iy6PEw8ILtwvF7k=; b=SsxIxyao9J7me6WcF1irb2y//lfJMNDqUqfApDkaf/FccFh3IdK38Eg7YNFX/fBP/+ 7TGS+Y9MtNl8r2aX1U8FPsChtJ7Ac0jV8BWyVSNVrO3Q0EXM79ya7ucZXJp7ZBbdDAQN qwJkEgDvsz4R8dfokSDcncicl8QzPaqh4JwMBhERQENyCAbkqfxiHWSV85E8/nu/VXBi B/b7+kEIauf4CoR2DaiStS7IcFK92X9TNsHr4CidIzWUjApcgZyYCCKtPAdhQsNsxFN7 14+79DjE0vi26kgNwDiprqN3XTmVt/33OEXkytOqRtKjVwENj2MYQarCInDzusJmDkpb ECgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=nM7f3kbW; 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=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x4-20020adff0c4000000b00241e3a133fbsi5396381wro.806.2023.02.22.11.21.08; Wed, 22 Feb 2023 11:21:31 -0800 (PST) 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=@chromium.org header.s=google header.b=nM7f3kbW; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231660AbjBVTP4 (ORCPT + 99 others); Wed, 22 Feb 2023 14:15:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjBVTPz (ORCPT ); Wed, 22 Feb 2023 14:15:55 -0500 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CEF33A0BD for ; Wed, 22 Feb 2023 11:15:50 -0800 (PST) Received: by mail-il1-x129.google.com with SMTP id b12so1151173ils.8 for ; Wed, 22 Feb 2023 11:15:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=I2c3lg+eD0Vch4RpQWqcPIBMzqi7iy6PEw8ILtwvF7k=; b=nM7f3kbWFpK5eMz3TP33DsONrx0dUPXyBQ9urgT0uhsqEzo5yKgunv8MjuMgEFPlFf Ptkx6NTZkhwDeZBBChJ/2MHr8B3tJcNa1g2A/gly43vIZaqQK/owG6pe+hX24yAfHHAC HGZ4Qwnw6Y2Xyjdz/rIFyQcajwP6BXzc353mU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=I2c3lg+eD0Vch4RpQWqcPIBMzqi7iy6PEw8ILtwvF7k=; b=kD1MtuHlkGAn/1eQ+jyJWt76P2z2UIhFx1sHgcBDLK0ABJhVY9AVLA3iMSmAj2AEe3 6l2kebQZl8ZHQU1cfbiijEAwZsW5osGIDAceih8O9euZ/OgjMQ4HQSbAtyWz39WcKuwY 4iKRklKMc/Wr4U2rPwMKqWs0mpldgyrnL03/CgvpDqBPDaK1LWew+NHbnT9VCcbcK9ut WuPcgRcfHS7DPifih2+kkJGKuBveGD4uIpG2YQ0MYTv8l6wHvmR+O87db1v4QZPN2QaI bNdIXFa0UeEF8GHigQ6qtLwzI3AVyO26t6Ejkh41UTSxfQFL+3zuLfDPe42HBHJC/eVa xc0Q== X-Gm-Message-State: AO0yUKXJP5q2kfKnIx9Ps7jarJDVTOBqFAHrS1T/SkIZ4E/GaFozIlA6 OgItZYZSUbYMzDII6inW2TE/iw== X-Received: by 2002:a92:7a06:0:b0:315:8bc0:1d85 with SMTP id v6-20020a927a06000000b003158bc01d85mr7077253ilc.11.1677093349797; Wed, 22 Feb 2023 11:15:49 -0800 (PST) Received: from localhost (30.23.70.34.bc.googleusercontent.com. [34.70.23.30]) by smtp.gmail.com with UTF8SMTPSA id g2-20020a0566380c4200b003c4f55da7easm1403449jal.45.2023.02.22.11.15.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Feb 2023 11:15:49 -0800 (PST) From: Matthias Kaehlcke To: Liam Girdwood , Mark Brown Cc: Stephen Boyd , Douglas Anderson , linux-kernel@vger.kernel.org, Matthias Kaehlcke Subject: [PATCH] regulator: core: Use ktime_get_boottime() to determine how long a regulator was off Date: Wed, 22 Feb 2023 19:15:46 +0000 Message-Id: <20230222191537.1.I9719661b8eb0a73b8c416f9c26cf5bd8c0563f99@changeid> X-Mailer: git-send-email 2.39.2.722.g9855ee24e9-goog MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,TVD_PH_BODY_ACCOUNTS_PRE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758560194372855624?= X-GMAIL-MSGID: =?utf-8?q?1758560194372855624?= For regulators with 'off-on-delay-us' the regulator framework currently uses ktime_get() to determine how long the regulator has been off before re-enabling it (after a delay if needed). A problem with using ktime_get() is that it doesn't account for the time the system is suspended. As a result a regulator with a longer 'off-on-delay' (e.g. 500ms) that was switched off during suspend might still incurr in a delay on resume before it is re-enabled, even though the regulator might have been off for hours. ktime_get_boottime() accounts for suspend time, use it instead of ktime_get(). Signed-off-by: Matthias Kaehlcke Reviewed-by: Stephen Boyd --- drivers/regulator/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index ae69e493913d..4fcd36055b02 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1584,7 +1584,7 @@ static int set_machine_constraints(struct regulator_dev *rdev) } if (rdev->desc->off_on_delay) - rdev->last_off = ktime_get(); + rdev->last_off = ktime_get_boottime(); /* If the constraints say the regulator should be on at this point * and we have control then make sure it is enabled. @@ -2673,7 +2673,7 @@ static int _regulator_do_enable(struct regulator_dev *rdev) * this regulator was disabled. */ ktime_t end = ktime_add_us(rdev->last_off, rdev->desc->off_on_delay); - s64 remaining = ktime_us_delta(end, ktime_get()); + s64 remaining = ktime_us_delta(end, ktime_get_boottime()); if (remaining > 0) _regulator_delay_helper(remaining); @@ -2912,7 +2912,7 @@ static int _regulator_do_disable(struct regulator_dev *rdev) } if (rdev->desc->off_on_delay) - rdev->last_off = ktime_get(); + rdev->last_off = ktime_get_boottime(); trace_regulator_disable_complete(rdev_get_name(rdev));