From 4d4e68d3fa0248eb3763a1d06e6d82599cd83002 Mon Sep 17 00:00:00 2001 From: Satvik Raj Gupta Date: Tue, 23 May 2023 08:54:07 +0000 Subject: [PATCH] NVIDIA: SAUCE: WAR: tee: optee: Add timeout in wq_sleep() BugLink: https://bugs.launchpad.net/bugs/2072591 This patch adds a timeout to wq_sleep() to fix the hang issue with StMM enabled. The OP-TEE thread waiting in kernel will periodically return to OP-TEE due to the timeout. http://nvbugs/3978993 Signed-off-by: Satvik Raj Gupta Tested-by: Abhilash G Reviewed-by: Abhilash G Signed-off-by: Laxman Dewangan Acked-by: Jacob Martin Acked-by: Noah Wager Signed-off-by: Noah Wager --- drivers/tee/optee/notif.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/tee/optee/notif.c b/drivers/tee/optee/notif.c index 05212842b0a5..74894c517151 100644 --- a/drivers/tee/optee/notif.c +++ b/drivers/tee/optee/notif.c @@ -1,17 +1,21 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2015-2021, Linaro Limited + * Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include #include +#include #include #include #include #include "optee_private.h" +#define SLEEP_TIMEOUT (msecs_to_jiffies(100)) + struct notif_entry { struct list_head link; struct completion c; @@ -70,7 +74,7 @@ int optee_notif_wait(struct optee *optee, u_int key) * Unlock temporarily and wait for completion. */ spin_unlock_irqrestore(&optee->notif.lock, flags); - wait_for_completion(&entry->c); + (void)wait_for_completion_timeout(&entry->c, SLEEP_TIMEOUT); spin_lock_irqsave(&optee->notif.lock, flags); list_del(&entry->link);