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: <AM6PR04MB496625ACFE460F756C49270B80D30@AM6PR04MB4966.eurprd04.prod.outlook.com>
Date:   Thu, 23 Apr 2020 10:39:42 +0000
From:   Aisheng Dong <aisheng.dong@....com>
To:     Peng Fan <peng.fan@....com>,
        "broonie@...nel.org" <broonie@...nel.org>
CC:     "rafael@...nel.org" <rafael@...nel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        dl-linux-imx <linux-imx@....com>,
        "S.j. Wang" <shengjiu.wang@....com>
Subject: RE: [PATCH] regmap: mmio: prepare/unprepare clk only when read/write

> From: Peng Fan <peng.fan@....com>
> Sent: Thursday, April 23, 2020 1:47 PM
> 
> use clk_prepare at the very beginning will invoke pm runtime resume, if the clk is
> binded with a power domain. This will cause runtime power high. Let's use
> clk_prepare_enable and clk_disable_unprepare when read/write to avoid the
> runtime power issue.
> 
> Signed-off-by: Peng Fan <peng.fan@....com>

I wonder you may can't do that because mmio bus is using spinlock.

Regards
Aisheng

> ---
>  drivers/base/regmap/regmap-mmio.c | 19 +++++--------------
>  1 file changed, 5 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/base/regmap/regmap-mmio.c
> b/drivers/base/regmap/regmap-mmio.c
> index af967d8f975e..a1ad7419c4a3 100644
> --- a/drivers/base/regmap/regmap-mmio.c
> +++ b/drivers/base/regmap/regmap-mmio.c
> @@ -118,7 +118,7 @@ static int regmap_mmio_write(void *context, unsigned
> int reg, unsigned int val)
>  	int ret;
> 
>  	if (!IS_ERR(ctx->clk)) {
> -		ret = clk_enable(ctx->clk);
> +		ret = clk_prepare_enable(ctx->clk);
>  		if (ret < 0)
>  			return ret;
>  	}
> @@ -126,7 +126,7 @@ static int regmap_mmio_write(void *context, unsigned
> int reg, unsigned int val)
>  	ctx->reg_write(ctx, reg, val);
> 
>  	if (!IS_ERR(ctx->clk))
> -		clk_disable(ctx->clk);
> +		clk_disable_unprepare(ctx->clk);
> 
>  	return 0;
>  }
> @@ -175,7 +175,7 @@ static int regmap_mmio_read(void *context, unsigned
> int reg, unsigned int *val)
>  	int ret;
> 
>  	if (!IS_ERR(ctx->clk)) {
> -		ret = clk_enable(ctx->clk);
> +		ret = clk_prepare_enable(ctx->clk);
>  		if (ret < 0)
>  			return ret;
>  	}
> @@ -183,7 +183,7 @@ static int regmap_mmio_read(void *context, unsigned
> int reg, unsigned int *val)
>  	*val = ctx->reg_read(ctx, reg);
> 
>  	if (!IS_ERR(ctx->clk))
> -		clk_disable(ctx->clk);
> +		clk_disable_unprepare(ctx->clk);
> 
>  	return 0;
>  }
> @@ -193,7 +193,6 @@ static void regmap_mmio_free_context(void *context)
>  	struct regmap_mmio_context *ctx = context;
> 
>  	if (!IS_ERR(ctx->clk)) {
> -		clk_unprepare(ctx->clk);
>  		if (!ctx->attached_clk)
>  			clk_put(ctx->clk);
>  	}
> @@ -305,12 +304,6 @@ static struct regmap_mmio_context
> *regmap_mmio_gen_context(struct device *dev,
>  		goto err_free;
>  	}
> 
> -	ret = clk_prepare(ctx->clk);
> -	if (ret < 0) {
> -		clk_put(ctx->clk);
> -		goto err_free;
> -	}
> -
>  	return ctx;
> 
>  err_free:
> @@ -361,7 +354,7 @@ int regmap_mmio_attach_clk(struct regmap *map,
> struct clk *clk)
>  	ctx->clk = clk;
>  	ctx->attached_clk = true;
> 
> -	return clk_prepare(ctx->clk);
> +	return 0;
>  }
>  EXPORT_SYMBOL_GPL(regmap_mmio_attach_clk);
> 
> @@ -369,8 +362,6 @@ void regmap_mmio_detach_clk(struct regmap *map)
> {
>  	struct regmap_mmio_context *ctx = map->bus_context;
> 
> -	clk_unprepare(ctx->clk);
> -
>  	ctx->attached_clk = false;
>  	ctx->clk = NULL;
>  }
> --
> 2.16.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ