From: Caesar Wang <caesar.upstream@gmail.com>
To: Boris Brezillon <boris.brezillon@free-electrons.com>,
Mark Brown <broonie@kernel.org>,
Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-kernel@vger.kernel.org, "Heiko Stübner" <heiko@sntech.de>,
"Stephen Barber" <smbarber@chromium.org>,
"Douglas Anderson" <dianders@chromium.org>,
"Brian Norris" <briannorris@chromium.org>
Subject: Re: [PATCH] regulator: reorder initialization steps in regulator_register()
Date: Tue, 12 Apr 2016 19:02:34 +0800 [thread overview]
Message-ID: <570CD5CA.5040400@gmail.com> (raw)
In-Reply-To: <1460457060-3946-1-git-send-email-boris.brezillon@free-electrons.com>
在 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
next prev parent reply other threads:[~2016-04-12 11:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=570CD5CA.5040400@gmail.com \
--to=caesar.upstream@gmail.com \
--cc=boris.brezillon@free-electrons.com \
--cc=briannorris@chromium.org \
--cc=broonie@kernel.org \
--cc=dianders@chromium.org \
--cc=heiko@sntech.de \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=smbarber@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox