[RFC PATCH 4/8] drm/virtio: make RESOURCE_UNREF use virtio_gpu_get_handle(..)
Gurchetan Singh
gurchetansingh at chromium.org
Thu Feb 27 00:25:57 UTC 2020
This hypercall is reusable for both shmem and (planned) vram
based virtgpu objects.
Signed-off-by: Gurchetan Singh <gurchetansingh at chromium.org>
---
drivers/gpu/drm/virtio/virtgpu_drv.h | 2 +-
drivers/gpu/drm/virtio/virtgpu_object.c | 2 +-
drivers/gpu/drm/virtio/virtgpu_vq.c | 17 +++++++++++------
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/virtgpu_drv.h
index 48ca1316ef7b..0e99487f2105 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.h
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -267,7 +267,7 @@ void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev,
struct virtio_gpu_object_array *objs,
struct virtio_gpu_fence *fence);
void virtio_gpu_cmd_unref_resource(struct virtio_gpu_device *vgdev,
- struct virtio_gpu_object *bo);
+ struct drm_gem_object *obj);
void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev,
uint64_t offset,
uint32_t width, uint32_t height,
diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c
index 283b6dadd7c8..84df573e13de 100644
--- a/drivers/gpu/drm/virtio/virtgpu_object.c
+++ b/drivers/gpu/drm/virtio/virtgpu_object.c
@@ -100,7 +100,7 @@ static void virtio_gpu_free_object(struct drm_gem_object *obj)
struct virtio_gpu_device *vgdev = bo->base.base.dev->dev_private;
if (bo->created) {
- virtio_gpu_cmd_unref_resource(vgdev, bo);
+ virtio_gpu_cmd_unref_resource(vgdev, obj);
virtio_gpu_notify(vgdev);
/* completion handler calls virtio_gpu_cleanup_object() */
return;
diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index 5e2375e0f7bb..feceda66da75 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -521,28 +521,33 @@ void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev,
static void virtio_gpu_cmd_unref_cb(struct virtio_gpu_device *vgdev,
struct virtio_gpu_vbuffer *vbuf)
{
- struct virtio_gpu_object *bo;
+ struct drm_gem_object *obj;
- bo = vbuf->resp_cb_data;
+ obj = vbuf->resp_cb_data;
vbuf->resp_cb_data = NULL;
- virtio_gpu_cleanup_object(bo);
+ if (obj && virtio_gpu_is_shmem(obj)) {
+ struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
+
+ virtio_gpu_cleanup_object(bo);
+ }
}
void virtio_gpu_cmd_unref_resource(struct virtio_gpu_device *vgdev,
- struct virtio_gpu_object *bo)
+ struct drm_gem_object *obj)
{
struct virtio_gpu_resource_unref *cmd_p;
struct virtio_gpu_vbuffer *vbuf;
+ uint32_t handle = virtio_gpu_get_handle(obj);
cmd_p = virtio_gpu_alloc_cmd_cb(vgdev, &vbuf, sizeof(*cmd_p),
virtio_gpu_cmd_unref_cb);
memset(cmd_p, 0, sizeof(*cmd_p));
cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_RESOURCE_UNREF);
- cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
+ cmd_p->resource_id = cpu_to_le32(handle);
- vbuf->resp_cb_data = bo;
+ vbuf->resp_cb_data = obj;
virtio_gpu_queue_ctrl_buffer(vgdev, vbuf);
}
--
2.25.1.481.gfbce0eb801-goog
More information about the dri-devel
mailing list