lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPDyKFrS3wdYs3AQtjZEOsLzNvxgy1n3EfxZ+a8w8J8rH8kQ-w@mail.gmail.com>
Date:   Mon, 24 May 2021 15:59:56 +0200
From:   Ulf Hansson <ulf.hansson@...aro.org>
To:     Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc:     Shawn Guo <shawnguo@...nel.org>,
        Sascha Hauer <s.hauer@...gutronix.de>,
        Sascha Hauer <kernel@...gutronix.de>,
        Fabio Estevam <festevam@...il.com>,
        dl-linux-imx <linux-imx@....com>,
        Wolfram Sang <wsa+renesas@...g-engineering.com>,
        Doug Anderson <dianders@...omium.org>,
        Rui Miguel Silva <rmfrfs@...il.com>,
        Chris Ball <cjb@...top.org>,
        Linux ARM <linux-arm-kernel@...ts.infradead.org>,
        linux-mmc <linux-mmc@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] mmc: mxs-mmc: Disable the 'reg_vmmc' regulator when needed

On Fri, 21 May 2021 at 14:36, Christophe JAILLET
<christophe.jaillet@...adoo.fr> wrote:
>
> The 'reg_vmmc' regulator is never disabled. Neither in the error handling
> of the probe, nor in the remove function.
>
> Add a managed action to do the required clean-up before a 'regulator_put()'
> call.
>
> Fixes: 4dc5a79f1350 ("mmc: mxs-mmc: enable regulator for mmc slot")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> ---
>  drivers/mmc/host/mxs-mmc.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 947581de7860..b043d53dd728 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -552,6 +552,13 @@ static const struct of_device_id mxs_mmc_dt_ids[] = {
>  };
>  MODULE_DEVICE_TABLE(of, mxs_mmc_dt_ids);
>
> +static void regulator_disable_action(void *_data)
> +{
> +       struct regulator *regulator = _data;
> +
> +       regulator_disable(regulator);
> +}
> +
>  static int mxs_mmc_probe(struct platform_device *pdev)
>  {
>         struct device_node *np = pdev->dev.of_node;
> @@ -591,6 +598,10 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>                                 "Failed to enable vmmc regulator: %d\n", ret);
>                         goto out_mmc_free;
>                 }
> +               ret = devm_add_action_or_reset(&pdev->dev,
> +                                       regulator_disable_action, reg_vmmc);
> +               if (ret)
> +                       goto out_mmc_free;

Even if this improves the behaviour, there is a standardized way for
how we deal with regulators for mmc.

1. Call mmc_regulator_get_supply() during probe to fetch the optional
regulator. If a regulator is found a corresponding OCR mask, in
host->ocr_avail is assigned.

2. In the ->set_ios() callback, invoke mmc_regulator_set_ocr(). This
will also set the correct voltage-level and turn on/off the regulator,
depending on the requested OCR/voltage-level.

>         }
>
>         ssp->clk = devm_clk_get(&pdev->dev, NULL);
> --
> 2.30.2
>

Kind regards
Uffe

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ