Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3121474pxm; Mon, 28 Feb 2022 12:28:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6ktPXWOUqx5drbUnOfinvqSkJ/cxNrtRGgHeVGzoqL9O2ncQpbFComiNCWyRE/3eVp0Ch X-Received: by 2002:a17:903:291:b0:150:4197:7cf2 with SMTP id j17-20020a170903029100b0015041977cf2mr17474933plr.173.1646080137761; Mon, 28 Feb 2022 12:28:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646080137; cv=none; d=google.com; s=arc-20160816; b=KjsmoL8/AX2xPzmRCy3tkIFlb3SyrYke4p3pdujlwD3Pmg/e7cuZaglqXFXlMM/31p DCCWsMG7YLtYp7izaRW5/jXrtdO6HiLgqa4OzknDnty2Miz5h/xoJK9pIAmn84KYCNXo ADQ/k2E1tf9bKGBOLAeSe8qTag1nHWbPL6mG5NPMNYSK1+kKWQqbzHvTjJMA6N3/Vbzx Br4a5InXXJR+6ygZbClRpIPbwlUt2hQfeOWIx0OQdLlzA6MOPYwXTekNTvRn6rVzvm9A Wxrlvd7FRFySKJdLUpBFR5lOTSpFVUU8e/sG6/oUnnPcN2gZVFL3Sy3urD2tGEd1Cu+3 v88w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mCxawyPN6KRYTDCClsWI1h6jdnBe5QeH3y4o4F1jrpo=; b=zLazFr5+qm1vHECuIxvltuARH/oikzvyHGH83qdIWKn+lln8VVhZAocngbHVGnHDjq UsJLwQH9wMEI/E7YyrJASf1L2G34zvg95aVEyhithZnk7S4povTvLixt4fys6b/8ey1T LP6lm3QyOzmpIB06GWBQs1Sk7iApc3OEYbNhomXpSwnOtpAFuPIuPJDLEPn/qE25aIUv UdLayg1+eZ57yZy2CErIWR0my9/Oe/IvmQmI4aIzBeakwHfSj4vUnfq1Fi2h09vkuGx1 ZrJIcJqknD398zar1N3bHTdfTJ6+auuccyyzhCMDBGQu5Uir/T/iroWFEcxk+JdThnAt cNTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=3IAAXcoM; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 16-20020a056a00071000b004e027138621si10413043pfl.217.2022.02.28.12.28.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:28:57 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=3IAAXcoM; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 62242F4D0C; Mon, 28 Feb 2022 11:46:55 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229495AbiB1Trb (ORCPT + 99 others); Mon, 28 Feb 2022 14:47:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbiB1Tr2 (ORCPT ); Mon, 28 Feb 2022 14:47:28 -0500 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 922B01FEF91 for ; Mon, 28 Feb 2022 11:45:46 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id n13-20020a05600c3b8d00b0037bff8a24ebso49822wms.4 for ; Mon, 28 Feb 2022 11:45:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mCxawyPN6KRYTDCClsWI1h6jdnBe5QeH3y4o4F1jrpo=; b=3IAAXcoMB/QWoNPp+N9bkTEFatjqZ+FxiKj9BAVrYt8LgdvWno/p1QehD/UBSMSjuV 98O8OxoZd6+bNpZbykPbdt+ZENX7K8cFL56i/qmrA0p4P2jQHb9BSKs3BO7x1WU0Iyk0 73vzMa8pTN+73Mm3gfrqJ3EdW8SzPwG+U9wIlgC3KA5qW8Bg6uUydpuHvQFTB87OTUPA hRTHlII00H/4/r4lhXe6coKagre4g6u+sKqNjOyq6rbyp6xC3WiEhoH/wjZcuRSI123x 1RYwQHjCQRxW0ZsIFMxEAvHWfCEJ0D8rOd4aS0v2rcyAOljcqO3H9Qh/QkyBrjHP2mW8 z4gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mCxawyPN6KRYTDCClsWI1h6jdnBe5QeH3y4o4F1jrpo=; b=dFjb04mDt+Qgc54nsRZDhdIsu7NWjQCWkGaSAbGjuCkmrfw9/gzuwVVvqoRn9OfK3O f6hyGOGw0VqOho0ztZ2bwdAnBMoFVZvrbMF2Rw3EaajkEhGtClpculu06VIg2UbyOtQv ot9qburpYOFvGhhQANy9x+vvpyCrWSzrWj9IquQZUb4TEKrTx85jf+pWpFvpj9EXNQUt hQwNoA3aGtO7EnRV4xoac3IaggRUpwWM9yNDyjp16WE5mdtOs/u0lwqYCLKXDghoiJjm OPr6B5L8VWnH8U9YqK4DJa+WvWGuS7J52oGuH1lo/vFLKkAhYXDGajFNm8oXfo5BLkke StQQ== X-Gm-Message-State: AOAM533Bz3rMVE1UdX5zLxlLcpthWLDH7Hdfjq0AnaL5URae/3H+Wi4a XOroQ9ZD9TVLGz2OYzRPqmoonA== X-Received: by 2002:a05:600c:35c2:b0:381:6cbc:7192 with SMTP id r2-20020a05600c35c200b003816cbc7192mr3955472wmq.146.1646077245906; Mon, 28 Feb 2022 11:40:45 -0800 (PST) Received: from localhost.localdomain (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id v25-20020a05600c215900b0038117f41728sm274143wml.43.2022.02.28.11.40.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 11:40:45 -0800 (PST) From: Corentin Labbe To: heiko@sntech.de, herbert@gondor.apana.org.au, krzysztof.kozlowski@canonical.com, robh+dt@kernel.org Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Corentin Labbe Subject: [PATCH 03/16] crypto: rockchip: do not do custom power management Date: Mon, 28 Feb 2022 19:40:24 +0000 Message-Id: <20220228194037.1600509-4-clabbe@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220228194037.1600509-1-clabbe@baylibre.com> References: <20220228194037.1600509-1-clabbe@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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") Signed-off-by: Corentin Labbe --- drivers/crypto/rockchip/rk3288_crypto.c | 4 ++-- drivers/crypto/rockchip/rk3288_crypto.h | 2 -- drivers/crypto/rockchip/rk3288_crypto_ahash.c | 3 +-- drivers/crypto/rockchip/rk3288_crypto_skcipher.c | 5 +++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/rockchip/rk3288_crypto.c b/drivers/crypto/rockchip/rk3288_crypto.c index 21d3f1458584..4cff49b82983 100644 --- a/drivers/crypto/rockchip/rk3288_crypto.c +++ b/drivers/crypto/rockchip/rk3288_crypto.c @@ -394,8 +394,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; @@ -422,6 +421,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; diff --git a/drivers/crypto/rockchip/rk3288_crypto.h b/drivers/crypto/rockchip/rk3288_crypto.h index 97278c2574ff..2fa7131e4060 100644 --- a/drivers/crypto/rockchip/rk3288_crypto.h +++ b/drivers/crypto/rockchip/rk3288_crypto.h @@ -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); diff --git a/drivers/crypto/rockchip/rk3288_crypto_ahash.c b/drivers/crypto/rockchip/rk3288_crypto_ahash.c index ed03058497bc..49017d1fb510 100644 --- a/drivers/crypto/rockchip/rk3288_crypto_ahash.c +++ b/drivers/crypto/rockchip/rk3288_crypto_ahash.c @@ -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 = { diff --git a/drivers/crypto/rockchip/rk3288_crypto_skcipher.c b/drivers/crypto/rockchip/rk3288_crypto_skcipher.c index 5bbf0d2722e1..8c44a19eab75 100644 --- a/drivers/crypto/rockchip/rk3288_crypto_skcipher.c +++ b/drivers/crypto/rockchip/rk3288_crypto_skcipher.c @@ -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 = { -- 2.34.1