From a7f55a4c1cd9cef0a3103b98bfc789da4fdd9a72 Mon Sep 17 00:00:00 2001 From: xiongmengbiao Date: Wed, 2 Jul 2025 11:36:30 +0800 Subject: [PATCH] crypto: ccp: use time_after() instead of time_before() to checks schedule condition Used time_before(jiffies, last_je) in psp_mutex_lock_timeout() which yields CPU too early. Fixed to time_after(jiffies, last_je + msecs_to_jiffies(100)) for proper 100ms wait. Signed-off-by: xiongmengbiao --- drivers/crypto/ccp/hygon/psp-dev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/ccp/hygon/psp-dev.c b/drivers/crypto/ccp/hygon/psp-dev.c index 67dfd13f17f3..6c3cfd757e94 100644 --- a/drivers/crypto/ccp/hygon/psp-dev.c +++ b/drivers/crypto/ccp/hygon/psp-dev.c @@ -86,7 +86,7 @@ int psp_mutex_lock_timeout(struct psp_mutex *mutex, uint64_t ms) int ret = 0; unsigned long je, last_je; - last_je = jiffies + msecs_to_jiffies(100); + last_je = jiffies; je = jiffies + msecs_to_jiffies(ms); do { if (psp_mutex_trylock(mutex)) { @@ -95,9 +95,9 @@ int psp_mutex_lock_timeout(struct psp_mutex *mutex, uint64_t ms) } // avoid triggering soft lockup warning - if (time_before(jiffies, last_je)) { + if (time_after(jiffies, last_je + msecs_to_jiffies(100))) { schedule(); - last_je = jiffies + msecs_to_jiffies(100); + last_je = jiffies; } } while ((ms == 0) || time_before(jiffies, je)); -- Gitee