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 <satvikrajg@nvidia.com>
Tested-by: Abhilash G <abhilashg@nvidia.com>
Reviewed-by: Abhilash G <abhilashg@nvidia.com>
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Jacob Martin <jacob.martin@canonical.com>
Acked-by: Noah Wager <noah.wager@canonical.com>
Signed-off-by: Noah Wager <noah.wager@canonical.com>
This commit is contained in:
Satvik Raj Gupta
2023-05-23 08:54:07 +00:00
committed by Noah Wager
parent 24898eb57b
commit 4d4e68d3fa
+5 -1
View File
@@ -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 <linux/arm-smccc.h>
#include <linux/errno.h>
#include <linux/jiffies.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/tee_drv.h>
#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);