tee: optee: system thread call property
[linux-2.6-microblaze.git] / drivers / tee / optee / call.c
index df5fb54..152ae9b 100644 (file)
@@ -40,7 +40,7 @@ struct optee_shm_arg_entry {
 };
 
 void optee_cq_wait_init(struct optee_call_queue *cq,
-                       struct optee_call_waiter *w)
+                       struct optee_call_waiter *w, bool sys_thread)
 {
        /*
         * We're preparing to make a call to secure world. In case we can't
@@ -328,7 +328,8 @@ int optee_open_session(struct tee_context *ctx,
                goto out;
        }
 
-       if (optee->ops->do_call_with_arg(ctx, shm, offs)) {
+       if (optee->ops->do_call_with_arg(ctx, shm, offs,
+                                        sess->use_sys_thread)) {
                msg_arg->ret = TEEC_ERROR_COMMUNICATION;
                msg_arg->ret_origin = TEEC_ORIGIN_COMMS;
        }
@@ -360,7 +361,8 @@ out:
        return rc;
 }
 
-int optee_close_session_helper(struct tee_context *ctx, u32 session)
+int optee_close_session_helper(struct tee_context *ctx, u32 session,
+                              bool system_thread)
 {
        struct optee *optee = tee_get_drvdata(ctx->teedev);
        struct optee_shm_arg_entry *entry;
@@ -374,7 +376,7 @@ int optee_close_session_helper(struct tee_context *ctx, u32 session)
 
        msg_arg->cmd = OPTEE_MSG_CMD_CLOSE_SESSION;
        msg_arg->session = session;
-       optee->ops->do_call_with_arg(ctx, shm, offs);
+       optee->ops->do_call_with_arg(ctx, shm, offs, system_thread);
 
        optee_free_msg_arg(ctx, entry, offs);
 
@@ -385,6 +387,7 @@ int optee_close_session(struct tee_context *ctx, u32 session)
 {
        struct optee_context_data *ctxdata = ctx->data;
        struct optee_session *sess;
+       bool system_thread;
 
        /* Check that the session is valid and remove it from the list */
        mutex_lock(&ctxdata->mutex);
@@ -394,9 +397,10 @@ int optee_close_session(struct tee_context *ctx, u32 session)
        mutex_unlock(&ctxdata->mutex);
        if (!sess)
                return -EINVAL;
+       system_thread = sess->use_sys_thread;
        kfree(sess);
 
-       return optee_close_session_helper(ctx, session);
+       return optee_close_session_helper(ctx, session, system_thread);
 }
 
 int optee_invoke_func(struct tee_context *ctx, struct tee_ioctl_invoke_arg *arg,
@@ -408,12 +412,15 @@ int optee_invoke_func(struct tee_context *ctx, struct tee_ioctl_invoke_arg *arg,
        struct optee_msg_arg *msg_arg;
        struct optee_session *sess;
        struct tee_shm *shm;
+       bool system_thread;
        u_int offs;
        int rc;
 
        /* Check that the session is valid */
        mutex_lock(&ctxdata->mutex);
        sess = find_session(ctxdata, arg->session);
+       if (sess)
+               system_thread = sess->use_sys_thread;
        mutex_unlock(&ctxdata->mutex);
        if (!sess)
                return -EINVAL;
@@ -432,7 +439,7 @@ int optee_invoke_func(struct tee_context *ctx, struct tee_ioctl_invoke_arg *arg,
        if (rc)
                goto out;
 
-       if (optee->ops->do_call_with_arg(ctx, shm, offs)) {
+       if (optee->ops->do_call_with_arg(ctx, shm, offs, system_thread)) {
                msg_arg->ret = TEEC_ERROR_COMMUNICATION;
                msg_arg->ret_origin = TEEC_ORIGIN_COMMS;
        }
@@ -457,12 +464,15 @@ int optee_cancel_req(struct tee_context *ctx, u32 cancel_id, u32 session)
        struct optee_shm_arg_entry *entry;
        struct optee_msg_arg *msg_arg;
        struct optee_session *sess;
+       bool system_thread;
        struct tee_shm *shm;
        u_int offs;
 
        /* Check that the session is valid */
        mutex_lock(&ctxdata->mutex);
        sess = find_session(ctxdata, session);
+       if (sess)
+               system_thread = sess->use_sys_thread;
        mutex_unlock(&ctxdata->mutex);
        if (!sess)
                return -EINVAL;
@@ -474,7 +484,7 @@ int optee_cancel_req(struct tee_context *ctx, u32 cancel_id, u32 session)
        msg_arg->cmd = OPTEE_MSG_CMD_CANCEL;
        msg_arg->session = session;
        msg_arg->cancel_id = cancel_id;
-       optee->ops->do_call_with_arg(ctx, shm, offs);
+       optee->ops->do_call_with_arg(ctx, shm, offs, system_thread);
 
        optee_free_msg_arg(ctx, entry, offs);
        return 0;