crypto: stm32/hash - Wait for idle before final CPU xmit
authorLinus Walleij <linus.walleij@linaro.org>
Wed, 25 Jan 2023 00:23:09 +0000 (01:23 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 3 Feb 2023 04:54:55 +0000 (12:54 +0800)
When calculating the hash using the CPU, right before the final
hash calculation, heavy testing on Ux500 reveals that it is wise
to wait for the hardware to go idle before calculating the
final hash.

The default test vectors mostly worked fine, but when I used the
extensive tests and stress the hardware I ran into this problem.

Acked-by: Lionel Debieve <lionel.debieve@foss.st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/stm32/stm32-hash.c

index cc0a4e413a825ea53eba741b498d387464478dee..d4eefd8292ff49b5e3017d78930a1ceb2fd23242 100644 (file)
@@ -362,6 +362,9 @@ static int stm32_hash_xmit_cpu(struct stm32_hash_dev *hdev,
                stm32_hash_write(hdev, HASH_DIN, buffer[count]);
 
        if (final) {
+               if (stm32_hash_wait_busy(hdev))
+                       return -ETIMEDOUT;
+
                stm32_hash_set_nblw(hdev, length);
                reg = stm32_hash_read(hdev, HASH_STR);
                reg |= HASH_STR_DCAL;