crypto: rockchip - do not do custom power management
authorCorentin Labbe <clabbe@baylibre.com>
Tue, 27 Sep 2022 07:54:41 +0000 (07:54 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:14:22 +0000 (13:14 +0100)
[ Upstream commit c50ef1411c8cbad0c7db100c477126076b6e3348 ]

The clock enable/disable at tfm init/exit is fragile,
if 2 tfm are init in the same time and one is removed just after,
it will leave the hardware uncloked even if a user remains.

Instead simply enable clocks at probe time.
We will do PM later.

Fixes: ce0183cb6464b ("crypto: rockchip - switch to skcipher API")
Reviewed-by: John Keeping <john@metanate.com>
Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/crypto/rockchip/rk3288_crypto.c
drivers/crypto/rockchip/rk3288_crypto.h
drivers/crypto/rockchip/rk3288_crypto_ahash.c
drivers/crypto/rockchip/rk3288_crypto_skcipher.c

index 35d7306..5f8444b 100644 (file)
@@ -395,8 +395,7 @@ static int rk_crypto_probe(struct platform_device *pdev)
                     rk_crypto_done_task_cb, (unsigned long)crypto_info);
        crypto_init_queue(&crypto_info->queue, 50);
 
-       crypto_info->enable_clk = rk_crypto_enable_clk;
-       crypto_info->disable_clk = rk_crypto_disable_clk;
+       rk_crypto_enable_clk(crypto_info);
        crypto_info->load_data = rk_load_data;
        crypto_info->unload_data = rk_unload_data;
        crypto_info->enqueue = rk_crypto_enqueue;
@@ -423,6 +422,7 @@ static int rk_crypto_remove(struct platform_device *pdev)
        struct rk_crypto_info *crypto_tmp = platform_get_drvdata(pdev);
 
        rk_crypto_unregister();
+       rk_crypto_disable_clk(crypto_tmp);
        tasklet_kill(&crypto_tmp->done_task);
        tasklet_kill(&crypto_tmp->queue_task);
        return 0;
index 97278c2..2fa7131 100644 (file)
@@ -220,8 +220,6 @@ struct rk_crypto_info {
        int (*start)(struct rk_crypto_info *dev);
        int (*update)(struct rk_crypto_info *dev);
        void (*complete)(struct crypto_async_request *base, int err);
-       int (*enable_clk)(struct rk_crypto_info *dev);
-       void (*disable_clk)(struct rk_crypto_info *dev);
        int (*load_data)(struct rk_crypto_info *dev,
                         struct scatterlist *sg_src,
                         struct scatterlist *sg_dst);
index ed03058..49017d1 100644 (file)
@@ -301,7 +301,7 @@ static int rk_cra_hash_init(struct crypto_tfm *tfm)
                                 sizeof(struct rk_ahash_rctx) +
                                 crypto_ahash_reqsize(tctx->fallback_tfm));
 
-       return tctx->dev->enable_clk(tctx->dev);
+       return 0;
 }
 
 static void rk_cra_hash_exit(struct crypto_tfm *tfm)
@@ -309,7 +309,6 @@ static void rk_cra_hash_exit(struct crypto_tfm *tfm)
        struct rk_ahash_ctx *tctx = crypto_tfm_ctx(tfm);
 
        free_page((unsigned long)tctx->dev->addr_vir);
-       return tctx->dev->disable_clk(tctx->dev);
 }
 
 struct rk_crypto_tmp rk_ahash_sha1 = {
index 5bbf0d2..8c44a19 100644 (file)
@@ -388,8 +388,10 @@ static int rk_ablk_init_tfm(struct crypto_skcipher *tfm)
        ctx->dev->update = rk_ablk_rx;
        ctx->dev->complete = rk_crypto_complete;
        ctx->dev->addr_vir = (char *)__get_free_page(GFP_KERNEL);
+       if (!ctx->dev->addr_vir)
+               return -ENOMEM;
 
-       return ctx->dev->addr_vir ? ctx->dev->enable_clk(ctx->dev) : -ENOMEM;
+       return 0;
 }
 
 static void rk_ablk_exit_tfm(struct crypto_skcipher *tfm)
@@ -397,7 +399,6 @@ static void rk_ablk_exit_tfm(struct crypto_skcipher *tfm)
        struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
 
        free_page((unsigned long)ctx->dev->addr_vir);
-       ctx->dev->disable_clk(ctx->dev);
 }
 
 struct rk_crypto_tmp rk_ecb_aes_alg = {