From: Christoph Gellner <cgellner@de.adit-jv.com>
To: <op-tee@lists.trustedfirmware.org>, <linux-kernel@vger.kernel.org>
Cc: <jens.wiklander@linaro.org>, Christoph Gellner <cgellner@de.adit-jv.com>
Subject: [PATCH 3/3] tee: optee: Allow to freeze while waiting in OPTEE_RPC_WAIT_QUEUE_SLEEP
Date: Fri, 16 Jul 2021 17:45:00 +0200 [thread overview]
Message-ID: <20210716154500.10115-4-cgellner@de.adit-jv.com> (raw)
In-Reply-To: <20210716154500.10115-1-cgellner@de.adit-jv.com>
When the system is going to hibernate or suspend and the task calling
the corresponding OPTEE_RPC_WAIT_QUEUE_WAKEUP gets frozen waiting
for completion in OPTEE_RPC_WAIT_QUEUE_SLEEP might get stuck.
Change wait to interruptible and add try_to_freeze in order to
allow that the waiting task is frozen as well.
Signed-off-by: Christoph Gellner <cgellner@de.adit-jv.com>
---
drivers/tee/optee/rpc.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/tee/optee/rpc.c b/drivers/tee/optee/rpc.c
index 1849180b0278..0851b19be529 100644
--- a/drivers/tee/optee/rpc.c
+++ b/drivers/tee/optee/rpc.c
@@ -10,6 +10,7 @@
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/tee_drv.h>
+#include <linux/freezer.h>
#include "optee_private.h"
#include "optee_smc.h"
#include "optee_rpc_cmd.h"
@@ -169,7 +170,13 @@ static void wq_sleep(struct optee_wait_queue *wq, u32 key)
struct wq_entry *w = wq_entry_get(wq, key);
if (w) {
- wait_for_completion(&w->c);
+ /*
+ * wait_for_completion but allow hibernation/suspend
+ * to freeze the waiting task
+ */
+ while (wait_for_completion_interruptible(&w->c))
+ try_to_freeze();
+
mutex_lock(&wq->mu);
list_del(&w->link);
mutex_unlock(&wq->mu);
--
2.32.0.rc0
prev parent reply other threads:[~2021-07-16 15:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-16 15:44 [PATCH 0/3] tee: optee: Allow to freeze when tee-supplicant is frozen Christoph Gellner
2021-07-16 15:44 ` [PATCH 1/3] tee: optee: Allow to freeze the task waiting for tee-supplicant Christoph Gellner
2021-07-16 15:44 ` [PATCH 2/3] tee: optee: Allow to freeze while waiting for call_queue Christoph Gellner
2021-07-16 15:45 ` Christoph Gellner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210716154500.10115-4-cgellner@de.adit-jv.com \
--to=cgellner@de.adit-jv.com \
--cc=jens.wiklander@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=op-tee@lists.trustedfirmware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).