mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
drm/virtio: resource teardown tweaks
Add new virtio_gpu_cleanup_object() helper function for object cleanup. Wire up callback function for resource unref, do cleanup from callback when we know the host stopped using the resource. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Link: http://patchwork.freedesktop.org/patch/msgid/20200207074638.26386-3-kraxel@redhat.com Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
This commit is contained in:
parent
8235eab012
commit
1ed5f698ad
3 changed files with 43 additions and 9 deletions
|
@ -61,6 +61,14 @@ static void virtio_gpu_resource_id_put(struct virtio_gpu_device *vgdev, uint32_t
|
|||
}
|
||||
}
|
||||
|
||||
void virtio_gpu_cleanup_object(struct virtio_gpu_object *bo)
|
||||
{
|
||||
struct virtio_gpu_device *vgdev = bo->base.base.dev->dev_private;
|
||||
|
||||
virtio_gpu_resource_id_put(vgdev, bo->hw_res_handle);
|
||||
drm_gem_shmem_free_object(&bo->base.base);
|
||||
}
|
||||
|
||||
static void virtio_gpu_free_object(struct drm_gem_object *obj)
|
||||
{
|
||||
struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(obj);
|
||||
|
@ -68,11 +76,12 @@ static void virtio_gpu_free_object(struct drm_gem_object *obj)
|
|||
|
||||
if (bo->pages)
|
||||
virtio_gpu_object_detach(vgdev, bo);
|
||||
if (bo->created)
|
||||
virtio_gpu_cmd_unref_resource(vgdev, bo->hw_res_handle);
|
||||
virtio_gpu_resource_id_put(vgdev, bo->hw_res_handle);
|
||||
|
||||
drm_gem_shmem_free_object(obj);
|
||||
if (bo->created) {
|
||||
virtio_gpu_cmd_unref_resource(vgdev, bo);
|
||||
/* completion handler calls virtio_gpu_cleanup_object() */
|
||||
return;
|
||||
}
|
||||
virtio_gpu_cleanup_object(bo);
|
||||
}
|
||||
|
||||
static const struct drm_gem_object_funcs virtio_gpu_gem_funcs = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue