]> Git Repo - linux.git/commitdiff
Merge tag 'optee-notif-wait-timeout-for-v6.11' of https://git.linaro.org/people/jens...
authorArnd Bergmann <[email protected]>
Thu, 27 Jun 2024 14:44:37 +0000 (16:44 +0200)
committerArnd Bergmann <[email protected]>
Thu, 27 Jun 2024 14:44:37 +0000 (16:44 +0200)
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 <[email protected]>
1  2 
drivers/tee/optee/notif.c
drivers/tee/optee/optee_private.h
drivers/tee/optee/rpc.c

index 0d7878e770cda38b18de5fc3ced492cb9a8cc974,d5e5c06456093396c64e234d700a02bc0e1ae9ec..1970880c796ffe982bca2011519bff93898529b7
@@@ -9,7 -9,7 +9,7 @@@
  #include <linux/errno.h>
  #include <linux/slab.h>
  #include <linux/spinlock.h>
 -#include <linux/tee_drv.h>
 +#include <linux/tee_core.h>
  #include "optee_private.h"
  
  struct notif_entry {
@@@ -29,7 -29,7 +29,7 @@@ static bool have_key(struct optee *opte
        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;
         * 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);
index 429cc20be5ccf05afb6dbe061fff729d00ca1c50,3f08c949b988113c77e8873d2c96b78540e3d509..424898cdc4e97d0aff07e2e427f274bbbe16bd3b
@@@ -9,7 -9,7 +9,7 @@@
  #include <linux/arm-smccc.h>
  #include <linux/rhashtable.h>
  #include <linux/semaphore.h>
 -#include <linux/tee_drv.h>
 +#include <linux/tee_core.h>
  #include <linux/types.h>
  #include "optee_msg.h"
  
@@@ -26,6 -26,9 +26,9 @@@
  #define TEEC_ERROR_BUSY                       0xFFFF000D
  #define TEEC_ERROR_SHORT_BUFFER               0xFFFF0010
  
+ /* API Return Codes are from the GP TEE Internal Core API Specification */
+ #define TEE_ERROR_TIMEOUT             0xFFFF3001
  #define TEEC_ORIGIN_COMMS             0x00000002
  
  /*
@@@ -252,7 -255,7 +255,7 @@@ struct optee_call_ctx 
  
  int optee_notif_init(struct optee *optee, u_int max_key);
  void optee_notif_uninit(struct optee *optee);
- int optee_notif_wait(struct optee *optee, u_int key);
+ int optee_notif_wait(struct optee *optee, u_int key, u32 timeout);
  int optee_notif_send(struct optee *optee, u_int key);
  
  u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params,
@@@ -283,6 -286,18 +286,6 @@@ int optee_cancel_req(struct tee_contex
  int optee_enumerate_devices(u32 func);
  void optee_unregister_devices(void);
  
 -int optee_pool_op_alloc_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
 -                             size_t size, size_t align,
 -                             int (*shm_register)(struct tee_context *ctx,
 -                                                 struct tee_shm *shm,
 -                                                 struct page **pages,
 -                                                 size_t num_pages,
 -                                                 unsigned long start));
 -void optee_pool_op_free_helper(struct tee_shm_pool *pool, struct tee_shm *shm,
 -                             int (*shm_unregister)(struct tee_context *ctx,
 -                                                   struct tee_shm *shm));
 -
 -
  void optee_remove_common(struct optee *optee);
  int optee_open(struct tee_context *ctx, bool cap_memref_null);
  void optee_release(struct tee_context *ctx);
diff --combined drivers/tee/optee/rpc.c
index f086812f117931c4f2e63156f21d0e2b2e9d3a02,13f63c0a7f049bdd017d181b07ca21c24b0ecaf2..5de4504665be9121c55ef78a5df02a13a21f3761
@@@ -8,7 -8,7 +8,7 @@@
  #include <linux/delay.h>
  #include <linux/i2c.h>
  #include <linux/slab.h>
 -#include <linux/tee_drv.h>
 +#include <linux/tee_core.h>
  #include "optee_private.h"
  #include "optee_rpc_cmd.h"
  
@@@ -130,6 -130,8 +130,8 @@@ static void handle_rpc_func_cmd_i2c_tra
  static void handle_rpc_func_cmd_wq(struct optee *optee,
                                   struct optee_msg_arg *arg)
  {
+       int rc = 0;
        if (arg->num_params != 1)
                goto bad;
  
  
        switch (arg->params[0].u.value.a) {
        case OPTEE_RPC_NOTIFICATION_WAIT:
-               if (optee_notif_wait(optee, arg->params[0].u.value.b))
+               rc = optee_notif_wait(optee, arg->params[0].u.value.b, arg->params[0].u.value.c);
+               if (rc)
                        goto bad;
                break;
        case OPTEE_RPC_NOTIFICATION_SEND:
        arg->ret = TEEC_SUCCESS;
        return;
  bad:
-       arg->ret = TEEC_ERROR_BAD_PARAMETERS;
+       if (rc == -ETIMEDOUT)
+               arg->ret = TEE_ERROR_TIMEOUT;
+       else
+               arg->ret = TEEC_ERROR_BAD_PARAMETERS;
  }
  
  static void handle_rpc_func_cmd_wait(struct optee_msg_arg *arg)
This page took 0.096903 seconds and 4 git commands to generate.