[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6e796751-86f3-42e5-b0a6-3a3602d3af13@amd.com>
Date: Wed, 2 Apr 2025 09:53:10 +0800
From: "Huang, Honglei1" <Honglei1.Huang@....com>
To: Dmitry Osipenko <dmitry.osipenko@...labora.com>,
David Airlie <airlied@...hat.com>, Gerd Hoffmann <kraxel@...hat.com>,
Gurchetan Singh <gurchetansingh@...omium.org>, Chia-I Wu
<olvaffe@...il.com>, Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
Simona Vetter <simona@...ll.ch>, Rob Clark <robdclark@...il.com>,
Huang Rui <ray.huang@....com>
Cc: dri-devel@...ts.freedesktop.org, virtualization@...ts.linux.dev,
linux-kernel@...r.kernel.org, Demi Marie Obenour <demiobenour@...il.com>
Subject: Re: [PATCH v2 7/7] drm/virtio: implement userptr: add interval tree
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.
>
Powered by blists - more mailing lists