@@ -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,
@@ -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;
@@ -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);
}
This hypercall is reusable for both shmem and (planned) vram based virtgpu objects. Signed-off-by: Gurchetan Singh <gurchetansingh@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(-)