History

tee: add supp_nowait flag in tee_context struct

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.

Sumit Garg committed 7 years ago

Commit 42bf4151 parent 49a57853 files · +28 −1Browse files

Unified · Split

3 files
  1. drivers/tee/optee/supp.c +9 −1
  2. drivers/tee/tee_core.c +13 −0
  3. include/linux/tee_drv.h +6 −0
drivers/tee/optee/supp.c+9−1
@@ -88,10 +88,18 @@ u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params, · 87 unmodified lines
8888 {
8989 struct optee *optee = tee_get_drvdata(ctx->teedev);
9090 struct optee_supp *supp = &optee->supp;
91− struct optee_supp_req *req = kzalloc(sizeof(*req), GFP_KERNEL);
91+ struct optee_supp_req *req;
9292 bool interruptable;
9393 u32 ret;
9494
95+ /*
96+ * Return in case there is no supplicant available and
97+ * non-blocking request.
98+ */
99+ if (!supp->ctx && ctx->supp_nowait)
100+ return TEEC_ERROR_COMMUNICATION;
101+
102+ req = kzalloc(sizeof(*req), GFP_KERNEL);
95103 if (!req)
96104 return TEEC_ERROR_OUT_OF_MEMORY;
97105
drivers/tee/tee_core.c+13−0
@@ -106,6 +106,11 @@ static int tee_open(struct inode *inode, struct file *filp) · 105 unmodified lines
106106 if (IS_ERR(ctx))
107107 return PTR_ERR(ctx);
108108
109+ /*
110+ * Default user-space behaviour is to wait for tee-supplicant
111+ * if not present for any requests in this context.
112+ */
113+ ctx->supp_nowait = false;
109114 filp->private_data = ctx;
110115 return 0;
111116 }
@@ -982,6 +987,14 @@ tee_client_open_context(struct tee_context *start, · 870 unmodified lines
982987 } while (IS_ERR(ctx) && PTR_ERR(ctx) != -ENOMEM);
983988
984989 put_device(put_dev);
990+ /*
991+ * Default behaviour for in kernel client is to not wait for
992+ * tee-supplicant if not present for any requests in this context.
993+ * Also this flag could be configured again before call to
994+ * tee_client_open_session() if any in kernel client requires
995+ * different behaviour.
996+ */
997+ ctx->supp_nowait = true;
985998 return ctx;
986999 }
9871000 EXPORT_SYMBOL_GPL(tee_client_open_context);
include/linux/tee_drv.h+6−0
@@ -47,6 +47,11 @@ struct tee_shm_pool; · 46 unmodified lines
4747 * @releasing: flag that indicates if context is being released right now.
4848 * It is needed to break circular dependency on context during
4949 * shared memory release.
50+ * @supp_nowait: flag that indicates that requests in this context should not
51+ * wait for tee-supplicant daemon to be started if not present
52+ * and just return with an error code. It is needed for requests
53+ * that arises from TEE based kernel drivers that should be
54+ * non-blocking in nature.
5055 */
5156 struct tee_context {
5257 struct tee_device *teedev;
@@ -54,6 +59,7 @@ struct tee_context { · 1 unmodified line
5459 void *data;
5560 struct kref refcount;
5661 bool releasing;
62+ bool supp_nowait;
5763 };
5864
5965 struct tee_param_memref {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t