linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Thompson <daniel.thompson@linaro.org>
To: Sumit Garg <sumit.garg@linaro.org>
Cc: jens.wiklander@linaro.org, herbert@gondor.apana.org.au,
	ard.biesheuvel@linaro.org, linux-arm-kernel@lists.infradead.org,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	yamada.masahiro@socionext.com, michal.lkml@markovi.net,
	mpm@selenic.com, robh+dt@kernel.org, mark.rutland@arm.com,
	arnd@arndb.de, gregkh@linuxfoundation.org, bhsharma@redhat.com,
	tee-dev@lists.linaro.org
Subject: Re: [PATCH v5 2/4] tee: add supp_nowait flag in tee_context struct
Date: Thu, 24 Jan 2019 09:48:07 +0000	[thread overview]
Message-ID: <20190124094807.yg5onsmbx46bi7bm@holly.lan> (raw)
In-Reply-To: <1548309279-5281-3-git-send-email-sumit.garg@linaro.org>

On Thu, Jan 24, 2019 at 11:24:37AM +0530, Sumit Garg wrote:
> This flag indicates that requests in this context should not wait for
> tee-supplicant daemon to be started if not present and just return
> with an error code. It is needed for requests which should be
> non-blocking in nature like ones arising from TEE based kernel drivers
> or any in kernel api that uses TEE internal client interface.
> 
> Signed-off-by: Sumit Garg <sumit.garg@linaro.org>

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>

> ---
>  drivers/tee/optee/supp.c | 10 +++++++++-
>  drivers/tee/tee_core.c   | 13 +++++++++++++
>  include/linux/tee_drv.h  |  6 ++++++
>  3 files changed, 28 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tee/optee/supp.c b/drivers/tee/optee/supp.c
> index 43626e1..92f56b8 100644
> --- a/drivers/tee/optee/supp.c
> +++ b/drivers/tee/optee/supp.c
> @@ -88,10 +88,18 @@ u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params,
>  {
>  	struct optee *optee = tee_get_drvdata(ctx->teedev);
>  	struct optee_supp *supp = &optee->supp;
> -	struct optee_supp_req *req = kzalloc(sizeof(*req), GFP_KERNEL);
> +	struct optee_supp_req *req;
>  	bool interruptable;
>  	u32 ret;
>  
> +	/*
> +	 * Return in case there is no supplicant available and
> +	 * non-blocking request.
> +	 */
> +	if (!supp->ctx && ctx->supp_nowait)
> +		return TEEC_ERROR_COMMUNICATION;
> +
> +	req = kzalloc(sizeof(*req), GFP_KERNEL);
>  	if (!req)
>  		return TEEC_ERROR_OUT_OF_MEMORY;
>  
> diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
> index 9f4c8bc..2612dfa 100644
> --- a/drivers/tee/tee_core.c
> +++ b/drivers/tee/tee_core.c
> @@ -105,6 +105,11 @@ static int tee_open(struct inode *inode, struct file *filp)
>  	if (IS_ERR(ctx))
>  		return PTR_ERR(ctx);
>  
> +	/*
> +	 * Default user-space behaviour is to wait for tee-supplicant
> +	 * if not present for any requests in this context.
> +	 */
> +	ctx->supp_nowait = false;
>  	filp->private_data = ctx;
>  	return 0;
>  }
> @@ -981,6 +986,14 @@ tee_client_open_context(struct tee_context *start,
>  	} while (IS_ERR(ctx) && PTR_ERR(ctx) != -ENOMEM);
>  
>  	put_device(put_dev);
> +	/*
> +	 * Default behaviour for in kernel client is to not wait for
> +	 * tee-supplicant if not present for any requests in this context.
> +	 * Also this flag could be configured again before call to
> +	 * tee_client_open_session() if any in kernel client requires
> +	 * different behaviour.
> +	 */
> +	ctx->supp_nowait = true;
>  	return ctx;
>  }
>  EXPORT_SYMBOL_GPL(tee_client_open_context);
> diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h
> index ce957ce..56d7f1b 100644
> --- a/include/linux/tee_drv.h
> +++ b/include/linux/tee_drv.h
> @@ -50,6 +50,11 @@ struct tee_shm_pool;
>   * @releasing:  flag that indicates if context is being released right now.
>   *		It is needed to break circular dependency on context during
>   *              shared memory release.
> + * @supp_nowait: flag that indicates that requests in this context should not
> + *              wait for tee-supplicant daemon to be started if not present
> + *              and just return with an error code. It is needed for requests
> + *              that arises from TEE based kernel drivers that should be
> + *              non-blocking in nature.
>   */
>  struct tee_context {
>  	struct tee_device *teedev;
> @@ -57,6 +62,7 @@ struct tee_context {
>  	void *data;
>  	struct kref refcount;
>  	bool releasing;
> +	bool supp_nowait;
>  };
>  
>  struct tee_param_memref {
> -- 
> 2.7.4
> 

  reply	other threads:[~2019-01-24  9:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-24  5:54 [PATCH v5 0/4] Introduce TEE bus driver framework Sumit Garg
2019-01-24  5:54 ` [PATCH v5 1/4] tee: add bus driver framework for TEE based devices Sumit Garg
2019-01-24  9:45   ` Daniel Thompson
2019-01-24 10:19     ` Sumit Garg
2019-01-24 10:49       ` Bhupesh Sharma
2019-01-24  5:54 ` [PATCH v5 2/4] tee: add supp_nowait flag in tee_context struct Sumit Garg
2019-01-24  9:48   ` Daniel Thompson [this message]
2019-01-24  5:54 ` [PATCH v5 3/4] tee: optee: add TEE bus device enumeration support Sumit Garg
2019-01-24 10:15   ` Daniel Thompson
2019-01-24 11:28     ` Sumit Garg
2019-01-24  5:54 ` [PATCH v5 4/4] hwrng: add OP-TEE based rng driver Sumit Garg
2019-01-24 12:30   ` Daniel Thompson
2019-01-24 14:02     ` Sumit Garg
2019-01-28  4:30   ` Sumit Garg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190124094807.yg5onsmbx46bi7bm@holly.lan \
    --to=daniel.thompson@linaro.org \
    --cc=ard.biesheuvel@linaro.org \
    --cc=arnd@arndb.de \
    --cc=bhsharma@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=jens.wiklander@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=michal.lkml@markovi.net \
    --cc=mpm@selenic.com \
    --cc=robh+dt@kernel.org \
    --cc=sumit.garg@linaro.org \
    --cc=tee-dev@lists.linaro.org \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).