From patchwork Mon Mar 13 18:18:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 69009 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1340223wrd; Mon, 13 Mar 2023 11:30:18 -0700 (PDT) X-Google-Smtp-Source: AK7set8DjIH32O1wRWGWWzxsuDY7F7hAPX/K4s81FWaB9eEfWi/nM/HyBqJ3/hSEnFFxtdv6ZmGJ X-Received: by 2002:a17:902:c948:b0:19e:3b41:1828 with SMTP id i8-20020a170902c94800b0019e3b411828mr12301259pla.22.1678732218355; Mon, 13 Mar 2023 11:30:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678732218; cv=none; d=google.com; s=arc-20160816; b=pDRz7nLoxUKP2M50VqMwPut67sbCKOVuQQm5TMxq/YBmVjzODKu8E1LBC/wYbjpm1i W3bFsM/Fp9bdcVFq9OytV2nJ996zZl1O6FJ/jHE+gLsYN9wiJFZXiUAvBbC7a442VocM pJ3QDdQ+9Kl3Ti6MZyIp68C0LNitkVYzSVaPR74A+7DUXlZ6rRibp3/Soq6LNkHace/1 fUtMGqW4Ht1LTnqn9wQzdya9GlDOnB5/p3l50vE78lrBpbWASZmGji+TCmBANmdyTYve bkAReTbP/2M2nwwzE2d/jN2Aaf16vfcCwgHL4KlEfLV4FYlKMMJePiFz0xdBan3zF+da IW5g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Qek4QFzg5aoX0CRg0LYKieeL+YfPUejJQDb+/Lp8t1M=; b=KuT1/2p1HyW+uhrOv5c+42kG8svbNxxRCHX95ZxsXlsu4aH8oEnWMza2nw6xOD7ESl IyjKUVnhx/2kVqTRGWzBs+zHCQJrldbWe3/VtkM0+kTTTxYDti5fCbmO/bjiM4Z2Rwz1 3SpC/ekmAQkRe1qbOVdaQe1Q5EL2JWqog/ZE8PtIbAdUsJTYxDBhiY+cHi0iAR/D2y1E pKSqMD05YCMq7Gkqw3cQ5fOMPwHgg46w6UBEmdYjkcZvkjt9BFee4EyxfaMv4BB5uv4T QncktToOxIQH/ejh2S71ipHvBdc0Xwk857YJXBRDp9JzlEcrmwrq0cGSej7tDWPsXFV/ f/wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mmxNMNZH; 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 ik6-20020a170902ab0600b001a0598795ecsi367084plb.148.2023.03.13.11.30.02; Mon, 13 Mar 2023 11:30:18 -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=@chromium.org header.s=google header.b=mmxNMNZH; 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 S230039AbjCMSTR (ORCPT + 99 others); Mon, 13 Mar 2023 14:19:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbjCMSTH (ORCPT ); Mon, 13 Mar 2023 14:19:07 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C999B5A6FC for ; Mon, 13 Mar 2023 11:19:02 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id c10so8173433pfv.13 for ; Mon, 13 Mar 2023 11:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1678731542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Qek4QFzg5aoX0CRg0LYKieeL+YfPUejJQDb+/Lp8t1M=; b=mmxNMNZHv2j0J2jp64hKGlBki3V/twTrg6jVvdh7fOMXp5M4e1y7x7GPS0vwD3KGqK nIseKRnavewPpWx91/uh9dkVRtHRSlmeGh2ufvNVbd18Y1kwscuRY0UAJlnG8ne/UkQQ oCV7xHTRWmvA5cNMFB9k2o51uo8+h1cr5GXxo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678731542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qek4QFzg5aoX0CRg0LYKieeL+YfPUejJQDb+/Lp8t1M=; b=4hGMphq3et0c7/+HMYEs2gUdfMZ9Xft8MBOVzWdFYbWUzj5o6PnVTxmynTHtTRDY9m 41IXC9SWuTZeEDrkLsJ+ZDRJrX56xPDYeJ7rVv96sGaI7658Jf0fNjHHm97UKb6DQHfM FSsk1N3SquL9izIbyZ4sAYwNhZmE781d8skAbRhHiZ6M2Lre+L9LVVVsy53VIqafVuF9 60K16fK5AOwKi7CCxe6eH01+ddGsWW7lkSBYK95jNcA5npebDQ04+FlSVBY9nRZQ5qO2 FQel9yM8WX008a2l+giKEeDjoR8YRPClklekidH/EOVloGZMqB4PHJUmHjRN8wxHWb7M sxtw== X-Gm-Message-State: AO0yUKX76nk9GGA1NEYAFKbA4cLW4Kold8Zp5phlWVYwK1rg8VMZAxwf 52kZOt2fcURqDInG2DgdXa1Pxw== X-Received: by 2002:a05:6a00:1912:b0:594:1f1c:3d3a with SMTP id y18-20020a056a00191200b005941f1c3d3amr12327707pfi.15.1678731541910; Mon, 13 Mar 2023 11:19:01 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:79c6:a848:199d:3491]) by smtp.gmail.com with ESMTPSA id a11-20020aa780cb000000b005ac419804d3sm25169pfn.186.2023.03.13.11.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Mar 2023 11:19:01 -0700 (PDT) From: Douglas Anderson To: Mark Brown Cc: mka@chromium.org, christian@kohlschutter.com, Douglas Anderson , Liam Girdwood , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] regulator: core: Shorten off-on-delay-us for always-on/boot-on by time since booted Date: Mon, 13 Mar 2023 11:18:19 -0700 Message-Id: <20230313111806.1.I2eaad872be0932a805c239a7c7a102233fb0b03b@changeid> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog In-Reply-To: <20230313181820.2482385-1-dianders@chromium.org> References: <20230313181820.2482385-1-dianders@chromium.org> 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 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?1760278314531931628?= X-GMAIL-MSGID: =?utf-8?q?1760278314531931628?= This is very close to a straight revert of commit 218320fec294 ("regulator: core: Fix off-on-delay-us for always-on/boot-on regulators"). We've identified that patch as causing a boot speed regression on sc7180-trogdor boards. While boot speed certainly isn't more important than making sure that power sequencing is correct, looking closely at the original change it doesn't seem to have been fully justified. It mentions "cycling issues" without describing exactly what the issues were. That means it's possible that the cycling issues were really a problem that should be fixed in a different way. Let's take a careful look at how we should handle regulators that have an off-on-delay and that are boot-on or always-on. Linux currently doesn't have any way to identify whether a GPIO regulator was already on when the kernel booted. That means that when the kernel boots we probe a regulator, see that it wants boot-on / always-on we, and then turn the regulator on. We could be in one of two cases when we do this: a) The regulator might have been left on by the bootloader and we're ensuring that it stays on. b) The regulator might have been left off by the bootloader and we're just now turning it on. For case a) we definitely don't need any sort of delay. For case b) we _might_ need some delay in case the bootloader turned the regulator off _right_ before booting the kernel. To get the proper delay for case b) then we can just assume a `last_off` of 0, which is what it gets initialized to by default. As per above, we can't tell whether we're in case a) or case b) so we'll assume the longer delay (case b). This basically puts the code to how it was before commit 218320fec294 ("regulator: core: Fix off-on-delay-us for always-on/boot-on regulators"). However, we add one important change: we make sure that the delay is actually honored if `last_off` is 0. Though the original "cycling issues" cited were vague, I'm hopeful that this important extra change will be enough to fix the issues that the initial commit mentioned. With this fix, I've confined that on a sc7180-trogdor board the delay at boot goes down from 500 ms to ~250 ms. That's not as good as the 0 ms that we had prior to commit 218320fec294 ("regulator: core: Fix off-on-delay-us for always-on/boot-on regulators"), but it's probably safer because we don't know if the bootloader turned the regulator off right before booting. One note is that it's possible that we could be in a state that's not a) or b) if there are other issues in the kernel. The only one I can think of is related to pinctrl. If the pinctrl driver being used on a board isn't careful about avoiding glitches when setting up a pin then it's possible that setting up a pin could cause the regulator to "turn off" briefly immediately before the regulator probes. If this is indeed causing problems then the pinctrl driver should be fixed, perhaps in a similar way to what was done in commit d21f4b7ffc22 ("pinctrl: qcom: Avoid glitching lines when we first mux to output") Fixes: 218320fec294 ("regulator: core: Fix off-on-delay-us for always-on/boot-on regulators") Cc: Christian Kohlschütter Signed-off-by: Douglas Anderson --- drivers/regulator/core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 4fcd36055b02..1490eb40c973 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1583,9 +1583,6 @@ static int set_machine_constraints(struct regulator_dev *rdev) rdev->constraints->always_on = true; } - if (rdev->desc->off_on_delay) - 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. */ @@ -1619,6 +1616,8 @@ static int set_machine_constraints(struct regulator_dev *rdev) if (rdev->constraints->always_on) rdev->use_count++; + } else if (rdev->desc->off_on_delay) { + rdev->last_off = ktime_get(); } print_constraints(rdev); @@ -2668,7 +2667,7 @@ static int _regulator_do_enable(struct regulator_dev *rdev) trace_regulator_enable(rdev_get_name(rdev)); - if (rdev->desc->off_on_delay && rdev->last_off) { + if (rdev->desc->off_on_delay) { /* if needed, keep a distance of off_on_delay from last time * this regulator was disabled. */ From patchwork Mon Mar 13 18:18:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 69006 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1338675wrd; Mon, 13 Mar 2023 11:26:25 -0700 (PDT) X-Google-Smtp-Source: AK7set+vPexY/cLrhE4QzS8mIhub1Vkm1SuSG7kMtcHONuHCJUp1t79mpRuvB7822MPq7MyAy4FM X-Received: by 2002:a05:6a20:431e:b0:cc:9b29:f617 with SMTP id h30-20020a056a20431e00b000cc9b29f617mr36957196pzk.0.1678731985634; Mon, 13 Mar 2023 11:26:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678731985; cv=none; d=google.com; s=arc-20160816; b=mBywh+i3hyW1++5cBl66qptNhR9zXKRa69AWuc2b/BqreEyPg2YTAfp5rtWYEWmxiO Be2XgqvFAdjZDymPWvdf686XeojMIgez8AIb0EQSq0MDsvVtq5E3fK02fCizcvAvlXWH Xx6Wwoxa0ZXHOqVUPr6L6WGN/y1FQhjDTzU1vxx1pEse1jVIqXM07P8U4t55aOX0S1u/ UbQW+yXWuqNjNPckDY+pgo2m1bXiEPSe/hwWUfdNQXSSf8C/b0oVWvcbOAlCfcHs4ZPN jzxXl7ez26JBAHbexBmjvkYlvfTSI/RV6TdlOS8hB/6vmlZNvaYRyZTuCVXIjTrYjvOD 1XjQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XstmFM2GshtLwvoAEIpsc9WtbOo21zJeuCi3J74UKuM=; b=MXcJH1qEvpZF4tZkLe9Y7Dq7NnvbhfgFwgGbiAV2ety009s/ZV4Y9HezKQ89ITXOhs Xwarr4M+VRd+jWX4Cy06rSpf18rIil+YalFjapAExWLxX+zaA8tVU7UHA5Yt1ZoQdhea iIdU3dCt3R0mFZ62SxCM8NijYO7fvYbDV4lfxLdnUg4vGcxdQ2TitnOuVM4NLICX1G1i 8jdA1XkcQfW/UQE33Stkybc/bppyBhhZrKuBLckoHbzyOV1RW2+pPV7BvVFJbVpZzSbe br9EEl/J8MvDOuuGtS9tAiXthLRcRB60STS6dVaLa3tOMu1XTnmDGpa+6xevKUaiYGil 2mhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AXHqUvDD; 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 r12-20020aa7962c000000b0058bc338c9b2si52980pfg.372.2023.03.13.11.26.09; Mon, 13 Mar 2023 11:26:25 -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=@chromium.org header.s=google header.b=AXHqUvDD; 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 S230081AbjCMSTU (ORCPT + 99 others); Mon, 13 Mar 2023 14:19:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230014AbjCMSTI (ORCPT ); Mon, 13 Mar 2023 14:19:08 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E832C6A052 for ; Mon, 13 Mar 2023 11:19:05 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id bd34so8216264pfb.3 for ; Mon, 13 Mar 2023 11:19:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1678731545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XstmFM2GshtLwvoAEIpsc9WtbOo21zJeuCi3J74UKuM=; b=AXHqUvDDmZPGCCP5cgSLitbVM+kqfQ7XsQEqKZ/cR7dPzDSiBHuZVBwGz0SqcN7oxs DBrJEwOiLSkhmgGZjRWmYnJNgtT5wofMgGiNBCn6tT4m+bsc3Wr3rS3hc3NMX5NvAenf qY8IA9nPi1oR6/dNzSBx9vfCEgoC1XFtoyiCI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678731545; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XstmFM2GshtLwvoAEIpsc9WtbOo21zJeuCi3J74UKuM=; b=5eicbU2+EH/P3D2qnn26LWeQWK8CRp1HEYE2Zd5nhZoIAv0AhIRrIZu0bAjdG5LmtQ mKeaZtaiXoXIX0QCasMArr8CbBzNq0orhCo0V+dMj+wG9j2kRkUyq9Bjw4rni14fqpXV VufhMFdseKFiAMMoXYdxgEvBKaqfRzwf80ROyMFEVVfYFfPZ1zp+tB1WR0KAVbGrCNEy OMRnH3qwMPUHV/m/CQapwg1Xp9ew3d3X/EckNejKBlCHIUrr/ah1bDe9hFjItQWJOGaW omvFrQb/K/wUw8YGIhtHR6DMNdvsmRjjfZVoEIKkVd2I33bBtNQw1+eXRSz+/Agdsxb/ 1j1g== X-Gm-Message-State: AO0yUKXi2tIZjExVZgCdXkaWTTxXUL9Yf0pblD7g7IN/3Pah2KdVZbP9 Nc12o47qhv64rOj4xpGJgU4acQ== X-Received: by 2002:aa7:9f44:0:b0:622:844e:80a8 with SMTP id h4-20020aa79f44000000b00622844e80a8mr5911107pfr.26.1678731545207; Mon, 13 Mar 2023 11:19:05 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:79c6:a848:199d:3491]) by smtp.gmail.com with ESMTPSA id a11-20020aa780cb000000b005ac419804d3sm25169pfn.186.2023.03.13.11.19.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Mar 2023 11:19:04 -0700 (PDT) From: Douglas Anderson To: Mark Brown Cc: mka@chromium.org, christian@kohlschutter.com, Douglas Anderson , Liam Girdwood , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] regulator: fixed: Set PROBE_PREFER_ASYNCHRONOUS Date: Mon, 13 Mar 2023 11:18:20 -0700 Message-Id: <20230313111806.2.Iee214b2dd184cb19197db8f97fad7e4adca273be@changeid> X-Mailer: git-send-email 2.40.0.rc1.284.g88254d51c5-goog In-Reply-To: <20230313181820.2482385-1-dianders@chromium.org> References: <20230313181820.2482385-1-dianders@chromium.org> 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 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?1760278070546899367?= X-GMAIL-MSGID: =?utf-8?q?1760278070546899367?= As of commit 218320fec294 ("regulator: core: Fix off-on-delay-us for always-on/boot-on regulators"), we now might have a big delay during probe of fixed regulators. That can have a significant boot speed impact. Let's mitigate this by preferring async probe for fixed regulators. The regulator framework itself has no issues with regulators probing in an asynchronous way. The fixed regulator driver is fairly straightforward and also has no issues. Signed-off-by: Douglas Anderson --- drivers/regulator/fixed.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index 2a9867abba20..1927dc2d4cf8 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -334,6 +334,7 @@ static struct platform_driver regulator_fixed_voltage_driver = { .probe = reg_fixed_voltage_probe, .driver = { .name = "reg-fixed-voltage", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, .of_match_table = of_match_ptr(fixed_of_match), }, };