@@ -137,6 +137,13 @@ i915_gem_evict_something(struct i915_address_space *vm,
137137 active = NULL ;
138138 INIT_LIST_HEAD (& eviction_list );
139139 list_for_each_entry_safe (vma , next , & vm -> bound_list , vm_link ) {
140+ if (vma == active ) { /* now seen this vma twice */
141+ if (flags & PIN_NONBLOCK )
142+ break ;
143+
144+ active = ERR_PTR (- EAGAIN );
145+ }
146+
140147 /*
141148 * We keep this list in a rough least-recently scanned order
142149 * of active elements (inactive elements are cheap to reap).
@@ -152,21 +159,12 @@ i915_gem_evict_something(struct i915_address_space *vm,
152159 * To notice when we complete one full cycle, we record the
153160 * first active element seen, before moving it to the tail.
154161 */
155- if (i915_vma_is_active (vma )) {
156- if (vma == active ) {
157- if (flags & PIN_NONBLOCK )
158- break ;
159-
160- active = ERR_PTR (- EAGAIN );
161- }
162-
163- if (active != ERR_PTR (- EAGAIN )) {
164- if (!active )
165- active = vma ;
162+ if (active != ERR_PTR (- EAGAIN ) && i915_vma_is_active (vma )) {
163+ if (!active )
164+ active = vma ;
166165
167- list_move_tail (& vma -> vm_link , & vm -> bound_list );
168- continue ;
169- }
166+ list_move_tail (& vma -> vm_link , & vm -> bound_list );
167+ continue ;
170168 }
171169
172170 if (mark_free (& scan , vma , flags , & eviction_list ))
0 commit comments