accel/qaic: Add support to export dmabuf fd

Add support to export BO as DMABUF to enable userspace to reuse buffers
and reduce number of copy.

Signed-off-by: Pranjal Ramajor Asha Kanojiya <[email protected]>
Signed-off-by: Youssef Samir <[email protected]>
Reviewed-by: Jeff Hugo <[email protected]>
Signed-off-by: Jeff Hugo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
This commit is contained in:
Pranjal Ramajor Asha Kanojiya authored and Jeff Hugo committed 2025-10-13 11:26:31 -06:00
1 parent 1226cd7c76
commit dba5f91829
1 file changed
+28
+28
View File
@@ -644,8 +644,36 @@ static void qaic_free_object(struct drm_gem_object *obj)
kfree(bo);
}
static struct sg_table *qaic_get_sg_table(struct drm_gem_object *obj)
{
struct qaic_bo *bo = to_qaic_bo(obj);
struct scatterlist *sg, *sg_in;
struct sg_table *sgt, *sgt_in;
int i;
sgt_in = bo->sgt;
sgt = kmalloc(sizeof(*sgt), GFP_KERNEL);
if (!sgt)
return ERR_PTR(-ENOMEM);
if (sg_alloc_table(sgt, sgt_in->orig_nents, GFP_KERNEL)) {
kfree(sgt);
return ERR_PTR(-ENOMEM);
}
sg = sgt->sgl;
for_each_sgtable_sg(sgt_in, sg_in, i) {
memcpy(sg, sg_in, sizeof(*sg));
sg = sg_next(sg);
}
return sgt;
}
static const struct drm_gem_object_funcs qaic_gem_funcs = {
.free = qaic_free_object,
.get_sg_table = qaic_get_sg_table,
.print_info = qaic_gem_print_info,
.mmap = qaic_gem_object_mmap,
.vm_ops = &drm_vm_ops,