From nobody Mon Feb 9 12:24:26 2026 Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 894B4350A19 for ; Fri, 9 Jan 2026 08:38:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947928; cv=none; b=Zx/Xzlp6NIchmAcBQFfpBEm8ZMifxNIapLxqlyuhjEg/TH6q7lIn+hudYa0QAd50/nHRN4Cr86jkTrdZw62lrrBgvuTeZvEQL8xVqd67QmRuwgbGrbVQKKnBktEDXoAAGwVginE1wDY/Y5oD+iT7Ls8nIDDFU4izfACjk+HDiKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947928; c=relaxed/simple; bh=EabHCtduQdrh97SYsYLZ9H5JBszs1KYLxj7vODU5wWw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ePdlvi4a09Y0O9uRT+APkLMBGjqev6Y10wLdgWPLoHrRF0tfOx/vJDR9/qE29rws8Bf6+U1Nl45Ldeg1vqoM1NntrV8Hm+1cfrEVPOGGoUDKY1nZdKUrquiLXhebUadmXLZPJtq3vr6B/L+g3zwNWt5Cme1B/ZCp3x4VI33SgrA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=p0Uj73ru; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="p0Uj73ru" Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-64b5ed53d0aso5819645a12.3 for ; Fri, 09 Jan 2026 00:38:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1767947921; x=1768552721; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=6mXjuOY33/2SHctvLHwFFtbPmaAgdrRr42yQiHPzhDg=; b=p0Uj73rujtGytNCIP8IyzKmAmKU9TXH+HZyRL37ZBB32A6Uy+Jr0t7A5SvzRXk6Nyw KXfnU3bIWikbXm2+Cgq+OghMzm8n88fcw51vQ1d2aE1GMtfUY45b+Z7MFO/Qs2muj358 no4z13NN3LHuwJ7BqxhxmbUlCcxzL3b3fVJU2sUw5m8FBPgi7kMuxagNSNuoIUkLusyz V9Ww5gYQtpuKE4E9MEn+CB7cicIB4gI0UbBUWYd/y12scKjrmSx82t74Lgw3lAAN2Bho k49EGxgNeEcT/sLde2hUiSyphX/xAVbnfZNNGPZZPV3DrVPVHdCFckn3VUx9O353ibMx jshQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767947921; x=1768552721; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=6mXjuOY33/2SHctvLHwFFtbPmaAgdrRr42yQiHPzhDg=; b=NwxnslkSor5q6kXU0jJ9Sjp/KL5AFrRWVkXB6Pvruq9KhZkkbGBDbH/vnrDd63icrz nOZlQtlABBqrXPtduYGPyD9dHToV061tsDurZ3bCVmPztts7+ShawM2NgzOUMXuuTeVL dVQyMNrkSQesMaSu41kC8hLCTs0c+KK8/RdKNBMSZk4dpNBWqjKLRFll7BRQpm3EfW6x u5gCNytbsxE/HM7TEuSfejUYKMCl4afmQXdslBNG1y573tR7gM5lFJHs7TnyO/uOhzK3 pF16UAxpbxmQ2F8okrXqRIe6+BAMTPkQNkLeINv+wUg+5c2Id4SjojXWZucT2HfOz6Iz USuQ== X-Forwarded-Encrypted: i=1; AJvYcCUO8JozOPZJoBQ2a3+2TcQGcJ1LIrh0KrG3nR/skbxM2d6h60MSYIIdAW5BQrzinm7xqiViUe8MXV6n40g=@vger.kernel.org X-Gm-Message-State: AOJu0YwXcIH5iObCs0XDiM0gSF5XttEB4jXZCx1D4NiM78BIvsql2Pv3 YX2QvCJ/FzXpeMh73t0vGtLR49QUij0Xw9/vHd5pZlJZ6zn3q3YS1JDm4s8AqtpnT6Q= X-Gm-Gg: AY/fxX7NL3qRajp17810svtywS4iHXE/tE4FJ/2lC6/EFa4a5pwPZETyvYe7WkTZZP0 I+lLPXf7Rjx+PVnpi7hmmK/9hsRaYElHFUtNNSL5uFK9WvW+t2I/sWBJtp3sVdN8BnRaHpesbev Y9abAyuHGmScuMIaJmvhofLHz4zvBl/8Ne5/I54bXI5v9nt6Th8f3u8SPLIIBc/W9/sTZe3sBkq GXIM+Vk5P8qzrh6j3/mHd8P+QLUJrgtdcnryf1Mi26L8FXiZ7/jCJ1fdyegqqYyDejPzhZlKu5S Xy2oIqzbJIliKhGAQkcIUpilpXQXr4aY6s/730yNASiRWgnSHBzQn0KPbGx/vJymx/HlKjXoyHF OJEsmmN0KFg/L8jLnnwdKw++lZZJp4YnG3aHXicugcLPfai6aff7azU1/GFQgZlPqBxMxnbCwIu KwVLG/XI6ZuPkoAiy+YRCedliCIFUFEu5O0i7FE/pyz9pdL4s5G3YtYFLGGJfEdUH6sqaSchoMQ O7/r9BwZcleWgBM X-Google-Smtp-Source: AGHT+IHku8bMmnWn90kgJ1jVXn54kGnrFJI3Z4JedO8R94JdZgh/7+J5s4YvH8g99HnsxlKc+AxP0w== X-Received: by 2002:aa7:c4e7:0:b0:64c:69e6:ad3a with SMTP id 4fb4d7f45d1cf-65097e6107amr6057567a12.27.1767947920721; Fri, 09 Jan 2026 00:38:40 -0800 (PST) Received: from puffmais2.c.googlers.com (244.175.141.34.bc.googleusercontent.com. [34.141.175.244]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6507be658b3sm9472950a12.18.2026.01.09.00.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jan 2026 00:38:40 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Fri, 09 Jan 2026 08:38:39 +0000 Subject: [PATCH v2 3/8] regulator: core: move supply check earlier in set_machine_constraints() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260109-regulators-defer-v2-3-1a25dc968e60@linaro.org> References: <20260109-regulators-defer-v2-0-1a25dc968e60@linaro.org> In-Reply-To: <20260109-regulators-defer-v2-0-1a25dc968e60@linaro.org> To: Liam Girdwood , Mark Brown , Javier Martinez Canillas , Jon Hunter , Dmitry Baryshkov , Oleksij Rempel Cc: Peter Griffin , Tudor Ambarus , Will McVicker , Juan Yescas , kernel-team@android.com, linux-kernel@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Draszik?= X-Mailer: b4 0.14.2 Since commit 98e48cd9283d ("regulator: core: resolve supply for boot-on/always-on regulators"), set_machine_constraints() can return -EPROBE_DEFER very late, after it has done a lot of work and configuration of the regulator. This means that configuration will happen multiple times for no benefit in that case. Furthermore, this can lead to timing-dependent voltage glitches as mentioned e.g. in commit 8a866d527ac0 ("regulator: core: Resolve supply name earlier to prevent double-init"). We can know that it's going to fail very early, in particular before going through the complete regulator configuration by moving some code around a little. Do so to avoid re-configuring the regulator multiple times, also avoiding the voltage glitches if we can. Fixes: 98e48cd9283d ("regulator: core: resolve supply for boot-on/always-on= regulators") Signed-off-by: Andr=C3=A9 Draszik --- drivers/regulator/core.c | 55 ++++++++++++++++++++++++++------------------= ---- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 48c091de68d81e3e89eacecd8526255ab9a446b2..9ce0eef1dcfcb39a072675e44a5= 577ae85d51982 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1444,6 +1444,33 @@ static int set_machine_constraints(struct regulator_= dev *rdev) int ret =3D 0; const struct regulator_ops *ops =3D rdev->desc->ops; =20 + /* + * If there is no mechanism for controlling the regulator then + * flag it as always_on so we don't end up duplicating checks + * for this so much. Note that we could control the state of + * a supply to control the output on a regulator that has no + * direct control. + */ + if (!rdev->ena_pin && !ops->enable) { + if (rdev->supply_name && !rdev->supply) + return -EPROBE_DEFER; + + if (rdev->supply) + rdev->constraints->always_on =3D + rdev->supply->rdev->constraints->always_on; + else + rdev->constraints->always_on =3D true; + } + + /* + * If we want to enable this regulator, make sure that we know the + * supplying regulator. + */ + if (rdev->constraints->always_on || rdev->constraints->boot_on) { + if (rdev->supply_name && !rdev->supply) + return -EPROBE_DEFER; + } + ret =3D machine_constraints_voltage(rdev, rdev->constraints); if (ret !=3D 0) return ret; @@ -1609,37 +1636,15 @@ static int set_machine_constraints(struct regulator= _dev *rdev) } } =20 - /* - * If there is no mechanism for controlling the regulator then - * flag it as always_on so we don't end up duplicating checks - * for this so much. Note that we could control the state of - * a supply to control the output on a regulator that has no - * direct control. - */ - if (!rdev->ena_pin && !ops->enable) { - if (rdev->supply_name && !rdev->supply) - return -EPROBE_DEFER; - - if (rdev->supply) - rdev->constraints->always_on =3D - rdev->supply->rdev->constraints->always_on; - else - rdev->constraints->always_on =3D true; - } - /* If the constraints say the regulator should be on at this point * and we have control then make sure it is enabled. */ if (rdev->constraints->always_on || rdev->constraints->boot_on) { bool supply_enabled =3D false; =20 - /* If we want to enable this regulator, make sure that we know - * the supplying regulator. - */ - if (rdev->supply_name && !rdev->supply) - return -EPROBE_DEFER; - - /* If supplying regulator has already been enabled, + /* We have ensured a potential supply has been resolved above. + * + * If supplying regulator has already been enabled, * it's not intended to have use_count increment * when rdev is only boot-on. */ --=20 2.52.0.457.g6b5491de43-goog