drm/i915: Use hangcheck score to find guilty context
Subsystems (2)
PATCH 1/2 drm/i915: Use hangcheck score to find guilty context
With full ppgtt using acthd is not enough to find guilty batch buffer. We get multiple false positives as acthd is per vm.
Instead of scanning which vm was running on a ring, to find corressponding context, use a different, simpler, strategy of finding batches that caused gpu hang:
If hangcheck has declared ring to be hung, find first non complete request on that ring and claim it was guilty.
v2: Rebase
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73652
--- drivers/gpu/drm/i915/i915_gem.c | 42 +++++++++++++++++++++---------- drivers/gpu/drm/i915/i915_irq.c | 3 +-- drivers/gpu/drm/i915/intel_ringbuffer.h | 2 ++ 3 files changed, 32 insertions(+), 15 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +29 -13
@@ -2332,9 +2332,10 @@ static bool i915_context_is_banned(struct drm_device *dev,static void i915_set_reset_status (struct intel_ring_buffer *ring,struct drm_i915_gem_request *request, -u32 acthd) +const bool guilty) { -bool inside, guilty; +const u32 acthd =intel_ring_get_active_head (ring); +bool inside;unsigned long offset =0 ;struct i915_hw_context *ctx = request->ctx;struct i915_ctx_hang_stats *hs;
@@ -2342,14 +2343,11 @@ static void i915_set_reset_status(struct intel_ring_buffer *ring,if (WARN_ON (!ctx))return ; -/* Innocent until proven guilty */ - guilty = false; -if (request->batch_obj) offset =i915_gem_obj_offset (request->batch_obj,request_to_vm (request)); -if (ring->hangcheck.action !=HANGCHECK_WAIT && +if (guilty &&i915_request_guilty (request, acthd, &inside)) { DRM_DEBUG("%s hung %s bo (0x%lx ctx %d) at 0x%x\n", ring->name,
@@ -2357,8 +2355,6 @@ static void i915_set_reset_status(struct intel_ring_buffer *ring, offset, ctx->id, acthd); - - guilty = true; }WARN_ON (!ctx->last_ring);
@@ -2385,19 +2381,39 @@ static void i915_gem_free_request(struct drm_i915_gem_request *request)kfree (request); } -static void i915_gem_reset_ring_status (struct drm_i915_private *dev_priv, -struct intel_ring_buffer *ring) +static struct drm_i915_gem_request * +i915_gem_find_first_non_complete (struct intel_ring_buffer *ring) { -u32 completed_seqno = ring->get_seqno (ring, false); -u32 acthd =intel_ring_get_active_head (ring);struct drm_i915_gem_request *request; +const u32 completed_seqno = ring->get_seqno (ring, false);list_for_each_entry (request, &ring->request_list, list) {if (i915_seqno_passed (completed_seqno, request->seqno))continue ; -i915_set_reset_status (ring, request, acthd); +return request; } + +return NULL ; +} + +static void i915_gem_reset_ring_status (struct drm_i915_private *dev_priv, +struct intel_ring_buffer *ring) +{ +struct drm_i915_gem_request *request; +bool ring_hung; + + request =i915_gem_find_first_non_complete (ring); + +if (request ==NULL ) +return ; + + ring_hung = ring->hangcheck.score >=HANGCHECK_SCORE_RING_HUNG ; + +i915_set_reset_status (ring, request, ring_hung); + +list_for_each_entry_continue (request, &ring->request_list, list) +i915_set_reset_status (ring, request, false); } static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/i915_irq.c +1 -2
@@ -2532,7 +2532,6 @@ static void i915_hangcheck_elapsed(unsigned long data)#define BUSY 1#define KICK 5#define HUNG 20 -#define FIRE 30if (!i915.enable_hangcheck)return ;
@@ -2616,7 +2615,7 @@ static void i915_hangcheck_elapsed(unsigned long data) }for_each_ring (ring, dev_priv, i) { -if (ring->hangcheck.score >FIRE ) { +if (ring->hangcheck.score >=HANGCHECK_SCORE_RING_HUNG ) {DRM_INFO ("%s on %s\n" , stuck[i] ?"stuck" :"no progress" , ring->name);
drivers/gpu/drm/i915/intel_ringbuffer.h +2 -0
@@ -41,6 +41,8 @@ enum intel_ring_hangcheck_action { HANGCHECK_HUNG, }; +#define HANGCHECK_SCORE_RING_HUNG 31 +struct intel_ring_hangcheck {bool deadlock;u32 seqno;
Signature · 1 line
1.7.9.5
PATCH 2/2 drm/i915: Get rid of acthd based guilty batch search
As we seek the guilty batch using request and hangcheck score, this code is not needed anymore.
v2: Rebase. Passing dev_priv instead of getting it from last_ring
--- drivers/gpu/drm/i915/i915_gem.c | 97 +++------------------------------------ 1 file changed, 6 insertions(+), 91 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +6 -91
@@ -2241,74 +2241,9 @@ i915_gem_request_remove_from_client(struct drm_i915_gem_request *request)spin_unlock (&file_priv->mm.lock); } -static bool i915_head_inside_object (u32 acthd,struct drm_i915_gem_object *obj, -struct i915_address_space *vm) -{ -if (acthd >=i915_gem_obj_offset (obj, vm) && - acthd <i915_gem_obj_offset (obj, vm) + obj->base.size) -return true; - -return false; -} - -static bool i915_head_inside_request (const u32 acthd_unmasked, -const u32 request_start, -const u32 request_end) -{ -const u32 acthd = acthd_unmasked &HEAD_ADDR ; - -if (request_start < request_end) { -if (acthd >= request_start && acthd < request_end) -return true; - }else if (request_start > request_end) { -if (acthd >= request_start || acthd < request_end) -return true; - } - -return false; -} - -static struct i915_address_space * -request_to_vm (struct drm_i915_gem_request *request) -{ -struct drm_i915_private *dev_priv = request->ring->dev->dev_private; -struct i915_address_space *vm; - -if (request->ctx) - vm = request->ctx->vm; -else - vm = &dev_priv->gtt.base; - -return vm; -} - -static bool i915_request_guilty (struct drm_i915_gem_request *request, -const u32 acthd,bool *inside) -{ -/* There is a possibility that unmasked head address -* pointing inside the ring, matches the batch_obj address range. -* However this is extremely unlikely. -*/ -if (request->batch_obj) { -if (i915_head_inside_object (acthd, request->batch_obj, -request_to_vm (request))) { - *inside = true; -return true; - } - } - -if (i915_head_inside_request (acthd, request->head, request->tail)) { - *inside = false; -return true; - } - -return false; -} - -static bool i915_context_is_banned (struct drm_device *dev, +static bool i915_context_is_banned (struct drm_i915_private *dev_priv,const struct i915_hw_context *ctx) { -struct drm_i915_private *dev_priv =to_i915 (dev);unsigned long elapsed; elapsed =get_seconds () - ctx->hang_stats.guilty_ts;
@@ -2330,39 +2265,19 @@ static bool i915_context_is_banned(struct drm_device *dev,return false; } -static void i915_set_reset_status (struct intel_ring_buffer *ring, -struct drm_i915_gem_request *request, +static void i915_set_reset_status (struct drm_i915_private *dev_priv, +struct i915_hw_context *ctx,const bool guilty) { -const u32 acthd =intel_ring_get_active_head (ring); -bool inside; -unsigned long offset =0 ; -struct i915_hw_context *ctx = request->ctx;struct i915_ctx_hang_stats *hs;if (WARN_ON (!ctx))return ; -if (request->batch_obj) - offset =i915_gem_obj_offset (request->batch_obj, -request_to_vm (request)); - -if (guilty && -i915_request_guilty (request, acthd, &inside)) { -DRM_DEBUG ("%s hung %s bo (0x%lx ctx %d) at 0x%x\n" , - ring->name, - inside ?"inside" :"flushing" , - offset, - ctx->id, - acthd); - } - -WARN_ON (!ctx->last_ring); - hs = &ctx->hang_stats;if (guilty) { - hs->banned =i915_context_is_banned (ring->dev, ctx); + hs->banned =i915_context_is_banned (dev_priv, ctx); hs->batch_active++; hs->guilty_ts =get_seconds (); }else {
@@ -2410,10 +2325,10 @@ static void i915_gem_reset_ring_status(struct drm_i915_private *dev_priv, ring_hung = ring->hangcheck.score >=HANGCHECK_SCORE_RING_HUNG ; -i915_set_reset_status (ring, request, ring_hung); +i915_set_reset_status (dev_priv, request->ctx, ring_hung);list_for_each_entry_continue (request, &ring->request_list, list) -i915_set_reset_status (ring, request, false); +i915_set_reset_status (dev_priv, request->ctx, false); } static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,
Signature · 1 line
1.7.9.5
Re: [PATCH 2/2] drm/i915: Get rid of acthd based guilty batch search
Quoted 7 lines · Mika Kuoppala
As we seek the guilty batch using request and hangcheck score, this code is not needed anymore.
v2: Rebase. Passing
dev_privinstead of getting it fromlast_ringSigned-off-by Mika Kuoppala <[email protected]>Reviewed-by Ben Widawsky <[email protected]> (v1)
Both merged, thanks for doing the quick rebase.
-Daniel
Quoted 147 lines
--- drivers/gpu/drm/i915/i915_gem.c | 97 +++------------------------------------ 1 file changed, 6 insertions(+), 91 deletions(-)drivers/gpu/drm/i915/i915_gem.c +6
-91@@ -2241,74 +2241,9 @@ i915_gem_request_remove_from_client(struct drm_i915_gem_request *request)spin_unlock (&file_priv->mm.lock); } -static bool i915_head_inside_object (u32 acthd,struct drm_i915_gem_object *obj, -struct i915_address_space *vm) -{ -if (acthd >=i915_gem_obj_offset (obj, vm) && - acthd <i915_gem_obj_offset (obj, vm) + obj->base.size) -return true; - -return false; -} - -static bool i915_head_inside_request (const u32 acthd_unmasked, -const u32 request_start, -const u32 request_end) -{ -const u32 acthd = acthd_unmasked &HEAD_ADDR ; - -if (request_start < request_end) { -if (acthd >= request_start && acthd < request_end) -return true; - }else if (request_start > request_end) { -if (acthd >= request_start || acthd < request_end) -return true; - } - -return false; -} - -static struct i915_address_space * -request_to_vm (struct drm_i915_gem_request *request) -{ -struct drm_i915_private *dev_priv = request->ring->dev->dev_private; -struct i915_address_space *vm; - -if (request->ctx) - vm = request->ctx->vm; -else - vm = &dev_priv->gtt.base; - -return vm; -} - -static bool i915_request_guilty (struct drm_i915_gem_request *request, -const u32 acthd,bool *inside) -{ -/* There is a possibility that unmasked head address -* pointing inside the ring, matches the batch_obj address range. -* However this is extremely unlikely. -*/ -if (request->batch_obj) { -if (i915_head_inside_object (acthd, request->batch_obj, -request_to_vm (request))) { - *inside = true; -return true; - } - } - -if (i915_head_inside_request (acthd, request->head, request->tail)) { - *inside = false; -return true; - } - -return false; -} - -static bool i915_context_is_banned (struct drm_device *dev, +static bool i915_context_is_banned (struct drm_i915_private *dev_priv,const struct i915_hw_context *ctx) { -struct drm_i915_private *dev_priv =to_i915 (dev);unsigned long elapsed; elapsed =get_seconds () - ctx->hang_stats.guilty_ts;@@ -2330,39 +2265,19 @@ static bool i915_context_is_banned(struct drm_device *dev,return false; } -static void i915_set_reset_status (struct intel_ring_buffer *ring, -struct drm_i915_gem_request *request, +static void i915_set_reset_status (struct drm_i915_private *dev_priv, +struct i915_hw_context *ctx,const bool guilty) { -const u32 acthd =intel_ring_get_active_head (ring); -bool inside; -unsigned long offset =0 ; -struct i915_hw_context *ctx = request->ctx;struct i915_ctx_hang_stats *hs;if (WARN_ON (!ctx))return ; -if (request->batch_obj) - offset =i915_gem_obj_offset (request->batch_obj, -request_to_vm (request)); - -if (guilty && -i915_request_guilty (request, acthd, &inside)) { -DRM_DEBUG ("%s hung %s bo (0x%lx ctx %d) at 0x%x\n" , - ring->name, - inside ?"inside" :"flushing" , - offset, - ctx->id, - acthd); - } - -WARN_ON (!ctx->last_ring); - hs = &ctx->hang_stats;if (guilty) { - hs->banned =i915_context_is_banned (ring->dev, ctx); + hs->banned =i915_context_is_banned (dev_priv, ctx); hs->batch_active++; hs->guilty_ts =get_seconds (); }else {@@ -2410,10 +2325,10 @@ static void i915_gem_reset_ring_status(struct drm_i915_private *dev_priv, ring_hung = ring->hangcheck.score >=HANGCHECK_SCORE_RING_HUNG ; -i915_set_reset_status (ring, request, ring_hung); +i915_set_reset_status (dev_priv, request->ctx, ring_hung);list_for_each_entry_continue (request, &ring->request_list, list) -i915_set_reset_status (ring, request, false); +i915_set_reset_status (dev_priv, request->ctx, false); } static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch