On 11/25/24 10:31, Vivek Kasireddy wrote: > struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, > struct dma_buf *buf) > { > + struct virtio_gpu_device *vgdev = dev->dev_private; > + struct dma_buf_attachment *attach; > + struct virtio_gpu_object *bo; > struct drm_gem_object *obj; > + int ret; > > if (buf->ops == &virtgpu_dmabuf_ops.ops) { > obj = buf->priv; > @@ -275,7 +304,32 @@ struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev, > } > } > > - return drm_gem_prime_import(dev, buf); > + if (!vgdev->has_resource_blob || vgdev->has_virgl_3d) > + return drm_gem_prime_import(dev, buf); > + > + bo = kzalloc(sizeof(*bo), GFP_KERNEL); > + if (!bo) > + return ERR_PTR(-ENOMEM); > + > + obj = &bo->base.base; > + obj->funcs = &virtgpu_gem_dma_buf_funcs; > + drm_gem_private_object_init(dev, obj, buf->size); > + > + attach = dma_buf_dynamic_attach(buf, dev->dev, > + &virtgpu_dma_buf_attach_ops, obj); > + if (IS_ERR(attach)) { > + kfree(bo); > + return ERR_CAST(attach); > + } > + > + obj->import_attach = attach; > + get_dma_buf(buf); > + > + ret = virtgpu_dma_buf_init_obj(dev, bo, attach); > + if (ret < 0) > + return ERR_PTR(ret); Perhaps for a future improvement. Think we can defer virtgpu_dma_buf_init_obj() until first use of the object in a case where exporter supports dynamic attachment. Otherwise, we're pinning object at the import time, partially defeating the purpose of the dynamic attachment, AFAICT. I.e. if importer never uses object, then there is no need to bother the exporter with the pinning. -- Best regards, Dmitry