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/
This commit is contained in:
parent
8ac7524633
commit
7eabaa892d
@ -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);
|
||||
|
@ -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__ */
|
||||
|
Loading…
Reference in New Issue
Block a user