Skip to content

Commit 18c7ae7

Browse files
Shown HanShown Han
Shown Han
authored and
Shown Han
committed
tee: optee: Fix RPC call break system sleep operation.
The system sleep can be break when freezer try to freeze tasks who are waitting for unreachable conditions. All RPC calls waiting on tee-supplicant results are unreachable conditions when tee-supplicant be frozen. And TEE wait queue sleep becomes to unreachable condition on the corresponding wakeup process be frozen. By introduce freezer help functions tell to freezer ignoring tasks which can help to avoid freezer wakeup those tasks and wait them call into try_to_freeze(), the wait of those tasks are constantly timeout because they are waitting on unreachable conditions. This patch utilize freezer help functions to enclose those potential unreachable conditions boundaries to avoid breaking system sleep. Signed-off-by: Shown Han <[email protected]>
1 parent 436d15c commit 18c7ae7

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

drivers/tee/optee/call.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ static void optee_cq_wait_init(struct optee_call_queue *cq,
4848
static void optee_cq_wait_for_completion(struct optee_call_queue *cq,
4949
struct optee_call_waiter *w)
5050
{
51+
/* Tell freezers to ignore the current task. */
52+
freezer_do_not_count();
53+
5154
wait_for_completion(&w->c);
5255

56+
/* Tell freezer to stop ignoring current task. */
57+
freezer_count();
58+
5359
mutex_lock(&cq->mutex);
5460

5561
/* Move to end of list to get out of the way for other waiters */

drivers/tee/optee/optee_private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/semaphore.h>
1111
#include <linux/tee_drv.h>
1212
#include <linux/types.h>
13+
#include <linux/freezer.h>
1314
#include "optee_msg.h"
1415

1516
#define OPTEE_MAX_ARG_SIZE 1024

drivers/tee/optee/rpc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@ static void wq_sleep(struct optee_wait_queue *wq, u32 key)
7777
struct wq_entry *w = wq_entry_get(wq, key);
7878

7979
if (w) {
80+
/* Tell freezers to ignore the current task. */
81+
freezer_do_not_count();
82+
8083
wait_for_completion(&w->c);
84+
85+
/* Tell freezer to stop ignoring current task. */
86+
freezer_count();
8187
mutex_lock(&wq->mu);
8288
list_del(&w->link);
8389
mutex_unlock(&wq->mu);

drivers/tee/optee/supp.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params,
108108
/* Tell an eventual waiter there's a new request */
109109
complete(&supp->reqs_c);
110110

111+
112+
/* Tell freezers to ignore the current task. */
113+
freezer_do_not_count();
114+
111115
/*
112116
* Wait for supplicant to process and return result, once we've
113117
* returned from wait_for_completion(&req->c) successfully we have
@@ -143,6 +147,9 @@ u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params,
143147
}
144148
}
145149

150+
/* Tell freezer to stop ignoring current task. */
151+
freezer_count();
152+
146153
ret = req->ret;
147154
kfree(req);
148155

0 commit comments

Comments
 (0)