Rev 5354 | Rev 6937 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5354 | Rev 6084 | ||
---|---|---|---|
Line 48... | Line 48... | ||
48 | 48 | ||
49 | /** |
49 | /** |
50 | * i915_gem_evict_something - Evict vmas to make room for binding a new one |
50 | * i915_gem_evict_something - Evict vmas to make room for binding a new one |
51 | * @dev: drm_device |
51 | * @dev: drm_device |
52 | * @vm: address space to evict from |
52 | * @vm: address space to evict from |
53 | * @size: size of the desired free space |
53 | * @min_size: size of the desired free space |
54 | * @alignment: alignment constraint of the desired free space |
54 | * @alignment: alignment constraint of the desired free space |
55 | * @cache_level: cache_level for the desired space |
55 | * @cache_level: cache_level for the desired space |
56 | * @mappable: whether the free space must be mappable |
56 | * @start: start (inclusive) of the range from which to evict objects |
- | 57 | * @end: end (exclusive) of the range from which to evict objects |
|
57 | * @nonblocking: whether evicting active objects is allowed or not |
58 | * @flags: additional flags to control the eviction algorithm |
58 | * |
59 | * |
59 | * This function will try to evict vmas until a free space satisfying the |
60 | * This function will try to evict vmas until a free space satisfying the |
60 | * requirements is found. Callers must check first whether any such hole exists |
61 | * requirements is found. Callers must check first whether any such hole exists |
61 | * already before calling this function. |
62 | * already before calling this function. |
62 | * |
63 | * |
63 | * This function is used by the object/vma binding code. |
64 | * This function is used by the object/vma binding code. |
- | 65 | * |
|
- | 66 | * Since this function is only used to free up virtual address space it only |
|
- | 67 | * ignores pinned vmas, and not object where the backing storage itself is |
|
- | 68 | * pinned. Hence obj->pages_pin_count does not protect against eviction. |
|
64 | * |
69 | * |
65 | * To clarify: This is for freeing up virtual address space, not for freeing |
70 | * To clarify: This is for freeing up virtual address space, not for freeing |
66 | * memory in e.g. the shrinker. |
71 | * memory in e.g. the shrinker. |
67 | */ |
72 | */ |
68 | int |
73 | int |
Line 194... | Line 199... | ||
194 | return ret; |
199 | return ret; |
195 | } |
200 | } |
Line 196... | Line 201... | ||
196 | 201 | ||
197 | /** |
202 | /** |
198 | * i915_gem_evict_vm - Evict all idle vmas from a vm |
- | |
199 | * |
203 | * i915_gem_evict_vm - Evict all idle vmas from a vm |
200 | * @vm: Address space to cleanse |
204 | * @vm: Address space to cleanse |
201 | * @do_idle: Boolean directing whether to idle first. |
205 | * @do_idle: Boolean directing whether to idle first. |
202 | * |
206 | * |
203 | * This function evicts all idles vmas from a vm. If all unpinned vmas should be |
207 | * This function evicts all idles vmas from a vm. If all unpinned vmas should be |
Line 212... | Line 216... | ||
212 | int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle) |
216 | int i915_gem_evict_vm(struct i915_address_space *vm, bool do_idle) |
213 | { |
217 | { |
214 | struct i915_vma *vma, *next; |
218 | struct i915_vma *vma, *next; |
215 | int ret; |
219 | int ret; |
Line -... | Line 220... | ||
- | 220 | ||
216 | 221 | WARN_ON(!mutex_is_locked(&vm->dev->struct_mutex)); |
|
Line 217... | Line 222... | ||
217 | trace_i915_gem_evict_vm(vm); |
222 | trace_i915_gem_evict_vm(vm); |
218 | 223 | ||
219 | if (do_idle) { |
224 | if (do_idle) { |
220 | ret = i915_gpu_idle(vm->dev); |
225 | ret = i915_gpu_idle(vm->dev); |
Line 221... | Line 226... | ||
221 | if (ret) |
226 | if (ret) |
- | 227 | return ret; |
|
- | 228 | ||
222 | return ret; |
229 | i915_gem_retire_requests(vm->dev); |
Line 223... | Line 230... | ||
223 | 230 | ||
224 | i915_gem_retire_requests(vm->dev); |
231 | WARN_ON(!list_empty(&vm->active_list)); |
225 | } |
232 | } |
Line 226... | Line 233... | ||
226 | 233 | ||
227 | list_for_each_entry_safe(vma, next, &vm->inactive_list, mm_list) |
234 | list_for_each_entry_safe(vma, next, &vm->inactive_list, mm_list) |
228 | if (vma->pin_count == 0) |
- | |
229 | WARN_ON(i915_vma_unbind(vma)); |
- | |
230 | - | ||
231 | return 0; |
- | |
232 | } |
- | |
233 | - | ||
234 | /** |
- | |
235 | * i915_gem_evict_everything - Try to evict all objects |
- | |
236 | * @dev: Device to evict objects for |
- | |
237 | * |
- | |
238 | * This functions tries to evict all gem objects from all address spaces. Used |
- | |
239 | * by the shrinker as a last-ditch effort and for suspend, before releasing the |
- | |
240 | * backing storage of all unbound objects. |
- | |
241 | */ |
- | |
242 | int |
- | |
243 | i915_gem_evict_everything(struct drm_device *dev) |
- | |
244 | { |
- | |
245 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
246 | struct i915_address_space *vm, *v; |
- | |
247 | bool lists_empty = true; |
- | |
248 | int ret; |
- | |
249 | - | ||
250 | list_for_each_entry(vm, &dev_priv->vm_list, global_link) { |
- | |
251 | lists_empty = (list_empty(&vm->inactive_list) && |
- | |
252 | list_empty(&vm->active_list)); |
- | |
253 | if (!lists_empty) |
- | |
254 | lists_empty = false; |
- | |
255 | } |
- | |
256 | - | ||
257 | if (lists_empty) |
- | |
258 | return -ENOSPC; |
- | |
259 | - | ||
260 | trace_i915_gem_evict_everything(dev); |
- | |
261 | - | ||
262 | /* The gpu_idle will flush everything in the write domain to the |
- | |
263 | * active list. Then we must move everything off the active list |
- | |
264 | * with retire requests. |
- | |
265 | */ |
- | |
266 | ret = i915_gpu_idle(dev); |
- | |
267 | if (ret) |
- | |
268 | return ret; |
- | |
269 | - | ||
270 | i915_gem_retire_requests(dev); |
- | |
271 | - | ||
272 | /* Having flushed everything, unbind() should never raise an error */ |
- |