Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+4 -4
+3 -3
drivers/gpu/drm/drm_gem_shmem_helper.c
··· 360 360 return 0; 361 361 } 362 362 363 - ret = drm_gem_shmem_get_pages_locked(shmem); 363 + ret = drm_gem_shmem_pin_locked(shmem); 364 364 if (ret) 365 365 goto err_zero_use; 366 366 ··· 383 383 384 384 err_put_pages: 385 385 if (!drm_gem_is_imported(obj)) 386 - drm_gem_shmem_put_pages_locked(shmem); 386 + drm_gem_shmem_unpin_locked(shmem); 387 387 err_zero_use: 388 388 shmem->vmap_use_count = 0; 389 389 ··· 420 420 return; 421 421 422 422 vunmap(shmem->vaddr); 423 - drm_gem_shmem_put_pages_locked(shmem); 423 + drm_gem_shmem_unpin_locked(shmem); 424 424 } 425 425 426 426 shmem->vaddr = NULL;
+1 -1
include/drm/drm_gem_shmem_helper.h
··· 130 130 static inline bool drm_gem_shmem_is_purgeable(struct drm_gem_shmem_object *shmem) 131 131 { 132 132 return (shmem->madv > 0) && 133 - !shmem->vmap_use_count && shmem->sgt && 133 + !refcount_read(&shmem->pages_pin_count) && shmem->sgt && 134 134 !shmem->base.dma_buf && !drm_gem_is_imported(&shmem->base); 135 135 } 136 136