We're moving away from implicit get_pages() that is done by get_pages_sgt() to simplify the refcnt handling. Drivers will have to pin pages while they use sgt. VirtIO-GPU doesn't support shrinker, hence pages are pinned and sgt is valid as long as pages' use-count > 0. Reviewed-by: Boris Brezillon <boris.brezillon@xxxxxxxxxxxxx> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@xxxxxxxxxxxxx> --- drivers/gpu/drm/virtio/virtgpu_object.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virtio/virtgpu_object.c index c7e74cf13022..e58528c562ef 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -67,6 +67,7 @@ void virtio_gpu_cleanup_object(struct virtio_gpu_object *bo) virtio_gpu_resource_id_put(vgdev, bo->hw_res_handle); if (virtio_gpu_is_shmem(bo)) { + drm_gem_shmem_put_pages(&bo->base); drm_gem_shmem_free(&bo->base); } else if (virtio_gpu_is_vram(bo)) { struct virtio_gpu_object_vram *vram = to_virtio_gpu_vram(bo); @@ -196,9 +197,13 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, return PTR_ERR(shmem_obj); bo = gem_to_virtio_gpu_obj(&shmem_obj->base); + ret = drm_gem_shmem_get_pages(shmem_obj); + if (ret) + goto err_free_gem; + ret = virtio_gpu_resource_id_get(vgdev, &bo->hw_res_handle); if (ret < 0) - goto err_free_gem; + goto err_put_pages; bo->dumb = params->dumb; @@ -243,6 +248,8 @@ int virtio_gpu_object_create(struct virtio_gpu_device *vgdev, kvfree(ents); err_put_id: virtio_gpu_resource_id_put(vgdev, bo->hw_res_handle); +err_put_pages: + drm_gem_shmem_put_pages(shmem_obj); err_free_gem: drm_gem_shmem_free(shmem_obj); return ret; -- 2.43.0