Lines Matching full:object

17 /* QTEE root object. */
36 * set is reserved for the primordial object.
55 struct qcomtee_object *object; in qcomtee_qtee_object_alloc() local
57 object = kzalloc(sizeof(*object), GFP_KERNEL); in qcomtee_qtee_object_alloc()
58 if (!object) in qcomtee_qtee_object_alloc()
62 object->name = kasprintf(GFP_KERNEL, "qcomtee-%u", object_id); in qcomtee_qtee_object_alloc()
63 QCOMTEE_OBJECT_SET(object, QCOMTEE_OBJECT_TYPE_TEE, object_id); in qcomtee_qtee_object_alloc()
64 kref_init(&object->refcount); in qcomtee_qtee_object_alloc()
65 /* A QTEE object requires a context for async operations. */ in qcomtee_qtee_object_alloc()
66 object->info.qcomtee_async_ctx = qcomtee->ctx; in qcomtee_qtee_object_alloc()
67 teedev_ctx_get(object->info.qcomtee_async_ctx); in qcomtee_qtee_object_alloc()
69 return object; in qcomtee_qtee_object_alloc()
72 static void qcomtee_qtee_object_free(struct qcomtee_object *object) in qcomtee_qtee_object_free() argument
75 teedev_ctx_put(object->info.qcomtee_async_ctx); in qcomtee_qtee_object_free()
77 kfree(object->name); in qcomtee_qtee_object_free()
78 kfree(object); in qcomtee_qtee_object_free()
83 struct qcomtee_object *object; in qcomtee_do_release_qtee_object() local
90 object = container_of(work, struct qcomtee_object, work); in qcomtee_do_release_qtee_object()
91 qcomtee = tee_get_drvdata(object->info.qcomtee_async_ctx->teedev); in qcomtee_do_release_qtee_object()
93 qcomtee->oic.ctx = object->info.qcomtee_async_ctx; in qcomtee_do_release_qtee_object()
95 ret = qcomtee_object_do_invoke_internal(&qcomtee->oic, object, in qcomtee_do_release_qtee_object()
101 queue_work(qcomtee->wq, &object->work); in qcomtee_do_release_qtee_object()
105 qcomtee_object_name(object), ret, result); in qcomtee_do_release_qtee_object()
106 qcomtee_qtee_object_free(object); in qcomtee_do_release_qtee_object()
110 static void qcomtee_release_qtee_object(struct qcomtee_object *object) in qcomtee_release_qtee_object() argument
113 tee_get_drvdata(object->info.qcomtee_async_ctx->teedev); in qcomtee_release_qtee_object()
115 INIT_WORK(&object->work, qcomtee_do_release_qtee_object); in qcomtee_release_qtee_object()
116 queue_work(qcomtee->wq, &object->work); in qcomtee_release_qtee_object()
121 struct qcomtee_object *object; in qcomtee_object_release() local
124 object = container_of(refcount, struct qcomtee_object, refcount); in qcomtee_object_release()
128 * to avoid releasing the object while it is being accessed in in qcomtee_object_release()
133 switch (typeof_qcomtee_object(object)) { in qcomtee_object_release()
135 qcomtee_release_qtee_object(object); in qcomtee_object_release()
139 name = object->name; in qcomtee_object_release()
141 if (object->ops->release) in qcomtee_object_release()
142 object->ops->release(object); in qcomtee_object_release()
155 * qcomtee_object_get() - Increase the object's reference count.
156 * @object: object to increase the reference count.
160 int qcomtee_object_get(struct qcomtee_object *object) in qcomtee_object_get() argument
162 if (object != &qcomtee_primordial_object && in qcomtee_object_get()
163 object != NULL_QCOMTEE_OBJECT && in qcomtee_object_get()
164 object != ROOT_QCOMTEE_OBJECT) in qcomtee_object_get()
165 return kref_get_unless_zero(&object->refcount); in qcomtee_object_get()
171 * qcomtee_object_put() - Decrease the object's reference count.
172 * @object: object to decrease the reference count.
174 void qcomtee_object_put(struct qcomtee_object *object) in qcomtee_object_put() argument
176 if (object != &qcomtee_primordial_object && in qcomtee_object_put()
177 object != NULL_QCOMTEE_OBJECT && in qcomtee_object_put()
178 object != ROOT_QCOMTEE_OBJECT) in qcomtee_object_put()
179 kref_put(&object->refcount, qcomtee_object_release); in qcomtee_object_put()
183 struct qcomtee_object *object) in qcomtee_idx_alloc() argument
188 return xa_alloc_cyclic(&qcomtee->xa_local_objects, idx, object, in qcomtee_idx_alloc()
206 * qcomtee_object_id_get() - Get an ID for an object to send to QTEE.
208 * @object: object to assign an ID.
209 * @object_id: object ID.
217 struct qcomtee_object *object, in qcomtee_object_id_get() argument
222 switch (typeof_qcomtee_object(object)) { in qcomtee_object_id_get()
224 if (qcomtee_idx_alloc(oic, &idx, object) < 0) in qcomtee_object_id_get()
232 *object_id = object->info.qtee_id; in qcomtee_object_id_get()
244 /* Release object ID assigned in qcomtee_object_id_get. */
252 * qcomtee_local_object_get() - Get the object referenced by the ID.
254 * @object_id: object ID.
257 * It is called on behalf of QTEE to obtain an instance of an object
258 * for a given ID. It increases the object's reference count on success.
261 * On success, returns the object.
268 struct qcomtee_object *object; in qcomtee_local_object_get() local
274 object = xa_load(&qcomtee->xa_local_objects, object_id); in qcomtee_local_object_get()
276 qcomtee_object_get(object); in qcomtee_local_object_get()
278 return object; in qcomtee_local_object_get()
282 * qcomtee_object_user_init() - Initialize an object for the user.
283 * @object: object to initialize.
284 * @ot: type of object as &enum qcomtee_object_type.
286 * @fmt: name assigned to the object.
290 int qcomtee_object_user_init(struct qcomtee_object *object, in qcomtee_object_user_init() argument
298 kref_init(&object->refcount); in qcomtee_object_user_init()
299 QCOMTEE_OBJECT_SET(object, QCOMTEE_OBJECT_TYPE_NULL); in qcomtee_object_user_init()
308 object->ops = ops; in qcomtee_object_user_init()
309 if (!object->ops->dispatch) in qcomtee_object_user_init()
313 object->name = kvasprintf_const(GFP_KERNEL, fmt, ap); in qcomtee_object_user_init()
314 QCOMTEE_OBJECT_SET(object, QCOMTEE_OBJECT_TYPE_CB); in qcomtee_object_user_init()
329 * qcomtee_object_type() - Returns the type of object represented by an ID.
330 * @object_id: object ID for the object.
332 * Similar to typeof_qcomtee_object(), but instead of receiving an object as
333 * an argument, it receives an object ID. It is used internally on the return
336 * Return: Returns the type of object referenced by @object_id.
350 * qcomtee_object_qtee_init() - Initialize an object for QTEE.
352 * @object: object returned.
353 * @object_id: object ID received from QTEE.
355 * Return: On failure, returns < 0 and sets @object to %NULL_QCOMTEE_OBJECT.
359 struct qcomtee_object **object, in qcomtee_object_qtee_init() argument
366 *object = NULL_QCOMTEE_OBJECT; in qcomtee_object_qtee_init()
370 *object = qcomtee_local_object_get(oic, object_id); in qcomtee_object_qtee_init()
371 if (*object == NULL_QCOMTEE_OBJECT) in qcomtee_object_qtee_init()
377 *object = qcomtee_qtee_object_alloc(oic, object_id); in qcomtee_object_qtee_init()
378 if (*object == NULL_QCOMTEE_OBJECT) in qcomtee_object_qtee_init()
396 struct qcomtee_object *object, u32 op, in qcomtee_prepare_msg() argument
411 /* Get the ID of the object being invoked. */ in qcomtee_prepare_msg()
412 if (qcomtee_object_id_get(oic, object, &object_id)) in qcomtee_prepare_msg()
460 /* Set object, operation, and argument counts. */ in qcomtee_prepare_msg()
617 /* Invoke a callback object. */
624 /* Get the object being invoked. */ in qcomtee_cb_object_invoke()
626 struct qcomtee_object *object; in qcomtee_cb_object_invoke() local
628 /* QTEE cannot invoke a NULL object or objects it hosts. */ in qcomtee_cb_object_invoke()
635 object = qcomtee_local_object_get(oic, object_id); in qcomtee_cb_object_invoke()
636 if (object == NULL_QCOMTEE_OBJECT) { in qcomtee_cb_object_invoke()
641 oic->object = object; in qcomtee_cb_object_invoke()
649 qcomtee_object_put(object); in qcomtee_cb_object_invoke()
654 qcomtee_object_get(object); in qcomtee_cb_object_invoke()
661 /* Release any object that arrived as input. */ in qcomtee_cb_object_invoke()
668 errno = object->ops->dispatch(oic, object, op, oic->u); in qcomtee_cb_object_invoke()
728 * qcomtee_object_do_invoke_internal() - Submit an invocation for an object.
730 * @object: object being invoked.
731 * @op: requested operation on the object.
736 * object, including @object. On return, the caller loses ownership of all
742 struct qcomtee_object *object, u32 op, in qcomtee_object_do_invoke_internal() argument
758 ret = qcomtee_prepare_msg(oic, object, op, u); in qcomtee_object_do_invoke_internal()
776 /* Invoke the remote object. */ in qcomtee_object_do_invoke_internal()
780 qto = oic->object; in qcomtee_object_do_invoke_internal()
792 oic->object = NULL_QCOMTEE_OBJECT; in qcomtee_object_do_invoke_internal()
849 struct qcomtee_object *object, u32 op, in qcomtee_object_do_invoke() argument
857 if (typeof_qcomtee_object(object) != QCOMTEE_OBJECT_TYPE_TEE && in qcomtee_object_do_invoke()
858 typeof_qcomtee_object(object) != QCOMTEE_OBJECT_TYPE_ROOT) in qcomtee_object_do_invoke()
866 return qcomtee_object_do_invoke_internal(oic, object, op, u, result); in qcomtee_object_do_invoke()
870 * qcomtee_object_get_client_env() - Get a privileged client env. object.
873 * The caller should call qcomtee_object_put() on the returned object
877 * On success, returns the object.