* [PATCH] regulator: reorder initialization steps in regulator_register()
@ 2016-04-12 10:31 Boris Brezillon
2016-04-12 10:39 ` Boris Brezillon
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Boris Brezillon @ 2016-04-12 10:31 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood
Cc: linux-kernel, Caesar Wang, Heiko Stübner, Stephen Barber,
Douglas Anderson, Brian Norris, Boris Brezillon
device_register() is calling ->get_voltage() as part of is sysfs attribute
initialization process, and this functions might need to know the regulator
constraints to return a valid value.
This is at least true for the pwm regulator driver (when operating in
continuous mode) which needs to know the minimum and maximum voltage values
to calculate the current voltage:
min_uV + (((max_uV - min_uV) * dutycycle) / 100);
Move device_register() after set_machine_constraints() to make sure those
constraints are correctly initialized when ->get_voltage() is called.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reported-by: Stephen Barber <smbarber@chromium.org>
---
drivers/regulator/core.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index e0b7642..8258568 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3950,13 +3950,6 @@ regulator_register(const struct regulator_desc *regulator_desc,
rdev->dev.parent = dev;
dev_set_name(&rdev->dev, "regulator.%lu",
(unsigned long) atomic_inc_return(®ulator_no));
- ret = device_register(&rdev->dev);
- if (ret != 0) {
- put_device(&rdev->dev);
- goto wash;
- }
-
- dev_set_drvdata(&rdev->dev, rdev);
/* set regulator constraints */
if (init_data)
@@ -3964,7 +3957,15 @@ regulator_register(const struct regulator_desc *regulator_desc,
ret = set_machine_constraints(rdev, constraints);
if (ret < 0)
- goto scrub;
+ goto wash;
+
+ ret = device_register(&rdev->dev);
+ if (ret != 0) {
+ put_device(&rdev->dev);
+ goto wash;
+ }
+
+ dev_set_drvdata(&rdev->dev, rdev);
if (init_data && init_data->supply_regulator)
rdev->supply_name = init_data->supply_regulator;
@@ -3993,8 +3994,6 @@ out:
unset_supplies:
unset_regulator_supplies(rdev);
-
-scrub:
regulator_ena_gpio_free(rdev);
device_unregister(&rdev->dev);
/* device core frees rdev */
@@ -4002,6 +4001,7 @@ scrub:
goto out;
wash:
+ kfree(rdev->constraints);
regulator_ena_gpio_free(rdev);
clean:
kfree(rdev);
--
2.5.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] regulator: reorder initialization steps in regulator_register()
2016-04-12 10:31 [PATCH] regulator: reorder initialization steps in regulator_register() Boris Brezillon
@ 2016-04-12 10:39 ` Boris Brezillon
2016-04-12 11:02 ` Caesar Wang
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2016-04-12 10:39 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood
Cc: linux-kernel, Caesar Wang, Heiko Stübner, Stephen Barber,
Douglas Anderson, Brian Norris
On Tue, 12 Apr 2016 12:31:00 +0200
Boris Brezillon <boris.brezillon@free-electrons.com> wrote:
> device_register() is calling ->get_voltage() as part of is sysfs attribute
^ its
> initialization process, and this functions might need to know the regulator
> constraints to return a valid value.
> This is at least true for the pwm regulator driver (when operating in
> continuous mode) which needs to know the minimum and maximum voltage values
> to calculate the current voltage:
>
> min_uV + (((max_uV - min_uV) * dutycycle) / 100);
>
> Move device_register() after set_machine_constraints() to make sure those
> constraints are correctly initialized when ->get_voltage() is called.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> Reported-by: Stephen Barber <smbarber@chromium.org>
> ---
> drivers/regulator/core.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index e0b7642..8258568 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -3950,13 +3950,6 @@ regulator_register(const struct regulator_desc *regulator_desc,
> rdev->dev.parent = dev;
> dev_set_name(&rdev->dev, "regulator.%lu",
> (unsigned long) atomic_inc_return(®ulator_no));
> - ret = device_register(&rdev->dev);
> - if (ret != 0) {
> - put_device(&rdev->dev);
> - goto wash;
> - }
> -
> - dev_set_drvdata(&rdev->dev, rdev);
>
> /* set regulator constraints */
> if (init_data)
> @@ -3964,7 +3957,15 @@ regulator_register(const struct regulator_desc *regulator_desc,
>
> ret = set_machine_constraints(rdev, constraints);
> if (ret < 0)
> - goto scrub;
> + goto wash;
> +
> + ret = device_register(&rdev->dev);
> + if (ret != 0) {
> + put_device(&rdev->dev);
> + goto wash;
> + }
> +
> + dev_set_drvdata(&rdev->dev, rdev);
>
> if (init_data && init_data->supply_regulator)
> rdev->supply_name = init_data->supply_regulator;
> @@ -3993,8 +3994,6 @@ out:
>
> unset_supplies:
> unset_regulator_supplies(rdev);
> -
> -scrub:
> regulator_ena_gpio_free(rdev);
> device_unregister(&rdev->dev);
> /* device core frees rdev */
> @@ -4002,6 +4001,7 @@ scrub:
> goto out;
>
> wash:
> + kfree(rdev->constraints);
> regulator_ena_gpio_free(rdev);
> clean:
> kfree(rdev);
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] regulator: reorder initialization steps in regulator_register()
2016-04-12 10:31 [PATCH] regulator: reorder initialization steps in regulator_register() Boris Brezillon
2016-04-12 10:39 ` Boris Brezillon
@ 2016-04-12 11:02 ` Caesar Wang
2016-04-13 6:41 ` Applied "regulator: reorder initialization steps in regulator_register()" to the regulator tree Mark Brown
2016-04-13 6:41 ` [PATCH] regulator: reorder initialization steps in regulator_register() Mark Brown
3 siblings, 0 replies; 6+ messages in thread
From: Caesar Wang @ 2016-04-12 11:02 UTC (permalink / raw)
To: Boris Brezillon, Mark Brown, Liam Girdwood
Cc: linux-kernel, Heiko Stübner, Stephen Barber,
Douglas Anderson, Brian Norris
在 2016年04月12日 18:31, Boris Brezillon 写道:
> device_register() is calling ->get_voltage() as part of is sysfs attribute
> initialization process, and this functions might need to know the regulator
> constraints to return a valid value.
> This is at least true for the pwm regulator driver (when operating in
> continuous mode) which needs to know the minimum and maximum voltage values
> to calculate the current voltage:
>
> min_uV + (((max_uV - min_uV) * dutycycle) / 100);
>
> Move device_register() after set_machine_constraints() to make sure those
> constraints are correctly initialized when ->get_voltage() is called.
>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> Reported-by: Stephen Barber <smbarber@chromium.org>
Tested-by: Caesar Wang <wxt@rock-chips.com>
Yep, do many reboot tests on my rk3399 evb board.
that's seem fix the crash issue.
[ 0.744584] task: ffffffc0edab8000 ti: ffffffc0edac0000 task.ti:
ffffffc0edac0000 [ 0.752803]
PC is at pwm_regulator_get_voltage+0x28/0x54 [ 0.758628]
LR is at pwm_regulator_get_voltage+0x14/0x54
....
As the same reported on https://patchwork.kernel.org/patch/8702441/
> ---
> drivers/regulator/core.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index e0b7642..8258568 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -3950,13 +3950,6 @@ regulator_register(const struct regulator_desc *regulator_desc,
> rdev->dev.parent = dev;
> dev_set_name(&rdev->dev, "regulator.%lu",
> (unsigned long) atomic_inc_return(®ulator_no));
> - ret = device_register(&rdev->dev);
> - if (ret != 0) {
> - put_device(&rdev->dev);
> - goto wash;
> - }
> -
> - dev_set_drvdata(&rdev->dev, rdev);
>
> /* set regulator constraints */
> if (init_data)
> @@ -3964,7 +3957,15 @@ regulator_register(const struct regulator_desc *regulator_desc,
>
> ret = set_machine_constraints(rdev, constraints);
> if (ret < 0)
> - goto scrub;
> + goto wash;
> +
> + ret = device_register(&rdev->dev);
> + if (ret != 0) {
> + put_device(&rdev->dev);
> + goto wash;
> + }
> +
> + dev_set_drvdata(&rdev->dev, rdev);
>
> if (init_data && init_data->supply_regulator)
> rdev->supply_name = init_data->supply_regulator;
> @@ -3993,8 +3994,6 @@ out:
>
> unset_supplies:
> unset_regulator_supplies(rdev);
> -
> -scrub:
> regulator_ena_gpio_free(rdev);
> device_unregister(&rdev->dev);
> /* device core frees rdev */
> @@ -4002,6 +4001,7 @@ scrub:
> goto out;
>
> wash:
> + kfree(rdev->constraints);
> regulator_ena_gpio_free(rdev);
> clean:
> kfree(rdev);
>
> --
> Thanks,
> Caesar
^ permalink raw reply [flat|nested] 6+ messages in thread
* Applied "regulator: reorder initialization steps in regulator_register()" to the regulator tree
2016-04-12 10:31 [PATCH] regulator: reorder initialization steps in regulator_register() Boris Brezillon
2016-04-12 10:39 ` Boris Brezillon
2016-04-12 11:02 ` Caesar Wang
@ 2016-04-13 6:41 ` Mark Brown
2016-04-13 6:41 ` [PATCH] regulator: reorder initialization steps in regulator_register() Mark Brown
3 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2016-04-13 6:41 UTC (permalink / raw)
To: Boris Brezillon
Cc: Stephen Barber, Caesar Wang, Mark Brown, Mark Brown,
Liam Girdwood, linux-kernel, Caesar Wang, Heiko Stübner,
Stephen Barber, Douglas Anderson, Brian Norris
The patch
regulator: reorder initialization steps in regulator_register()
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 469b640e4f4a28bdd50f0ac1d2b310907afb464c Mon Sep 17 00:00:00 2001
From: Boris Brezillon <boris.brezillon@free-electrons.com>
Date: Tue, 12 Apr 2016 12:31:00 +0200
Subject: [PATCH] regulator: reorder initialization steps in
regulator_register()
device_register() is calling ->get_voltage() as part of it's sysfs attribute
initialization process, and this functions might need to know the regulator
constraints to return a valid value.
This is at least true for the pwm regulator driver (when operating in
continuous mode) which needs to know the minimum and maximum voltage values
to calculate the current voltage:
min_uV + (((max_uV - min_uV) * dutycycle) / 100);
Move device_register() after set_machine_constraints() to make sure those
constraints are correctly initialized when ->get_voltage() is called.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reported-by: Stephen Barber <smbarber@chromium.org>
Tested-by: Caesar Wang <wxt@rock-chips.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
drivers/regulator/core.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index e0b764284773..8258568c793a 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3950,13 +3950,6 @@ regulator_register(const struct regulator_desc *regulator_desc,
rdev->dev.parent = dev;
dev_set_name(&rdev->dev, "regulator.%lu",
(unsigned long) atomic_inc_return(®ulator_no));
- ret = device_register(&rdev->dev);
- if (ret != 0) {
- put_device(&rdev->dev);
- goto wash;
- }
-
- dev_set_drvdata(&rdev->dev, rdev);
/* set regulator constraints */
if (init_data)
@@ -3964,7 +3957,15 @@ regulator_register(const struct regulator_desc *regulator_desc,
ret = set_machine_constraints(rdev, constraints);
if (ret < 0)
- goto scrub;
+ goto wash;
+
+ ret = device_register(&rdev->dev);
+ if (ret != 0) {
+ put_device(&rdev->dev);
+ goto wash;
+ }
+
+ dev_set_drvdata(&rdev->dev, rdev);
if (init_data && init_data->supply_regulator)
rdev->supply_name = init_data->supply_regulator;
@@ -3993,8 +3994,6 @@ out:
unset_supplies:
unset_regulator_supplies(rdev);
-
-scrub:
regulator_ena_gpio_free(rdev);
device_unregister(&rdev->dev);
/* device core frees rdev */
@@ -4002,6 +4001,7 @@ scrub:
goto out;
wash:
+ kfree(rdev->constraints);
regulator_ena_gpio_free(rdev);
clean:
kfree(rdev);
--
2.8.0.rc3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] regulator: reorder initialization steps in regulator_register()
2016-04-12 10:31 [PATCH] regulator: reorder initialization steps in regulator_register() Boris Brezillon
` (2 preceding siblings ...)
2016-04-13 6:41 ` Applied "regulator: reorder initialization steps in regulator_register()" to the regulator tree Mark Brown
@ 2016-04-13 6:41 ` Mark Brown
2016-04-14 16:21 ` Boris Brezillon
3 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2016-04-13 6:41 UTC (permalink / raw)
To: Boris Brezillon
Cc: Liam Girdwood, linux-kernel, Caesar Wang, Heiko Stübner,
Stephen Barber, Douglas Anderson, Brian Norris
[-- Attachment #1: Type: text/plain, Size: 1228 bytes --]
On Tue, Apr 12, 2016 at 12:31:00PM +0200, Boris Brezillon wrote:
> device_register() is calling ->get_voltage() as part of is sysfs attribute
> initialization process, and this functions might need to know the regulator
> constraints to return a valid value.
I've pushed this as a signed tag:
The following changes since commit f55532a0c0b8bb6148f4e07853b876ef73bc69ca:
Linux 4.6-rc1 (2016-03-26 16:03:24 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git tags/regulator-sysfs-init-order
for you to fetch changes up to 469b640e4f4a28bdd50f0ac1d2b310907afb464c:
regulator: reorder initialization steps in regulator_register() (2016-04-13 07:33:44 +0100)
----------------------------------------------------------------
regulator: Pull the sysfs init after constraint setup
The sysfs attributes can indirectly use information from the constraints
so can trigger warnings with some systems.
----------------------------------------------------------------
Boris Brezillon (1):
regulator: reorder initialization steps in regulator_register()
drivers/regulator/core.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] regulator: reorder initialization steps in regulator_register()
2016-04-13 6:41 ` [PATCH] regulator: reorder initialization steps in regulator_register() Mark Brown
@ 2016-04-14 16:21 ` Boris Brezillon
0 siblings, 0 replies; 6+ messages in thread
From: Boris Brezillon @ 2016-04-14 16:21 UTC (permalink / raw)
To: Thierry Reding
Cc: Mark Brown, Liam Girdwood, linux-kernel, Caesar Wang,
Heiko Stübner, Stephen Barber, Douglas Anderson,
Brian Norris
Hi Thierry,
On Wed, 13 Apr 2016 07:41:40 +0100
Mark Brown <broonie@kernel.org> wrote:
> On Tue, Apr 12, 2016 at 12:31:00PM +0200, Boris Brezillon wrote:
> > device_register() is calling ->get_voltage() as part of is sysfs attribute
> > initialization process, and this functions might need to know the regulator
> > constraints to return a valid value.
I realize you were not CCed for this patch, but if we want all the
pwm-atomic support changes (including the pwm-regulator ones) to go
through your tree, you'll have to pull the following branch before
applying "regulator: pwm: retrieve correct voltage".
>
> I've pushed this as a signed tag:
>
> The following changes since commit f55532a0c0b8bb6148f4e07853b876ef73bc69ca:
>
> Linux 4.6-rc1 (2016-03-26 16:03:24 -0700)
>
> are available in the git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git tags/regulator-sysfs-init-order
>
> for you to fetch changes up to 469b640e4f4a28bdd50f0ac1d2b310907afb464c:
>
> regulator: reorder initialization steps in regulator_register() (2016-04-13 07:33:44 +0100)
>
> ----------------------------------------------------------------
> regulator: Pull the sysfs init after constraint setup
>
> The sysfs attributes can indirectly use information from the constraints
> so can trigger warnings with some systems.
>
> ----------------------------------------------------------------
> Boris Brezillon (1):
> regulator: reorder initialization steps in regulator_register()
>
> drivers/regulator/core.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
Thanks,
Boris
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-04-14 16:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-12 10:31 [PATCH] regulator: reorder initialization steps in regulator_register() Boris Brezillon
2016-04-12 10:39 ` Boris Brezillon
2016-04-12 11:02 ` Caesar Wang
2016-04-13 6:41 ` Applied "regulator: reorder initialization steps in regulator_register()" to the regulator tree Mark Brown
2016-04-13 6:41 ` [PATCH] regulator: reorder initialization steps in regulator_register() Mark Brown
2016-04-14 16:21 ` Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox