[PATCH v2 7/7] drm/virtio: implement userptr: add interval tree
Huang, Honglei1
Honglei1.Huang at amd.com
Wed Apr 2 01:53:10 UTC 2025
On 2025/3/30 19:57, Dmitry Osipenko wrote:
> 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?
This situation need to be considered, I will add flag check, and add
handle the situation of increasing write permissions.
>
>> + 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?
Will add Bo refcount in next version.
>
>> + 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
Will use the system's built-in error code, really thanks for the review.
>
More information about the dri-devel
mailing list