Skip to content

Commit 832a3aa

Browse files
icklejnikula
authored andcommitted
drm/i915: Keep ring->active_list and ring->requests_list consistent
If we retire requests last, we may use a later seqno and so clear the requests lists without clearing the active list, leading to confusion. Hence we should retire requests first for consistency with the early return. The order used to be important as the lifecycle for the object on the active list was determined by request->seqno. However, the requests themselves are now reference counted removing the constraint from the order of retirement. Fixes regression from commit 1b5a433 Author: John Harrison <John.C.Harrison@Intel.com> Date: Mon Nov 24 18:49:42 2014 +0000 drm/i915: Convert 'i915_seqno_passed' calls into 'i915_gem_request_completed ' and a WARNING: CPU: 0 PID: 1383 at drivers/gpu/drm/i915/i915_gem_evict.c:279 i915_gem_evict_vm+0x10c/0x140() WARN_ON(!list_empty(&vm->active_list)) Identified by updating WATCH_LISTS: [drm:i915_verify_lists] *ERROR* blitter ring: active list not empty, but no requests WARNING: CPU: 0 PID: 681 at drivers/gpu/drm/i915/i915_gem.c:2751 i915_gem_retire_requests_ring+0x149/0x230() WARN_ON(i915_verify_lists(ring->dev)) Note that this is only a problem in evict_vm where the following happens after a retire_request has cleaned out all requests, but not all active bo: - intel_ring_idle called from i915_gpu_idle notices that no requests are outstanding and immediately returns. - i915_gem_retire_requests_ring called from i915_gem_retire_requests also immediately returns when there's no request, still leaving the bo on the active list. - evict_vm hits the WARN_ON(!list_empty(&vm->active_list)) after evicting all active objects that there's still stuff left that shouldn't be there. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: John Harrison <John.C.Harrison@Intel.com> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
1 parent 59a58cb commit 832a3aa

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

drivers/gpu/drm/i915/i915_gem.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2737,24 +2737,11 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
27372737

27382738
WARN_ON(i915_verify_lists(ring->dev));
27392739

2740-
/* Move any buffers on the active list that are no longer referenced
2741-
* by the ringbuffer to the flushing/inactive lists as appropriate,
2742-
* before we free the context associated with the requests.
2740+
/* Retire requests first as we use it above for the early return.
2741+
* If we retire requests last, we may use a later seqno and so clear
2742+
* the requests lists without clearing the active list, leading to
2743+
* confusion.
27432744
*/
2744-
while (!list_empty(&ring->active_list)) {
2745-
struct drm_i915_gem_object *obj;
2746-
2747-
obj = list_first_entry(&ring->active_list,
2748-
struct drm_i915_gem_object,
2749-
ring_list);
2750-
2751-
if (!i915_gem_request_completed(obj->last_read_req, true))
2752-
break;
2753-
2754-
i915_gem_object_move_to_inactive(obj);
2755-
}
2756-
2757-
27582745
while (!list_empty(&ring->request_list)) {
27592746
struct drm_i915_gem_request *request;
27602747
struct intel_ringbuffer *ringbuf;
@@ -2789,6 +2776,23 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
27892776
i915_gem_free_request(request);
27902777
}
27912778

2779+
/* Move any buffers on the active list that are no longer referenced
2780+
* by the ringbuffer to the flushing/inactive lists as appropriate,
2781+
* before we free the context associated with the requests.
2782+
*/
2783+
while (!list_empty(&ring->active_list)) {
2784+
struct drm_i915_gem_object *obj;
2785+
2786+
obj = list_first_entry(&ring->active_list,
2787+
struct drm_i915_gem_object,
2788+
ring_list);
2789+
2790+
if (!i915_gem_request_completed(obj->last_read_req, true))
2791+
break;
2792+
2793+
i915_gem_object_move_to_inactive(obj);
2794+
}
2795+
27922796
if (unlikely(ring->trace_irq_req &&
27932797
i915_gem_request_completed(ring->trace_irq_req, true))) {
27942798
ring->irq_put(ring);

0 commit comments

Comments
 (0)