Commit 7eabaa89 authored by Dmitry Osipenko's avatar Dmitry Osipenko

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: default avatarThomas Zimmermann <tzimmermann@suse.de>
Suggested-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://lore.kernel.org/all/20230108210445.3948344-4-dmitry.osipenko@collabora.com/
parent 8ac75246
......@@ -1459,3 +1459,21 @@ drm_gem_lru_scan(struct drm_gem_lru *lru, unsigned nr_to_scan,
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);
......@@ -164,6 +164,16 @@ struct drm_gem_object_funcs {
*/
int (*mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma);
/**
* @evict:
*
* Evicts gem object out from memory. Used by the drm_gem_object_evict()
* helper. Returns 0 on success, -errno otherwise.
*
* This callback is optional.
*/
int (*evict)(struct drm_gem_object *obj);
/**
* @vm_ops:
*
......@@ -479,4 +489,6 @@ void drm_gem_lru_move_tail(struct drm_gem_lru *lru, struct drm_gem_object *obj);
unsigned long drm_gem_lru_scan(struct drm_gem_lru *lru, unsigned nr_to_scan,
bool (*shrink)(struct drm_gem_object *obj));
int drm_gem_evict(struct drm_gem_object *obj);
#endif /* __DRM_GEM_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment