[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231110115913.48f5672b@collabora.com>
Date: Fri, 10 Nov 2023 11:59:13 +0100
From: Boris Brezillon <boris.brezillon@...labora.com>
To: Dmitry Osipenko <dmitry.osipenko@...labora.com>
Cc: David Airlie <airlied@...il.com>,
Gerd Hoffmann <kraxel@...hat.com>,
Gurchetan Singh <gurchetansingh@...omium.org>,
Chia-I Wu <olvaffe@...il.com>, Daniel Vetter <daniel@...ll.ch>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
Christian König <christian.koenig@....com>,
Qiang Yu <yuq825@...il.com>,
Steven Price <steven.price@....com>,
Emma Anholt <emma@...olt.net>, Melissa Wen <mwen@...lia.com>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
kernel@...labora.com, virtualization@...ts.linux-foundation.org
Subject: Re: [PATCH v18 16/26] drm/virtio: Explicitly get and put drm-shmem
pages
On Mon, 30 Oct 2023 02:01:55 +0300
Dmitry Osipenko <dmitry.osipenko@...labora.com> wrote:
> 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.
>
> Signed-off-by: Dmitry Osipenko <dmitry.osipenko@...labora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@...labora.com>
> ---
> 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 ee5d2a70656b..998f8b05ceb1 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;
Powered by blists - more mailing lists