mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-13 15:19:26 -04:00
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 <quic_pkanojiy@quicinc.com> Signed-off-by: Youssef Samir <youssef.abdulrahman@oss.qualcomm.com> Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com> Signed-off-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com> Link: https://lore.kernel.org/r/20251007053853.193608-1-youssef.abdulrahman@oss.qualcomm.com
This commit is contained in:
committed by
Jeff Hugo
parent
1226cd7c76
commit
dba5f91829
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user