@@ -367,6 +367,7 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev,
struct virtio_gpu_fence *fence);
bool virtio_gpu_is_shmem(struct drm_gem_object *obj);
+uint32_t virtio_gpu_get_handle(struct drm_gem_object *obj);
/* virtgpu_prime.c */
struct drm_gem_object *virtgpu_gem_prime_import_sg_table(
@@ -62,6 +62,19 @@ static void virtio_gpu_resource_id_put(struct virtio_gpu_device *vgdev, uint32_t
}
}
+uint32_t virtio_gpu_get_handle(struct drm_gem_object *obj)
+{
+ if (virtio_gpu_is_shmem(obj)) {
+ struct virtio_gpu_object *bo;
+
+ bo = gem_to_virtio_gpu_obj(obj);
+ return bo->hw_res_handle;
+ }
+
+ DRM_ERROR("resource handle not found\n");
+ return 0;
+}
+
void virtio_gpu_cleanup_object(struct virtio_gpu_object *bo)
{
struct virtio_gpu_device *vgdev = bo->base.base.dev->dev_private;
Whether the resource is a shmem based resource or a (planned) vram based resource, it will have a resource handle associated with it. Since the hypercall interface works on resource handles, add a function that returns the handle given a GEM object. Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org> --- drivers/gpu/drm/virtio/virtgpu_drv.h | 1 + drivers/gpu/drm/virtio/virtgpu_object.c | 13 +++++++++++++ 2 files changed, 14 insertions(+)