Commit c2c1d491 authored by Daniel Vetter's avatar Daniel Vetter

drm/i915: Kerneldoc for i915_gem_evict.c

Request by Ben Widawsky in his review of a patch touching this code.

v2: Clarify the disdinction between evicting vmas (to free up virtual
address space) and evicting objects (to free up actual system memory).
Suggested by Ben.

Cc: Ben Widawsky <benjamin.widawsky@intel.com>
Acked-by: default avatarBen Widawsky <benjamin.widawsky@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 3036537d
...@@ -46,6 +46,25 @@ mark_free(struct i915_vma *vma, struct list_head *unwind) ...@@ -46,6 +46,25 @@ mark_free(struct i915_vma *vma, struct list_head *unwind)
return drm_mm_scan_add_block(&vma->node); return drm_mm_scan_add_block(&vma->node);
} }
/**
* i915_gem_evict_something - Evict vmas to make room for binding a new one
* @dev: drm_device
* @vm: address space to evict from
* @size: size of the desired free space
* @alignment: alignment constraint of the desired free space
* @cache_level: cache_level for the desired space
* @mappable: whether the free space must be mappable
* @nonblocking: whether evicting active objects is allowed or not
*
* This function will try to evict vmas until a free space satisfying the
* requirements is found. Callers must check first whether any such hole exists
* already before calling this function.
*
* This function is used by the object/vma binding code.
*
* To clarify: This is for freeing up virtual address space, not for freeing
* memory in e.g. the shrinker.
*/
int int
i915_gem_evict_something(struct drm_device *dev, struct i915_address_space *vm, i915_gem_evict_something(struct drm_device *dev, struct i915_address_space *vm,
int min_size, unsigned alignment, unsigned cache_level, int min_size, unsigned alignment, unsigned cache_level,
...@@ -177,19 +196,19 @@ i915_gem_evict_something(struct drm_device *dev, struct i915_address_space *vm, ...@@ -177,19 +196,19 @@ i915_gem_evict_something(struct drm_device *dev, struct i915_address_space *vm,
} }
/** /**
* i915_gem_evict_vm - Try to free up VM space * i915_gem_evict_vm - Evict all idle vmas from a vm
* *
* @vm: Address space to evict from * @vm: Address space to cleanse
* @do_idle: Boolean directing whether to idle first. * @do_idle: Boolean directing whether to idle first.
* *
* VM eviction is about freeing up virtual address space. If one wants fine * This function evicts all idles vmas from a vm. If all unpinned vmas should be
* grained eviction, they should see evict something for more details. In terms * evicted the @do_idle needs to be set to true.
* of freeing up actual system memory, this function may not accomplish the
* desired result. An object may be shared in multiple address space, and this
* function will not assert those objects be freed.
* *
* Using do_idle will result in a more complete eviction because it retires, and * This is used by the execbuf code as a last-ditch effort to defragment the
* inactivates current BOs. * address space.
*
* To clarify: This is for freeing up virtual address space, not for freeing
* memory in e.g. the shrinker.
*/ */
int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle) int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle)
{ {
...@@ -213,6 +232,14 @@ int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle) ...@@ -213,6 +232,14 @@ int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle)
return 0; return 0;
} }
/**
* i915_gem_evict_everything - Try to evict all objects
* @dev: Device to evict objects for
*
* This functions tries to evict all gem objects from all address spaces. Used
* by the shrinker as a last-ditch effort and for suspend, before releasing the
* backing storage of all unbound objects.
*/
int int
i915_gem_evict_everything(struct drm_device *dev) i915_gem_evict_everything(struct drm_device *dev)
{ {
......
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