|
24 | 24 | #include <linux/err.h> |
25 | 25 | #include <linux/slab.h> |
26 | 26 | #include <linux/moduleparam.h> |
| 27 | +#include <linux/sched.h> |
| 28 | +#include <linux/jiffies.h> |
27 | 29 |
|
28 | 30 | #include <asm/pgtable.h> |
29 | 31 |
|
@@ -143,6 +145,29 @@ static void handle_rpc_func_cmd_mutex_wait(struct teesmc32_arg *arg32) |
143 | 145 | arg32->ret = TEEC_ERROR_BAD_PARAMETERS; |
144 | 146 | } |
145 | 147 |
|
| 148 | +static void handle_rpc_func_cmd_wait(struct teesmc32_arg *arg32) |
| 149 | +{ |
| 150 | + struct teesmc32_param *params; |
| 151 | + u32 msec_to_wait; |
| 152 | + |
| 153 | + if (arg32->num_params != 1) |
| 154 | + goto bad; |
| 155 | + |
| 156 | + params = TEESMC32_GET_PARAMS(arg32); |
| 157 | + msec_to_wait = params[0].u.value.a; |
| 158 | + |
| 159 | + /* set task's state to interruptible sleep */ |
| 160 | + set_current_state(TASK_INTERRUPTIBLE); |
| 161 | + |
| 162 | + /* take a nap */ |
| 163 | + schedule_timeout(msecs_to_jiffies(msec_to_wait)); |
| 164 | + |
| 165 | + arg32->ret = TEEC_SUCCESS;; |
| 166 | + return; |
| 167 | +bad: |
| 168 | + arg32->ret = TEEC_ERROR_BAD_PARAMETERS; |
| 169 | +} |
| 170 | + |
146 | 171 | static void handle_rpc_func_cmd_to_supplicant(struct teesmc32_arg *arg32) |
147 | 172 | { |
148 | 173 | struct teesmc32_param *params; |
@@ -220,11 +245,16 @@ static void handle_rpc_func_cmd(u32 parg32) |
220 | 245 |
|
221 | 246 | arg32 = tee_shm_pool_p2v(DEV, TZop.Allocator, parg32); |
222 | 247 |
|
223 | | - if (arg32->cmd == TEE_RPC_MUTEX_WAIT) |
224 | | - handle_rpc_func_cmd_mutex_wait(arg32); |
225 | | - else |
226 | | - handle_rpc_func_cmd_to_supplicant(arg32); |
227 | | - |
| 248 | + switch (arg32->cmd) { |
| 249 | + case TEE_RPC_MUTEX_WAIT: |
| 250 | + handle_rpc_func_cmd_mutex_wait(arg32); |
| 251 | + break; |
| 252 | + case TEE_RPC_WAIT: |
| 253 | + handle_rpc_func_cmd_wait(arg32); |
| 254 | + break; |
| 255 | + default: |
| 256 | + handle_rpc_func_cmd_to_supplicant(arg32); |
| 257 | + } |
228 | 258 | } |
229 | 259 |
|
230 | 260 | static u32 handle_rpc(struct smc_param64 *param) |
|
0 commit comments