All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] regulator: core: Resolve supplies before disabling unused regulators
@ 2017-02-16 17:30 Javier Martinez Canillas
  2017-02-16 18:14 ` Mark Brown
  2017-02-16 19:05 ` Applied "regulator: core: Resolve supplies before disabling unused regulators" to the regulator tree Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Javier Martinez Canillas @ 2017-02-16 17:30 UTC (permalink / raw)
  To: linux-kernel
  Cc: Mauro Carvalho Chehab, Andi Shyti, Mark Brown, Shuah Khan,
	Inki Dae, Jon Hunter, Liam Girdwood, Javier Martinez Canillas

After commit 66d228a2bf03 ("regulator: core: Don't use regulators as
supplies until the parent is bound"), input supplies aren't resolved
if the input supplies parent device has not been bound. This prevent
regulators to hold an invalid reference if its supply parent device
driver probe is deferred.

But this causes issues on some boards where a PMIC's regulator use as
input supply a regulator from another PMIC whose driver is registered
after the driver for the former.

In this case the regulators for the first PMIC will fail to resolve
input supplies on regulators registration (since the other PMIC wasn't
probed yet). And when the core attempts to resolve again latter when
the other PMIC registers its own regulators, it will fail again since
the parent device isn't bound yet.

This will cause some parent supplies to never be resolved and wrongly
be disabled on boot due taking them as unused.

To solve this problem, also attempt to resolve the pending regulators
input supplies before disabling the unused regulators.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>

---

Hello,

I found this issue since after the mentioned commit the Exynos5800 Peach
Pi Chromebook was failing to boot as reported by kernelci:

https://storage.kernelci.org/broonie-regulator/regulator-fix-v4.10-rc6-58-g3761de31e8aa/arm-exynos_defconfig/lab-collabora/boot-exynos5800-peach-pi.html

This patch fixes the issue.

Best regards,
Javier

Changes in v2:
- Leave the supply resolve logic on regulator registration since is useful
  for modules.

 drivers/regulator/core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index cc68604ad97a..896cea137360 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -4556,6 +4556,16 @@ static int __init regulator_init_complete(void)
 	if (of_have_populated_dt())
 		has_full_constraints = true;
 
+	/*
+	 * 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(&regulator_class, NULL, NULL,
+			      regulator_register_resolve_supply);
+
 	/* If we have a full configuration then disable any regulators
 	 * we have permission to change the status for and which are
 	 * not in use or always_on.  This is effectively the default
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] regulator: core: Resolve supplies before disabling unused regulators
  2017-02-16 17:30 [PATCH v2] regulator: core: Resolve supplies before disabling unused regulators Javier Martinez Canillas
@ 2017-02-16 18:14 ` Mark Brown
  2017-02-16 19:05 ` Applied "regulator: core: Resolve supplies before disabling unused regulators" to the regulator tree Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2017-02-16 18:14 UTC (permalink / raw)
  To: Javier Martinez Canillas
  Cc: linux-kernel, Mauro Carvalho Chehab, Andi Shyti, Shuah Khan,
	Inki Dae, Jon Hunter, Liam Girdwood

[-- Attachment #1: Type: text/plain, Size: 254 bytes --]

On Thu, Feb 16, 2017 at 02:30:02PM -0300, Javier Martinez Canillas wrote:

> Changes in v2:
> - Leave the supply resolve logic on regulator registration since is useful
>   for modules.

...I was just writing a mail asking whhy you'd removed that on v1.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Applied "regulator: core: Resolve supplies before disabling unused regulators" to the regulator tree
  2017-02-16 17:30 [PATCH v2] regulator: core: Resolve supplies before disabling unused regulators Javier Martinez Canillas
  2017-02-16 18:14 ` Mark Brown
@ 2017-02-16 19:05 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2017-02-16 19:05 UTC (permalink / raw)
  To: Javier Martinez Canillas
  Cc: Mark Brown, linux-kernel, Mauro Carvalho Chehab, Andi Shyti,
	Mark Brown, Shuah Khan, Inki Dae, Jon Hunter, Liam Girdwood,
	linux-kernel

The patch

   regulator: core: Resolve supplies before disabling unused regulators

has been applied to the regulator tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 3827b64dba27ebadb4faf51f2c91143e01ba1f6d Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javier@osg.samsung.com>
Date: Thu, 16 Feb 2017 14:30:02 -0300
Subject: [PATCH] regulator: core: Resolve supplies before disabling unused
 regulators

After commit 66d228a2bf03 ("regulator: core: Don't use regulators as
supplies until the parent is bound"), input supplies aren't resolved
if the input supplies parent device has not been bound. This prevent
regulators to hold an invalid reference if its supply parent device
driver probe is deferred.

But this causes issues on some boards where a PMIC's regulator use as
input supply a regulator from another PMIC whose driver is registered
after the driver for the former.

In this case the regulators for the first PMIC will fail to resolve
input supplies on regulators registration (since the other PMIC wasn't
probed yet). And when the core attempts to resolve again latter when
the other PMIC registers its own regulators, it will fail again since
the parent device isn't bound yet.

This will cause some parent supplies to never be resolved and wrongly
be disabled on boot due taking them as unused.

To solve this problem, also attempt to resolve the pending regulators
input supplies before disabling the unused regulators.

Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/core.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 04baac9a165b..8028835d3967 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -4540,6 +4540,16 @@ static int __init regulator_init_complete(void)
 	if (of_have_populated_dt())
 		has_full_constraints = true;
 
+	/*
+	 * 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(&regulator_class, NULL, NULL,
+			      regulator_register_resolve_supply);
+
 	/* If we have a full configuration then disable any regulators
 	 * we have permission to change the status for and which are
 	 * not in use or always_on.  This is effectively the default
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-02-16 19:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-16 17:30 [PATCH v2] regulator: core: Resolve supplies before disabling unused regulators Javier Martinez Canillas
2017-02-16 18:14 ` Mark Brown
2017-02-16 19:05 ` Applied "regulator: core: Resolve supplies before disabling unused regulators" to the regulator tree Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.