diff options
author | Dmitry Osipenko <dmitry.osipenko@collabora.com> | 2022-11-16 15:07:50 +0100 |
---|---|---|
committer | Dmitry Osipenko <dmitry.osipenko@collabora.com> | 2023-02-27 05:09:41 +0100 |
commit | 7eabaa892d9c57ad9b2946f923d781e8a16f8e88 (patch) | |
tree | 04055fb89034b3535b5901c9247d64a2bda94b02 /drivers/gpu/drm/drm_gem.c | |
parent | drm/virtio: use strscpy() to instead of strncpy() (diff) | |
download | linux-7eabaa892d9c57ad9b2946f923d781e8a16f8e88.tar.xz linux-7eabaa892d9c57ad9b2946f923d781e8a16f8e88.zip |
drm/gem: Add evict() callback to drm_gem_object_funcs
Add new common evict() callback to drm_gem_object_funcs and corresponding
drm_gem_object_evict() helper. This is a first step on a way to providing
common GEM-shrinker API for DRM drivers.
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://lore.kernel.org/all/20230108210445.3948344-4-dmitry.osipenko@collabora.com/
Diffstat (limited to 'drivers/gpu/drm/drm_gem.c')
-rw-r--r-- | drivers/gpu/drm/drm_gem.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index aa15c52ae182..9b2e7864dbd0 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c @@ -1459,3 +1459,21 @@ tail: return freed; } EXPORT_SYMBOL(drm_gem_lru_scan); + +/** + * drm_gem_evict - helper to evict backing pages for a GEM object + * @obj: obj in question + */ +int drm_gem_evict(struct drm_gem_object *obj) +{ + dma_resv_assert_held(obj->resv); + + if (!dma_resv_test_signaled(obj->resv, DMA_RESV_USAGE_READ)) + return -EBUSY; + + if (obj->funcs->evict) + return obj->funcs->evict(obj); + + return 0; +} +EXPORT_SYMBOL(drm_gem_evict); |