Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2254049imw; Sun, 17 Jul 2022 05:03:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uDWDM7/+xqZNgNHc3z4TZob49lq2eZ2j5JuLv2rzE7MsgFgAxy16GE7ow+7nSM0yTpM9Cj X-Received: by 2002:a05:6808:1313:b0:335:cad6:715c with SMTP id y19-20020a056808131300b00335cad6715cmr11401053oiv.130.1658059424839; Sun, 17 Jul 2022 05:03:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658059424; cv=none; d=google.com; s=arc-20160816; b=BvsIaUQTiqmBxdFHy4cYlxbMceSpgoqXS598Vkq3LlIp/vXkk5iJssGbIPbXLhlrtR 0RpCk4QFoVgWlnPIDGLZXEHoUplPyCTcjIClk2duYfBrZt3rWdumWl4WJr2AXtZ1eVNB jDUNgEM/I39XtqJpY55T71DDLIY3LXlA6Vro8Ti7xOwoND/8ijHxNvoGFnKGebbdGRdw DS6Fba+4X92sWRMHDcAY3mr9zj1Kg9q+OMeqhPD7VMr1+RfVUcp0jHUm1fOxZK3i8rlj YMtNsOorJQDef0KPfDgpGQzS8RI8Y2pqTlu+U28ssfJH4IfQcs9oBxLpAbrilZysSwxY 4yzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=SC4Y9bQ5Mv3/wN6+CzaaZu23YdaRhhafcPtQU+MEiaw=; b=PSVA3S99CHJoCv0M3GYablsA2EfXRXYkNegjPtEIg7JR0CqkZla3Ezb4TgQ38QoSQz Z8OBsidH1ue2y5WYpO4TrtNQ7Q3yu/fntxNkoR38F7otf4kZUg3s6LOAhobz5n7ocRkx 0CXM5+Itlh1QMIl4h1U7GNtSoSahx3Y4o5U4ncAP0XxCJ3LU20zKMi2tQUmvk3zOYcpk vMkLqIv7ZKpz4NqZoMctyStdaSAC2ji3UsWpni/qqRKB8L0mULefMiqvh7jeJAtXBfSd w8V4cX+BPt53SRtps4L4lki1+RzBpahtvUgGkvZC3R6xMs0jxFXkFccQzq8F46DI8coa fNuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kohlschutter-com.20210112.gappssmtp.com header.s=20210112 header.b=AgL9bPDO; 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 q31-20020a056830441f00b0061c9cca0d18si1494491otv.125.2022.07.17.05.03.22; Sun, 17 Jul 2022 05:03:44 -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=@kohlschutter-com.20210112.gappssmtp.com header.s=20210112 header.b=AgL9bPDO; 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 S231256AbiGQLt3 (ORCPT + 99 others); Sun, 17 Jul 2022 07:49:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiGQLt1 (ORCPT ); Sun, 17 Jul 2022 07:49:27 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C5BD14D11 for ; Sun, 17 Jul 2022 04:49:26 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id k30so11828536edk.8 for ; Sun, 17 Jul 2022 04:49:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kohlschutter-com.20210112.gappssmtp.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=SC4Y9bQ5Mv3/wN6+CzaaZu23YdaRhhafcPtQU+MEiaw=; b=AgL9bPDO5bHJE2njG5yxdz+bkwVKdHy4FLDnj0NHavCS0Y2RlWaur1CNKXD5QZIgJE yerieaFIbY6jno2f1xE/Z4WqutyJVwAvZh2hc/uRUmZVHOaGeNYHuQ1mq8sp43iavUtF TA42IyhGe0Sn+enezgOLFDAI7KL5WZlZ54H6td8AmTNZCIGRit95xpOLnrOyNVqo5mgf Wc0su6Hm9hCy0yu/S4MJUBdah8eGdmqqkg4KHFGNkggHILhQaPV8RhGfIFDXI69kEYyx 3Ti2gkO+97DYiyChZfmxp0EIIrmcOMr4CgReXHQc5WtaYhHH7439fjv+IPcb89uKboSY CaBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=SC4Y9bQ5Mv3/wN6+CzaaZu23YdaRhhafcPtQU+MEiaw=; b=DlSSouWn+NwUmH/hejidO12n0j5ig1v5pyUE47J4gfpeDxkQDa3fi4LbCEHLrz5jNB uhN8D5bRkdJolRmOsY36POgm5kisS/n2gpaEE6POcUR7qymUavSEz5pmGMjSrGUlyrk8 OVobCY9N502M6z+P+xWnoDdqOFN9SkVINOcXd9GYxIfwuD2FaZ+zNpsj8GLrNJIp3m05 e4OCIBiTLuIaI/7WCX4fSIlNA5+0I4ZU8A+XX1ymkuwbLjO5GHCttda0PFXXmQz1zcCT d+ptAlk2t+dxOPgCoiY7L8sxVBhURRymP9IafMEoO151VXXbdH1/z8sLAV2n/SQNsBjt GPbg== X-Gm-Message-State: AJIora/ewAGj8BUvSzk22oa4O2KLoVQUc7QYCYWfja9vP4M4y55hE1DV g71YQSs4wQZKb7QsECno6tek3w== X-Received: by 2002:a05:6402:270b:b0:43a:d89e:8c2d with SMTP id y11-20020a056402270b00b0043ad89e8c2dmr30993250edd.413.1658058565125; Sun, 17 Jul 2022 04:49:25 -0700 (PDT) Received: from smtpclient.apple (ip5b434222.dynamic.kabel-deutschland.de. [91.67.66.34]) by smtp.gmail.com with ESMTPSA id qx21-20020a170906fcd500b0072abb95c9f4sm4252027ejb.193.2022.07.17.04.49.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Jul 2022 04:49:24 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) Subject: Re: [PATCH] regulator: core: Fix off-on-delay-us for always-on/boot-on regulators From: =?utf-8?Q?Christian_Kohlsch=C3=BCtter?= In-Reply-To: <2B145293-BAAE-40AE-B408-FCFC4A80E46D@kohlschutter.com> Date: Sun, 17 Jul 2022 13:49:23 +0200 Cc: Robin Murphy , wens@kernel.org, =?utf-8?Q?Heiko_St=C3=BCbner?= , Markus Reichl , linux-arm-kernel , "open list:ARM/Rockchip SoC..." , Linux MMC List Content-Transfer-Encoding: quoted-printable Message-Id: <96D772F2-16D8-49BD-A438-A827B69DB670@kohlschutter.com> References: <2B145293-BAAE-40AE-B408-FCFC4A80E46D@kohlschutter.com> To: Liam Girdwood , Mark Brown , linux-kernel X-Mailer: Apple Mail (2.3696.100.31) X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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 +CC mmc/rockchip folks > Am 17.07.2022 um 13:39 schrieb Christian Kohlsch=C3=BCtter = : >=20 > This is _somewhat_ related to "[PATCH] regulator: core: Fix = off-on-delay-us for always-on/boot-on regulators" > That other patch is the right solution for my specific problem, and no = further fixes are necessary. >=20 > This change fixes an attempted "bandage" solution (adding an = "off-on-delay-us") that we had initially tried to no avail. > While the cleanup not only reduces complexity, it may also prevent = future code changes reintroducing the non-delayed cycling after = registration. >=20 > from arch/arm64/boot/dts/rockchip/rk3399-nanopi4.dtsi: > vcc3v0_sd: vcc3v0-sd { > compatible =3D "regulator-fixed"; > enable-active-high; > gpio =3D <&gpio0 RK_PA1 GPIO_ACTIVE_HIGH>; > pinctrl-names =3D "default"; > pinctrl-0 =3D <&sdmmc0_pwr_h>; > regulator-always-on; // prevents setting last_off upon = registration > off-on-delay-us =3D <500000>; // would not be honored upon = regulator_register > regulator-min-microvolt =3D <3000000>; > regulator-max-microvolt =3D <3000000>; > regulator-name =3D "vcc3v0_sd"; > vin-supply =3D <&vcc3v3_sys>; > }; >=20 >> Am 17.07.2022 um 13:30 schrieb Christian Kohlschuetter = : >>=20 >> 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. >>=20 >> This is caused by the "last_off" state not being initialized in this >> case. >>=20 >> Fix the "last_off" initialization by setting it to the current kernel >> time upon initialization, regardless of always_on/boot_on state. >>=20 >> Signed-off-by: Christian Kohlsch=C3=BCtter = >> --- >> drivers/regulator/core.c | 5 +++-- >> 1 file changed, 3 insertions(+), 2 deletions(-) >>=20 >> 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 >>=20 >>=20 >=20 >=20 >=20 > --=20 > Dr. Christian Kohlsch=C3=BCtter >=20 >=20 >=20