Skip to content

Commit 955da9d

Browse files
icklerodrigovivi
authored andcommitted
drm/i915: Handle idling during i915_gem_evict_something busy loops
i915_gem_evict_something() is charged with finding a slot within the GTT that we may reuse. Since our goal is not to stall, we first look for a slot that only overlaps idle vma. To this end, on the first pass we move any active vma to the end of the search list. However, we only stopped moving active vma after we see the first active vma twice. If during the search, that first active vma completed, we would not notice and keep on extending the search list. Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/1746 Fixes: 2850748 ("drm/i915: Pull i915_vma_pin under the vm->mutex") Fixes: b1e3177 ("drm/i915: Coordinate i915_active with its own mutex") Signed-off-by: Chris Wilson <[email protected]> Cc: Tvrtko Ursulin <[email protected]> Cc: <[email protected]> # v5.5+ Reviewed-by: Mika Kuoppala <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] (cherry picked from commit 73e28cc) Signed-off-by: Rodrigo Vivi <[email protected]>
1 parent 475e842 commit 955da9d

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

drivers/gpu/drm/i915/i915_gem_evict.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ i915_gem_evict_something(struct i915_address_space *vm,
128128
active = NULL;
129129
INIT_LIST_HEAD(&eviction_list);
130130
list_for_each_entry_safe(vma, next, &vm->bound_list, vm_link) {
131+
if (vma == active) { /* now seen this vma twice */
132+
if (flags & PIN_NONBLOCK)
133+
break;
134+
135+
active = ERR_PTR(-EAGAIN);
136+
}
137+
131138
/*
132139
* We keep this list in a rough least-recently scanned order
133140
* of active elements (inactive elements are cheap to reap).
@@ -143,21 +150,12 @@ i915_gem_evict_something(struct i915_address_space *vm,
143150
* To notice when we complete one full cycle, we record the
144151
* first active element seen, before moving it to the tail.
145152
*/
146-
if (i915_vma_is_active(vma)) {
147-
if (vma == active) {
148-
if (flags & PIN_NONBLOCK)
149-
break;
150-
151-
active = ERR_PTR(-EAGAIN);
152-
}
153-
154-
if (active != ERR_PTR(-EAGAIN)) {
155-
if (!active)
156-
active = vma;
153+
if (active != ERR_PTR(-EAGAIN) && i915_vma_is_active(vma)) {
154+
if (!active)
155+
active = vma;
157156

158-
list_move_tail(&vma->vm_link, &vm->bound_list);
159-
continue;
160-
}
157+
list_move_tail(&vma->vm_link, &vm->bound_list);
158+
continue;
161159
}
162160

163161
if (mark_free(&scan, vma, flags, &eviction_list))

0 commit comments

Comments
 (0)