[PATCH v1] drm/virtio: Set missing bo->attached flag

Dmitry Osipenko posted 1 patch 3 weeks, 6 days ago
drivers/gpu/drm/virtio/virtgpu_prime.c | 1 -
drivers/gpu/drm/virtio/virtgpu_vq.c    | 3 +++
2 files changed, 3 insertions(+), 1 deletion(-)
[PATCH v1] drm/virtio: Set missing bo->attached flag
Posted by Dmitry Osipenko 3 weeks, 6 days ago
VirtIO-GPU driver now supports detachment of shmem BOs from host, but
doing it only for imported dma-bufs. Mark all shmem BOs as attached, not
just dma-bufs. This is a minor correction since detachment of a non-dmabuf
BOs not supported today.

Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
---
 drivers/gpu/drm/virtio/virtgpu_prime.c | 1 -
 drivers/gpu/drm/virtio/virtgpu_vq.c    | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c b/drivers/gpu/drm/virtio/virtgpu_prime.c
index 688810d1b611..33084ce1d01d 100644
--- a/drivers/gpu/drm/virtio/virtgpu_prime.c
+++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
@@ -249,7 +249,6 @@ static int virtgpu_dma_buf_init_obj(struct drm_device *dev,
 	virtio_gpu_cmd_resource_create_blob(vgdev, bo, &params,
 					    ents, nents);
 	bo->guest_blob = true;
-	bo->attached = true;
 
 	dma_buf_unpin(attach);
 	dma_resv_unlock(resv);
diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index ad91624df42d..062639250a4e 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -1300,6 +1300,9 @@ virtio_gpu_cmd_resource_create_blob(struct virtio_gpu_device *vgdev,
 
 	virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
 	bo->created = true;
+
+	if (nents)
+		bo->attached = true;
 }
 
 void virtio_gpu_cmd_set_scanout_blob(struct virtio_gpu_device *vgdev,
-- 
2.47.0
RE: [PATCH v1] drm/virtio: Set missing bo->attached flag
Posted by Kasireddy, Vivek 3 weeks, 3 days ago
> Subject: [PATCH v1] drm/virtio: Set missing bo->attached flag
> 
> VirtIO-GPU driver now supports detachment of shmem BOs from host, but
> doing it only for imported dma-bufs. Mark all shmem BOs as attached, not
> just dma-bufs. This is a minor correction since detachment of a non-dmabuf
> BOs not supported today.
> 
> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
> ---
>  drivers/gpu/drm/virtio/virtgpu_prime.c | 1 -
>  drivers/gpu/drm/virtio/virtgpu_vq.c    | 3 +++
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/virtio/virtgpu_prime.c
> b/drivers/gpu/drm/virtio/virtgpu_prime.c
> index 688810d1b611..33084ce1d01d 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_prime.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_prime.c
> @@ -249,7 +249,6 @@ static int virtgpu_dma_buf_init_obj(struct
> drm_device *dev,
>  	virtio_gpu_cmd_resource_create_blob(vgdev, bo, &params,
>  					    ents, nents);
>  	bo->guest_blob = true;
> -	bo->attached = true;
> 
>  	dma_buf_unpin(attach);
>  	dma_resv_unlock(resv);
> diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c
> b/drivers/gpu/drm/virtio/virtgpu_vq.c
> index ad91624df42d..062639250a4e 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> @@ -1300,6 +1300,9 @@ virtio_gpu_cmd_resource_create_blob(struct
> virtio_gpu_device *vgdev,
> 
>  	virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
>  	bo->created = true;
> +
> +	if (nents)
> +		bo->attached = true;
Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com>

>  }
> 
>  void virtio_gpu_cmd_set_scanout_blob(struct virtio_gpu_device *vgdev,
> --
> 2.47.0