Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2233514imw; Sun, 17 Jul 2022 04:35:38 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vJjHv45I1dUgB4pQcUHTYw1m/bRTUpx2qWTDGNGDFt76XqUUd5AuzQi63XW8nHY/AH6b8u X-Received: by 2002:a05:6402:5212:b0:43a:ad74:b336 with SMTP id s18-20020a056402521200b0043aad74b336mr30937298edd.16.1658057738165; Sun, 17 Jul 2022 04:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658057738; cv=none; d=google.com; s=arc-20160816; b=kygUpboBiGm8BqOvNpkcNtPxouXDJ9PK90KZi7XAbiIrWqeSZq8Rp0iUJh/seJwfZJ j2jf5QA1/twMQIa9eFifRSAapHERCC9Ral0EtM9LvbAymT+Wjw5L52+auCR7rwGMoXuX guR2pPmTWW6SjhevMkhEgrYOoS0eFgrIsz3zrJfqBZ/cKwQppIf7iH2LTDojVWXI5HdL yg3j8hU5GX7e1yWrp9g8TZOK9OVUQjjBwF18aa3mQlUU5ELUVPeIPD7iKlnFBFzpyy/7 mejQCVZGE+l6x4mGKvE9a0UGYJVY0mXmTaVwi9bARIkekO2h8bL9fUFFirKbX7aLM/4I NFAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:date:message-id:subject:mime-version :content-transfer-encoding:from:dkim-signature; bh=UYLgzmwQ3mswywLI0ANNamr/kYqFy4glMlF3d7pnLQc=; b=aogmoF2scDxQCTcDViN7BIcLtjmocPhPL4EIPHljowS+NZjzMNasm/VUifcSUHb60n T25tieZIARhTkBKcc6AiewXrwPmmPeWRMWs8Jn0qIYJAhfMmIFh1a/eBySB7BpJRZW1k y5Wbmbssf+O8BBKK6W0InQrj/xwNeXOuC7Yi6BwifVoOIqCo59QrMxqHvPG9qUjUULnO R8gfI7Kj1oDLerUQbO9MEgqdCAe0V8qJVtQebKYe7X1CSxK+PBdNwC2xoVCwSbQvRIOg 2LOw/aVP0qSKOdmGT8JCF/NFAOXaQGXR5cqIkUh+mS2t3x/KG9SU/hXkSSZl8sci59hp xe/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kohlschuetter-com.20210112.gappssmtp.com header.s=20210112 header.b=rzp2GSXU; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n13-20020a05640205cd00b00437dce124fesi13988372edx.519.2022.07.17.04.35.13; Sun, 17 Jul 2022 04:35:38 -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=@kohlschuetter-com.20210112.gappssmtp.com header.s=20210112 header.b=rzp2GSXU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231400AbiGQLam (ORCPT + 99 others); Sun, 17 Jul 2022 07:30:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbiGQLak (ORCPT ); Sun, 17 Jul 2022 07:30:40 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC9E613E8E for ; Sun, 17 Jul 2022 04:30:39 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id ez10so16543439ejc.13 for ; Sun, 17 Jul 2022 04:30:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kohlschuetter-com.20210112.gappssmtp.com; s=20210112; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=UYLgzmwQ3mswywLI0ANNamr/kYqFy4glMlF3d7pnLQc=; b=rzp2GSXU43wAI9LLKpwc9qlPKOfRtDxrBtTCuXglNM5EKco9iaYEdfJqH1VU96z7g5 gmEsqF96DEas0rzHjuNWJSII6fgCtIJ55+agiXcZraEfGv8HWiKHfdd8Ab5oK4oX5B6k UHpxpgEmnq+UpR+vrgW5MsV3Hli2yB3ATY15Z06J+I2gytNCVWojVCPk/cMZ2UL7as6Q +Ez0GvjIWhMJjHPBz8Kh4bs+HkfeYBe87kQdntBO8bZfA91i0pMVhddGqPHW0DqW0Aqt JYLvrDdnnOsEfcr/+wYE0qctva1rnr3S/zevCH+a09vHI3zBaG06kKRoUfxD9AT0ofzD shCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=UYLgzmwQ3mswywLI0ANNamr/kYqFy4glMlF3d7pnLQc=; b=OQVmHNQyYW+jzF+4draM87/RTu9PHb3n1HQFFD0xcMl8OgLy4i3yaRKlIeMBW6eanI TcWXYqTwzPmS1fvExo9E3otYjVL3h0+xgQI6Ch8KYwsHzbX3yJcUAFJzzJLTxwbzX8Ml 4XOJ7rzvSDA9PeWPFzVcLMsmMdcEx6HMDKVhtRTR+8IaYaMlGDQBEA4vmNdkhGTvwo8o BQnyjaRli/dQk5WM6cWBwfkPG3f7v/8IU9xOewonXz8o3pKot7oGvGb7Tt0lvJcG/v1X xWw9EgqpfdKWLoLJM5tN+BgcBXzP/LRUirMBaoOjImazfjOGNAxMpt3zsKx/ERtf68Pu dt6A== X-Gm-Message-State: AJIora9mfdj9Nj1GFZ6pc77ezQ+Y/ZI6iz1IdQqcFwSmwvqc9Od4qKsY 9j6eOlWs17LVciIq+enZcMrVJQORL6apfA== X-Received: by 2002:a17:906:4fd3:b0:72f:2306:32a6 with SMTP id i19-20020a1709064fd300b0072f230632a6mr2592634ejw.83.1658057438293; Sun, 17 Jul 2022 04:30:38 -0700 (PDT) Received: from smtpclient.apple (ip5b434222.dynamic.kabel-deutschland.de. [91.67.66.34]) by smtp.gmail.com with ESMTPSA id g21-20020a1709061e1500b00722f8d02928sm4314699ejj.174.2022.07.17.04.30.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Jul 2022 04:30:37 -0700 (PDT) From: Christian Kohlschuetter Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) Subject: [PATCH] regulator: core: Fix off-on-delay-us for always-on/boot-on regulators Message-Id: Date: Sun, 17 Jul 2022 13:30:36 +0200 To: Liam Girdwood , Mark Brown , linux-kernel X-Mailer: Apple Mail (2.3696.100.31) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 Regulators marked with "regulator-always-on" or "regulator-boot-on" as well as an "off-on-delay-us", may run into cycling issues that are hard to detect. This is caused by the "last_off" state not being initialized in this case. Fix the "last_off" initialization by setting it to the current kernel time upon initialization, regardless of always_on/boot_on state. Signed-off-by: Christian Kohlsch=C3=BCtter --- drivers/regulator/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index c4d844ffad7a..48ed33ad48c8 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1522,6 +1522,9 @@ static int set_machine_constraints(struct = regulator_dev *rdev) } } =20 + if (rdev->desc->off_on_delay) + rdev->last_off =3D ktime_get(); + /* If the constraints say the regulator should be on at this = point * and we have control then make sure it is enabled. */ @@ -1549,8 +1552,6 @@ static int set_machine_constraints(struct = regulator_dev *rdev) =20 if (rdev->constraints->always_on) rdev->use_count++; - } else if (rdev->desc->off_on_delay) { - rdev->last_off =3D ktime_get(); } =20 print_constraints(rdev); --=20 2.36.1