From: Linus Walleij Date: Wed, 25 Jan 2023 00:23:09 +0000 (+0100) Subject: crypto: stm32/hash - Wait for idle before final CPU xmit X-Git-Tag: io_uring-6.3-2023-03-03~14^2~80 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=5a2d52b54065c2aeb0012d050734ead78252215a;p=linux-2.6-block.git crypto: stm32/hash - Wait for idle before final CPU xmit 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 Signed-off-by: Linus Walleij Signed-off-by: Herbert Xu --- diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c index cc0a4e413a82..d4eefd8292ff 100644 --- a/drivers/crypto/stm32/stm32-hash.c +++ b/drivers/crypto/stm32/stm32-hash.c @@ -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;