Re: [PATCH] regulator: vctrl-regulator: Avoid deadlock getting and setting the voltage

From: Dmitry Osipenko
Date: Fri Jan 17 2020 - 11:28:09 EST


16.01.2020 12:45, Enric Balletbo i Serra ÐÐÑÐÑ:
> `cat /sys/kernel/debug/regulator/regulator_summary` ends on a deadlock
> when you have a voltage controlled regulator (vctrl).
>
> The problem is that the vctrl_get_voltage() and vctrl_set_voltage() calls the
> regulator_get_voltage() and regulator_set_voltage() and that will try to lock
> again the dependent regulators (the regulator supplying the control voltage).
>
> Fix the issue by exporting the unlocked version of the regulator_get_voltage()
> and regulator_set_voltage() API so drivers that need it, like the voltage
> controlled regulator driver can use it.
>
> Fixes: f8702f9e4aa7 ("regulator: core: Use ww_mutex for regulators locking")
> Reported-by: Douglas Anderson <dianders@xxxxxxxxxxxx>
> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@xxxxxxxxxxxxx>
> ---
>
> drivers/regulator/core.c | 2 ++
> drivers/regulator/vctrl-regulator.c | 38 +++++++++++++++++------------
> 2 files changed, 25 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 03d79fee2987..e7d167ce326c 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -3470,6 +3470,7 @@ int regulator_set_voltage_rdev(struct regulator_dev *rdev, int min_uV,
> out:
> return ret;
> }
> +EXPORT_SYMBOL(regulator_set_voltage_rdev);
>
> static int regulator_limit_voltage_step(struct regulator_dev *rdev,
> int *current_uV, int *min_uV)
> @@ -4034,6 +4035,7 @@ int regulator_get_voltage_rdev(struct regulator_dev *rdev)
> return ret;
> return ret - rdev->constraints->uV_offset;
> }
> +EXPORT_SYMBOL(regulator_get_voltage_rdev);

I think it should be EXPORT_SYMBOL_GPL().