Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'optee-notif-wait-timeout-for-v6.11' of https://git.linaro.org/people/jens.wiklander/linux-tee into soc/drivers

optee: add timeout parameter for notification wait

* tag 'optee-notif-wait-timeout-for-v6.11' of https://git.linaro.org/people/jens.wiklander/linux-tee:
optee: add timeout value to optee_notif_wait() to support timeout

Link: https://lore.kernel.org/r/20240627095325.GA2585076@rayden
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+20 -5
+7 -2
drivers/tee/optee/notif.c
··· 29 29 return false; 30 30 } 31 31 32 - int optee_notif_wait(struct optee *optee, u_int key) 32 + int optee_notif_wait(struct optee *optee, u_int key, u32 timeout) 33 33 { 34 34 unsigned long flags; 35 35 struct notif_entry *entry; ··· 70 70 * Unlock temporarily and wait for completion. 71 71 */ 72 72 spin_unlock_irqrestore(&optee->notif.lock, flags); 73 - wait_for_completion(&entry->c); 73 + if (timeout != 0) { 74 + if (!wait_for_completion_timeout(&entry->c, timeout)) 75 + rc = -ETIMEDOUT; 76 + } else { 77 + wait_for_completion(&entry->c); 78 + } 74 79 spin_lock_irqsave(&optee->notif.lock, flags); 75 80 76 81 list_del(&entry->link);
+4 -1
drivers/tee/optee/optee_private.h
··· 26 26 #define TEEC_ERROR_BUSY 0xFFFF000D 27 27 #define TEEC_ERROR_SHORT_BUFFER 0xFFFF0010 28 28 29 + /* API Return Codes are from the GP TEE Internal Core API Specification */ 30 + #define TEE_ERROR_TIMEOUT 0xFFFF3001 31 + 29 32 #define TEEC_ORIGIN_COMMS 0x00000002 30 33 31 34 /* ··· 255 252 256 253 int optee_notif_init(struct optee *optee, u_int max_key); 257 254 void optee_notif_uninit(struct optee *optee); 258 - int optee_notif_wait(struct optee *optee, u_int key); 255 + int optee_notif_wait(struct optee *optee, u_int key, u32 timeout); 259 256 int optee_notif_send(struct optee *optee, u_int key); 260 257 261 258 u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params,
+1
drivers/tee/optee/optee_rpc_cmd.h
··· 41 41 * Waiting on notification 42 42 * [in] value[0].a OPTEE_RPC_NOTIFICATION_WAIT 43 43 * [in] value[0].b notification value 44 + * [in] value[0].c timeout in milliseconds or 0 if no timeout 44 45 * 45 46 * Sending a synchronous notification 46 47 * [in] value[0].a OPTEE_RPC_NOTIFICATION_SEND
+8 -2
drivers/tee/optee/rpc.c
··· 130 130 static void handle_rpc_func_cmd_wq(struct optee *optee, 131 131 struct optee_msg_arg *arg) 132 132 { 133 + int rc = 0; 134 + 133 135 if (arg->num_params != 1) 134 136 goto bad; 135 137 ··· 141 139 142 140 switch (arg->params[0].u.value.a) { 143 141 case OPTEE_RPC_NOTIFICATION_WAIT: 144 - if (optee_notif_wait(optee, arg->params[0].u.value.b)) 142 + rc = optee_notif_wait(optee, arg->params[0].u.value.b, arg->params[0].u.value.c); 143 + if (rc) 145 144 goto bad; 146 145 break; 147 146 case OPTEE_RPC_NOTIFICATION_SEND: ··· 156 153 arg->ret = TEEC_SUCCESS; 157 154 return; 158 155 bad: 159 - arg->ret = TEEC_ERROR_BAD_PARAMETERS; 156 + if (rc == -ETIMEDOUT) 157 + arg->ret = TEE_ERROR_TIMEOUT; 158 + else 159 + arg->ret = TEEC_ERROR_BAD_PARAMETERS; 160 160 } 161 161 162 162 static void handle_rpc_func_cmd_wait(struct optee_msg_arg *arg)