It turns out that commit aea6cb99703e ("regulator: resolve supply
after creating regulator") exposed a number of issues in regulator
initialization and introduced a memory leak of its own. One uncovered
problem was already fixed by cf1ad559a20d ("regulator: defer probe when
trying to get voltage from unresolved supply"). This series fixes the
remaining ones and adds a two debugging aids to help in the future.
The final patch adds a workaround to preexisting problem occurring with
regulators that have the same name as its supply_name. This worked
before by accident, so might be worth backporting. The error message is
left on purpose so that these configurations can be detected and fixed.
(The first two patches are resends from Nov 5).
(Series resent because of wrong arm-kernel ML address.)
Michał Mirosław (4):
regulator: fix memory leak with repeated set_machine_constraints()
regulator: debug early supply resolving
regulator: avoid resolve_supply() infinite recursion
regulator: workaround self-referent regulators
drivers/regulator/core.c | 40 ++++++++++++++++++++++++----------------
1 file changed, 24 insertions(+), 16 deletions(-)
--
2.20.1
When a regulator's name equals its supply's name the
regulator_resolve_supply() recurses indefinitely. Add a check
so that debugging the problem is easier. The "fixed" commit
just exposed the problem.
Fixes: aea6cb99703e ("regulator: resolve supply after creating regulator")
Cc: [email protected]
Reported-by: Ahmad Fatoum <[email protected]>
Signed-off-by: Michał Mirosław <[email protected]>
---
drivers/regulator/core.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index ad36f03d7ee6..ab922ed273f3 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1841,6 +1841,12 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
}
}
+ if (r == rdev) {
+ dev_err(dev, "Supply for %s (%s) resolved to itself\n",
+ rdev->desc->name, rdev->supply_name);
+ return -EINVAL;
+ }
+
/*
* If the supply's parent device is not the same as the
* regulator's parent device, then ensure the parent device
--
2.20.1
Hello Michał,
On 11/13/20 1:20 AM, Michał Mirosław wrote:
> It turns out that commit aea6cb99703e ("regulator: resolve supply
> after creating regulator") exposed a number of issues in regulator
> initialization and introduced a memory leak of its own. One uncovered
> problem was already fixed by cf1ad559a20d ("regulator: defer probe when
> trying to get voltage from unresolved supply"). This series fixes the
> remaining ones and adds a two debugging aids to help in the future.
>
> The final patch adds a workaround to preexisting problem occurring with
> regulators that have the same name as its supply_name. This worked
> before by accident, so might be worth backporting. The error message is
> left on purpose so that these configurations can be detected and fixed.
>
> (The first two patches are resends from Nov 5).
>
> (Series resent because of wrong arm-kernel ML address.)
lxa-mc1 (STM32MP1 board with STPMIC) now manages to boot again with following
new warning:
stpmic1-regulator 5c002000.i2c:stpmic@33:regulators: Supply for VREF_DDR
So for the whole series,
Tested-by: Ahmad Fatoum <[email protected]> # stpmic1
Thanks!
Ahmad
>
> Michał Mirosław (4):
> regulator: fix memory leak with repeated set_machine_constraints()
> regulator: debug early supply resolving
> regulator: avoid resolve_supply() infinite recursion
> regulator: workaround self-referent regulators
>
> drivers/regulator/core.c | 40 ++++++++++++++++++++++++----------------
> 1 file changed, 24 insertions(+), 16 deletions(-)
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
CC += linux-stm32 as other STM32MP1 boards are also affected.
On 11/13/20 12:19 PM, Ahmad Fatoum wrote:
> Hello Michał,
>
> On 11/13/20 1:20 AM, Michał Mirosław wrote:
>> It turns out that commit aea6cb99703e ("regulator: resolve supply
>> after creating regulator") exposed a number of issues in regulator
>> initialization and introduced a memory leak of its own. One uncovered
>> problem was already fixed by cf1ad559a20d ("regulator: defer probe when
>> trying to get voltage from unresolved supply"). This series fixes the
>> remaining ones and adds a two debugging aids to help in the future.
>>
>> The final patch adds a workaround to preexisting problem occurring with
>> regulators that have the same name as its supply_name. This worked
>> before by accident, so might be worth backporting. The error message is
>> left on purpose so that these configurations can be detected and fixed.
>>
>> (The first two patches are resends from Nov 5).
>>
>> (Series resent because of wrong arm-kernel ML address.)
>
> lxa-mc1 (STM32MP1 board with STPMIC) now manages to boot again with following
> new warning:
>
> stpmic1-regulator 5c002000.i2c:stpmic@33:regulators: Supply for VREF_DDR
>
> So for the whole series,
> Tested-by: Ahmad Fatoum <[email protected]> # stpmic1
>
> Thanks!
> Ahmad
>
>>
>> Michał Mirosław (4):
>> regulator: fix memory leak with repeated set_machine_constraints()
>> regulator: debug early supply resolving
>> regulator: avoid resolve_supply() infinite recursion
>> regulator: workaround self-referent regulators
>>
>> drivers/regulator/core.c | 40 ++++++++++++++++++++++++----------------
>> 1 file changed, 24 insertions(+), 16 deletions(-)
>>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |