From nobody Sun Feb 8 10:04:04 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 6D08B350A1C for ; Fri, 9 Jan 2026 08:38:41 +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=1767947926; cv=none; b=WkTGfgu9XzCwRBR2mzDOhbRW9U/8VnDXno0+CPmt4EoKR3s9tfK09L/YTdJvUUBuUYKS4mrzq+15eu/hMUQ/tC2duMn7zZ0L2COOSwkrK65hzxwpBuO29NZynCllAYociwc37eCnYEvFQkhCKcJgnqqSWC9lWXid6im7wuYU/iM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947926; c=relaxed/simple; bh=wpsSL6A4cEk5yirhuxjRb1Ls8ZJuBT9kv2aZnZ7E4tE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=feJ1BAnou/IJEKUOyg+79sXCQgQZTsQzApd92SD048K+V2RD/cvnv6FoMYUIoTBzOSU9LyyWEN5+R1ary7HWz4shNxKMBQFNOSUsqn63yWyhJqpytzgpXYGimUWw+rjIq7wZhBemFz2AXZkXEqEm/83h+k6UFxuaiJbsD1+pXc0= 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=CuT0GcWu; 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="CuT0GcWu" Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-64b9230f564so5758241a12.1 for ; Fri, 09 Jan 2026 00:38:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1767947920; x=1768552720; 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=eR2M5vZrFrQ4qJBhOQVvbO4YXmcPexSacB/A1uPHlIU=; b=CuT0GcWu40PBptl42duU8c4PrtHHuarkBQZNWiIG8+GvINGO8xfOvdCbTTUw3DIAvt RjOHyCGZkj5iY8V2zGpZz5M+I7QaZI+iHgzaxQ/xmoTGLxLMYNvJYAZlrS6/ZZtapjBr qEB8o5EVleQ2ID0R5eM0mEQGwzl8kvLPaWqhoJCAqcoxtpyXTVtI9VbtBCYyJnugi9Fk wnVJEVVDsteDosxRomDqFUGuCiVRAAHrbmSgcAqrFygjlJMeOREqnHvM1gcu2cW1fewI wNBljLbhaW5SjlU4z1m+gB2RI49snf/e74VgY8EV6f+FUdrneGEhcF1XhJNcoTddZ94B eGjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767947920; x=1768552720; 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=eR2M5vZrFrQ4qJBhOQVvbO4YXmcPexSacB/A1uPHlIU=; b=fQzca51rx3YlWDeu90QeaqfoHsa2GtuUBfw1iWTb9HDA9gIWELhB1yL52o1JZT2hk8 wKstHX8/uBVFsjKN5d+mDTV4T/slRBnJ1vKCQZ4bNJoZ3d9apyxXcJBBfrCV+vjjnCIP 29TssnQwj+hWAmM4mZXDq26gX8dHDwdrEo5j2DnPyAWNACRf17udIGajASkjT4mPgpTg EoemFGu18JUg3aVx05GN0s7jPZayexk2CFG6nbjAFEauBpgFgvuhlnyKVV6Ft251dSZZ c2AKsPxZqu/Crqkm5ojLikYu/zLTRHPddm0OU59T+eToGGt8oaV1+rmcw7zz06ZqNNvp VaKg== X-Forwarded-Encrypted: i=1; AJvYcCWpbfftB98VjJOEWyug+kZw7of0cGg7vNnU/Gg1V00v0QGm63DiYUUdpDenUAfhdgxrVPB7EkAcZPWFjoY=@vger.kernel.org X-Gm-Message-State: AOJu0YxnIeA6Vc7WOep6K8KjnGn2mN/jmWWcoPxa4TfwnWn7Z+APkTU0 sePhnVDe1c2UOL6t8e5x7TV+QzVn9Ua3k+WcV6xioU+fiqooyPSmfX58TXIafIc9t24= X-Gm-Gg: AY/fxX4me3lh3Ee5wWZBmYcXXl/pSbmmspuqeZRiGT6JFwGS8EQ2yq9lGGZ8l3rrOag nY6tm/4cG6INoFdp5SFsB4D4NUuQNwJobEt9ZF5MhgUyNU+E+mrunu6UnIBetc0hHAM/N89uK8G CVYIerCZ/rw9pTomu5C4aAKkO0Jk7PXr7LyK7eD8vUYOOWooO7NAfiXJnDcB7B5JP27RiHsQP0a 7mrEq+26/TcImZDVJpr2sxn7C5yb02IfeEjHxlQVT/Lrw+A828zgQ2Ujc4zrtez00vR7OZEHmOk 8ZZedt1UUsu648qqiFNx5xd3KoeSuav5ekHcnUVqnkg2PWBqwd/e3HeKdD1OvNnOUXyyP74kHPr 2ptv/3HJbcpRsEXsYgWidsZGEyvL/EJLbpzDJWZTZv6IOXbu4Ht4f4KKnYwiXth3qW8TbguFkAD RkCgRKSZlDF59eb4Ab8HnQpquPzTKhlCr3AV4HEeTBS0VLOXTnwPcHQIcVlY+sVy7cz0Pl2C0AK mkP4Q== X-Google-Smtp-Source: AGHT+IHSig42xTL9M5XmqkaDreEuEOif5gmvnT7sVudYQt0tkr7u0+a02ZWRBp974/bmgCGxBdqdPA== X-Received: by 2002:a05:6402:1ec5:b0:64e:f50d:ec9a with SMTP id 4fb4d7f45d1cf-65097e743e5mr8004766a12.30.1767947919731; Fri, 09 Jan 2026 00:38:39 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jan 2026 00:38:39 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Fri, 09 Jan 2026 08:38:37 +0000 Subject: [PATCH v2 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: <20260109-regulators-defer-v2-1-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 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.457.g6b5491de43-goog From nobody Sun Feb 8 10:04:04 2026 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 A4E2B350A29 for ; Fri, 9 Jan 2026 08:38:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947928; cv=none; b=C+AbkjAOzBgJV9g11PShBmZ9U6wOwG9W/6GEjgZngZ7gY1MNur2QwZv4voDXKQ3fTCCJjo5vCZ9EqufNxnT6n9GSaysi0Uwrw49oLvGL4n07aRoIWRvD4Kse9Ys+TGRK6rlSGTsIJGazwweHQz3Ku8l1fOmQSY1Oumewp9vNVMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947928; c=relaxed/simple; bh=K5tgOiq77r3lfwLEiFdQfx8ViR1Uk6xWP59K0FlgwXE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=s83j9WYTrETVzdqu7NCIQ3KbfgRB0+effExG/H0w6LNztR5+8J0WJ00vmYJ50JUrzhuotV6Pk0ZJvl9j5u0dBu9qvEsvn6NFrwk9rs8zSzQ1GGTj3PnycP3vld8HgEyi+Z99410h5Rh2sjUJdzjrK6ixYIqinUJzz7pb/Yf86b8= 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=ji4+9gdK; arc=none smtp.client-ip=209.85.208.49 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="ji4+9gdK" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-64b7a38f07eso6134492a12.0 for ; Fri, 09 Jan 2026 00:38:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1767947920; x=1768552720; 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=uC8GxDilhXr5xxzhTNKaI/12HBAgcI5kP1knrtl3u+U=; b=ji4+9gdKSRwFVS7cBRig0R7w0aGAUWiboStFiYalpy2l+bKoFZdHcC9+zvbyeExgmU YxbifEVoI9FPvoYGCx5vTC9D/ku99ysRNqzZqPeyyY4m4FWTltHCsD4CJK8WuDlQzeKl kTNUeA+sjeoQIwZTYv7vRikI69F19dWa6P450UKYNWMMmw4j5d8TaX/LkKaOFOPZygnj U7Jdvb6RQK2gymijH9Gsc/4kaQSv2deC2sVW4eFtX4hQnxKd/zFbJuUnLbuPlxqH4eS3 df0hye2p4Y8CtqTyErA4HJyIUDhBj4ZfZs3tQK3nfCyN3vF+b/ukL4xbJGTOpMq7acZr kNxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767947920; x=1768552720; 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=uC8GxDilhXr5xxzhTNKaI/12HBAgcI5kP1knrtl3u+U=; b=XD0gEgTe97AxkUHAVc/WnjEY9xDmD/DwcLcBloPUTZTBf9Ux52ilXLfbysslwpfUPc XAPAfHH08DrK5dGpN1UXgAyUxed+EKQzchUKLQW3k7T1XxCHPyyidAjvGLhdp2CT0NjP CZKq9Q5mZYA6s5hHs71wo7vaYD4/3tPfLuONYim/c9YqJNrajqh8VB1z84iMeE1T4zj5 d9hdviWdzZd2I27nVHLW17Ue3+8cZ6uIZpyHi58qZV4WxSsuypG0aSv2946V3reCiVbU egAPrRVREPFOvKQ5SQDgTwntCPNBAINZgWd2JSOPDPT05OGsyb6aAnHQUk8TK5TSmedV Bh+w== X-Forwarded-Encrypted: i=1; AJvYcCU3hRogeHpdpsdgy0khS+bdpEjHRZSKoIk/IaZZT3raPXGPUmm6FI865mGbcKrkm18x8KZrRVwdQmQtc1Q=@vger.kernel.org X-Gm-Message-State: AOJu0YzdRnvCQBB6U7AAIxHowpl/wIfvw0+WfcAXDtE9n9jixw1JwDqG dGFQkH0TgsRIbFQWMQkaVc0O/mM08HSWNaTDLYlIXazPxRkIanNF4iGj7ZB/u9vb0HE= X-Gm-Gg: AY/fxX5qCUZIlA3/9dinNSTI2ym5Ev8UD0cDzg82sR2xb6+zqyS+6erC4FMfTZ73Mz0 myPZ9y0ceg0/W7qMqy9hDMEhnmEkfRyyLQIFRASMhsMv0GHb60CN7ztpBhQ6rjDVx8ajwpBoQoB hLruzr23N+Ubx47mKBURy0AxahZ4H09lp18jZ8HoECQceAN7t5J7ibBFk1WlGQudIkjnvE+OIGa dXg86Yy/UEHwRMXYD00RHGHuKxmu3CNWeoF7ommytrYrxw8IOrzVs0FvbCtWq7PtO9zs9fbVwDI 55au+1Xegw2kk1GIT9OCln91HmHGqJXnMakfXW+t7zEKSHzo+kbgEFs86lN5Ntqqv6FE8g0eoNS gHG7qlToF+MTZjuX82UK4cdSTjlPUjKoTuHHxkmQs7+RXpuKBU5HkURy3cgopgmO7FBb7gsbtfR bZinT9HFtMbk7NFo92YVJR+B9RyydVG497eZHVTkqoYG6ewJI/eUKYoWJgwf7lJ80LklU610OLa 6oFJA== X-Google-Smtp-Source: AGHT+IFDH/o78VbXPhGGAflSnPiHmLX0RmySvMYvEZDhaC2NdO/ElgxNE7vLs94AbRVB7D03NVhjXQ== X-Received: by 2002:a05:6402:270c:b0:64d:65d:230b with SMTP id 4fb4d7f45d1cf-65097decd6fmr7904920a12.12.1767947920253; 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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jan 2026 00:38:39 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Fri, 09 Jan 2026 08:38:38 +0000 Subject: [PATCH v2 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: <20260109-regulators-defer-v2-2-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 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.457.g6b5491de43-goog From nobody Sun Feb 8 10:04:04 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 From nobody Sun Feb 8 10:04:04 2026 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) (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 B490C350D5F for ; Fri, 9 Jan 2026 08:38:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947930; cv=none; b=HJDFNSMSAaYltRWXqlCAbsvZ2KiDTsPAVgwjN/ybDKCF/aoMbG+sPzImcdRjv9ds9uhczdxWbePwFMVrKfyQsxled84PJE/Hl3kFt85xYu5DWnhDNvvg0r7HAU0WRo/4ILfJq7Y3VuWyHRobjco0kauEro3jqFEpo9QEcUmXKg4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947930; c=relaxed/simple; bh=DdBBgFhglOKY0ph9pTP5LrAKEsDqCeX9xP03lLUHCto=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hLLLqI2Hvy62Lesc508El9/VOx3u7L0EA0hqOWhvg36EZYw/PPQzrW2hpa/Y9n6yjqtTdxaWj55qzEZaVsuFSNKHNCfdYClUFh9JbZ1M4/H6jCgPNgVnKsEV9YmbM6Aw9LV3ewb74Cy/vNImbIlKMFgFGcBLxtmW0OpV014GajQ= 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=D4O6UdH0; arc=none smtp.client-ip=209.85.218.43 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="D4O6UdH0" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-b79ea617f55so796919166b.3 for ; Fri, 09 Jan 2026 00:38:45 -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=jIG9jHDbaVAm5OgY4WVVwK7anANLOwHME3rcrsh86ys=; b=D4O6UdH0FHy0AV8fB2mIXRVLSwFQSYPGbe+1ISUXcvnBgnmojWv2y9CZbLhIftfHb7 9JxcrpE1VCtWpcIG7VrvgMuo8LskptlPXLD8YbDWVc4amqTkiLARcB4VzVifhMueoAil tQgztCodvgidRYtW+xKyn1Aoj31IRGJi7RONZ9skEdQUjJuq86f6NB4biEnb8Lf5deEA hvMW12m9wgCl6NwQbugOIbUb22sLr3oDzKONm7cgzYiZNQvxT9lti4UkwvOq1NaOk3ZK RI6+9mNRhO3C/gYP5+TFjf3Zg5aKsGB7j2JE9o13ziIMhrD2VvboxQIDJxR1SZolXcmB eNWg== 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=jIG9jHDbaVAm5OgY4WVVwK7anANLOwHME3rcrsh86ys=; b=AuSVf13baZSWi43/0mfA/QihzDmPWwm/jNEgIGREMoTACvW9jYciEkJWyOQU46HUSU 89QrRKyc9GtauTIpCF5WBljuNEny8HkBYyjusbz2orwn1UIE+ft+rj0h+vjB2PzLdUU1 oDdes9kGYc5PWbT+6zHY6ZPH9MuLD4RWVM38rXqsm1AwHLOZCfpRyrOzGGk5eyGQ5Mwi Xl5o7Gz8ang/qOJ6VXXFLKcW13TBNGlZPegyy9WaSOGUR/ofUDh3ZA9GFWA/Bw1a4Rvw 2ohJHIpD4zkq5aeGTI2Ios5F2jKlzbglK7OuAOG/QycehtzAcCyFoQkYzS14JaZwOAUO WuYg== X-Forwarded-Encrypted: i=1; AJvYcCVRh2nwIJrqGdgchfaKWzQlmYDUVCq8bJ9l3cIG18gbBV9z0y4roLhXRDvaTB6k+Yb6JhvucHHWicpZ5xc=@vger.kernel.org X-Gm-Message-State: AOJu0YzAAbEYH6Ce+7OmvysKPohqKjcQP+RGKoeNy65UjxMM8KxtL7Mk y76uJVTrj3XAYv4csupdr9Kz9Ju0Sf3cFdaLYs7JMyfXEUxfFlv0QdZStKmeVo8PgLE= X-Gm-Gg: AY/fxX4dgwmy31me7Xnv89EL5aZgGD2loFBpH4ukszJr+AV2gIVFC8GEYLfswTbEoho ootMUnHENcYRFTfrBW+7tq4EIVSX+c2c06O9rffor8bVp2S8vtOyZ+tdtQt4EkKeDXBcaNk6gzi G+caTUqmsNqC8QmroOSbMrNo/IFIlGbwZ6ftD73x4VzC1CWE3cUGggpYG79YeHhoY45vd3DoQuR E6Rb6ICX8YkhKlSxT2CgL9hbNomxpdBxD1iZhiQ+vQMlOx8S+rVtO1spw/br2sc4odoEiS3pbtB 05/cVoh0w2V4tN4KMSW2OkJADSfBhhzY2dQS7ckDyZGag3Laifyo5UyLwQ45yROrrRHu6ZCJHkf 3Keng4jFwCQjxoTj86rTHj8IrcZ+hMQATs8ixr3HFawKH2LHycQbJDOLLqEMZdGDA2c/u0PahZ+ fsJ5CExq/zQ2lMNgMNHiXJ3ZdTFS0EtGhIv1MCdcd2Fwpb0IvH8zHQiajqsy1/nQRTmW2JxeBD9 zWRoQ== X-Google-Smtp-Source: AGHT+IHInIFLTMr5PC+UzvqZOLFLWW0IssOpqxXKKMxaAq+HXKBORW8AkyzM1Yi+pmL1ogSGa8uQPA== X-Received: by 2002:a17:907:1b0f:b0:b83:1326:62e6 with SMTP id a640c23a62f3a-b8445179ea9mr877965366b.35.1767947921344; Fri, 09 Jan 2026 00:38:41 -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:40 +0000 Subject: [PATCH v2 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: <20260109-regulators-defer-v2-4-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 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.457.g6b5491de43-goog From nobody Sun Feb 8 10:04:04 2026 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 D0938350D41 for ; Fri, 9 Jan 2026 08:38:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947927; cv=none; b=u6ciZDZ/qJ1NUrXBx06SoVUO53VuNwmd6Fh9QsqgauENbQC5cCKioLQLgVoaRxe4hAH1AaLLbVMMb9IiECnTQhdLPcrGpr8NKBvzi3YP+RiG91v4pRsyHN+aFztJyVf191q/0zQzUca22TpHPpZquzQo2HZZvTEga0mwmavEga4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947927; c=relaxed/simple; bh=hQC7FP4uFy0QVNeIoV5XnfaYefHrbJONVVIEMohvuMA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FbU6qvr1e5gksFhtNfEwV5Qc6I00gbGSk0ruomHVkvz1w+dhOtaqrH13Y+iV2XuvNWr22NMugbXmwUyQY02yBC9RpU0xiMbTli/T1RN+ACqQt09f59KKvVkTXW6bF5wEJ5j3QXirsnPCWKExCrRI8AJfntTRlB7L+Msc/n3J+Gk= 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=qfdiocTE; arc=none smtp.client-ip=209.85.208.41 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="qfdiocTE" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-64ba9a00b5aso5720334a12.2 for ; Fri, 09 Jan 2026 00:38:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1767947922; x=1768552722; 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=E7QqTZp8PrnJ3a9bxEtgB54OlzIsP95TzLs4Ah0uU9I=; b=qfdiocTExA5RFUrDBd+0dR/3sLITDz27xfUztOtelVq5SV9HQs1TUmjXBy30UcLfFp htyxL5CVNnZ/P88qiFV0vKshUh0i2A3aOtIumy5Ey52NGJUXTTKt17ruk1J2Q7bu20oN qXvqBW5xLG9VOSZlorswGEnlCcI0AYde2vFjSqdi1eC7B64uIabkmO2qzDLurvAvyCjq Nvp4HmIAHrmDsiyJurpMUgcrsiZRI74AnyxBrDwCjW74Uzab47tQceZC6o4kA7fwMJBI jRqDt8xZ9VDy5LUYoxWn94eG8yhjo+iBYRTjNyCp4xrcD7QFB0gc5NRWgaWfcPe4Ioa1 RYAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767947922; x=1768552722; 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=E7QqTZp8PrnJ3a9bxEtgB54OlzIsP95TzLs4Ah0uU9I=; b=qBojbaiaiN1QanbZdmYF8rg3WvBPuj+UbZ2MbVh9Tl0X/r2I+Nu/FYL+r+H3ioC57/ wsh63bx1C9+VaOpFNPZqKOu1juGkgaaCr0kDFKj/ZtBVl+B5+Sdw3L8y8YYC+sJscm9+ XT9l117CWpDTIsgpA0V/Dn2J95X0zTGSnH7Xow7W845HQqyu77UGLY79Zct43uU4EUct laRlk0c77PIRLBC/iNEsjqt0crYecxhVD0bKeCrkz0VLAWQBUpSZ2CdsgmBV9K8+W1Zr OWcN8/KNGeKp0i/FP++DVNRrfP9aG59Xb5TFTDFjY/yGA6FnoyVLqA2HXNPPm8/yS50W CFDw== X-Forwarded-Encrypted: i=1; AJvYcCW4KWlgX7IoZa0N8CmJbfh1xowVIqLTMkkTKAk0Kmres4i5r48RKuF1J9lVPdNrkFSRg6QnbK8LOWq9Ygg=@vger.kernel.org X-Gm-Message-State: AOJu0Yzu4nF71/hMtM50zzmGSRmp2MS0eudAqlDb+mCWE+Z2KKZU+VyS VeOEyKXZpX2C7xhTV8ifZOtaTuckLrjgUe5+I7HNkqv4uNTU7b65q3a8GPV70YwOSEo= X-Gm-Gg: AY/fxX7ITv6bhjpSt1ihS56hwcNJ646/6hDJ6+p3C+V0EnbUK0ebuI7GURA5UDoYHKM 2NaKlJUz1aU0eIfBb+vOwDlSMXY7VykThifrP1IQfDQgmGgaHVGYtOUXeu8UNRwQz+8lh5GPnPC //PY2XHRrJVz7XdHkVZ44cW1TrdxZ4odrQXOkazBnb+rpAzUZdJBylikvg9qYu167GZjxdXad4O qz0oDaWIAP7q7M05R1SOP1Hp0qlLN8C+jBzZbVcX8XSZ5Ob1snPNv1NnzP23flawjMRmk9fzitc /bRFTP0zqQ8k2jJgHPDNznAYaKeazyDUoLliE7ZRTX7OiiCHmqHb8bZcfdNVkyNzzrj3MVWsMms oWnOo8siT0fFfpbonNDsBFE6BD+ubq8iY4QZ2mewpkFBN/G+WR5mltqrxNBGjyXadg4dq+uhRkN 3wKam7Nd3Ck14FEYzcfalGQbvmFmi4tRfZamIiVbUWMauL0ZwCWq8wNYTb8SNGqwn/kJP74+1Ce 8Zt2g== X-Google-Smtp-Source: AGHT+IH5ZNRry2+POjUdYlW2DpytYLe/Xx1cqSGa80PgtBhPn3fqpT+AWBOumVspvPMIEoZ9Gfu23Q== X-Received: by 2002:a05:6402:4301:b0:64d:65d:2314 with SMTP id 4fb4d7f45d1cf-65097e5f88fmr7989682a12.23.1767947921892; Fri, 09 Jan 2026 00:38:41 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jan 2026 00:38:41 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Fri, 09 Jan 2026 08:38:41 +0000 Subject: [PATCH v2 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: <20260109-regulators-defer-v2-5-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") 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. Signed-off-by: Andr=C3=A9 Draszik --- v2: - drop fixes tag (Mark) --- 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.457.g6b5491de43-goog From nobody Sun Feb 8 10:04:04 2026 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.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 A754F350A2F for ; Fri, 9 Jan 2026 08:38:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947928; cv=none; b=SM+N+Neclk+WIkmPft7ndbPrdX1sTVjfTh9cB4BOGDe/W3c8MHDzgjULnERIczuTtmJ8gnAsJ3NZkleIXnZPxs0oI91ORlxzycMWWsk2tD8j7wXLR86lebI6Q4Z69FQbC8Ygr7IuFCjS4mdLY5zCzEeaUO60MLMhlkzd6LnMw3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947928; c=relaxed/simple; bh=nr38tge6MqeHJlzuWU/dTgRarW9sJohtVyW5AG7QXdA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UAsdkDkLa5oGLxiPTJTZ55ezZ/5h2HmtSidZ/EJQgjA0laO1rY2D7xJh5lKeRkLD+QtOgV8W5EYlrV9PktRqWwN3/sWsamaMEjSWYaoOhLqQULY/lD76i5zHgattanwkAOLsZFpjLewugwMUvCwX4/q3s79RoREuJyP3Dcqqw7M= 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=DAk5EXHm; arc=none smtp.client-ip=209.85.208.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="DAk5EXHm" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-6505cac9879so6838108a12.1 for ; Fri, 09 Jan 2026 00:38:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1767947922; x=1768552722; 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=8lFceD8j3Zv7X2wI+TtTpu4Ty19M2h0l6eOvE19hymA=; b=DAk5EXHmBaqOnHT7pSVktU/K0lMvp3NJPmiInk+XpMQS2loeKbNDnM4CTKvFAbVuWg YBye0v7Aszn5xii/3jPgSg7v/Ct6m/6u7L+t6JuwlIoNVK2J/Kmujp+MTfUKlUjvKzKa D4nkRf4pis4MNbR7Kq+PdgAKKSaU/XiWfsKr30HYoq2jWj9esC1KXk+fKuzqHbn553UA 4wykFQ8ZUqaCcsaOxW6cnOom1/q/Pxm6wUMZUjNLXxPOkForpRnbb3OahbBO6Xk+cN5k eva+wGCVWA/FxDqnGIBrQFrXYI2mczZ2w4IgANUfU53+ZdBpkgI0PelYbMsXKgP+/LAu gKOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767947922; x=1768552722; 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=8lFceD8j3Zv7X2wI+TtTpu4Ty19M2h0l6eOvE19hymA=; b=M3vuSxx6tqZaQk/wDy3Ki9mKx7/y1Eqc4n8kIMtXMEUNvLnWgsQ9eBlTMy4jJu0v6L bzDAd5AQcvAUnLoqauCP27jZxLOK8QVzwjxWEL/juoRB7ljPJMScpe7lx512n7e2q/MA OC9R4lGxjWMexh8I3lKW3LlQBaJcNzHKtesiTNZCojZkq80gxXV6EtMbM3krTLSWGEJI MxUDmL30vTWvO3IeLKhraNZH+ijq+/qKus9h8rN3eqYIs1+BMFzpdVTnStySKfMs1Z8k X6JdhJPY5avRVKqtl0ORBrnK+J1/q4JcoMt6SU7CpnCTKMU6K8IUIO89CItdzEgfyS4n gsWQ== X-Forwarded-Encrypted: i=1; AJvYcCV4RnrZTcwgFBYOrRa2Lx4tGwC8k/ZvEozZrmHdFOaQg41LwBv0NyTq7XnLkNCdSMaE0uRP5XCCdMaWZSM=@vger.kernel.org X-Gm-Message-State: AOJu0Yw8DnIWKS6rAG63nEL6sONKWyTh8dNgL9W6roExe7THDNWuksdI Kk8AS201UXCfTEwfgjmIwnw/s1Ku2YAUpYPaLtgObQpK3//YkSIER4lFkPSVfB88kXM= X-Gm-Gg: AY/fxX6dNGi0ndmFArt3OhpSmzy3JYOmmCGG0xGrbmhU+3+89LfkB6wta/LFzY9xpXQ fGamlwHsnXojS2fLX76QaaUnJgaKHggoI2LVBYQ/hIXTKfE72gcosE57qvHCtXGTvDOIIThfk9d cgfG8Os/fYgJJil0e4XRGhIDipjJbEhmOYRdN+dBZuhd3pgZ8mHaA5hkJhJyi+yaAvM6U5rvNVa QX19aGK6Ii0PBNv7B1N+kgG6YKP0bkV4TWlIV+ZGONtP8mxNjJvStXZl+3LKLqEHS8flHMoWwJM nr03Gj1gkq4/vcIG77hCOAuYWIgJTWfz4KKetgWO0OfKAbCY7U3Fpv2a3Lc6gLj07s20yMOVbtY tqI9GKy+s9ZRcIuU1zSp82Z5XUJNwc+dlOFrHckqzG8trOoi1owi7x6tzmFRJTaqvv2p40whATD PxJPOslwal1v8R3MmxR5tgiLT/zK1icngECE5HeXnC3mpWOUqNntR/U6+rzvlJSDbVyZ/tFgeOj YVHtA== X-Google-Smtp-Source: AGHT+IE7DpaQM4d4JyducO1kEDtDGv7S4l8cnvssbW1JcE2kqCS/LpOWl5VzU06EIFNtBM5WjZYZHA== X-Received: by 2002:a05:6402:358c:b0:64d:16ba:b1c4 with SMTP id 4fb4d7f45d1cf-65097e46b58mr8229865a12.19.1767947922464; Fri, 09 Jan 2026 00:38:42 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jan 2026 00:38:42 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Fri, 09 Jan 2026 08:38:42 +0000 Subject: [PATCH v2 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: <20260109-regulators-defer-v2-6-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 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.457.g6b5491de43-goog From nobody Sun Feb 8 10:04:04 2026 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.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 8D7B3345CA3 for ; Fri, 9 Jan 2026 08:38:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947933; cv=none; b=ueFN7ITJL2Z3ajvGHdmWUjEOWkV4tXb/ZQ+HPbeKohLoo2++KsNgFXTl2gmf8cZ3UamhX9QzsisL8s9cGb0rnTyF4dnm8nKxMToyEapHVN5gfMLE/l0U29f4UCOPdZe5debN05Kz08KKzD4r+fdUphjWoG+fOrkH8ferelMPtKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947933; c=relaxed/simple; bh=d8cLybDQoqK0ecW63A3vCUhMpI226Ljh6t0Jr/0nVfY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=R3Wy162vuJ/SUINUOWuL+QJqmz5WZkVokDe4/oAddei2iwAgOPLIzjZ/7IXbY9n/20IIIXhUj6iZEmU3xjHV4DjpvZvtdMVttOYx0nn90Xn189R0ylHZ/mnFx3bS5UwzQkF19Cf3epk7KQg0eKiVijP2mJyrYIcPdgj8pZ/lxII= 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=lnWGTBOh; arc=none smtp.client-ip=209.85.218.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="lnWGTBOh" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-b7277324054so728118666b.0 for ; Fri, 09 Jan 2026 00:38:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1767947925; x=1768552725; 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=hBGmyLG3qgKnnQ8cOO0a6IdRyzbs/Ys7SdmEW226de0=; b=lnWGTBOhs2ZbeyHYrbsvE/Fh52pcNY5GuJ9Ur6q4F4HqjMcsnKHNkwv2K/QlLA6sjW eqQhyDiSZBkIKT8k5gME8xP1pI4HcLKrFfjN/IxW8+h312KulcqzT9nesNWlMMtB6MoF fBan3xmpAqWZiv3ri78RzxFTY6shKBvttS59XBoQnR8SI8vp/zbXSg6T36XQGG3kJrLO U88JQcJbmbtMP7tI7PMV7sBq6Hhix+yozgTJPcZlYMvOHlw18gd+l+20WuW3q2CNm52T XbeXCZ8nTUvQWdGx/1lLXAokWlOfOVDQTWErNTgyqz/4lEv0joamprwPs8hKpYieE7Vs ne5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767947925; x=1768552725; 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=hBGmyLG3qgKnnQ8cOO0a6IdRyzbs/Ys7SdmEW226de0=; b=f8c99ZoHTQJOimvVUGZQ2jm1EqRHMZ5gS2Qa2bcXfYQKb2+zfPwS1bfqexl1H62K62 LA0xr5Y1hNNzcFCEVA0RAYjClf8cnJ7PmTvAjccppzSn2TRc7eQw1pDu04e+H/LG9W+L CbF+erVoC0+jBlpJ+gJ05zDBWp1DZBDYGyhxxC5gC9r+SC8PPOWGnA9zYRHUWAWX3821 SFq9XoJdsoRG7NxTO+oeAoUN6AyPd5KyDXPaJ+Tv/zHpN3CUzHkXrFEo7Dc006pxT/yJ +WiAmopysZLZtekvvBPkb4mcKzo9xaOWYJB2yB1GQ86HigJLLLF2lRSTq7xnQ45xyoyc 6bdQ== X-Forwarded-Encrypted: i=1; AJvYcCWlxJVgdbP9+sG+SRocmLyZX1W53+W89N6Uw5hk2M4id/9lDXjmsjiC0UiJWLv0SPHHDtLQyk7t6qwre7A=@vger.kernel.org X-Gm-Message-State: AOJu0Yw3cYy+kIsninUAwe1KNV9waoR06nqhky2QlrtRkIH1qQT2HSZN 2p3zHoA3E5NJXq0Or8D8HvTPbLz6YuI3fjQFpCczRAu+yI0LdpTYghl9bruM+ekyeaw= X-Gm-Gg: AY/fxX7e5RPuJ6FK4HeyKoYU/Y3AklCsG3lVS7/WrPZ/bh8S9k3sD+cogH5gj74Khc5 UlA1tZBm/8DwQOlbfWyDrnHExG93s+xq0lwuOoEwC2TBFjmvA9jM560ZP3pc8BSauZiVB9WjQLl lm8h4WkN+xGTNBapU3aYDrZTeNHtXQDh2MdSZK5eWCwQd6jX4mWLq3pu2S1HmNflbn5WQ7CWZFq k1MF73Y4orr07k5lr4btTFu9+x8/wMhEGLwlWygejtbRcG+m3pPAbLaJ1Z1gbJEA+5dCvzo4BHW tdXAsUwJNROQQh/N/aQPRuHvUO6qwtw0oRK6+HWFc+B1SMgQHxNZvzCjE1MSWaAkI2F5IPUfQ1A ogoyarGGssnMwMlIhQlPutASi1XmMgkFme2FzivGgDeptkeGpTz29T6bZGTxeZDKbiLNMJLXJht 5KJ6BoKzV54UGntVfSw6y3ZruFoM+NJuIZMlSsea0rVA1ymhjVChrLkm4z15X4iIdRsVrc2T8vc w6SSg== X-Google-Smtp-Source: AGHT+IH48Qk48+aQ/D0Va34RWZPT5qOOOWj4vaACv8nVBwipDi6uAlqwYVjMBAA1I9Wx/bAc4DcwCQ== X-Received: by 2002:a17:906:7955:b0:b83:dc86:122b with SMTP id a640c23a62f3a-b84451acde1mr819705166b.18.1767947925020; Fri, 09 Jan 2026 00:38:45 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jan 2026 00:38:44 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Fri, 09 Jan 2026 08:38:43 +0000 Subject: [PATCH v2 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: <20260109-regulators-defer-v2-7-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 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.457.g6b5491de43-goog From nobody Sun Feb 8 10:04:04 2026 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.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 AAF62350A2C for ; Fri, 9 Jan 2026 08:38:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947933; cv=none; b=kyqPjhPAN3F/BJsfjLeMgMyicdCXQT5uSf7x4ZecuI/CfkUQDqP4rGKaWVrwQzyba0HzR5LZEvHhfNnAIqDq93IyXzZToNJZRY5gCqjLZZzoGMZSXvQpN9j6kCM5tIU72y7vkJIpUI7quFggjTqJX2Xy0VpvOX4sKS44aqHlrSM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767947933; c=relaxed/simple; bh=QIKs3GJ5GULNM8vWmOIRu/hSMW7MZfqLfr2sWZ9It0s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QzjabiAVn28t9CLZp5G9tDAna2WPahbta/UtpIFiunIshME1KsFm8MMkRW0KM8w4dhyoCTvbNYUscP5vcnBlS0WEKCvZ7a/GIEA01JlPYFSEsCqMy/3nsLWM3Ru/WcbJ2Pqm4fLwcwNz0vi5cuw4DK1lzLQEYXnqzxJtq2nrpZI= 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=TUchLwD9; arc=none smtp.client-ip=209.85.208.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="TUchLwD9" Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-64d0d41404cso6079420a12.0 for ; Fri, 09 Jan 2026 00:38:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1767947926; x=1768552726; 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=l8pQ2O89CDfbM4KnmV94WjzlfRn0Vqk2cTQV/55mLOw=; b=TUchLwD9O3i5MPedjhLl65nFzq9qA5LvcHyYX9logsDOuBpnsWlZ4+7fyG/L4pJpcR 66+ExKg1Wa+YOc7N1upuWzGyjZC61Pju9J5+3efi74H39RjaU/2gemLH9WQ2Nahc9Jj3 cNWRvlfKBPQVHmwdDdcPUF8hDAbKmtlqegHgSbQl71QW2e9kk6KpG5oVN4rNA3YFCW63 uWR0Y3vjeOXNFVm03KqVTn3zoZuc/ls32fL7UxrM6T6BMYh+qSFGhv+gv+v//io/G2fz E1Ve02YZdJ+hE4SpUr6m2Tuo/dJjy5YHvpXOZ26ctbTAHYqM9KW/QHrBgTE5t4XRFvNj xDkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767947926; x=1768552726; 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=l8pQ2O89CDfbM4KnmV94WjzlfRn0Vqk2cTQV/55mLOw=; b=EeUlxipa6kBibll4ZKJO99yyhK6K9n5tpstolxAIPmZdJEV9B6Uh+9r9xpSh9WPUXa 5RQH+z00WjJtVHN04YrM2MhxEWs4SgStdcJUGnv0WgXVdrE1vwpe3ewFoHXuzFAVrh3i qgtsnOjEBNw9niF1NlRdQbNHMTsKakCUHFPym1eDBtu4PdvwfIfWdowEyrifaFxF0FTE wNmF5Tu16tRDdvqKXPtr12bGBfnZCyGwh+4Q1k16ivgPbJkAH0HXFhR71mu+UiBHtRTh HhNmoENjpjQM1hTgkFBIs37TCm6q24yNtRm9vaVQJGW0pmET3IeVrHO/xc+N06FtdzAf XjUA== X-Forwarded-Encrypted: i=1; AJvYcCVhe4lXVDfhDUsn80CsR/X2f46u/OIMGDYLk2NWPDpSHYdwyKs+jI1Y0Ly0NKGfFIqrHvaJnzLx1DbnIkk=@vger.kernel.org X-Gm-Message-State: AOJu0YzC8jJQfSQLfPz7Hqs0mn04/c0x2QW0D+A2UKo0Iv1lA48CS1m4 jiNUhid2gOpytJENgmfzhyL1mMpqwcumPXPWJcHwJxRsy5uVY5zpaYppmr8oQgLYqig= X-Gm-Gg: AY/fxX4f1lWjzMwIAUhkzDb4dW1CQETG8dXBRQwKzkr0QWnKgF2ByWd6qWKx8Gi7j0I W+1g6FqBDFq3TG8OFTAQBpa/wlWi/liC8T5MzCLElZ5rdbnwK7FGbBr5L/bfelN35259yP9Q8Em SZv0rh2gG5mergUtHrA47kXxNF852K5x83flmOEc08pTQecvL6lfX9PXccXYNwLjiibmIEwapC2 SPiLwvqJ1iu1m3GPKQT+o/WgSJE1//THVUcLl0SL/ZGRudZcYhs5ue4K/N/QGvtOsLyOhmEHhJO kSTPPICQH5+ISZS7wcCPvN9H/bKTyFmn6SHjwcbN0PlzuOw/d+/KWqZfSgAs9GNzXpILi4vv/9V x5XcaS+oGdBKBrLUfA0FDym8vHQ0e+uYhdSYpelTGv3l+GvWH20x4rjTq3rl4rmOJS+31II3gvT 3PVARKBKfmN+pcVRsWQOw+YUTHtdJUtgwGRiEDxLBNrmZ8Fc8NqxJrx/LNF/P73kw7TNpUmMfrF /LIcQ== X-Google-Smtp-Source: AGHT+IGBH9buOdSCIMONSIdN9fsAAzFbWizOF21BannRPrJ1XSgK1lKuKzgSqqnYqrCKckDZKQwrWg== X-Received: by 2002:a17:907:2d2b:b0:b77:18a0:3c8b with SMTP id a640c23a62f3a-b8444c4d2bamr764454266b.1.1767947925731; Fri, 09 Jan 2026 00:38:45 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jan 2026 00:38:45 -0800 (PST) From: =?utf-8?q?Andr=C3=A9_Draszik?= Date: Fri, 09 Jan 2026 08:38:44 +0000 Subject: [PATCH v2 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: <20260109-regulators-defer-v2-8-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"), 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.457.g6b5491de43-goog