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: <CAO4ZVTM99FksM71BAiraYj7eyREO1Qi=L1NFzEkNmMgBmphBww@mail.gmail.com>
Date:   Thu, 12 Sep 2019 08:35:51 +0200
From:   Maxime Ripard <maxime.ripard@...ndra.org>
To:     Corentin Labbe <clabbe.montjoie@...il.com>
Cc:     davem@...emloft.net, herbert@...dor.apana.org.au,
        Maxime Ripard <mripard@...nel.org>,
        Chen-Yu Tsai <wens@...e.org>,
        linux-arm-kernel@...ts.infradead.org, linux-crypto@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-sunxi@...glegroups.com
Subject: Re: [PATCH 2/2] crypto: sun4i-ss: enable pm_runtime

Hi,

Le mer. 11 sept. 2019 à 13:46, Corentin Labbe
<clabbe.montjoie@...il.com> a écrit :
>
> This patch enables power management on the Security System.
>
> Signed-off-by: Corentin Labbe <clabbe.montjoie@...il.com>
> ---
>  drivers/crypto/sunxi-ss/sun4i-ss-cipher.c |  5 +++
>  drivers/crypto/sunxi-ss/sun4i-ss-core.c   | 42 ++++++++++++++++++++++-
>  2 files changed, 46 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
> index fa4b1b47822e..1fedec9e83b0 100644
> --- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
> +++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
> @@ -10,6 +10,8 @@
>   *
>   * You could find the datasheet in Documentation/arm/sunxi.rst
>   */
> +
> +#include <linux/pm_runtime.h>
>  #include "sun4i-ss.h"
>
>  static int noinline_for_stack sun4i_ss_opti_poll(struct skcipher_request *areq)
> @@ -497,13 +499,16 @@ int sun4i_ss_cipher_init(struct crypto_tfm *tfm)
>                 return PTR_ERR(op->fallback_tfm);
>         }
>
> +       pm_runtime_get_sync(op->ss->dev);
>         return 0;
>  }
>
>  void sun4i_ss_cipher_exit(struct crypto_tfm *tfm)
>  {
>         struct sun4i_tfm_ctx *op = crypto_tfm_ctx(tfm);
> +
>         crypto_free_sync_skcipher(op->fallback_tfm);
> +       pm_runtime_put_sync(op->ss->dev);
>  }
>
>  /* check and set the AES key, prepare the mode to be used */
> diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-core.c b/drivers/crypto/sunxi-ss/sun4i-ss-core.c
> index 2c9ff01dddfc..5e6e1a308f60 100644
> --- a/drivers/crypto/sunxi-ss/sun4i-ss-core.c
> +++ b/drivers/crypto/sunxi-ss/sun4i-ss-core.c
> @@ -14,6 +14,7 @@
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
>  #include <crypto/scatterwalk.h>
>  #include <linux/scatterlist.h>
>  #include <linux/interrupt.h>
> @@ -258,6 +259,37 @@ static int sun4i_ss_enable(struct sun4i_ss_ctx *ss)
>         return err;
>  }
>
> +#ifdef CONFIG_PM
> +static int sun4i_ss_pm_suspend(struct device *dev)
> +{
> +       struct sun4i_ss_ctx *ss = dev_get_drvdata(dev);
> +
> +       sun4i_ss_disable(ss);
> +       return 0;
> +}
> +
> +static int sun4i_ss_pm_resume(struct device *dev)
> +{
> +       struct sun4i_ss_ctx *ss = dev_get_drvdata(dev);
> +
> +       return sun4i_ss_enable(ss);
> +}
> +#endif
> +
> +const struct dev_pm_ops sun4i_ss_pm_ops = {
> +       SET_RUNTIME_PM_OPS(sun4i_ss_pm_suspend, sun4i_ss_pm_resume, NULL)
> +};
> +
> +static void sun4i_ss_pm_init(struct sun4i_ss_ctx *ss)
> +{
> +       pm_runtime_use_autosuspend(ss->dev);
> +       pm_runtime_set_autosuspend_delay(ss->dev, 1000);
> +
> +       pm_runtime_get_noresume(ss->dev);
> +       pm_runtime_set_active(ss->dev);
> +       pm_runtime_enable(ss->dev);
> +}

It's not really clear to me what you're doing here? Can you explain?

The rest looks fine.

Maxime

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ