drm/shmem-helper: Switch drm_gem_shmem_vmap/vunmap to use pin/unpin

The vmapped pages shall be pinned in memory and previously get/put_pages()
were implicitly hard-pinning/unpinning the pages. This will no longer be
the case with addition of memory shrinker because pages_use_count > 0 won't
determine anymore whether pages are hard-pinned (they will be soft-pinned),
while the new pages_pin_count will do the hard-pinning. Switch the
vmap/vunmap() to use pin/unpin() functions in a preparation of addition
of the memory shrinker support to drm-shmem.

Acked-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.d>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250322212608.40511-10-dmitry.osipenko@collabora.com
This commit is contained in:
Dmitry Osipenko
2025-03-23 00:26:07 +03:00
parent 051b6646d3
commit 0271cc484f
2 changed files with 4 additions and 4 deletions

View File

@@ -360,7 +360,7 @@ int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem,
return 0;
}
ret = drm_gem_shmem_get_pages_locked(shmem);
ret = drm_gem_shmem_pin_locked(shmem);
if (ret)
goto err_zero_use;
@@ -383,7 +383,7 @@ int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem,
err_put_pages:
if (!drm_gem_is_imported(obj))
drm_gem_shmem_put_pages_locked(shmem);
drm_gem_shmem_unpin_locked(shmem);
err_zero_use:
shmem->vmap_use_count = 0;
@@ -420,7 +420,7 @@ void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem,
return;
vunmap(shmem->vaddr);
drm_gem_shmem_put_pages_locked(shmem);
drm_gem_shmem_unpin_locked(shmem);
}
shmem->vaddr = NULL;