Lines Matching refs:obj

150 static TEE_Result allocate_private(struct caamdmaobj *obj, unsigned int type)  in allocate_private()  argument
158 obj->priv = priv; in allocate_private()
179 static void add_sgtdata_entry(struct caamdmaobj *obj, struct sgtdata *sgtdata, in add_sgtdata_entry() argument
193 obj->sgtbuf.length += dma->length; in add_sgtdata_entry()
309 struct caamdmaobj *obj) in dmaobj_cache_operation() argument
311 if (!obj->sgtbuf.length) in dmaobj_cache_operation()
314 if (obj->sgtbuf.sgt_type) in dmaobj_cache_operation()
315 caam_sgt_cache_op(op, &obj->sgtbuf, obj->sgtbuf.length); in dmaobj_cache_operation()
316 else if (!obj->sgtbuf.buf->nocache) in dmaobj_cache_operation()
317 cache_operation(op, obj->sgtbuf.buf->data, obj->sgtbuf.length); in dmaobj_cache_operation()
515 static TEE_Result check_buffer_boundary(struct caamdmaobj *obj, in check_buffer_boundary() argument
519 struct priv_dmaobj *priv = obj->priv; in check_buffer_boundary()
595 static enum caam_status entry_sgtbuf_dmabuf(struct caamdmaobj *obj, in entry_sgtbuf_dmabuf() argument
599 struct priv_dmaobj *priv = obj->priv; in entry_sgtbuf_dmabuf()
600 struct caambuf *sgtbuf = &obj->sgtbuf.buf[index]; in entry_sgtbuf_dmabuf()
618 add_sgtdata_entry(obj, &priv->sgtdata[index], entry, sgtbuf, off); in entry_sgtbuf_dmabuf()
633 static enum caam_status entry_sgtbuf(struct caamdmaobj *obj, in entry_sgtbuf() argument
637 struct priv_dmaobj *priv = obj->priv; in entry_sgtbuf()
638 struct caambuf *sgtbuf = &obj->sgtbuf.buf[index]; in entry_sgtbuf()
647 add_sgtdata_entry(obj, sgtdata, entry, sgtbuf, off); in entry_sgtbuf()
652 TEE_Result caam_dmaobj_init_input(struct caamdmaobj *obj, const void *data, in caam_dmaobj_init_input() argument
659 if (!data || !length || !obj) { in caam_dmaobj_init_input()
664 obj->orig.paddr = virt_to_phys((void *)data); in caam_dmaobj_init_input()
665 if (!obj->orig.paddr) { in caam_dmaobj_init_input()
671 obj->orig.data = (void *)data; in caam_dmaobj_init_input()
672 obj->orig.length = length; in caam_dmaobj_init_input()
674 obj->orig.nocache = 1; in caam_dmaobj_init_input()
676 ret = allocate_private(obj, DMAOBJ_INPUT); in caam_dmaobj_init_input()
678 ret = check_buffer_boundary(obj, &obj->orig, obj->orig.length); in caam_dmaobj_init_input()
685 TEE_Result caam_dmaobj_input_sgtbuf(struct caamdmaobj *obj, const void *data, in caam_dmaobj_input_sgtbuf() argument
691 ret = caam_dmaobj_init_input(obj, data, length); in caam_dmaobj_input_sgtbuf()
695 ret = caam_dmaobj_prepare(obj, NULL, length); in caam_dmaobj_input_sgtbuf()
699 ret = caam_dmaobj_sgtbuf_build(obj, &size_done, 0, length); in caam_dmaobj_input_sgtbuf()
709 TEE_Result caam_dmaobj_init_output(struct caamdmaobj *obj, void *data, in caam_dmaobj_init_output() argument
719 if (!obj) { in caam_dmaobj_init_output()
724 ret = allocate_private(obj, DMAOBJ_OUTPUT); in caam_dmaobj_init_output()
729 obj->orig.paddr = virt_to_phys((void *)data); in caam_dmaobj_init_output()
730 if (!obj->orig.paddr) { in caam_dmaobj_init_output()
736 obj->orig.data = (void *)data; in caam_dmaobj_init_output()
737 obj->orig.length = length; in caam_dmaobj_init_output()
739 obj->orig.nocache = 1; in caam_dmaobj_init_output()
741 ret = check_buffer_boundary(obj, &obj->orig, in caam_dmaobj_init_output()
742 MIN(min_length, obj->orig.length)); in caam_dmaobj_init_output()
752 entry = dmalist_add_entry(obj->priv, &newbuf); in caam_dmaobj_init_output()
759 add_dma_require(obj->priv, newbuf.length); in caam_dmaobj_init_output()
772 TEE_Result caam_dmaobj_output_sgtbuf(struct caamdmaobj *obj, void *data, in caam_dmaobj_output_sgtbuf() argument
800 ret = caam_dmaobj_init_output(obj, buf.data, buf.length, size); in caam_dmaobj_output_sgtbuf()
805 obj->orig.length = min_length; in caam_dmaobj_output_sgtbuf()
808 priv = obj->priv; in caam_dmaobj_output_sgtbuf()
811 ret = caam_dmaobj_init_output(obj, data, length, min_length); in caam_dmaobj_output_sgtbuf()
816 ret = caam_dmaobj_prepare(NULL, obj, min_length); in caam_dmaobj_output_sgtbuf()
821 ret = caam_dmaobj_sgtbuf_build(obj, &size, 0, min_length); in caam_dmaobj_output_sgtbuf()
831 void caam_dmaobj_cache_push(struct caamdmaobj *obj) in caam_dmaobj_cache_push() argument
836 if (!obj || !obj->priv) in caam_dmaobj_cache_push()
839 priv = obj->priv; in caam_dmaobj_cache_push()
843 dmaobj_cache_operation(op, obj); in caam_dmaobj_cache_push()
846 size_t caam_dmaobj_copy_to_orig(struct caamdmaobj *obj) in caam_dmaobj_copy_to_orig() argument
854 if (!obj || !obj->orig.data || !obj->priv) in caam_dmaobj_copy_to_orig()
857 dmaobj_cache_operation(TEE_CACHEINVALIDATE, obj); in caam_dmaobj_copy_to_orig()
859 priv = obj->priv; in caam_dmaobj_copy_to_orig()
866 dst_rlen = MIN(obj->orig.length, obj->sgtbuf.length); in caam_dmaobj_copy_to_orig()
870 for (idx = 0; idx < obj->sgtbuf.number; idx++) { in caam_dmaobj_copy_to_orig()
889 size_t caam_dmaobj_copy_ltrim_to_orig(struct caamdmaobj *obj) in caam_dmaobj_copy_ltrim_to_orig() argument
900 if (!obj || !obj->orig.data || !obj->priv) in caam_dmaobj_copy_ltrim_to_orig()
903 dmaobj_cache_operation(TEE_CACHEINVALIDATE, obj); in caam_dmaobj_copy_ltrim_to_orig()
905 priv = obj->priv; in caam_dmaobj_copy_ltrim_to_orig()
908 for (idx = 0; idx < obj->sgtbuf.number; idx++) { in caam_dmaobj_copy_ltrim_to_orig()
924 if (off < obj->orig.length) in caam_dmaobj_copy_ltrim_to_orig()
925 dst_rlen = obj->orig.length - off; in caam_dmaobj_copy_ltrim_to_orig()
927 dst = obj->orig.data; in caam_dmaobj_copy_ltrim_to_orig()
930 obj->sgtbuf.sgt_type); in caam_dmaobj_copy_ltrim_to_orig()
942 for (; idx < obj->sgtbuf.number; idx++) { in caam_dmaobj_copy_ltrim_to_orig()
969 void caam_dmaobj_free(struct caamdmaobj *obj) in caam_dmaobj_free() argument
976 if (!obj) in caam_dmaobj_free()
980 priv = obj->priv; in caam_dmaobj_free()
986 obj->orig.data, obj->orig.length); in caam_dmaobj_free()
1001 obj->sgtbuf.number = priv->nb_sgtbuf; in caam_dmaobj_free()
1002 obj->sgtbuf.sgt_type = (priv->nb_sgtbuf > 1) ? true : false; in caam_dmaobj_free()
1012 caam_free_buf(&obj->orig); in caam_dmaobj_free()
1019 if (obj->sgtbuf.number) { in caam_dmaobj_free()
1020 DMAOBJ_TRACE("Free #%d SGT/Buffer %p", obj->sgtbuf.number, in caam_dmaobj_free()
1021 &obj->sgtbuf); in caam_dmaobj_free()
1022 caam_sgtbuf_free(&obj->sgtbuf); in caam_dmaobj_free()
1025 memset(obj, 0, sizeof(*obj)); in caam_dmaobj_free()
1030 TEE_Result caam_dmaobj_add_first_block(struct caamdmaobj *obj, in caam_dmaobj_add_first_block() argument
1037 if (!obj || !obj->priv || !block) in caam_dmaobj_add_first_block()
1040 priv = obj->priv; in caam_dmaobj_add_first_block()
1063 TEE_Result caam_dmaobj_derive_sgtbuf(struct caamdmaobj *obj, in caam_dmaobj_derive_sgtbuf() argument
1074 if (!obj || !from || !length || !from->priv) { in caam_dmaobj_derive_sgtbuf()
1092 retstatus = caam_sgt_derive(&obj->sgtbuf, &from->sgtbuf, offset, in caam_dmaobj_derive_sgtbuf()
1108 static size_t get_dma_max_alloc_size(struct caamdmaobj *obj) in get_dma_max_alloc_size() argument
1113 if (!obj) in get_dma_max_alloc_size()
1116 priv = obj->priv; in get_dma_max_alloc_size()
1137 static TEE_Result try_allocate_dmabuf_max_size(struct caamdmaobj *obj, in try_allocate_dmabuf_max_size() argument
1147 alloc_size = get_dma_max_alloc_size(obj); in try_allocate_dmabuf_max_size()
1155 priv = obj->priv; in try_allocate_dmabuf_max_size()
1268 TEE_Result caam_dmaobj_sgtbuf_build(struct caamdmaobj *obj, size_t *length, in caam_dmaobj_sgtbuf_build() argument
1282 DMAOBJ_TRACE("obj=%p of %zu bytes (offset=%zu) - align %zu", obj, in caam_dmaobj_sgtbuf_build()
1285 if (!obj || !obj->priv || !length || !*length) { in caam_dmaobj_sgtbuf_build()
1290 priv = obj->priv; in caam_dmaobj_sgtbuf_build()
1332 obj->sgtbuf.number = priv->nb_sgtbuf; in caam_dmaobj_sgtbuf_build()
1333 obj->sgtbuf.sgt_type = (priv->nb_sgtbuf > 1); in caam_dmaobj_sgtbuf_build()
1335 caam_sgtbuf_free(&obj->sgtbuf); in caam_dmaobj_sgtbuf_build()
1340 obj->sgtbuf.number = nb_sgt; in caam_dmaobj_sgtbuf_build()
1341 obj->sgtbuf.sgt_type = (nb_sgt > 1) ? true : false; in caam_dmaobj_sgtbuf_build()
1344 retstatus = caam_sgtbuf_alloc(&obj->sgtbuf); in caam_dmaobj_sgtbuf_build()
1346 obj->sgtbuf.number, retstatus); in caam_dmaobj_sgtbuf_build()
1360 obj->sgtbuf.number = nb_sgt; in caam_dmaobj_sgtbuf_build()
1361 obj->sgtbuf.sgt_type = (nb_sgt > 1) ? true : false; in caam_dmaobj_sgtbuf_build()
1370 obj->sgtbuf.length = 0; in caam_dmaobj_sgtbuf_build()
1375 retstatus = entry_sgtbuf_dmabuf(obj, entry, idx, in caam_dmaobj_sgtbuf_build()
1382 retstatus = entry_sgtbuf(obj, entry, idx, offset); in caam_dmaobj_sgtbuf_build()
1389 if (obj->sgtbuf.length >= max_length) { in caam_dmaobj_sgtbuf_build()
1391 obj->sgtbuf.length = max_length; in caam_dmaobj_sgtbuf_build()
1397 if (obj->sgtbuf.sgt_type) { in caam_dmaobj_sgtbuf_build()
1399 caam_sgt_fill_table(&obj->sgtbuf); in caam_dmaobj_sgtbuf_build()
1401 obj->sgtbuf.paddr = virt_to_phys(obj->sgtbuf.sgt); in caam_dmaobj_sgtbuf_build()
1403 obj->sgtbuf.paddr = obj->sgtbuf.buf->paddr; in caam_dmaobj_sgtbuf_build()
1406 *length = obj->sgtbuf.length; in caam_dmaobj_sgtbuf_build()