Commit 7b796122 authored by Ben Widawsky's avatar Ben Widawsky Committed by Daniel Vetter

drm/i915: Extract vm specific part of eviction

As we'll see in the next patch, being able to evict for just 1 VM is
handy.
Signed-off-by: default avatarBen Widawsky <ben@bwidawsk.net>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 23f54483
...@@ -155,12 +155,31 @@ i915_gem_evict_something(struct drm_device *dev, struct i915_address_space *vm, ...@@ -155,12 +155,31 @@ i915_gem_evict_something(struct drm_device *dev, struct i915_address_space *vm,
return ret; return ret;
} }
static int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle)
{
struct i915_vma *vma, *next;
int ret;
if (do_idle) {
ret = i915_gpu_idle(vm->dev);
if (ret)
return ret;
i915_gem_retire_requests(vm->dev);
}
list_for_each_entry_safe(vma, next, &vm->inactive_list, mm_list)
if (vma->obj->pin_count == 0)
WARN_ON(i915_vma_unbind(vma));
return 0;
}
int int
i915_gem_evict_everything(struct drm_device *dev) i915_gem_evict_everything(struct drm_device *dev)
{ {
drm_i915_private_t *dev_priv = dev->dev_private; drm_i915_private_t *dev_priv = dev->dev_private;
struct i915_address_space *vm; struct i915_address_space *vm;
struct i915_vma *vma, *next;
bool lists_empty = true; bool lists_empty = true;
int ret; int ret;
...@@ -187,11 +206,8 @@ i915_gem_evict_everything(struct drm_device *dev) ...@@ -187,11 +206,8 @@ i915_gem_evict_everything(struct drm_device *dev)
i915_gem_retire_requests(dev); i915_gem_retire_requests(dev);
/* Having flushed everything, unbind() should never raise an error */ /* Having flushed everything, unbind() should never raise an error */
list_for_each_entry(vm, &dev_priv->vm_list, global_link) { list_for_each_entry(vm, &dev_priv->vm_list, global_link)
list_for_each_entry_safe(vma, next, &vm->inactive_list, mm_list) WARN_ON(i915_gem_evict_vm(vm, false));
if (vma->obj->pin_count == 0)
WARN_ON(i915_vma_unbind(vma));
}
return 0; return 0;
} }
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