From nobody Sun Feb 8 13:16:46 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 09242314A6C for ; Sat, 27 Dec 2025 12:17:50 +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=1766837876; cv=none; b=ilB+Jb6WDxtUX73lST8Z5HoO2uCAcItcNlWA49+RY899w2W1nzYW/d8j4c341WhAHJqucUcW0p1LqyXd97htQCS2f44IHaYwfCUTL/vaRcsk73u9S6KIhPrMu10uFmBUtA2kRhU8ilXFgKO8L68GhaIhqgG66QUZ/d0vGqHJAM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837876; c=relaxed/simple; bh=Rb1vpvnfwbnjnDowVbEvpL46lzzwqyDYexQdpgKUi/w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rtlAvIoGzuQDNeuH00GbM+ij2wuaLlxFaJEsgDIP4KZo0Chb09vuMCM0uF6ohL7MIdXP1qAgchlQ9UPpm7eJ513RKVIn6V8DbQd2jFROBS9/Y9bZ69RWuy/vkNnW4xkiFf9WY75FWyY5Igi/aC/80soqtrmFNJKRoQOq0/4QCM8= 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=vq/1ecYn; 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="vq/1ecYn" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-b7277324204so1180818366b.0 for ; Sat, 27 Dec 2025 04:17:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766837868; x=1767442668; 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=HlRDfavExAja0FFeQuS56y8e5AL4It8tjarFDjm4Eus=; b=vq/1ecYnaYj461UUaFAPVhF/maQRxvvHVDIxXJC0fLP5D5aC1SStJCtdx0usVOKYne sEjof0VoF7Gebbc90zpr1IWfhtxmBiNWByxH49LA/wFc+cfG2Ez67L+i72SFk2HiEOhG 1Cz3AApjDRQH/2cs+6ek2U7BMshVYragI3ISdbQns4A864LM1OLsMHxD/ZIaDLk3iWpe Vc78ZRnb6nVUdCFd00pl33cEuvdglYR0S5+I670loHC5WhoUQpX7WmpdvvtCuDMXy0Vn Uol7iFhSXNaM7sUqPs76FC+G5uoPrRBi3pXUU2mf+CRx1q6c7xrEe+obQ8j/W9dTHGyV XhWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766837868; x=1767442668; 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=HlRDfavExAja0FFeQuS56y8e5AL4It8tjarFDjm4Eus=; b=e7fUeETChIum+9lIr9ve/OolTiFfBC3buzWcERE6j9+KoPfO0wz1Lejt6Wj8UeVmk6 DYQdfcaOeBZDHMo8udiQnVEsjHs6zBd49nUN71sDIWKgC/d7IYlphHKfMpHML6GChAE3 /vjil2yH13/RjuDcoR+lEm0B/6ON9p/cfi8cDnLJpJuqVrUxVvefJYUpxNNZJc3Cnng3 UyXGd5UZNwt5mWSpTTM9OYxp1LR69CagGjhnalpM4Jt2QfXQ5xwIl9WuPyWz3hJoJ8L2 R02v4YbMKZUWmokr6OkeWv7hzE0plThj116r/p7+qhcUJnbOawQu2QeBXIQ3ec9q6aqv ibIQ== X-Forwarded-Encrypted: i=1; AJvYcCWmN2HqB+Tkt8qPDWqzRqtjflyKp704YJ+s8YPl6vfseVHgzeKg2FVQ0dCoL+RfcpALLyTbaqq8wCjovrk=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6FUIHVPr/8MyYaP+Ar/vh5L40Qtal3XZONi+91f0R3jAeX+Hf 1E+gd1iF78YHYxbURD6r0YBASSBq3Zzefvs3+ThLVPLl0fPvTAXAXJWYfAxs6EaIik8= X-Gm-Gg: AY/fxX4JKEAGslG2ZDpKej4RHaoJVDM2s8x/39aT56knws2u5siXe1GNQk5rdkY7C+R /Lnm8sW5ts68wEn9BFtmIH7MrM10IHRAZUc9zKNlLkKbpcFH8oxyKbqLP4o7Htkzvvb8uPB8VTA dyoREhv6a8W9MBE/3sNjW5WvTTlq0ZRJKw+AQQklPaNMx9RpP0GbXHgYNj0ZQUFMV/KSs7UkQ3n hxwcq9wXmsOwkpUsskqyDUwCXiM+7Di+0i0ZNGJbCRORszI5ffFfktOmI4nqAHCgaiQwPBes0s8 RBWSLQSPNkaY9Q2bFUpChMsPZvGWQ2WXomy0nhs4sCn01ZTAOCsqkYOGW1ysaVo/ys+E8Jl5erA 9mjXMmcsV5LIMTYoW1y6KuVdzDUJiPw9OWkpGJVEstiNpVjhfqaGs3NKKh+6tbSPDYz68T9gLiW BpeQRYQ+8BBthh8Sp6/3TqB4gOTUE7UY9VLDe/Feo4DxJ2/eykYTtGzUBjVdnV6F1INGyA6sC6b 5iKzw== X-Google-Smtp-Source: AGHT+IHJFbxTCCPlbZaE1ce0zdloaGm3osLlZXpUAJWMVhAaDt336Plvz1lZ7JLHkwiKjuhWNBymDQ== X-Received: by 2002:a17:907:984:b0:b73:54d8:7bc8 with SMTP id a640c23a62f3a-b8037284cc2mr2538444766b.59.1766837868261; Sat, 27 Dec 2025 04:17:48 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Dec 2025 04:17:47 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Sat, 27 Dec 2025 12:17:45 +0000 Subject: [PATCH 1/8] regulator: core: update two debug messages 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-1-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 1) In print_constraints_debug(), the power budget is printed as: lldo2: 450 <--> 1300 mV at 900 mV 2147483647 mW budge, enabled (note the missing t in budget). This is because there is a --count just below the call to scnprintf(), to make space for the comma. All similar calls to scnprintf() above add an extra space to the format string to allow for that, but this one doesn't, so the last character t is stripped instead. Update the format string to fix the message. 2) Add the name of the supply to the failure message printed when the supply can not be resolved when debug messages are enabled to help with debug. Signed-off-by: Andr=C3=A9 Draszik --- 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 4b6182cde859adb356d160a012e54dcf1646da38..a723bd00e1716c2c3899c63314c= 6249015698216 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1183,7 +1183,7 @@ static void print_constraints_debug(struct regulator_= dev *rdev) count +=3D scnprintf(buf + count, len - count, "standby "); =20 if (constraints->pw_budget_mW) - count +=3D scnprintf(buf + count, len - count, "%d mW budget", + count +=3D scnprintf(buf + count, len - count, "%d mW budget ", constraints->pw_budget_mW); =20 if (!count) @@ -5697,7 +5697,8 @@ static int regulator_register_resolve_supply(struct d= evice *dev, void *data) struct regulator_dev *rdev =3D dev_to_rdev(dev); =20 if (regulator_resolve_supply(rdev)) - rdev_dbg(rdev, "unable to resolve supply\n"); + rdev_dbg(rdev, "unable to resolve supply '%s'\n", + rdev->supply_name); =20 return 0; } --=20 2.52.0.351.gbe84eed79e-goog From nobody Sun Feb 8 13:16:46 2026 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) (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 87BC6312800 for ; Sat, 27 Dec 2025 12:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837938; cv=none; b=ivF7lpONLIMsdPOsFP0xnHoF+5vY2MRlLTrGf1l5ZIEz1yK6aLu61k/R0AIzVx3whP5QyDoUeKctKPde5qZt/u12pYjiCsZ+L7B1PLmQOnaCnAQnkMhOfv6lXPhajB+xc54nNBzdfYgm0qbbYKQKUI5cHE2+FjLiZpF6IMQvh6Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837938; c=relaxed/simple; bh=yOXA6IU92rs/sPMHoI+khftQph5Q3jgI9j+NUGdNLjQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cFOQaaLoGcv3OIcFc+6zhDYvctd6mQHOp4FoZwHraOki5azEmKKpVsGrB1e7Z8fc99w53ASm+AhwZpYl7i1mYOlJzpbEaieZlK9CI7q8GNj2kfGBP00UzWQss/ZSnltM5bjl2RDqakWeSp/5A3dkakKPKyuzZDQ+7tZo+32/B+M= 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=Ivg0H0dv; arc=none smtp.client-ip=209.85.208.47 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="Ivg0H0dv" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-64b9cb94ff5so9041828a12.2 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=OMJh7i2y//JuRngdUmq5ugjIn2B/PMBcQErV6SQUmlw=; b=Ivg0H0dvnBNHaIWJIYjQiKhkz2GnehOBf4GlYeTPJ11S6+HpHkt9s472huhHUxENVF qHR9xuNmIhz2m/PTYmfsnAgFBc+wBK4/snz9q+PC7NezKpqVr6JXoBAvt5AHKOGB1bVo Cf5uTh0UfAuNuAblJAYUQ8jNFQdm5PnjCHRieIxR8lfdMPLE6MFCDjHkotjOsKxpWhof vWlZ9yM3Tb2UjJapWpBCq+1fdXoV6gDQCUU1LyUVr9jEdS9ygn/4y+eoLj0muNyOXDz3 KsSGq8YyaeNwEBgnRVys734zNyk8QDnDCYjwMxT8/t/dx1mna8hszRljEkt3f/JrCTZM 3SJQ== 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=OMJh7i2y//JuRngdUmq5ugjIn2B/PMBcQErV6SQUmlw=; b=oh8nCDpS18pCP+HsuPr//bctcvWfyTv8JivTMzkci1mGsMOBPaXjY5QZy5XH7jT/Dy NekjwxHYfCw8mf4vTsNdylWLhbverkpKV1S1VJKhTOI0Ve1eGXcW1688FPwP5Lj+HYxp yCc1OiYTYgqtBPztKVGxnANJLRttCmeS/MMc3/EbalCZu0Ljizl26BRgCbTHyaNfyPYj T+ktwpH/loCVIYRu5WCbgBkcHom/Gv1jvgI2GXZ6L4mItHwZSstzskMTv7f/dSfPhJr4 EcvS8dPc0WAJ+qN19GRAX7y2iu0qfRePFH+Pj4ryHq3MekPp/+yzxtH+8+zEBAOtbICe 8+Yw== X-Forwarded-Encrypted: i=1; AJvYcCWHmyiwjM6/8Op3cytg5qcmthXGk6EXrOw7CPYyDLYLm7WtY0EzWL8iNb9hl0sxcQxIuozpr1s8TkKYBog=@vger.kernel.org X-Gm-Message-State: AOJu0YxSVz7LPRRK+rv7vPXjA0pQqBGQqEhRsuooBL5Tc5fA7QZWplgo oQnA6FTks1u4hWHHIZjViDEzlJWsutId6rX5SQLCDzsGV3s4D5/i4MmnFup9/QoobIU= X-Gm-Gg: AY/fxX4/ckJqxG1bN9x6D/orIhX5toJFwd3d9qli4iOCurK/Cj8MiEwgsCEMFIIpSYZ shx2Y1mqiGToLif2X/l6izKiU16jvRg9I4dYYbPcsC2oJ3YnjXs3qnrX9x+0i92WfXECAczQunC Y1yHtv83LpOxdfamHUJNYFyCuNGsk6jhLKz/X7vdi2ogcFPkobRDtIJol3REcSt2N5UZQZFvVD6 wMdUFD9EpqUpAObD0UtXV5N9u4RmsvMKmKcwnLyAGpwhzdTPyqCXmKEFBZjcEP4Osi+4o9LnOe8 wZ3LyM8W3Pxdr85vrarYjeOB7XksD0mNF05hZC9Yc1uu5VWgIwkCbCM/Jw6JnnNnYYJtJPDVw4W f/B+50QquOITyFknbukjXjR4kTzG8gUktF1lRTQO2c/geVL0vyz3FH+VMhMWsGthyLrzx83r2Nf /TFs4Uzio7G/628F52CsLWKb03uWVyGuzvA1wJ28DN2P70LCyhdLdazDFnE3AwC01MT9x0M3/l7 Ohz1g== X-Google-Smtp-Source: AGHT+IF0PlolWEbFwtEpPFUfU+LHipgZ1hi8LcRzdHZUBBAM0q/hEM3uPs6eHk1P0RLek8hz7wgFwA== X-Received: by 2002:a17:907:6ea4:b0:b80:f2e:6e1 with SMTP id a640c23a62f3a-b803722a7demr2716142566b.43.1766837868786; Sat, 27 Dec 2025 04:17:48 -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:48 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Sat, 27 Dec 2025 12:17:46 +0000 Subject: [PATCH 2/8] regulator: core: fix locking in regulator_resolve_supply() error path 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-2-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 If late enabling of a supply regulator fails in regulator_resolve_supply(), the code currently triggers a lockdep warning: WARNING: drivers/regulator/core.c:2649 at _regulator_put+0x80/0xa0, CPU= #6: kworker/u32:4/596 ... Call trace: _regulator_put+0x80/0xa0 (P) regulator_resolve_supply+0x7cc/0xbe0 regulator_register_resolve_supply+0x28/0xb8 as the regulator_list_mutex must be held when calling _regulator_put(). To solve this, simply switch to using regulator_put(). While at it, we should also make sure that no concurrent access happens to our rdev while we clear out the supply pointer. Add appropriate locking to ensure that. While the code in question will be removed altogether in a follow-up commit, I believe it is still beneficial to have this corrected before removal for future reference. Fixes: 36a1f1b6ddc6 ("regulator: core: Fix memory leak in regulator_resolve= _supply()") Fixes: 8e5356a73604 ("regulator: core: Clear the supply pointer if enabling= fails") Signed-off-by: Andr=C3=A9 Draszik --- drivers/regulator/core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a723bd00e1716c2c3899c63314c6249015698216..48c091de68d81e3e89eacecd852= 6255ab9a446b2 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2285,8 +2285,16 @@ static int regulator_resolve_supply(struct regulator= _dev *rdev) if (rdev->use_count) { ret =3D regulator_enable(rdev->supply); if (ret < 0) { - _regulator_put(rdev->supply); + struct regulator *supply; + + regulator_lock_two(rdev, rdev->supply->rdev, &ww_ctx); + + supply =3D rdev->supply; rdev->supply =3D NULL; + + regulator_unlock_two(rdev, supply->rdev, &ww_ctx); + + regulator_put(supply); goto out; } } --=20 2.52.0.351.gbe84eed79e-goog From nobody Sun Feb 8 13:16:46 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 From nobody Sun Feb 8 13:16:46 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 2AF6D314D19 for ; Sat, 27 Dec 2025 12:17:52 +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=1766837877; cv=none; b=N50+hkRWLt+QceMj/sO2swqlfs3f38X76vwx3Bvx82sCQqp2qBQwLLa5TKOiwgQesrTytQ68nLh09QMB2Ciy8gJ0UD+bRVsib3IUQ1U5f2i9geAGuwVQeP06V3l8tLIMhrCmWj4xRjUX6eobbx3rASB3dg6fwLmwrh6cX/2gqtE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837877; c=relaxed/simple; bh=flDp/n5fNdRNaijbrxj7fWKZJmSjLItwp7qfWjhxONg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UsUD/h7dNOFyf0NfY4Thfm+EbDbktqeA6S1NW5kVo+t7lV38qP5bcByiFcUdZZ56TaVXIPXXmP5ubSI4tDwQrkXG+QaFxMNrLvo2BiE9WHHUlzf4neRQRE6U+OEsp6MMUfSu9FsXj4sLe0+eW+19oGD7UDfKIOBDxotM82Dcx5g= 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=fpVrkTwc; 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="fpVrkTwc" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-b73161849e1so1522613866b.2 for ; Sat, 27 Dec 2025 04:17:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766837870; x=1767442670; 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=q/jZnK8nS4pEmw7rnsILBau4+awmUqMLUa+J8ILnmjg=; b=fpVrkTwcsMgye7pw2+lghQvkUmqeaVbqooh5TQJgX92jg0a9fBYWeB+Mv8uBmhQqNk hA2V7foT38TX8m60rQ9sGI74U5i0sjhFJjoY/oJHjqni/gir+CdBy70tOMxY19sl5tZy J6H2EBZZVB1RMi+c7GqvMiqQioMAW3E3G8xmkq7HSbhTai8Slr5Mjs+9oFRc6qPpEcE4 DefY4e9nSpnSf9Utc/d43e4Cpo9WKPqXKFrvrGJaFfVplHAUqUzqbobdyhpi8vhE0t6S MSw4HPLzCLTkDbADa97XydxreF95tSegrBZEWzlmJL5lejmKKx7ASf3DG802m88zTw01 s+Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766837870; x=1767442670; 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=q/jZnK8nS4pEmw7rnsILBau4+awmUqMLUa+J8ILnmjg=; b=BUjFwW3am1JrxPjk1ENPTILl724mmqzqdnwlwKJQNki/xFV6MGu5Fyu+EVeAmplzVg gLWYyMmmtHiVBj3l1zY3CKeEzRwbcXUN6o6foyJqn4w72y5enQkXIpuuCMeYKmzrWS67 Puv4cDWhpiZRt3dunChcmVWioxFsLuzOrJNg2lKw/GbRzqk7fXVXFRNrNxm0QQAAorEv hYea2rCoZmy7VHi60dkExJ2PPRtW/ja/FECp/P2tZ2870SxQf14eSySSzDZ7cDbbDmkS qDO8mn0sGAtdv9iRmoC86ANvAyHiy9rtR7kP9x8Zeexx6N7Yw9vFKCSwPN8WzYeTPHXz l+DQ== X-Forwarded-Encrypted: i=1; AJvYcCX/Wp8pz4mCpVee/D4vS4GHogmdh5YsllWEcx3xYBeySfCwDESvFXrpRsE74NhXZoiXhuax/OAUr/c/VWI=@vger.kernel.org X-Gm-Message-State: AOJu0YyZq7s13sz8Lm05aBBWmQ60kK80w0dkQkJv6DBkFjLrVdMRs3oT o9tjJkTa0jeo8ukGY9VBu8Z9L49VN3agmalWwhZ0PzHRnQ0TeCWBjmMFCOtzUV1a3yI= X-Gm-Gg: AY/fxX7adhD/UsGMJ8qJexdy/mID86rVybl7bOBGNqBYrDBBAuUFTcq4wzycYsRj0oM 2dj3BYZYy2uS2PfXyfteCTxQWSME8s79ePtsZqzReQeOruwL/O8W7K6Y6Sd03VejVR4Qy/Qa06w +E7M2shUxFm237daOCkEt7efXCYNgepykwiLlRNmKb8Z0Y3i/c+z/6Kjs89K9dx0+Co3wzsUYZ1 ka6XsOWANj1LKfDfP6XXw+PcL2ssJHc5qpF+cyz+3VeZUrMplEAxsNaXrSjAA1D/dwkikBF4EW7 2k9tD+jxtRRp1cXiVdEPtmrCVtvQYBw/XUJDbK3C5xFc8muA7iYt18G1Qk5/cbkZs3WFbgnEOoa 380LWq/6tMybGn1FX+B4n9O7EdTZkzw2hBFbxjkGpAK4xA1X2xdmA2MoV1TxgqfejAcrUpVWFSQ /EZSpdJPstIAOgzcdyo+DKA8x8l8eJXLNKzv0bCkqPLdvPzpRkdEcBU28s1VRGl7cbRFCyRergi T2VQg== X-Google-Smtp-Source: AGHT+IHSYPouoO0YSE7EVZLxcVrQOmYqxHDL1OxgSIqt/5HlkhrtWWxMKhDWlgt2J8VEaoTc4sStUQ== X-Received: by 2002:a17:907:d1c:b0:b79:f753:6910 with SMTP id a640c23a62f3a-b803705dbe2mr2913770266b.40.1766837869823; 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.49 (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:48 +0000 Subject: [PATCH 4/8] regulator: core: streamline supply resolution for always-on/boot-on regulators 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-4-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 For always-on and boot-on regulators, regulator_register() is currently trying to anticipate the requirement to resolve a supply early. Unfortunately, this code executes too early, before we have potentially updated the regulator's always_on constraint as part of set_machine_constraints(), causing it to miss cases. Rather than trying to hack it more, just defer to the outcome of set_machine_constraints(). The latter returns early (without doing any regulator initialisation) with -EPROBE_DEFER as of commit 'regulator: core: move supply check earlier in set_machine_constraints()' and is therefore safe to call multiple times to determine if supplies need to be resolved early. Commit 8a866d527ac0 ("regulator: core: Resolve supply name earlier to prevent double-init") (later updated by commit 520fb178212d ("regulator: core: Fix regulator supply registration with sysfs")) added these tests originally to avoid calling set_machine_constraints() multiple times to try to avoid voltage glitches due to all the regulator initialisation happening each time. This isn't an issue anymore as per above. Signed-off-by: Andr=C3=A9 Draszik --- drivers/regulator/core.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 9ce0eef1dcfcb39a072675e44a5577ae85d51982..08bdb1e4175e6d47d154e7a2d85= 9a9d39dcfd021 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -5937,7 +5937,6 @@ regulator_register(struct device *dev, bool dangling_cfg_gpiod =3D false; bool dangling_of_gpiod =3D false; int ret, i; - bool resolved_early =3D false; =20 if (cfg =3D=3D NULL) return ERR_PTR(-EINVAL); @@ -6075,17 +6074,6 @@ regulator_register(struct device *dev, goto wash; } =20 - if ((rdev->supply_name && !rdev->supply) && - (rdev->constraints->always_on || - rdev->constraints->boot_on)) { - ret =3D regulator_resolve_supply(rdev); - if (ret) - rdev_dbg(rdev, "unable to resolve supply early: %pe\n", - ERR_PTR(ret)); - - resolved_early =3D true; - } - if (config->ena_gpiod) { ret =3D regulator_ena_gpio_request(rdev, config); if (ret !=3D 0) { @@ -6099,9 +6087,10 @@ regulator_register(struct device *dev, } =20 ret =3D set_machine_constraints(rdev); - if (ret =3D=3D -EPROBE_DEFER && !resolved_early) { - /* Regulator might be in bypass mode and so needs its supply - * to set the constraints + if (ret =3D=3D -EPROBE_DEFER) { + /* Regulator might be in bypass mode or an always-on or boot-on + * regulator and so needs its supply to set the constraints or + * for enable. */ /* FIXME: this currently triggers a chicken-and-egg problem * when creating -SUPPLY symlink in sysfs to a regulator --=20 2.52.0.351.gbe84eed79e-goog From nobody Sun Feb 8 13:16:46 2026 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 28161315D32 for ; Sat, 27 Dec 2025 12:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837878; cv=none; b=h7FdncrpKGGJ0jqtb1UYP2JRaKyG6xRHGZHLGiYBeqgizZIHlaY8Yc0rkto2BPWuk0c7KIlCHyVQPtMZxTkuwG513+dNs9UZwM9DwXckQnabOUBxDeiseqcwt4xY6uxUAM+wN7L4Wr8jlC8zOD73xEO+gKP/70YVN0KIJ8TcJ7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837878; c=relaxed/simple; bh=nquanBULeO6xKzKO4nj8Ei9OarW51quNRhICQgnB8BA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JE8S9p6oqYYzXA5j93XxML4/aRcdOS4zmKTf4hVoB8sKdWvbYRVatbZBdAuZ1ynazDSK1Or8s7DHUe7DeXV7LCuvvovdsIpLblTHNsW1jDzReEvGv+roUhMb3Yu1sPCuLjsq3JoGI0CN25pA/IjQr+sWSZjgjc2ZN2hG5RB0AdY= 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=y4VZyGmt; arc=none smtp.client-ip=209.85.218.54 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="y4VZyGmt" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-b804646c718so776056166b.2 for ; Sat, 27 Dec 2025 04:17:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766837870; x=1767442670; 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=9RDG90BShY04pEbW8nv19ek68fiClLIBjgI2NCpLlGA=; b=y4VZyGmt0MJfFaNEO6u7vtd+wqd1bv16Bd8LqppUCIoD3U/gbFgw82QUsDIknMqCpA Gg46/kGtcr7KJfBO6nPBe8MEWc9iNhXenVx3hWaMQcHw/hZSMusLDNRqwpUNHNRkk9z3 hVSS4qO43umePAAIBUycZ01y8NSsQkbOlqG2iPm60UDmyikWedGqDBbcdvAU/e7q0yC3 EMDnLhtKre4jpYyeDgftKBDH2LTn5490+7j6Rr5LzZOSrWDdz9Mn7XECwYiUrB38vT25 e1AKpWxD5f9lir93sDlVBd6G6EBvef0pJqcY9lptyBPYIPhSdebOL1qqo7LX+4tXXUL0 Mu0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766837870; x=1767442670; 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=9RDG90BShY04pEbW8nv19ek68fiClLIBjgI2NCpLlGA=; b=e1CngOF0vg2SAmQPvZluOd4ylZuUhT1VczzbR/efpn8AkodaU9klxhAjvWwWIy3yga R1DlwHvQLaVpOM4BJzPdSDCQm4DfFis2IScsJomQjAssRYDAWGFYcs+A4N23tE6uvkkI Xc4PVMyCD3Jj41TDA362O/esg3gcUI47Pw11quHwmV8GK16e5dRX04p5e/ZskYCre3gN vWEWjr4B1C1ZsRrjZyUsWAdXw9y4B6UUoOJMBJYWqiKZmfSlx3CT4kMGE/BNKlgO+Yqi gWuI/aWqLP//wm054bmOZ4AfSztTnnf5JHNOHl65p6bK9k/vEoJ49lMolto8dtW49rEP jcPA== X-Forwarded-Encrypted: i=1; AJvYcCWVYQsyPdB1RjaOoy5jJDu0ef/K5DLneAEArx14aGANnX3wtpUDGwFbQ8qeM57QTmvwPuOxXwVA/MZykCA=@vger.kernel.org X-Gm-Message-State: AOJu0YzyuwMSXAL+/V1+/q4pAr74iaiAgC1ecKwDwia3wCbyPi4WhVKP F9UAN9Z1VErqwksVUfdIOFGZIdNTwhN0WyhDpijXOLKE0lJs0Ml6izl2T3MVqYQ4yAA= X-Gm-Gg: AY/fxX6DISexwIQ9Tmz3SV44BPKwH2r2ynRrTn98QWWR3RtTEiAsujJsAWhCOg+klCN NNR4S69vCyjURv4MmOevAXNegBDleDjkyyEXzZLl/OWCW135T+GXpbBZIkifWB+FBhY5um5tpk7 ECQ219qfS84X3p66fjxzkFwanfVbn+T4R2FFOKjQ0HoYjl+lJDZgygQiSTqflm326wekSgYOLqb MMKfmQnjLJoy+TmWr3EMvB78cGPwBwxBxKMmbsEJ/b+Bn30aB9exeYsPchrIaaYzAP6D6FM//BC DnJT2ObVnfOSDXtJlaonwK8K1TQ7PGPDTx0iYFCfpJIlilqtDeAM8/XVjjCe4cdxXxDqXo9KLIR MXqvnzItwFrU88LmrqGDyJ/FuuSKQZPIzyQR7e4rJpk2SiRymFUJs3wLAGAWxOX1Jib2YXOY+iL sss6HBwPMnDmU7OyLZwHLm3h/9jdPS0hqvJFPBgE/TL/VeZbF0onLXPzEo8VXsm6HicxxJ8Ot+G 83rFw== X-Google-Smtp-Source: AGHT+IGQecDueUGZfL4ZM1NVtq0XX5KhDj8pci1KCpMzItV2EblvTpK929IOxznTat07v80WgMrikA== X-Received: by 2002:a17:907:6d0e:b0:b72:d8da:7aac with SMTP id a640c23a62f3a-b80371f10e6mr2820658966b.56.1766837870300; Sat, 27 Dec 2025 04:17:50 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Dec 2025 04:17:50 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Sat, 27 Dec 2025 12:17:49 +0000 Subject: [PATCH 5/8] regulator: core: remove dead code in regulator_resolve_supply() 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-5-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") we require that a regulator's supply has been resolved before enabling the regulator. Furthermore, regulator_get() also fails if the supply hasn't been resolved yet (preventing consumers from enabling a regulator without its supply known). In combination this means that regulator_resolve_supply() now always runs before the regulator has been enabled via set_machine_constraints(). The code here was meant to run after enabling the regulator in case the supply hadn't been resolved at that time and can therefore never execute anymore since that commit. Remove it. No functional change intended. Fixes: 98e48cd9283d ("regulator: core: resolve supply for boot-on/always-on= regulators") Signed-off-by: Andr=C3=A9 Draszik --- drivers/regulator/core.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 08bdb1e4175e6d47d154e7a2d859a9d39dcfd021..fd8da369c0529da12d6e80d9003= 2e07bed414316 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2282,28 +2282,6 @@ static int regulator_resolve_supply(struct regulator= _dev *rdev) /* rdev->supply was created in set_supply() */ link_and_create_debugfs(rdev->supply, r, &rdev->dev); =20 - /* - * In set_machine_constraints() we may have turned this regulator on - * but we couldn't propagate to the supply if it hadn't been resolved - * yet. Do it now. - */ - if (rdev->use_count) { - ret =3D regulator_enable(rdev->supply); - if (ret < 0) { - struct regulator *supply; - - regulator_lock_two(rdev, rdev->supply->rdev, &ww_ctx); - - supply =3D rdev->supply; - rdev->supply =3D NULL; - - regulator_unlock_two(rdev, supply->rdev, &ww_ctx); - - regulator_put(supply); - goto out; - } - } - out: return ret; } --=20 2.52.0.351.gbe84eed79e-goog From nobody Sun Feb 8 13:16:46 2026 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (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 2A39F3148C3 for ; Sat, 27 Dec 2025 12:17:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837877; cv=none; b=ErSMpKCdZ3AG18R+1i8MbjorzmZgBLH7JugHZkR74lhcRtQuJ8OT+XiWTtidCK+xkGIktU+olsnbTPgyYwW9a7Zj98MbMijcyZqp2sSDKa1AMhYhFsomhCnsiB9OSfoE76Lq82WIlGoBTlGHt5B0JYvXm8oTnMRwcQPVtsxdmnM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837877; c=relaxed/simple; bh=g7vjWoXnb2wErw2pXGilOcZRY2UtJd0VKIpjLqQ0jFk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fjyn16EWxSnmHM7gOOkeCuY4LTs2qe5QrV8VutWggHjxMJxPyi+TjVGQmTeyyt57oiCpfwxYRftlzxmjmYSuo0baciFUA4FKWKEsfq39+CV6UcqMPjJ/gAjhz927qy7QTKy4QziXKVVotOwMEhaUFWhz30EX9OmJjTdSgz9sXKo= 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=ct9C0Oel; arc=none smtp.client-ip=209.85.208.42 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="ct9C0Oel" Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-64d2c50f0d6so8160807a12.3 for ; Sat, 27 Dec 2025 04:17:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766837871; x=1767442671; 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=dH+IcWZ7Hp5DOdrxmSeMrUXVZaD5ihy5s0VkQhp0qtQ=; b=ct9C0OelMHhH4Uc+ZkVBmpNsSP6WKJ9bGdrr5V8z5EXW6zEF6FQktwjqgTPYY+IU+0 S/bMIABkoY/jt0aVaQXGlykqlDvAwMl1+Qdsvo9o20pTvnzkuIbieKBhKAtSz9H9n85Q w8O0FJVVyb/MQJYdscVZk3lq/qz5ZhV9qwy/KoqlPd6sl1dcisYbW0tzCzc2gAtyAa6/ 9n7oNuJykNQvBSDAP7T4lsabPV6ere/4+3NllcfYavGySGFHQl0Z8G3gmZVEtNzsT+Q+ 8Jhwup9Y81mqaRGMjNUNRzboZkr8azyaufHHOpJFtjs9gW26mZVLbYbCaBTZYsvd8UIg UwPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766837871; x=1767442671; 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=dH+IcWZ7Hp5DOdrxmSeMrUXVZaD5ihy5s0VkQhp0qtQ=; b=HvZmC8Ys6PJnvkAeLIRCQ9gqWf8Vb3aegvloSr/q3iUibNtGUKbAuVRcZk/CGtX0CO DbC4ccT6eGZJvveDaPDCw4IREPwe/yHk5wCENV0gRGMlJMhX7u97kXs7+r91EgnmIVv9 0J172P7B4EMeO+DpTirNxpXU4hH/0qFkgyJbxXDozgHm5y9IPCyn1eASu/TARN8aZbCB xpV+A1l14CI0ddHYtdd2d6Nn+y0uqejX7N9Wsu8zU1zt0A4+2tLvyumCo80fRqLASX3M jI34xbBU/EknJEKF2fYrsb3eUJItistp8o0z3rO091OYYFUmPB9wcWtSiaertJnI3HSd O9WA== X-Forwarded-Encrypted: i=1; AJvYcCXONPubuuiVg+8rAsQH4BPk38yqy0FlZrsm4+EStksh/Ye19htmIv1t65O/qEsti2IbUPYen4SqahwGuYw=@vger.kernel.org X-Gm-Message-State: AOJu0YyNi6UfyYmr5gzELAjyhagm3xBhL8x4f+JSpwkiPCKQfBBlQYqy yJspjSc/Kf3Zseh0jiT8zL7OlS7F1iQyEPk5/mrmLCyuzKhdlNBXPyvovmVlKoT8yoA= X-Gm-Gg: AY/fxX7JxGZcB6p+d3Z8CMTAkpOpEX3Qqd0JRiXl2qFWZkO5quNkSBKmw3LmaTr1Kch HxHtHs79E4TN4Z2kuCPWcELsM0kHUIAlsnhtwlNlrpv33jh2ouX1loCMo1+/A6dMh2t7RD3treg FpTOdwkZoaNcRrNfGX0ngeJVJCOJZKdrdifv0YE+5qSih0RJhXhUR7p/l6GMg5Xy8WgEKHa905+ suDlKkzzwyqL/Bdu+yOKE0u6PyqY1ALsk4ExmwLYbJedOp6Gbb+6AxstJuBRZn4RLQNQTQztVdR vBmZRJLpWbooAXxTSURqv8gWM7ImuD+DESUHkp6WOUECBSLjQ09xnsftYFctVknRKR6I8LBJVKB KWgEtvL04heB8qMcy4XEcTm2aHmEmelobMXTavsDbPDeuXdJnVVGIY8gTRxYMMei7UOBwdpbIov +qJe0n103Oi6Fq3EgcZQXX/sopsp07NgC+mNLbJjBh8fIBeY3fuT8xVgdFSoYT5ALm21IXL7mBn 4boKQ== X-Google-Smtp-Source: AGHT+IFxLJhySmbzqKKN5f1k19NMRw4YAMo+p1rLarzbgXU+B3E+eTFXBDwdWc9HEfREHc0Gj6WpaQ== X-Received: by 2002:a17:907:8686:b0:b7c:e5d6:2462 with SMTP id a640c23a62f3a-b8036f60923mr2824273066b.28.1766837870771; Sat, 27 Dec 2025 04:17:50 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Dec 2025 04:17:50 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Sat, 27 Dec 2025 12:17:50 +0000 Subject: [PATCH 6/8] regulator: core: don't ignore errors from event forwarding setup 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-6-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 Receiving and forwarding critical supply events seems like they're important information and we shouldn't ignore errors occurring during registration for such events. With this change the supply is unset on event registration failure, allowing us to potentially retry another time. Fixes: 433e294c3c5b ("regulator: core: forward undervoltage events downstre= am by default") Signed-off-by: Andr=C3=A9 Draszik --- drivers/regulator/core.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index fd8da369c0529da12d6e80d90032e07bed414316..86dbee3ffda0b950619db8b52d6= c6eab8be31a53 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2273,10 +2273,21 @@ static int regulator_resolve_supply(struct regulato= r_dev *rdev) * under-voltage. */ ret =3D register_regulator_event_forwarding(rdev); - if (ret < 0) + if (ret < 0) { + struct regulator *supply; + rdev_warn(rdev, "Failed to register event forwarding: %pe\n", ERR_PTR(ret)); =20 + supply =3D rdev->supply; + rdev->supply =3D NULL; + + regulator_unlock_two(rdev, supply->rdev, &ww_ctx); + + regulator_put(supply); + goto out; + } + regulator_unlock_two(rdev, r, &ww_ctx); =20 /* rdev->supply was created in set_supply() */ --=20 2.52.0.351.gbe84eed79e-goog From nobody Sun Feb 8 13:16:46 2026 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (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 CB81631280C for ; Sat, 27 Dec 2025 12:17:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837880; cv=none; b=RKJE5oyjS5Loh7M+XRFuLZMuR6G6g45f2ciNHN6APJXN3NNK/1UdLsj0dpGqpupOBRs/wPDQkeqEqq5u8a06g+6fERg/d7LqXPh33/EZOIAgGwfuuGjhCqrzpztps6QwEyt1eD1ZjHk79cja3gSbDdqOjGeA/XD5z4Hl2BWymmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837880; c=relaxed/simple; bh=DTt6cIAe+OUCl4SozH/frfTEZ8TJ3BMCApzCKcJiowQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I9HD4cZFCCo5OuDx3bAxNdo6DOWR0ya3woj63xmFgFKE0YmzWsoPe/H1rNKl7iL8dduypxYX1YXozki5tIOSmp2uajtsd93NhSOVTLjj9MMe0gWM2oaNsgn324vLbH3bSgH/uMm5E3aH6XZEmrA2tW8sITJVAyNO1rmqVIaVRc0= 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=aN6vb0+F; arc=none smtp.client-ip=209.85.218.50 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="aN6vb0+F" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-b7cee045187so1396997566b.0 for ; Sat, 27 Dec 2025 04:17:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766837871; x=1767442671; 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=wYPevBhP4Z7tB1bUOGzVebYfDjp810+7VQSE4xcnspw=; b=aN6vb0+FG5UHIvztCHIGnxln6NrnTeRJNj4W1jhCoSG3sAhRGNK6uSffCA7qQbReLO rDsoGAU6TCjDTQ+PrdaazPFLt2eFZ6EgkIAOMUux0f8YgdR6/ktloKgnTr6lH5Bl5GNk YviRktCLcEHxa67J1vCMCY4aW2iBmbglCyvrLxP0Qr/Ogxx3CYLyyayt90b8IkrfqOZV 9PQlwm/ljCqwu6S319XgBSQy9Q040BX0cp080yBJmMEktduXO3SFEu0mCpLZGWjwnBpu zXsXGrlYN1iFs4iiRt1jrlG1GBbxf4aSi3bV75erEX7ArRC78WclTubPTA7Yc0lAmO1O VD4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766837871; x=1767442671; 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=wYPevBhP4Z7tB1bUOGzVebYfDjp810+7VQSE4xcnspw=; b=HoPBzBK7cdOvzAcdRR+5hQ06W7iG7JSGs4WkJ3Xt//sS8Mxle78pTKQdhyNPZ+3dqN SR4sIDreStvLsrSpthhwCj261cItEy15O6QAF4/h5g1liPAC2MMEd5Xb3P149fw5vdON uL32mVcpiNFzKPayX/BR4LCVV8HlNUIabEbNdD0sFm7XwvTK855FCvmu9xG9jZddFnlO 8rreflvbs0MGUBzrNcgEA3K1cT6vriOIRlLdJRDLdJ5Q/W9XD5NJx1PeTLTJqCPJxGqv kx0mqnULDLtXlIWG0iTsC/eaTA4VwhfyeAgaDBTFHJM5OlExLukYjRkAhYzd4H9Mcagk BcTw== X-Forwarded-Encrypted: i=1; AJvYcCUpGJ7iTlZlHPvn8yuUmBB6oNLwMHfrpPCT/xEEYFOnhzGmPug7VFxq+aCdDCspPJAjv8eZeVpgUPUEUe0=@vger.kernel.org X-Gm-Message-State: AOJu0YzNbtKK3VO0Ho2I5mrV1ZWVl3L/HNSNHdrXsu7mzb/UUZBhAEAP IRwOnt1OPAWuN6W110ggwS5UmFm1rVFHy1aUhbxg27MvMhujmbQKebdNo1xOj2NfGmw= X-Gm-Gg: AY/fxX4Zv6ZtXs8CMBelKlQ5msAjEfZYqayTKHSp2vdM3YXRfagmtemPVfxVCMxRvap j/qSQTH8lql3hvLdTvbCRysr1Uez9MD8LqJrciZGn5NvsIhaKc5qcyMd0l4k1eLnqEVI7wWO9VI scvprbrQ1T6rcBMjzVA6zQnlnhjocNR/DQ8Nu2YuB0IdQMxQeQvarmprixTjxaYQv1PoiKKhhph 6EIKm3xJof2tob3tAb1w78O7xGQJV2BbFx0Y7y2Fg08hV+MRGtXOFjpxhQPrmhSNuMwCc5iu4+z JkME1o34XuhTILZdBqRK35aPuR8EThBrTeSg8ccGXsj9o4Ik258SEqSguTjEflHBy8RVn+gWhH5 /tMGsZWhvD4D4aVEhWaGyVxB2K1j0yGLEpYjeFr0uizRLkybHz5IAZZQxjy3GYey8hjsb67a9/T HSuCGIAxJw55MSVc4Tx14rhoZGKff/v6DHuS/lLIBRdA9y3uX8BeNnmk2D+05zM7ouv/ILZj3cG JnCQA== X-Google-Smtp-Source: AGHT+IHExlt4c5QXm/HrLuZhwkcKc6ZSYj+mnHkWL3FZeW4sD9O68OjZVkvLZwzWmYDCYzs6y4uDwg== X-Received: by 2002:a17:907:97d4:b0:b80:344b:421a with SMTP id a640c23a62f3a-b8035743e21mr3170118866b.18.1766837871265; Sat, 27 Dec 2025 04:17:51 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Dec 2025 04:17:50 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Sat, 27 Dec 2025 12:17:51 +0000 Subject: [PATCH 7/8] regulator: core: reresolve unresolved supplies when available 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-7-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 When a regulator A and its supply B are provided by different devices, the driver implementing B might be last to probe (with A still pending resolution of its supply B). While we try to resolve all pending supplies for all regulators (including A) during regulator_register() of B via regulator_register_resolve_supply(), Supply resolution will still not work for A as the driver for B hasn't finished binding to the PMIC device corresponding to B at that stage yet. The regulator core explicitly only allows supplies from other devices to be used once the relevant driver has fully bound, mainly to avoid having to deal with cases where B itself might -EPROBE_DEFER. In this case, A's supply will only be resolved as part of the core's regulator_init_complete_work_function(), which currently is scheduled to run after 30s. This was added as a work-around in commit 3827b64dba27 ("regulator: core: Resolve supplies before disabling unused regulators") to cover this situation. There are two problems with that approach: * it potentially runs long after all our consumers have probed * an upcoming change will allow regulator_register() to complete successfully even when required supplies (e.g. due to always-on or boot-on) are missing at register time, deferring full configuration of the regulator (and usability by consumers, i.e. usually consumer probe) until the supply becomes available. Resolving supplies in the late work func can therefore make it impossible for consumers to probe at all, as the driver core will not know to reprobe consumers when supplies have resolved. We could schedule an earlier work to try to resolve supplies sooner, but that'd be racy as consumers of A might try to probe before A's supply gets fully resolved via this extra work. Instead, add a very simple regulator bus and add a dummy device with a corresponding driver to it for each regulator that is missing its supply during regulator_register(). This way, the driver core will call our bus' probe whenever a new (regulator) device was successfully bound, allowing us to retry resolving the supply during (our bus) probe and to bind this dummy device if successful. In turn this means the driver core will see a newly bound device and retry probing of all pending consumers, if any. With that in place, we can avoid walking the full list of all known regulators to try resolve missing supplies during regulator_register(), as the driver core will invoke the bus probe for regulators that are still pending their supplies. We can also drop the code trying to resolve supplies one last time before unused regulators get disabled, as all supplies should have resolved at that point in time, and if they haven't then there's no point in trying again, as the outcome won't change. Note: We can not reuse the existing struct device created for each rail, as a device can not be part of a class and a bus simultaneously. Signed-off-by: Andr=C3=A9 Draszik --- drivers/regulator/core.c | 121 +++++++++++++++++++++++++++++++----= ---- include/linux/regulator/driver.h | 1 + 2 files changed, 98 insertions(+), 24 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 86dbee3ffda0b950619db8b52d6c6eab8be31a53..08e92b1ba2dc2ff9efdabaa1618= 7a4a38cf66fb2 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -44,6 +44,8 @@ static LIST_HEAD(regulator_supply_alias_list); static LIST_HEAD(regulator_coupler_list); static bool has_full_constraints; =20 +static const struct bus_type regulator_bus; + static struct dentry *debugfs_root; =20 /* @@ -5694,17 +5696,6 @@ static void rdev_init_debugfs(struct regulator_dev *= rdev) &rdev->bypass_count); } =20 -static int regulator_register_resolve_supply(struct device *dev, void *dat= a) -{ - struct regulator_dev *rdev =3D dev_to_rdev(dev); - - if (regulator_resolve_supply(rdev)) - rdev_dbg(rdev, "unable to resolve supply '%s'\n", - rdev->supply_name); - - return 0; -} - int regulator_coupler_register(struct regulator_coupler *coupler) { mutex_lock(®ulator_list_mutex); @@ -5923,6 +5914,7 @@ regulator_register(struct device *dev, struct regulator_config *config =3D NULL; static atomic_t regulator_no =3D ATOMIC_INIT(-1); struct regulator_dev *rdev; + bool tried_supply_resolve =3D false; bool dangling_cfg_gpiod =3D false; bool dangling_of_gpiod =3D false; int ret, i; @@ -6093,6 +6085,7 @@ regulator_register(struct device *dev, else rdev_dbg(rdev, "unable to resolve supply early: %pe\n", ERR_PTR(ret)); + tried_supply_resolve =3D true; } if (ret < 0) goto wash; @@ -6124,6 +6117,37 @@ regulator_register(struct device *dev, if (ret !=3D 0) goto unset_supplies; =20 + if (!tried_supply_resolve) { + /* + * As an optimisation, try to resolve our supply (if any) now to + * avoid adding the bus device. Errors are not fatal at this + * stage, we'll simply try again later. + */ + ret =3D regulator_resolve_supply(rdev); + if (ret) + rdev_dbg(rdev, + "unable to resolve supply (ignoring): %pe\n", + ERR_PTR(ret)); + } + + /* + * If we have a supply but couldn't resolve it yet, register a device + * with our bus, so that the bus probe gets called whenever any new + * driver binds, allowing us to retry matching supplies and which then + * triggers (re)probe of consumers if successful. + */ + if (rdev->supply_name && !rdev->supply) { + device_initialize(&rdev->bdev); + rdev->bdev.bus =3D ®ulator_bus; + rdev->bdev.parent =3D &rdev->dev; + device_set_pm_not_required(&rdev->dev); + dev_set_name(&rdev->bdev, "%s.bdev", dev_name(&rdev->dev)); + + ret =3D device_add(&rdev->bdev); + if (ret) + goto del_cdev_and_bdev; + } + rdev_init_debugfs(rdev); =20 /* try to resolve regulators coupling since a new one was registered */ @@ -6131,12 +6155,13 @@ regulator_register(struct device *dev, regulator_resolve_coupling(rdev); mutex_unlock(®ulator_list_mutex); =20 - /* try to resolve regulators supply since a new one was registered */ - class_for_each_device(®ulator_class, NULL, NULL, - regulator_register_resolve_supply); kfree(config); return rdev; =20 +del_cdev_and_bdev: + if (rdev->bdev.bus =3D=3D ®ulator_bus) + put_device(&rdev->bdev); + device_del(&rdev->dev); unset_supplies: mutex_lock(®ulator_list_mutex); unset_regulator_supplies(rdev); @@ -6189,6 +6214,9 @@ void regulator_unregister(struct regulator_dev *rdev) unset_regulator_supplies(rdev); list_del(&rdev->list); regulator_ena_gpio_free(rdev); + if (rdev->bdev.bus =3D=3D ®ulator_bus) + /* only if the device was added in the first place */ + device_unregister(&rdev->bdev); device_unregister(&rdev->dev); =20 mutex_unlock(®ulator_list_mutex); @@ -6269,6 +6297,45 @@ const struct class regulator_class =3D { .pm =3D ®ulator_pm_ops, #endif }; + +#define bdev_to_rdev(__bdev) container_of_const(__bdev, struct regulator_d= ev, bdev) + +static int regulator_bus_match(struct device *bdev, + const struct device_driver *drv) +{ + /* Match always succeeds, we only have one driver */ + return 1; +} + +static int regulator_bus_probe(struct device *bdev) +{ + struct regulator_dev *rdev =3D bdev_to_rdev(bdev); + int ret; + + ret =3D regulator_resolve_supply(rdev); + if (ret) + rdev_dbg(rdev, + "unable to resolve supply or constraints '%s': %pe\n", + rdev->supply_name, ERR_PTR(ret)); + else + rdev_dbg(rdev, "resolved supply '%s'\n", rdev->supply_name); + + return ret; +} + +static const struct bus_type regulator_bus =3D { + .name =3D "regulator", + .match =3D regulator_bus_match, + .probe =3D regulator_bus_probe, +}; + +static struct device_driver regulator_bus_driver =3D { + .name =3D "regulator-bus-drv", + .bus =3D ®ulator_bus, + .suppress_bind_attrs =3D true, + .probe_type =3D PROBE_PREFER_ASYNCHRONOUS, +}; + /** * regulator_has_full_constraints - the system has fully specified constra= ints * @@ -6602,7 +6669,17 @@ static int __init regulator_init(void) { int ret; =20 + ret =3D bus_register(®ulator_bus); + if (ret) + return ret; + ret =3D class_register(®ulator_class); + if (ret) + goto err_class; + + ret =3D driver_register(®ulator_bus_driver); + if (ret) + goto err_driver; =20 debugfs_root =3D debugfs_create_dir("regulator", NULL); if (IS_ERR(debugfs_root)) @@ -6619,6 +6696,12 @@ static int __init regulator_init(void) =20 regulator_coupler_register(&generic_regulator_coupler); =20 + return 0; + +err_driver: + class_unregister(®ulator_class); +err_class: + bus_unregister(®ulator_bus); return ret; } =20 @@ -6679,16 +6762,6 @@ __setup("regulator_ignore_unused", regulator_ignore_= unused_setup); =20 static void regulator_init_complete_work_function(struct work_struct *work) { - /* - * Regulators may had failed to resolve their input supplies - * when were registered, either because the input supply was - * not registered yet or because its parent device was not - * bound yet. So attempt to resolve the input supplies for - * pending regulators before trying to disable unused ones. - */ - class_for_each_device(®ulator_class, NULL, NULL, - regulator_register_resolve_supply); - /* * For debugging purposes, it may be useful to prevent unused * regulators from being disabled. diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/dri= ver.h index 978cf593b6624228fe1fd9c2a3e186b53ef172f8..d38353f2b56f8bbab865d903ad0= ec97ca0b5c834 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -635,6 +635,7 @@ struct regulator_dev { int ref_cnt; struct module *owner; struct device dev; + struct device bdev; struct regulation_constraints *constraints; struct regulator *supply; /* for tree */ const char *supply_name; --=20 2.52.0.351.gbe84eed79e-goog From nobody Sun Feb 8 13:16:46 2026 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 4C26731619A for ; Sat, 27 Dec 2025 12:17:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837886; cv=none; b=PTgb9LFzTwod1Jd8OYAGNixXMJzmifZ7UGQyPNsB31Svli6IECbtyz8UH1FaINZ4FF7Cbl41XnC7li4kTD+O/Rp/OppJV9sJ2Jb4Mcc6Fr4dMrEgSgk6QSQDOQQ5R8zlzCbzC48nUAgL74TGUUjor93w678Kj3kqHlMBKLYFEVM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766837886; c=relaxed/simple; bh=+wEqtGb1mT5TBazth4wWosQDATUcEUvo7aZ1Vrf3o+4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N2qsQMJkRwL63gdCF+8ZXjGb3dskJYhiBQdnMF6d+2RWOSvDy5et3IlrUtfL1xrnXTDWXmr8IoHlzdivTFz9OPnMhhaykUwVApzjarNEynOVMhXHBLYWZkGs5CAhBZ/9NRjI5TSh7KO+MwN/WwdayDlT9kj6IjK06UMZRExrCIU= 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=vvQVQtTv; arc=none smtp.client-ip=209.85.208.53 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="vvQVQtTv" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-64b921d9e67so10840367a12.3 for ; Sat, 27 Dec 2025 04:17:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1766837876; x=1767442676; 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=f6eq2tvfa3ZOSLXibtVic90tZ1iImogx/6bP2FWF+Uw=; b=vvQVQtTvcp6G9i3D3p2qfslRswljvvceRYOkkWtEW6xizGINPS0+UtzedRB66uobVp D1DSoWJb8tsWQe+sFM7SmLRDOpw3Hn3KGChkJfH74XRKCrkNNUVRsohzP7s3AAQNqJZe d6VexucK4/E+KnPqQjbi/EEm21xsORhxpA98rhifFSzcKfkTjqDXwO+E/fNkYwb3LFUU JZsbHl0bnV7sgyfBpRh5frrJIdXKl+ef3M25plaulFCIpu4pwC7meiDMsXqv/8uGpsVq E7ffO0/Oi9zYkzJZDC6QpFsiw96MxJ6hduVp8UvatcYlMfZSmaERtHetYYnrcvGZnDae +slw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766837876; x=1767442676; 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=f6eq2tvfa3ZOSLXibtVic90tZ1iImogx/6bP2FWF+Uw=; b=XQT78KhUU43qe5m+RU8JDGZC1Y+3Z95HkVrxvY0D/QzCNCI0ImgK7e5aL7EUOuORzV cgbrD1PdD/WE4EpmxxyEZUXM4K+OXBadtlbQes03nn7x6Q21pVE5/bWhckR99o5E3PZw qs9CjuuQsA322mc8wB4PAQBPzhkuoOtLrQASclhVjHrlExuBybC7pEDTn4Go50mz34hf HAd4wjkZm4xDn71YGmRhox8VsFZbjY3rJxXDL0Stg7NEYGusalHfonpwmg5XnxwaoEkb v1LZIvjwown3F4PPfrAH7gdbYsFdsprEXtBqXP+zTnz2IDx+f4RDc1mi+P55SBFbzxlO iMkg== X-Forwarded-Encrypted: i=1; AJvYcCV6SkPa1RFeRjfDTGcIehxd3fDfih/4fkBhWrhgmdKNhyWM50a59sXLRjRRGWNNvGWOq4Z22V+5QIfNfH0=@vger.kernel.org X-Gm-Message-State: AOJu0YxONa8MFQOS7V1sHFGyk9pBk1orivzFH4v8MS20goxjZnwjClo7 qTYVjcjm4eGjuWShPW1HG9EzO3dmg+dkQw/wphzXzS+auug9EIjnM7jGvlQkYmFFsuw= X-Gm-Gg: AY/fxX42X9Exy8yr0IxyAcxreEBpbSUMGziFVi1rLAkmurNM0xIrwCiTNBkdZ/EahgH JSquTXa0dLHh8g2+++LydIyZxfh4BuDsF1au7qnx+hPgQiehiAdeJHXPDDy34xXxBeDiCcNR0lO P64kRFjGle5kCCiuJ7m003OwOsZ2KccId1EOWKFzYKnluz97bPUjezsH38ddzw2+k+Kk7MG3clb FeeocEn3R6baEqqt7uh/gV2wFrZgEPd9cIzrscfQ0LQBx7Iaz7lMFg79IBZzkvGMSHb4jwCvS6s EuaI1GeXmXKlzBgOopjSPP/qWSr/H4ijkEoKAMX6hFlAeScKD+hb2tGthBspVTDr0um3OfymgnH LmHvpL7duuI5MP/u4sIBRh44pdpUNIXN1ZascqMKgII5iSI1RkOErgvgOShIbRB5qNx0g28B8lS z2hHMbAtJzqkGSQtJhHQ4J87lIgWeL9jKUPnfh4JMCc96f/4tdvHeKwetUh6jp3ZXnI00pYj5rE DgD8g== X-Google-Smtp-Source: AGHT+IFNOOczDHpioRtQCE0+GGGgWj80+rcrFYYJMFAUFQyyh69c5IFa8olrIAoVk1WBi/k2ouOjpw== X-Received: by 2002:a17:907:9408:b0:b73:8f33:eed3 with SMTP id a640c23a62f3a-b8036f49371mr2496537266b.26.1766837871744; Sat, 27 Dec 2025 04:17:51 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Dec 2025 04:17:51 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Sat, 27 Dec 2025 12:17:52 +0000 Subject: [PATCH 8/8] regulator: core: don't fail regulator_register() with missing required supply 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-8-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"), the regulator core returns -EPROBE_DEFER if a supply can not be resolved at regulator_register() time due to set_machine_constraints() requiring that supply (e.g. because of always-on or boot-on). In some hardware designs, multiple PMICs are used where individual rails of each act as supplies for rails of the other, and vice-versa. In such a design no PMIC driver can probe when registering one top- level regulator device (as is common practice for almost all regulator drivers in Linux) since that commit. Supplies are only considered when their driver has fully bound, but because in a design like the above two drivers / devices depend on each other, neither will have fully bound while the other probes. The Google Pixel 6 and 6 Pro (oriole and raven) are examples of such a design. One way to make this work would be to register each rail as an individual device, rather than just one top-level regulator device. Then, fw-devlink and Linux' driver core could do their usual handling of deferred device probe as each rail would be probed individually. This approach was dismissed in [1] as each regulator driver would have to take care of this itself. Alternatively, we can change the regulator core to not fail regulator_register() if a rail's required supply can not be resolved while keeping the intended change from above mentioned commit, and instead retry whenever a new rail is registered. This commit implements such an approach: If set_machine_constraints() requests probe deferral, regulator_register() still succeeds and we retry setting constraints as part of regulator_resolve_supply(). We still do not enable the regulator or allow consumers to use it until constraints have been set (including resolution of the supply) to prevent enabling of a regulator before its supply. With this change, we keep track of regulators with missing required supplies and can therefore try to resolve them again and try to set the constraints again once more regulators become available. Care has to be taken to not allow consumers to use regulators that haven't had their constraints set yet. regulator_get() ensures that and now returns -EPROBE_DEFER in that case. The implementation is straight-forward, thanks to our newly introduced regulator-bus. Locking in regulator_resolve_supply() has to be done carefully, as a combination of regulator_(un)lock_two() and regulator_(un)lock_dependent() is needed. The reason is that set_machine_constraints() might call regulator_enable() which needs rdev and all its dependents locked, but everything else requires to only have rdev and its supply locked. Link: https://lore.kernel.org/all/aRn_-o-vie_QoDXD@sirena.co.uk/ [1] Signed-off-by: Andr=C3=A9 Draszik --- drivers/regulator/core.c | 148 +++++++++++++++++++++++++++++++----= ---- include/linux/regulator/driver.h | 1 + 2 files changed, 119 insertions(+), 30 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 08e92b1ba2dc2ff9efdabaa16187a4a38cf66fb2..8c2fd20edd50591c962454a3584= 59e52e97c8ac0 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -98,6 +98,7 @@ struct regulator_event_work { unsigned long event; }; =20 +static int _regulator_enable(struct regulator *regulator); static int _regulator_is_enabled(struct regulator_dev *rdev); static int _regulator_disable(struct regulator *regulator); static int _regulator_get_error_flags(struct regulator_dev *rdev, unsigned= int *flags); @@ -1432,6 +1433,7 @@ static int handle_notify_limits(struct regulator_dev = *rdev, /** * set_machine_constraints - sets regulator constraints * @rdev: regulator source + * @is_locked: whether or not this is called with locks held already * * Allows platform initialisation code to define and constrain * regulator circuits e.g. valid voltage/current ranges, etc. NOTE: @@ -1441,7 +1443,8 @@ static int handle_notify_limits(struct regulator_dev = *rdev, * * Return: 0 on success or a negative error number on failure. */ -static int set_machine_constraints(struct regulator_dev *rdev) +static int set_machine_constraints(struct regulator_dev *rdev, + bool is_locked) { int ret =3D 0; const struct regulator_ops *ops =3D rdev->desc->ops; @@ -1653,7 +1656,9 @@ static int set_machine_constraints(struct regulator_d= ev *rdev) if (rdev->supply && (rdev->constraints->always_on || !regulator_is_enabled(rdev->supply))) { - ret =3D regulator_enable(rdev->supply); + ret =3D (is_locked + ? _regulator_enable(rdev->supply) + : regulator_enable(rdev->supply)); if (ret < 0) { _regulator_put(rdev->supply); rdev->supply =3D NULL; @@ -1781,6 +1786,15 @@ static int register_regulator_event_forwarding(struc= t regulator_dev *rdev) return 0; } =20 +static void unregister_regulator_event_forwarding(struct regulator_dev *rd= ev) +{ + if (!rdev->supply_fwd_nb.notifier_call) + return; + + regulator_unregister_notifier(rdev->supply, &rdev->supply_fwd_nb); + rdev->supply_fwd_nb.notifier_call =3D NULL; +} + /** * set_supply - set regulator supply regulator * @rdev: regulator (locked) @@ -2169,6 +2183,8 @@ static int regulator_resolve_supply(struct regulator_= dev *rdev) struct regulator_dev *r; struct device *dev =3D rdev->dev.parent; struct ww_acquire_ctx ww_ctx; + struct regulator *supply; + bool do_final_setup; int ret =3D 0; =20 /* No supply to resolve? */ @@ -2176,7 +2192,7 @@ static int regulator_resolve_supply(struct regulator_= dev *rdev) return 0; =20 /* Supply already resolved? (fast-path without locking contention) */ - if (rdev->supply) + if (rdev->supply && !rdev->constraints_pending) return 0; =20 /* first do a dt based lookup on the node described in the virtual @@ -2257,46 +2273,115 @@ static int regulator_resolve_supply(struct regulat= or_dev *rdev) =20 /* Supply just resolved by a concurrent task? */ if (rdev->supply) { + /* Constraints might still be pending due to concurrency. */ + bool done =3D !rdev->constraints_pending; + + supply =3D rdev->supply; + regulator_unlock_two(rdev, r, &ww_ctx); put_device(&r->dev); - goto out; - } =20 - ret =3D set_supply(rdev, r); - if (ret < 0) { + /* + * Supply resolved by concurrent task, and constraints set as + * well (or not required): fast path. + */ + if (done) + goto out; + + do_final_setup =3D false; + } else { + ret =3D set_supply(rdev, r); + if (ret < 0) { + regulator_unlock_two(rdev, r, &ww_ctx); + put_device(&r->dev); + goto out; + } + + supply =3D rdev->supply; + + /* + * Automatically register for event forwarding from the new + * supply. This creates the downstream propagation link for + * events like under-voltage. + */ + ret =3D register_regulator_event_forwarding(rdev); + if (ret < 0) { + rdev_warn(rdev, + "Failed to register event forwarding: %pe\n", + ERR_PTR(ret)); + + goto unset_supply; + } + regulator_unlock_two(rdev, r, &ww_ctx); - put_device(&r->dev); - goto out; + + do_final_setup =3D true; } =20 /* - * Automatically register for event forwarding from the new supply. - * This creates the downstream propagation link for events like - * under-voltage. + * Now that we have the supply, we can retry setting the machine + * constraints, if necessary. */ - ret =3D register_regulator_event_forwarding(rdev); - if (ret < 0) { - struct regulator *supply; - - rdev_warn(rdev, "Failed to register event forwarding: %pe\n", - ERR_PTR(ret)); - - supply =3D rdev->supply; - rdev->supply =3D NULL; + regulator_lock_dependent(rdev, &ww_ctx); + if (rdev->constraints_pending) { + if (!rdev->supply) { + /* + * Supply could have been released by another task that + * failed to set the constraints or event forwarding. + */ + regulator_unlock_dependent(rdev, &ww_ctx); + ret =3D -EPROBE_DEFER; + goto out; + } =20 - regulator_unlock_two(rdev, supply->rdev, &ww_ctx); + ret =3D set_machine_constraints(rdev, true); + if (ret < 0) { + regulator_unlock_dependent(rdev, &ww_ctx); + + rdev_warn(rdev, + "Failed to set machine constraints: %pe\n", + ERR_PTR(ret)); + + regulator_lock_two(rdev, r, &ww_ctx); + + if (supply !=3D rdev->supply) { + /* + * Supply could have been released by another + * task that got here before us. If it did, it + * will have released 'supply' (i.e. the + * previous rdev->supply) and we shouldn't do + * that again via unset_supply. + */ + regulator_unlock_two(rdev, r, &ww_ctx); + goto out; + } =20 - regulator_put(supply); - goto out; + unregister_regulator_event_forwarding(rdev); + rdev->constraints_pending =3D true; + goto unset_supply; + } + rdev->constraints_pending =3D false; } + regulator_unlock_dependent(rdev, &ww_ctx); =20 - regulator_unlock_two(rdev, r, &ww_ctx); + if (!do_final_setup) + goto out; =20 /* rdev->supply was created in set_supply() */ - link_and_create_debugfs(rdev->supply, r, &rdev->dev); + link_and_create_debugfs(rdev->supply, rdev->supply->rdev, &rdev->dev); =20 out: return ret; + +unset_supply: + lockdep_assert_held_once(&rdev->mutex.base); + lockdep_assert_held_once(&r->mutex.base); + rdev->supply =3D NULL; + regulator_unlock_two(rdev, supply->rdev, &ww_ctx); + + regulator_put(supply); + + return ret; } =20 /* common pre-checks for regulator requests */ @@ -6067,7 +6152,7 @@ regulator_register(struct device *dev, dangling_of_gpiod =3D false; } =20 - ret =3D set_machine_constraints(rdev); + ret =3D set_machine_constraints(rdev, false); if (ret =3D=3D -EPROBE_DEFER) { /* Regulator might be in bypass mode or an always-on or boot-on * regulator and so needs its supply to set the constraints or @@ -6081,14 +6166,17 @@ regulator_register(struct device *dev, rdev->supply_name); ret =3D regulator_resolve_supply(rdev); if (!ret) - ret =3D set_machine_constraints(rdev); + ret =3D set_machine_constraints(rdev, false); else rdev_dbg(rdev, "unable to resolve supply early: %pe\n", ERR_PTR(ret)); tried_supply_resolve =3D true; } - if (ret < 0) - goto wash; + if (ret < 0) { + if (ret !=3D -EPROBE_DEFER) + goto wash; + rdev->constraints_pending =3D true; + } =20 ret =3D regulator_init_coupling(rdev); if (ret < 0) diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/dri= ver.h index d38353f2b56f8bbab865d903ad0ec97ca0b5c834..09f3b67638f9e63a32cfdbaf9c8= 654afbd02a547 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -650,6 +650,7 @@ struct regulator_dev { struct regulator_enable_gpio *ena_pin; unsigned int ena_gpio_state:1; =20 + unsigned int constraints_pending:1; unsigned int is_switch:1; =20 /* time when this regulator was disabled last time */ --=20 2.52.0.351.gbe84eed79e-goog