All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: linux-crypto@vger.kernel.org,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S . Miller" <davem@davemloft.net>
Cc: phone-devel@vger.kernel.org, Stefan Hansson <newbyte@disroot.org>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH v3 08/16] crypto: ux500/hash: Stop saving/restoring compulsively
Date: Tue, 16 Aug 2022 16:00:41 +0200	[thread overview]
Message-ID: <20220816140049.102306-9-linus.walleij@linaro.org> (raw)
In-Reply-To: <20220816140049.102306-1-linus.walleij@linaro.org>

The driver is saving/restoring state very intensively, because
of assumptions that suspend/resume can be called at any time.
(Android behaviours.) We removed the state save/restore from
the PM hooks and will use runtime PM for this instead so get
rid of this.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v2->v3:
- Rebased on v6.0-rc1
ChangeLog v1->v2:
- No changes
---
 drivers/crypto/ux500/hash/hash_alg.h  |  1 -
 drivers/crypto/ux500/hash/hash_core.c | 44 +++------------------------
 2 files changed, 4 insertions(+), 41 deletions(-)

diff --git a/drivers/crypto/ux500/hash/hash_alg.h b/drivers/crypto/ux500/hash/hash_alg.h
index d124fd17519f..d9d59dba6e6e 100644
--- a/drivers/crypto/ux500/hash/hash_alg.h
+++ b/drivers/crypto/ux500/hash/hash_alg.h
@@ -369,7 +369,6 @@ struct hash_device_data {
 	spinlock_t		power_state_lock;
 	struct regulator	*regulator;
 	struct clk		*clk;
-	struct hash_state	state; /* Used for saving and resuming state */
 	struct hash_dma		dma;
 };
 
diff --git a/drivers/crypto/ux500/hash/hash_core.c b/drivers/crypto/ux500/hash/hash_core.c
index c5cd9a5f7e5c..844ef70301d5 100644
--- a/drivers/crypto/ux500/hash/hash_core.c
+++ b/drivers/crypto/ux500/hash/hash_core.c
@@ -674,19 +674,7 @@ static int hash_process_data(struct hash_device_data *device_data,
 			break;
 		}
 
-		if (req_ctx->hw_initialized) {
-			ret = hash_resume_state(device_data,
-						&device_data->state);
-			memmove(req_ctx->state.buffer,
-				device_data->state.buffer,
-				HASH_BLOCK_SIZE);
-			if (ret) {
-				dev_err(device_data->dev,
-					"%s: hash_resume_state() failed!\n",
-					__func__);
-				goto out;
-			}
-		} else {
+		if (!req_ctx->hw_initialized) {
 			ret = init_hash_hw(device_data, ctx);
 			if (ret) {
 				dev_err(device_data->dev,
@@ -725,17 +713,6 @@ static int hash_process_data(struct hash_device_data *device_data,
 		msg_length -= (HASH_BLOCK_SIZE - *index);
 		*index = 0;
 
-		ret = hash_save_state(device_data,
-				      &device_data->state);
-
-		memmove(device_data->state.buffer,
-			req_ctx->state.buffer,
-			HASH_BLOCK_SIZE);
-		if (ret) {
-			dev_err(device_data->dev, "%s: hash_save_state() failed!\n",
-				__func__);
-			goto out;
-		}
 	} while (msg_length != 0);
 out:
 
@@ -759,15 +736,7 @@ static int hash_dma_final(struct ahash_request *req)
 	dev_dbg(device_data->dev, "%s: (ctx=0x%lx)!\n", __func__,
 		(unsigned long)ctx);
 
-	if (req_ctx->hw_initialized) {
-		ret = hash_resume_state(device_data, &device_data->state);
-
-		if (ret) {
-			dev_err(device_data->dev, "%s: hash_resume_state() failed!\n",
-				__func__);
-			goto out;
-		}
-	} else {
+	if (!req_ctx->hw_initialized) {
 		ret = hash_setconfiguration(device_data, ctx);
 		if (ret) {
 			dev_err(device_data->dev,
@@ -858,13 +827,8 @@ static int hash_hw_final(struct ahash_request *req)
 		(unsigned long)ctx);
 
 	if (req_ctx->hw_initialized) {
-		ret = hash_resume_state(device_data, &device_data->state);
-
-		if (ret) {
-			dev_err(device_data->dev,
-				"%s: hash_resume_state() failed!\n", __func__);
-			goto out;
-		}
+		/* That's fine, result is in HW */
+		dev_dbg(device_data->dev, "%s hw initialized\n", __func__);
 	} else if (req->nbytes == 0 && ctx->keylen == 0) {
 		u8 zero_hash[SHA256_DIGEST_SIZE];
 		u32 zero_hash_size = 0;
-- 
2.37.2


  parent reply	other threads:[~2022-08-16 14:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16 14:00 [PATCH v3 00/16] Ux500 hash cleanup Linus Walleij
2022-08-16 14:00 ` [PATCH v3 01/16] crypto: ux500/hash: Pass ctx to hash_setconfiguration() Linus Walleij
2022-08-16 14:00 ` [PATCH v3 02/16] crypto: ux500/hash: Get rid of custom device list Linus Walleij
2022-08-16 14:00 ` [PATCH v3 03/16] crypto: ux500/hash: Pass context to zero message digest Linus Walleij
2022-08-16 14:00 ` [PATCH v3 04/16] crypto: ux500/hash: Drop custom state save/restore Linus Walleij
2022-08-16 14:00 ` [PATCH v3 05/16] crypto: ux500/hash: Drop bit index Linus Walleij
2022-08-16 14:00 ` [PATCH v3 06/16] crypto: ux500/hash: Break while/do instead of if/else Linus Walleij
2022-08-16 14:00 ` [PATCH v3 07/16] crypto: ux500/hash: Rename and switch type of member Linus Walleij
2022-08-16 14:00 ` Linus Walleij [this message]
2022-08-16 14:00 ` [PATCH v3 09/16] crypto: ux500/hash: Get rid of state from request context Linus Walleij
2022-08-16 14:00 ` [PATCH v3 10/16] crypto: ux500/hash: Implement .export and .import Linus Walleij
2022-08-25  9:30   ` Herbert Xu
2022-09-13 19:14     ` Linus Walleij
2022-09-18  3:16       ` Herbert Xu
2022-08-16 14:00 ` [PATCH v3 11/16] crypto: ux500/hash: Drop custom uint64 type Linus Walleij
2022-08-16 14:00 ` [PATCH v3 12/16] crypto: ux500/hash: Drop regulator handling Linus Walleij
2022-08-16 14:00 ` [PATCH v3 13/16] crypto: ux500/hash: Convert to regmap MMIO Linus Walleij
2022-08-16 14:00 ` [PATCH v3 14/16] crypto: ux500/hash: Use AMBA core primecell IDs Linus Walleij
2022-08-16 14:00 ` [PATCH v3 15/16] crypto: ux500/hash: Implement runtime PM Linus Walleij
2022-08-16 14:00 ` [PATCH v3 16/16] crypto: ux500/hash: Use accelerated noinc MMIO Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220816140049.102306-9-linus.walleij@linaro.org \
    --to=linus.walleij@linaro.org \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=newbyte@disroot.org \
    --cc=phone-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.