From nobody Tue Feb 10 07:39:12 2026 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.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 0C4B8315D24 for ; Sat, 27 Dec 2025 12:17:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837875; cv=none; b=mFDK+LVauV2hYQeJyWCPnoP0E+1/vToSk7NyAV1Z6PN/wu2BlB46TK3FaCOTfP38Pl15PW3olcO4ezCcnLqzgVhDY/MRvIVZQtAmqZVhIDaw8Uuy02bOuexZ6f0NMoeUOpHfQEQo0nczC902DwjCa7jj2hRYgpTwhQR/F8XG9Ys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837875; c=relaxed/simple; bh=pKanK01/6ci1Nq6/41AM5YZAp3FqFQlP5A3HYGA8/gg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LydXyqvtBJyKc1qTI3jes0z8IPrci9K8vRHZAd2iRKk3vOm0DNGLtmJaWdIw0adQpElO52Ehv7EVASxAr2f2gSavBlza3dgQf51bm78lBL4BLS8a6OcqUSJwVQCFLG5EHjS5H8Tk0pmWyYdGR9QE1ZHfw49UrUETJ7uLygCoQUQ= 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=tNK6SUUm; arc=none smtp.client-ip=209.85.218.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="tNK6SUUm" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-b7a72874af1so1342715866b.3 for ; Sat, 27 Dec 2025 04:17:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766837869; x=1767442669; 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=PSogidtZBMDKLRApi+K0MZhf3bs4bL3I18rYn4Uhthk=; b=tNK6SUUmRJnGccgHgMJNYOZ6DW6FvEV5k53KK+26pyw9GMLjccb+6k62niDlxTwFVu LkPMASh8qwVPECzsItsG7r3eGAsQTIiQ1G9bmSqCIrso6aRGrAyIYa2E1sM5S9/rJ/Cs PoHsm7B70OQXtKw/Fu+xfBwoz+fzT/adJg5+PnDczxW1rKRvfPSJiovQ+1UUDQ9SzDSS musW2Myqb1kocZEfIT4d0mXxp0jYUaRFbtG9AF3x581cNPoH6nNrAAelCtzXnDnpoDfT gvcKl7el8iUHKuxEUtIIQECsHz7PWeepgDsCUgYdyRs2Xx0KCgGYz+LNc1KOgmS+o+Ti yLHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766837869; x=1767442669; 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=PSogidtZBMDKLRApi+K0MZhf3bs4bL3I18rYn4Uhthk=; b=lEMf/3QDuyF0/YhhRAeYXD2h9FKI0AwUZIjGTqeMfjnq/3I8ce98yagMRNlt2R2/41 ML/q1SLaFKmWx9T5qK9zAsDMCkv57dr55jX2djxr5ekEWHrI20ROjbriSjGNdjskC2rj lCSSUxsal92ov2qEe+Z4O3KHKL5Hgtct86UfdKj0pwde1gXd/DgR3QkM68qcB9mX0Gju vqZd7R09YOu+4eEQ3wxEYNQInVmzk3YE+Nbzs3qgzNbbS+K+zTWkTXCjs/BHa4efLvBw i5V33aFy04mLWXXNywbpKpnTtIR/XxuvpEwQmYcvxZ3Nr8S5uK0nZR5JQvW8YszRoma8 nI+Q== X-Forwarded-Encrypted: i=1; AJvYcCUJMBRMClTyTKxcsHVCsohL9o6gUWTS4TqYvNKmfCrl3dBVsG0JzO/RnIAYbAe7BQqhY9zixZd/ORo4xeg=@vger.kernel.org X-Gm-Message-State: AOJu0YyVqyd12+Ad+nZwwVKyRIPpis3khX+t1ae8O0XCWvbBLwBVYV69 nDdj6UySKfvuVZ8KIOhojyw/AFqR/Y1RRhPCZHxMN7DcVBD3DH1iwNigzkXGvlr2P8o= X-Gm-Gg: AY/fxX4vWrbZponaNb4qJv5CV05IUD5qStTLqj+tTEi5pVjt4+3RBkhkyVtf01MNpQ4 m102B5arpMNn8v2aWm/w5TOo90t77SlnSjeGG1nju0Ps2haMKlOVH7/bkCocC9Clcr138aMospJ GNkoc90QzT99nzZlULQzT0go6Xaml0Zsvm5JxNHfHrFBAcOF/oPhgx3QIYV6Fk4hYA6YK4nBU78 PEI7PZFNIzo0/gHkqHwEWvPObGH7H3+KEJSAeO2rLVl9pmh2XL/8mKxP3YcKgCg0Lks13GClo2P BwEoIxenqZpQB5JVlpm1xdytUMn25MlooOSXjCH8vxomPZ9bYa1iQ1CE8qxxdBDOdj1h34k3zh5 y/b+EAlkrxjBSqrUF0fTnrQGPpcSDrO7Tp+d8bgnEb65sjC7S4guh2fboXuR08tiepf9/b9RDgF PcPyfvikvWH1WZD9pB24Zp82VEuStPQHcoKfxrGIVjshh7KqBMVdQrbcenCTd1I1plH4Z7WV2Gk wxH4kLMUzZsu6Vj X-Google-Smtp-Source: AGHT+IEGGJ5ypx3GInB6VYO0/C+nGxHsnyT9YoXO9OzkIHP/ZY9ZdVsuJhn5+0HhCSmv5dcqAsOBgA== X-Received: by 2002:a17:907:7e86:b0:b76:8074:344b with SMTP id a640c23a62f3a-b8036ebdd9emr2437849866b.8.1766837869330; Sat, 27 Dec 2025 04:17:49 -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 a640c23a62f3a-b8037f18575sm2616274666b.54.2025.12.27.04.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Dec 2025 04:17:49 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Sat, 27 Dec 2025 12:17:47 +0000 Subject: [PATCH 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: <20251227-regulators-defer-v1-3-3104b22d84cb@linaro.org> References: <20251227-regulators-defer-v1-0-3104b22d84cb@linaro.org> In-Reply-To: <20251227-regulators-defer-v1-0-3104b22d84cb@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.351.gbe84eed79e-goog