[PATCH 1/2] crypto: rockchip - fix inverted hash completion poll
Timur Kussainov
kusainov.timur at gmail.com
Sat Nov 28 12:47:44 PST 2026
Before commit 37bc22159c45 ("crypto: rockchip - use read_poll_timeout"),
rk_hash_run() waited for the hash engine with
while (!CRYPTO_READ(tctx->dev, RK_CRYPTO_HASH_STS))
udelay(10);
i.e. it spun until RK_CRYPTO_HASH_STS became non-zero (HASH_DONE set).
The conversion to readl_poll_timeout() inverted the condition to
"v == 0", so the poll now waits for the opposite state. The return value
was ignored at the time, so the bug went unnoticed: the digest was read
after the 1 ms timeout and happened to be correct.
Now that the timeout is reported as an error, every hash request fails
with "HASH idle timeout" and the rk-sha1/rk-sha256/rk-md5 self-tests
fail.
Poll for the HASH_DONE bit, as the original code did.
Tested on an ASUS Tinker Board (RK3288): the md5/sha1/sha256 self-tests
pass, and 300 digests of random buffers (4 bytes to 1 MiB) computed via
AF_ALG match the generic implementation.
Fixes: 37bc22159c45 ("crypto: rockchip - use read_poll_timeout")
Cc: stable at vger.kernel.org
Signed-off-by: Timur Kussainov <kusainov.timur at gmail.com>
---
drivers/crypto/rockchip/rk3288_crypto_ahash.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/rockchip/rk3288_crypto_ahash.c b/drivers/crypto/rockchip/rk3288_crypto_ahash.c
index d3482619a..922980b66 100644
--- a/drivers/crypto/rockchip/rk3288_crypto_ahash.c
+++ b/drivers/crypto/rockchip/rk3288_crypto_ahash.c
@@ -325,7 +325,7 @@ static int rk_hash_run(struct crypto_engine *engine, void *breq)
* complete.
*/
err = readl_poll_timeout(rkc->reg + RK_CRYPTO_HASH_STS, v,
- v == 0, 10, 1000);
+ v & RK_CRYPTO_HASH_DONE, 10, 1000);
if (err) {
dev_err(rkc->dev, "HASH idle timeout\n");
goto theend;
--
2.47.3
More information about the Linux-rockchip
mailing list