linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] optee: support wq_sleep_timeout
@ 2024-01-25  5:27 gavin.liu
  2024-01-25  9:46 ` Jerome Forissier
  2024-01-25 15:02 ` Jens Wiklander
  0 siblings, 2 replies; 5+ messages in thread
From: gavin.liu @ 2024-01-25  5:27 UTC (permalink / raw)
  To: Jens Wiklander, Sumit Garg, Matthias Brugger
  Cc: AngeloGioacchino Del Regno, op-tee, linux-kernel,
	linux-arm-kernel, linux-mediatek, gavin.liu,
	Project_Global_Chrome_Upstream_Group

From: Gavin Liu <gavin.liu@mediatek.com>

Add wq_sleep_timeout to support self waking when timeout for secure
driver usage.

Signed-off-by: Gavin Liu <gavin.liu@mediatek.com>
---
 drivers/tee/optee/notif.c         |  9 +++++++--
 drivers/tee/optee/optee_private.h |  2 +-
 drivers/tee/optee/rpc.c           | 10 ++++++++--
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/tee/optee/notif.c b/drivers/tee/optee/notif.c
index 05212842b0a5..d5e5c0645609 100644
--- a/drivers/tee/optee/notif.c
+++ b/drivers/tee/optee/notif.c
@@ -29,7 +29,7 @@ static bool have_key(struct optee *optee, u_int key)
 	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;
@@ -70,7 +70,12 @@ int optee_notif_wait(struct optee *optee, u_int key)
 	 * 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);
diff --git a/drivers/tee/optee/optee_private.h b/drivers/tee/optee/optee_private.h
index 7a5243c78b55..da990c4016ec 100644
--- a/drivers/tee/optee/optee_private.h
+++ b/drivers/tee/optee/optee_private.h
@@ -252,7 +252,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,
diff --git a/drivers/tee/optee/rpc.c b/drivers/tee/optee/rpc.c
index e69bc6380683..14e6246aaf05 100644
--- a/drivers/tee/optee/rpc.c
+++ b/drivers/tee/optee/rpc.c
@@ -130,6 +130,8 @@ static void handle_rpc_func_cmd_i2c_transfer(struct tee_context *ctx,
 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;
 
@@ -139,7 +141,8 @@ static void handle_rpc_func_cmd_wq(struct optee *optee,
 
 	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:
@@ -153,7 +156,10 @@ static void handle_rpc_func_cmd_wq(struct optee *optee,
 	arg->ret = TEEC_SUCCESS;
 	return;
 bad:
-	arg->ret = TEEC_ERROR_BAD_PARAMETERS;
+	if (rc == -ETIMEDOUT)
+		arg->ret = TEEC_ERROR_BUSY;
+	else
+		arg->ret = TEEC_ERROR_BAD_PARAMETERS;
 }
 
 static void handle_rpc_func_cmd_wait(struct optee_msg_arg *arg)
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] optee: support wq_sleep_timeout
  2024-01-25  5:27 [PATCH] optee: support wq_sleep_timeout gavin.liu
@ 2024-01-25  9:46 ` Jerome Forissier
  2024-01-29  2:32   ` Gavin Liu (劉哲廷)
  2024-01-25 15:02 ` Jens Wiklander
  1 sibling, 1 reply; 5+ messages in thread
From: Jerome Forissier @ 2024-01-25  9:46 UTC (permalink / raw)
  To: gavin.liu, Jens Wiklander, Sumit Garg, Matthias Brugger
  Cc: AngeloGioacchino Del Regno, op-tee, linux-kernel,
	linux-arm-kernel, linux-mediatek,
	Project_Global_Chrome_Upstream_Group



On 1/25/24 06:27, gavin.liu via OP-TEE wrote:
> From: Gavin Liu <gavin.liu@mediatek.com>
> 
> Add wq_sleep_timeout to support self waking when timeout for secure
> driver usage.
> 
> Signed-off-by: Gavin Liu <gavin.liu@mediatek.com>
> ---
>  drivers/tee/optee/notif.c         |  9 +++++++--
>  drivers/tee/optee/optee_private.h |  2 +-
>  drivers/tee/optee/rpc.c           | 10 ++++++++--
>  3 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/tee/optee/notif.c b/drivers/tee/optee/notif.c
> index 05212842b0a5..d5e5c0645609 100644
> --- a/drivers/tee/optee/notif.c
> +++ b/drivers/tee/optee/notif.c
> @@ -29,7 +29,7 @@ static bool have_key(struct optee *optee, u_int key)
>  	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;
> @@ -70,7 +70,12 @@ int optee_notif_wait(struct optee *optee, u_int key)
>  	 * 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);
> diff --git a/drivers/tee/optee/optee_private.h b/drivers/tee/optee/optee_private.h
> index 7a5243c78b55..da990c4016ec 100644
> --- a/drivers/tee/optee/optee_private.h
> +++ b/drivers/tee/optee/optee_private.h
> @@ -252,7 +252,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,
> diff --git a/drivers/tee/optee/rpc.c b/drivers/tee/optee/rpc.c
> index e69bc6380683..14e6246aaf05 100644
> --- a/drivers/tee/optee/rpc.c
> +++ b/drivers/tee/optee/rpc.c
> @@ -130,6 +130,8 @@ static void handle_rpc_func_cmd_i2c_transfer(struct tee_context *ctx,
>  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;
>  
> @@ -139,7 +141,8 @@ static void handle_rpc_func_cmd_wq(struct optee *optee,
>  
>  	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);

optee/optee_rpc_cmd.h needs updating (near "Waiting on notification") to reflect the meaning
of value.c.

Was value.c required to be zero prior to this change? Otherwise this could lead to undefined
behavior.
 

> +		if (rc)
>  			goto bad;
>  		break;
>  	case OPTEE_RPC_NOTIFICATION_SEND:
> @@ -153,7 +156,10 @@ static void handle_rpc_func_cmd_wq(struct optee *optee,
>  	arg->ret = TEEC_SUCCESS;
>  	return;
>  bad:
> -	arg->ret = TEEC_ERROR_BAD_PARAMETERS;
> +	if (rc == -ETIMEDOUT)
> +		arg->ret = TEEC_ERROR_BUSY;
> +	else
> +		arg->ret = TEEC_ERROR_BAD_PARAMETERS;
>  }
>  
>  static void handle_rpc_func_cmd_wait(struct optee_msg_arg *arg)

-- 
Jerome

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] optee: support wq_sleep_timeout
  2024-01-25  5:27 [PATCH] optee: support wq_sleep_timeout gavin.liu
  2024-01-25  9:46 ` Jerome Forissier
@ 2024-01-25 15:02 ` Jens Wiklander
  2024-01-29  2:17   ` Gavin Liu (劉哲廷)
  1 sibling, 1 reply; 5+ messages in thread
From: Jens Wiklander @ 2024-01-25 15:02 UTC (permalink / raw)
  To: gavin.liu
  Cc: Sumit Garg, Matthias Brugger, AngeloGioacchino Del Regno, op-tee,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Project_Global_Chrome_Upstream_Group, Jerome Forissier

On Thu, Jan 25, 2024 at 6:28 AM gavin.liu <gavin.liu@mediatek.com> wrote:
>
> From: Gavin Liu <gavin.liu@mediatek.com>
>
> Add wq_sleep_timeout to support self waking when timeout for secure
> driver usage.
>
> Signed-off-by: Gavin Liu <gavin.liu@mediatek.com>
> ---
>  drivers/tee/optee/notif.c         |  9 +++++++--
>  drivers/tee/optee/optee_private.h |  2 +-
>  drivers/tee/optee/rpc.c           | 10 ++++++++--
>  3 files changed, 16 insertions(+), 5 deletions(-)

I'd like to see the corresponding secure world changes taking
advantage of this ABI change before we take this any further.

Thanks,
Jens

>
> diff --git a/drivers/tee/optee/notif.c b/drivers/tee/optee/notif.c
> index 05212842b0a5..d5e5c0645609 100644
> --- a/drivers/tee/optee/notif.c
> +++ b/drivers/tee/optee/notif.c
> @@ -29,7 +29,7 @@ static bool have_key(struct optee *optee, u_int key)
>         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;
> @@ -70,7 +70,12 @@ int optee_notif_wait(struct optee *optee, u_int key)
>          * 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);
> diff --git a/drivers/tee/optee/optee_private.h b/drivers/tee/optee/optee_private.h
> index 7a5243c78b55..da990c4016ec 100644
> --- a/drivers/tee/optee/optee_private.h
> +++ b/drivers/tee/optee/optee_private.h
> @@ -252,7 +252,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,
> diff --git a/drivers/tee/optee/rpc.c b/drivers/tee/optee/rpc.c
> index e69bc6380683..14e6246aaf05 100644
> --- a/drivers/tee/optee/rpc.c
> +++ b/drivers/tee/optee/rpc.c
> @@ -130,6 +130,8 @@ static void handle_rpc_func_cmd_i2c_transfer(struct tee_context *ctx,
>  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;
>
> @@ -139,7 +141,8 @@ static void handle_rpc_func_cmd_wq(struct optee *optee,
>
>         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:
> @@ -153,7 +156,10 @@ static void handle_rpc_func_cmd_wq(struct optee *optee,
>         arg->ret = TEEC_SUCCESS;
>         return;
>  bad:
> -       arg->ret = TEEC_ERROR_BAD_PARAMETERS;
> +       if (rc == -ETIMEDOUT)
> +               arg->ret = TEEC_ERROR_BUSY;
> +       else
> +               arg->ret = TEEC_ERROR_BAD_PARAMETERS;
>  }
>
>  static void handle_rpc_func_cmd_wait(struct optee_msg_arg *arg)
> --
> 2.18.0
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] optee: support wq_sleep_timeout
  2024-01-25 15:02 ` Jens Wiklander
@ 2024-01-29  2:17   ` Gavin Liu (劉哲廷)
  0 siblings, 0 replies; 5+ messages in thread
From: Gavin Liu (劉哲廷) @ 2024-01-29  2:17 UTC (permalink / raw)
  To: jens.wiklander
  Cc: sumit.garg, linux-kernel, linux-mediatek,
	Project_Global_Chrome_Upstream_Group, linux-arm-kernel, op-tee,
	matthias.bgg, jerome.forissier, angelogioacchino.delregno

Hi Jens,

Thanks very much for the reviewing.

On Thu, 2024-01-25 at 16:02 +0100, Jens Wiklander wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  On Thu, Jan 25, 2024 at 6:28 AM gavin.liu <gavin.liu@mediatek.com>
> wrote:
> >
> > From: Gavin Liu <gavin.liu@mediatek.com>
> >
> > Add wq_sleep_timeout to support self waking when timeout for secure
> > driver usage.
> >
> > Signed-off-by: Gavin Liu <gavin.liu@mediatek.com>
> > ---
> >  drivers/tee/optee/notif.c         |  9 +++++++--
> >  drivers/tee/optee/optee_private.h |  2 +-
> >  drivers/tee/optee/rpc.c           | 10 ++++++++--
> >  3 files changed, 16 insertions(+), 5 deletions(-)
> 
> I'd like to see the corresponding secure world changes taking
> advantage of this ABI change before we take this any further.
> 
> Thanks,
> Jens
> 
 I just sent a PR for the secure world change.
> >
> > diff --git a/drivers/tee/optee/notif.c b/drivers/tee/optee/notif.c
> > index 05212842b0a5..d5e5c0645609 100644
> > --- a/drivers/tee/optee/notif.c
> > +++ b/drivers/tee/optee/notif.c
> > @@ -29,7 +29,7 @@ static bool have_key(struct optee *optee, u_int
> key)
> >         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;
> > @@ -70,7 +70,12 @@ int optee_notif_wait(struct optee *optee, u_int
> key)
> >          * 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);
> > diff --git a/drivers/tee/optee/optee_private.h
> b/drivers/tee/optee/optee_private.h
> > index 7a5243c78b55..da990c4016ec 100644
> > --- a/drivers/tee/optee/optee_private.h
> > +++ b/drivers/tee/optee/optee_private.h
> > @@ -252,7 +252,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,
> > diff --git a/drivers/tee/optee/rpc.c b/drivers/tee/optee/rpc.c
> > index e69bc6380683..14e6246aaf05 100644
> > --- a/drivers/tee/optee/rpc.c
> > +++ b/drivers/tee/optee/rpc.c
> > @@ -130,6 +130,8 @@ static void
> handle_rpc_func_cmd_i2c_transfer(struct tee_context *ctx,
> >  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;
> >
> > @@ -139,7 +141,8 @@ static void handle_rpc_func_cmd_wq(struct optee
> *optee,
> >
> >         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:
> > @@ -153,7 +156,10 @@ static void handle_rpc_func_cmd_wq(struct
> optee *optee,
> >         arg->ret = TEEC_SUCCESS;
> >         return;
> >  bad:
> > -       arg->ret = TEEC_ERROR_BAD_PARAMETERS;
> > +       if (rc == -ETIMEDOUT)
> > +               arg->ret = TEEC_ERROR_BUSY;
> > +       else
> > +               arg->ret = TEEC_ERROR_BAD_PARAMETERS;
> >  }
> >
> >  static void handle_rpc_func_cmd_wait(struct optee_msg_arg *arg)
> > --
> > 2.18.0
> >

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] optee: support wq_sleep_timeout
  2024-01-25  9:46 ` Jerome Forissier
@ 2024-01-29  2:32   ` Gavin Liu (劉哲廷)
  0 siblings, 0 replies; 5+ messages in thread
From: Gavin Liu (劉哲廷) @ 2024-01-29  2:32 UTC (permalink / raw)
  To: jerome.forissier, jens.wiklander, matthias.bgg, sumit.garg
  Cc: linux-arm-kernel, linux-kernel, linux-mediatek,
	angelogioacchino.delregno, op-tee,
	Project_Global_Chrome_Upstream_Group

Hi Jerome,

Thanks very much for the reviewing.

On Thu, 2024-01-25 at 10:46 +0100, Jerome Forissier wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  
> 
> On 1/25/24 06:27, gavin.liu via OP-TEE wrote:
> > From: Gavin Liu <gavin.liu@mediatek.com>
> > 
> > Add wq_sleep_timeout to support self waking when timeout for secure
> > driver usage.
> > 
> > Signed-off-by: Gavin Liu <gavin.liu@mediatek.com>
> > ---
> >  drivers/tee/optee/notif.c         |  9 +++++++--
> >  drivers/tee/optee/optee_private.h |  2 +-
> >  drivers/tee/optee/rpc.c           | 10 ++++++++--
> >  3 files changed, 16 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/tee/optee/notif.c b/drivers/tee/optee/notif.c
> > index 05212842b0a5..d5e5c0645609 100644
> > --- a/drivers/tee/optee/notif.c
> > +++ b/drivers/tee/optee/notif.c
> > @@ -29,7 +29,7 @@ static bool have_key(struct optee *optee, u_int
> key)
> >  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;
> > @@ -70,7 +70,12 @@ int optee_notif_wait(struct optee *optee, u_int
> key)
> >   * 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);
> > diff --git a/drivers/tee/optee/optee_private.h
> b/drivers/tee/optee/optee_private.h
> > index 7a5243c78b55..da990c4016ec 100644
> > --- a/drivers/tee/optee/optee_private.h
> > +++ b/drivers/tee/optee/optee_private.h
> > @@ -252,7 +252,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,
> > diff --git a/drivers/tee/optee/rpc.c b/drivers/tee/optee/rpc.c
> > index e69bc6380683..14e6246aaf05 100644
> > --- a/drivers/tee/optee/rpc.c
> > +++ b/drivers/tee/optee/rpc.c
> > @@ -130,6 +130,8 @@ static void
> handle_rpc_func_cmd_i2c_transfer(struct tee_context *ctx,
> >  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;
> >  
> > @@ -139,7 +141,8 @@ static void handle_rpc_func_cmd_wq(struct optee
> *optee,
> >  
> >  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);
> 
> optee/optee_rpc_cmd.h needs updating (near "Waiting on notification")
> to reflect the meaning
> of value.c.
> 
Ok, I will update the patch for this.

> Was value.c required to be zero prior to this change? Otherwise this
> could lead to undefined
> behavior.
>  
> 
This value comes from optee-os, and it is zero by default now.

> > +if (rc)
> >  goto bad;
> >  break;
> >  case OPTEE_RPC_NOTIFICATION_SEND:
> > @@ -153,7 +156,10 @@ static void handle_rpc_func_cmd_wq(struct
> optee *optee,
> >  arg->ret = TEEC_SUCCESS;
> >  return;
> >  bad:
> > -arg->ret = TEEC_ERROR_BAD_PARAMETERS;
> > +if (rc == -ETIMEDOUT)
> > +arg->ret = TEEC_ERROR_BUSY;
> > +else
> > +arg->ret = TEEC_ERROR_BAD_PARAMETERS;
> >  }
> >  
> >  static void handle_rpc_func_cmd_wait(struct optee_msg_arg *arg)
> 
> -- 
> Jerome

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-29  2:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-25  5:27 [PATCH] optee: support wq_sleep_timeout gavin.liu
2024-01-25  9:46 ` Jerome Forissier
2024-01-29  2:32   ` Gavin Liu (劉哲廷)
2024-01-25 15:02 ` Jens Wiklander
2024-01-29  2:17   ` Gavin Liu (劉哲廷)

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).