crypto:starfive: Switch CSR polling instead of interrupt for HMAC.
authorjiajie.ho <jiajie.ho@starfivetech.com>
Wed, 20 Jul 2022 03:20:55 +0000 (11:20 +0800)
committerjiajie.ho <jiajie.ho@starfivetech.com>
Wed, 20 Jul 2022 03:28:03 +0000 (11:28 +0800)
Observed interrupt signal goes HIGH before HMAC calculations
has been completed. Switching to use CSR polling to check for
HMAC_DONE instead.

Signed-off-by: Jia Jie Ho <jiajie.ho@starfivetech.com>
drivers/crypto/starfive/jh7110/jh7110-regs.h
drivers/crypto/starfive/jh7110/jh7110-sha.c
drivers/crypto/starfive/jh7110/jh7110-str.h

index 4c6ab3b..e513381 100644 (file)
@@ -273,6 +273,7 @@ union jh7110_sha_shacsr {
 #define JH7110_SHA_KEY_DONE                                    BIT(13)
                u32 key_done                    :1;
                u32 key_flag                    :1;
+#define JH7110_SHA_HMAC_DONE                                   BIT(15)
                u32 hmac_done                   :1;
 #define JH7110_SHA_BUSY                                                BIT(16)
                u32 busy                        :1;
index ac498c6..c8b33c6 100644 (file)
 static inline int jh7110_hash_wait_hmac_done(struct jh7110_sec_ctx *ctx)
 {
        struct jh7110_sec_dev *sdev = ctx->sdev;
-       int ret = -1;
-
-       if (sdev->done_flags & JH7110_SHA_HMAC_DONE)
-               ret = 0;
+       u32 status;
 
-       return ret;
+       return readl_relaxed_poll_timeout(sdev->io_base + JH7110_SHA_SHACSR, status,
+                       (status & JH7110_SHA_HMAC_DONE), 10, 100000);
 }
 
 static inline int jh7110_hash_wait_busy(struct jh7110_sec_ctx *ctx)
@@ -312,8 +310,6 @@ static int jh7110_hash_xmit(struct jh7110_sec_ctx *ctx, int flags)
 
        rctx->csr.sha_csr.v = 0;
        rctx->csr.sha_csr.mode = ctx->sha_mode & JH7110_SHA_MODE_MASK;
-       if (ctx->sdev->use_dma)
-               rctx->csr.sha_csr.ie = 1;
 
        if (ctx->sha_mode & JH7110_SHA_HMAC_FLAGS)
                ret = jh7110_sha_hmac_key(ctx);
index c68657a..085fa2e 100644 (file)
@@ -107,7 +107,6 @@ struct jh7110_sec_dev {
        struct mutex                            aes_lock;
        struct mutex                            rsa_lock;
 
-#define JH7110_SHA_HMAC_DONE                   BIT(1)
 #define JH7110_SHA_SHA_DONE                    BIT(2)
 #define JH7110_AES_DONE                                BIT(3)
 #define JH7110_DES_DONE                                BIT(4)