If the purpose of this feature is to dedup usrptr BOs of a the single
process/application, can this can be done in userspace?
On 3/21/25 11:00, Honglei Huang wrote:
int virtio_gpu_userptr_create(struct virtio_gpu_device *vgdev,
struct drm_file *file,
struct virtio_gpu_object_params *params,
- struct virtio_gpu_object **bo_ptr)
+ struct virtio_gpu_object **bo_ptr,
+ struct drm_virtgpu_resource_create_blob *rc_blob)
{
+ struct virtio_gpu_fpriv *vfpriv = file->driver_priv;
struct virtio_gpu_object_userptr *userptr;
int ret, si;
struct sg_table *sgt;
@@ -187,6 +290,20 @@ int virtio_gpu_userptr_create(struct virtio_gpu_device *vgdev,
params->size))
return -EFAULT;
+ mutex_lock(&vfpriv->userptrs_tree_lock);
+
+ userptr = virtio_gpu_userptr_from_addr_range(
+ vfpriv, params->userptr, params->userptr + params->size - 1UL);
Is it possible that userptr address will be same for two different
processes?
What if userptr->flags mismatch?
+ if (userptr) {
+ *bo_ptr = &userptr->base;
+ rc_blob->res_handle = userptr->base.hw_res_handle;
+ rc_blob->bo_handle = userptr->bo_handle;
Doesn't BO refcount need to be bumped?
+ rc_blob->offset = virtio_gpu_userptr_get_offset(
+ &userptr->base, rc_blob->userptr);
+ mutex_unlock(&vfpriv->userptrs_tree_lock);
+ return STATE_RES_EXISTS;
STATE_RES_EXISTS isn't a error code