summaryrefslogtreecommitdiff
path: root/drivers/tee/optee/notif.c
diff options
context:
space:
mode:
authorGavin Liu <gavin.liu@mediatek.com>2024-05-07 05:00:37 +0300
committerJens Wiklander <jens.wiklander@linaro.org>2024-05-30 11:19:28 +0300
commit14ca6401d8703725c7297dcc4bf8de73323411ac (patch)
treec2baa9a63392a86b54c427cf9ee23ae1753c9b2e /drivers/tee/optee/notif.c
parenta38297e3fb012ddfa7ce0321a7e5a8daeb1872b6 (diff)
downloadlinux-14ca6401d8703725c7297dcc4bf8de73323411ac.tar.xz
optee: add timeout value to optee_notif_wait() to support timeout
Add timeout value to support self waking when timeout to avoid waiting indefinitely. Signed-off-by: Gavin Liu <gavin.liu@mediatek.com> Reviewed-by: Sumit Garg <sumit.garg@linaro.org> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'drivers/tee/optee/notif.c')
-rw-r--r--drivers/tee/optee/notif.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/tee/optee/notif.c b/drivers/tee/optee/notif.c
index 05212842b0a5..d5e5c0645609 100644
--- a/drivers/tee/optee/notif.c
+++ b/drivers/tee/optee/notif.c
@@ -29,7 +29,7 @@ static bool have_key(struct optee *optee, u_int key)
return false;
}
-int optee_notif_wait(struct optee *optee, u_int key)
+int optee_notif_wait(struct optee *optee, u_int key, u32 timeout)
{
unsigned long flags;
struct notif_entry *entry;
@@ -70,7 +70,12 @@ 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);
+ if (timeout != 0) {
+ if (!wait_for_completion_timeout(&entry->c, timeout))
+ rc = -ETIMEDOUT;
+ } else {
+ wait_for_completion(&entry->c);
+ }
spin_lock_irqsave(&optee->notif.lock, flags);
list_del(&entry->link);