drm/i915: Inspect subunit states on hangcheck
Subsystems (2)
PATCH 1/1 drm/i915: Inspect subunit states on hangcheck
If head seems stuck and engine in question is rcs, inspect subunit state transitions before deciding that this really is a hang instead of limited progress.
References: https://bugs.freedesktop.org/show_bug.cgi?id=93029
--- drivers/gpu/drm/i915/i915_irq.c | 49 +++++++++++++++++++++++++++++---- drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + 2 files changed, 45 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +44 -5
@@ -2913,13 +2913,31 @@ static void semaphore_clear_deadlocks(struct drm_i915_private *dev_priv) ring->hangcheck.deadlock =0 ; } -static enum intel_ring_hangcheck_action -ring_stuck (struct intel_engine_cs *ring,u64 acthd) +static bool subunits_stuck (struct intel_engine_cs *ring) { -struct drm_device *dev = ring->dev; -struct drm_i915_private *dev_priv = dev->dev_private; -u32 tmp; +int i; +u32 instdone[I915_NUM_INSTDONE_REG ]; +bool stuck; + +if (ring->id !=RCS ) +return true; + +i915_get_extra_instdone (ring->dev, instdone); + stuck = true; +for (i =0 ; i <I915_NUM_INSTDONE_REG ; i++) { +if (instdone[i] != ring->hangcheck.instdone[i]) + stuck = false; + + ring->hangcheck.instdone[i] = instdone[i]; + } + +return stuck; +} + +static enum intel_ring_hangcheck_action +head_stuck (struct intel_engine_cs *ring,u64 acthd) +{if (acthd != ring->hangcheck.acthd) {if (acthd > ring->hangcheck.max_acthd) { ring->hangcheck.max_acthd = acthd;
@@ -2929,6 +2947,24 @@ ring_stuck(struct intel_engine_cs *ring, u64 acthd)return HANGCHECK_ACTIVE_LOOP ; } +if (!subunits_stuck (ring)) +return HANGCHECK_ACTIVE_LOOP ; + +return HANGCHECK_HUNG ; +} + +static enum intel_ring_hangcheck_action +ring_stuck (struct intel_engine_cs *ring,u64 acthd) +{ +struct drm_device *dev = ring->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +enum intel_ring_hangcheck_action ha; +u32 tmp; + + ha =head_stuck (ring, acthd); +if (ha !=HANGCHECK_HUNG ) +return ha; +if (IS_GEN2 (dev))return HANGCHECK_HUNG ;
@@ -3064,6 +3100,9 @@ static void i915_hangcheck_elapsed(struct work_struct *work) ring->hangcheck.score--; ring->hangcheck.acthd = ring->hangcheck.max_acthd =0 ; + +memset (ring->hangcheck.instdone,0 , +sizeof (ring->hangcheck.instdone)); } ring->hangcheck.seqno = seqno;
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
@@ -93,6 +93,7 @@ struct intel_ring_hangcheck {int score;enum intel_ring_hangcheck_action action;int deadlock; +u32 instdone[I915_NUM_INSTDONE_REG ]; };struct intel_ringbuffer {
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 9 lines · Mika Kuoppala
If head seems stuck and engine in question is rcs, inspect subunit state transitions before deciding that this really is a hang instead of limited progress.
References: https://bugs.freedesktop.org/show_bug.cgi?id=93029
Cc Chris Wilson <[email protected]>Cc Dave Gordon <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Mika Kuoppala <[email protected]>
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 32 lines · Mika Kuoppala
If head seems stuck and engine in question is rcs, inspect subunit state transitions before deciding that this really is a hang instead of limited progress.
References: https://bugs.freedesktop.org/show_bug.cgi?id=93029
Cc Chris Wilson <[email protected]>Cc Dave Gordon <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Mika Kuoppala <[email protected]>--- drivers/gpu/drm/i915/i915_irq.c | 49 +++++++++++++++++++++++++++++---- drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + 2 files changed, 45 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/i915_irq.c +4
-5@@ -2913,13 +2913,31 @@ static void semaphore_clear_deadlocks(struct drm_i915_private *dev_priv) ring->hangcheck.deadlock =0 ; } -static enum intel_ring_hangcheck_action -ring_stuck (struct intel_engine_cs *ring,u64 acthd) +static bool subunits_stuck (struct intel_engine_cs *ring) { -struct drm_device *dev = ring->dev; -struct drm_i915_private *dev_priv = dev->dev_private; -u32 tmp; +int i; +u32 instdone[I915_NUM_INSTDONE_REG ]; +bool stuck;
drivers/gpu/drm/i915/i915_irq.c static void semaphore_clear_deadlocks(struct drm_i915_private *dev_priv) · line 2930
Quoted 10 lines
drivers/gpu/drm/i915/i915_irq.c +9
-0+ +if (ring->id !=RCS ) +return true; + +i915_get_extra_instdone (ring->dev, instdone); + stuck = true; +for (i =0 ; i <I915_NUM_INSTDONE_REG ; i++) { +if (instdone[i] != ring->hangcheck.instdone[i]) + stuck = false;
This may not be completely reliable. Tomas Elf in his TDR tests observed that instdone kept changing even when CS is hung and in a stable state.
regards
Arun
Quoted 54 lines
drivers/gpu/drm/i915/i915_irq.c +31
-0+ + ring->hangcheck.instdone[i] = instdone[i]; + } + +return stuck; +} + +static enum intel_ring_hangcheck_action +head_stuck (struct intel_engine_cs *ring,u64 acthd) +{if (acthd != ring->hangcheck.acthd) {if (acthd > ring->hangcheck.max_acthd) { ring->hangcheck.max_acthd = acthd;@@ -2929,6 +2947,24 @@ ring_stuck(struct intel_engine_cs *ring, u64 acthd)return HANGCHECK_ACTIVE_LOOP ; } +if (!subunits_stuck (ring)) +return HANGCHECK_ACTIVE_LOOP ; + +return HANGCHECK_HUNG ; +} + +static enum intel_ring_hangcheck_action +ring_stuck (struct intel_engine_cs *ring,u64 acthd) +{ +struct drm_device *dev = ring->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +enum intel_ring_hangcheck_action ha; +u32 tmp; + + ha =head_stuck (ring, acthd); +if (ha !=HANGCHECK_HUNG ) +return ha; +if (IS_GEN2 (dev))return HANGCHECK_HUNG ;@@ -3064,6 +3100,9 @@ static void i915_hangcheck_elapsed(struct work_struct *work) ring->hangcheck.score--; ring->hangcheck.acthd = ring->hangcheck.max_acthd =0 ; + +memset (ring->hangcheck.instdone,0 , +sizeof (ring->hangcheck.instdone)); } ring->hangcheck.seqno = seqno;drivers/gpu/drm/i915/intel_ringbuffer.h +0
-0
drivers/gpu/drm/i915/intel_ringbuffer.h struct intel_ring_hangcheck { · line 99
Quoted 7 lines
drivers/gpu/drm/i915/intel_ringbuffer.h +1
-0@@ -93,6 +93,7 @@ struct intel_ring_hangcheck {int score;enum intel_ring_hangcheck_action action;int deadlock; +u32 instdone[I915_NUM_INSTDONE_REG ]; };struct intel_ringbuffer {
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 4 lines · Mika Kuoppala
If head seems stuck and engine in question is rcs, inspect subunit state transitions before deciding that this really is a hang instead of limited progress.
One thing to add into this description is that now as we always have one extra hangcheck step even in true stuck cases, this makes the hang declaration one tick longer, 7.5s.
If this becomes a problem, we can sample the instdone state on first check converge back to old behaviour.
One real, but hard to achive, improvement in determinism would be to normalize the amount of 'work' each gen does in a given tick. This way the shader progressions would be more or less equal and same amount of shader work would cause same hangcheck behaviour regardless of actual speed of computation.
-Mika
Quoted 105 lines
References: https://bugs.freedesktop.org/show_bug.cgi?id=93029
Cc Chris Wilson <[email protected]>Cc Dave Gordon <[email protected]>Cc Daniel Vetter <[email protected]>Signed-off-by Mika Kuoppala <[email protected]>--- drivers/gpu/drm/i915/i915_irq.c | 49 +++++++++++++++++++++++++++++---- drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + 2 files changed, 45 insertions(+), 5 deletions(-)drivers/gpu/drm/i915/i915_irq.c +44
-5@@ -2913,13 +2913,31 @@ static void semaphore_clear_deadlocks(struct drm_i915_private *dev_priv) ring->hangcheck.deadlock =0 ; } -static enum intel_ring_hangcheck_action -ring_stuck (struct intel_engine_cs *ring,u64 acthd) +static bool subunits_stuck (struct intel_engine_cs *ring) { -struct drm_device *dev = ring->dev; -struct drm_i915_private *dev_priv = dev->dev_private; -u32 tmp; +int i; +u32 instdone[I915_NUM_INSTDONE_REG ]; +bool stuck; + +if (ring->id !=RCS ) +return true; + +i915_get_extra_instdone (ring->dev, instdone); + stuck = true; +for (i =0 ; i <I915_NUM_INSTDONE_REG ; i++) { +if (instdone[i] != ring->hangcheck.instdone[i]) + stuck = false; + + ring->hangcheck.instdone[i] = instdone[i]; + } + +return stuck; +} + +static enum intel_ring_hangcheck_action +head_stuck (struct intel_engine_cs *ring,u64 acthd) +{if (acthd != ring->hangcheck.acthd) {if (acthd > ring->hangcheck.max_acthd) { ring->hangcheck.max_acthd = acthd;@@ -2929,6 +2947,24 @@ ring_stuck(struct intel_engine_cs *ring, u64 acthd)return HANGCHECK_ACTIVE_LOOP ; } +if (!subunits_stuck (ring)) +return HANGCHECK_ACTIVE_LOOP ; + +return HANGCHECK_HUNG ; +} + +static enum intel_ring_hangcheck_action +ring_stuck (struct intel_engine_cs *ring,u64 acthd) +{ +struct drm_device *dev = ring->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +enum intel_ring_hangcheck_action ha; +u32 tmp; + + ha =head_stuck (ring, acthd); +if (ha !=HANGCHECK_HUNG ) +return ha; +if (IS_GEN2 (dev))return HANGCHECK_HUNG ;@@ -3064,6 +3100,9 @@ static void i915_hangcheck_elapsed(struct work_struct *work) ring->hangcheck.score--; ring->hangcheck.acthd = ring->hangcheck.max_acthd =0 ; + +memset (ring->hangcheck.instdone,0 , +sizeof (ring->hangcheck.instdone)); } ring->hangcheck.seqno = seqno;drivers/gpu/drm/i915/intel_ringbuffer.h +1
-0@@ -93,6 +93,7 @@ struct intel_ring_hangcheck {int score;enum intel_ring_hangcheck_action action;int deadlock; +u32 instdone[I915_NUM_INSTDONE_REG ]; };struct intel_ringbuffer {Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 drm/i915: Inspect subunit states on hangcheck
In reply to Mika KuoppalaIf head seems stuck and engine in question is rcs, inspect subunit state transitions from undone to done, before deciding that this really is a hang instead of limited progress. Only account the transitions of subunits from undone to done once, to prevent unstable subunit states to keep us falsely active.
As this adds one extra steps to hangcheck heuristics, before hang is declared, it adds 1500ms to to detect hang for render ring to a total of 7500ms. We could sample the subunit states on first head stuck condition but decide not to do so only in order to mimic old behaviour. This way the check order of promotion from seqno > atchd > instdone is consistently done.
v2: Deal with unstable done states (Arun)
Clear instdone progress on head and seqno movement (Chris) Report raw and accumulated instdone's in in debugfs (Chris) Return HANGCHECK_ACTIVE on undone->done
References: https://bugs.freedesktop.org/show_bug.cgi?id=93029
--- drivers/gpu/drm/i915/i915_debugfs.c | 20 ++++++++++- drivers/gpu/drm/i915/i915_irq.c | 62 ++++++++++++++++++++++++++++++--- drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + 3 files changed, 77 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +19 -1
@@ -1332,7 +1332,8 @@ static int i915_hangcheck_info(struct seq_file *m, void *unused)struct intel_engine_cs *ring;u64 acthd[I915_NUM_RINGS ];u32 seqno[I915_NUM_RINGS ]; -int i; +u32 instdone[I915_NUM_INSTDONE_REG ]; +int i, j;if (!i915.enable_hangcheck) {seq_printf (m,"Hangcheck disabled\n" );
@@ -1346,6 +1347,8 @@ static int i915_hangcheck_info(struct seq_file *m, void *unused) acthd[i] =intel_ring_get_active_head (ring); } +i915_get_extra_instdone (dev, instdone); +intel_runtime_pm_put (dev_priv);if (delayed_work_pending (&dev_priv->gpu_error.hangcheck_work)) {
@@ -1366,6 +1369,21 @@ static int i915_hangcheck_info(struct seq_file *m, void *unused) (long long)ring->hangcheck.max_acthd);seq_printf (m,"\tscore = %d\n" , ring->hangcheck.score);seq_printf (m,"\taction = %d\n" , ring->hangcheck.action); + +if (ring->id ==RCS ) { +seq_puts (m,"\tinstdone read =" ); + +for (j =0 ; j <I915_NUM_INSTDONE_REG ; j++) +seq_printf (m," 0x%08x" , instdone[j]); + +seq_puts (m,"\n\tinstdone accu =" ); + +for (j =0 ; j <I915_NUM_INSTDONE_REG ; j++) +seq_printf (m," 0x%08x" , + ring->hangcheck.instdone[j]); + +seq_puts (m,"\n" ); + } }return 0 ;
drivers/gpu/drm/i915/i915_irq.c +57 -5
84 lines not on this page · raw message
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
@@ -93,6 +93,7 @@ struct intel_ring_hangcheck {int score;enum intel_ring_hangcheck_action action;int deadlock; +u32 instdone[I915_NUM_INSTDONE_REG ]; };struct intel_ringbuffer {
Signature · 6 lines
2.5.0 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 20 lines · Mika Kuoppala
If head seems stuck and engine in question is rcs, inspect subunit state transitions from undone to done, before deciding that this really is a hang instead of limited progress. Only account the transitions of subunits from undone to done once, to prevent unstable subunit states to keep us falsely active.
As this adds one extra steps to hangcheck heuristics, before hang is declared, it adds 1500ms to to detect hang for render ring to a total of 7500ms. We could sample the subunit states on first head stuck condition but decide not to do so only in order to mimic old behaviour. This way the check order of promotion from seqno > atchd > instdone is consistently done.
v2: Deal with unstable done states (Arun)
Clear instdone progress on head and seqno movement (Chris) Report raw and accumulated instdone's in in debugfs (Chris) ReturnHANGCHECK_ACTIVEonundone->done
Quoted 6 lines
References: https://bugs.freedesktop.org/show_bug.cgi?id=93029
Cc Chris Wilson <[email protected]>Cc Dave Gordon <[email protected]>Cc Daniel Vetter <[email protected]>Cc Arun Siluvery <[email protected]>Signed-off-by Mika Kuoppala <[email protected]>
I feel slightly dubious in discarding the 1->0 transitions (as it just means that a shared function that was previously idle is now in use again), but if they truly do fluctuate randomly? then accumulating should mean we eventually escape.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 28 lines · Chris Wilson
Quoted 20 lines · Mika Kuoppala
If head seems stuck and engine in question is rcs, inspect subunit state transitions from undone to done, before deciding that this really is a hang instead of limited progress. Only account the transitions of subunits from undone to done once, to prevent unstable subunit states to keep us falsely active.
As this adds one extra steps to hangcheck heuristics, before hang is declared, it adds 1500ms to to detect hang for render ring to a total of 7500ms. We could sample the subunit states on first head stuck condition but decide not to do so only in order to mimic old behaviour. This way the check order of promotion from seqno > atchd > instdone is consistently done.
v2: Deal with unstable done states (Arun)
Clear instdone progress on head and seqno movement (Chris) Report raw and accumulated instdone's in in debugfs (Chris) ReturnHANGCHECK_ACTIVEonundone->doneQuoted 6 lines
References: https://bugs.freedesktop.org/show_bug.cgi?id=93029
Cc Chris Wilson <[email protected]>Cc Dave Gordon <[email protected]>Cc Daniel Vetter <[email protected]>Cc Arun Siluvery <[email protected]>Signed-off-by Mika Kuoppala <[email protected]>
Quoted 4 lines
I feel slightly dubious in discarding the 1->0 transitions (as it just means that a shared function that was previously idle is now in use again), but if they truly do fluctuate randomly? then accumulating should mean we eventually escape.
Atleast with a tight bb start loop inside one batch one bit fluctulated.
We could improve further by having maximum amount of transitions per bit?
Quoted 3 lines
Reviewed-by Chris Wilson <[email protected]>-Chris
Thanks,
-Mika
Quoted 3 lines
Signature · 2 lines
-- Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Mika Kuoppala
AppliedQuoted 28 lines · Chris Wilson
Quoted 20 lines · Mika Kuoppala
If head seems stuck and engine in question is rcs, inspect subunit state transitions from undone to done, before deciding that this really is a hang instead of limited progress. Only account the transitions of subunits from undone to done once, to prevent unstable subunit states to keep us falsely active.
As this adds one extra steps to hangcheck heuristics, before hang is declared, it adds 1500ms to to detect hang for render ring to a total of 7500ms. We could sample the subunit states on first head stuck condition but decide not to do so only in order to mimic old behaviour. This way the check order of promotion from seqno > atchd > instdone is consistently done.
v2: Deal with unstable done states (Arun)
Clear instdone progress on head and seqno movement (Chris) Report raw and accumulated instdone's in in debugfs (Chris) ReturnHANGCHECK_ACTIVEonundone->doneQuoted 6 lines
References: https://bugs.freedesktop.org/show_bug.cgi?id=93029
Cc Chris Wilson <[email protected]>Cc Dave Gordon <[email protected]>Cc Daniel Vetter <[email protected]>Cc Arun Siluvery <[email protected]>Signed-off-by Mika Kuoppala <[email protected]>
Quoted 6 lines
I feel slightly dubious in discarding the 1->0 transitions (as it just means that a shared function that was previously idle is now in use again), but if they truly do fluctuate randomly? then accumulating should mean we eventually escape.
Reviewed-by Chris Wilson <[email protected]>
Queued for -next, thanks for the review.
-Mika
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 30 lines · Mika Kuoppala
Quoted 28 lines · Chris Wilson
Quoted 26 lines · Mika Kuoppala
If head seems stuck and engine in question is rcs, inspect subunit state transitions from undone to done, before deciding that this really is a hang instead of limited progress. Only account the transitions of subunits from undone to done once, to prevent unstable subunit states to keep us falsely active.
As this adds one extra steps to hangcheck heuristics, before hang is declared, it adds 1500ms to to detect hang for render ring to a total of 7500ms. We could sample the subunit states on first head stuck condition but decide not to do so only in order to mimic old behaviour. This way the check order of promotion from seqno > atchd > instdone is consistently done.
v2: Deal with unstable done states (Arun)
Clear instdone progress on head and seqno movement (Chris) Report raw and accumulated instdone's in in debugfs (Chris) ReturnHANGCHECK_ACTIVEonundone->doneReferences: https://bugs.freedesktop.org/show_bug.cgi?id=93029
Cc Chris Wilson <[email protected]>Cc Dave Gordon <[email protected]>Cc Daniel Vetter <[email protected]>Cc Arun Siluvery <[email protected]>Signed-off-by Mika Kuoppala <[email protected]>
Quoted 8 lines
Quoted 6 lines
I feel slightly dubious in discarding the 1->0 transitions (as it just means that a shared function that was previously idle is now in use again), but if they truly do fluctuate randomly? then accumulating should mean we eventually escape.
Reviewed-by Chris Wilson <[email protected]>Queued for -next, thanks for the review.
Hmm, you just reminded me that we have a problem with HEAD running wild now as we only detect a loop when it goes past 1<<48 (and we only increment the score when we loop).
Something like:
drivers/gpu/drm/i915/i915_irq.c +4 -8
@@ -2949,21 +2949,15 @@ static enum intel_engine_hangcheck_action head_stuck(struct intel_engine_cs *ring, u64 acthd) {if (acthd != ring->hangcheck.acthd) { -/* Clear subunit states on head movement */ memset (ring->hangcheck.instdone,0 ,sizeof (ring->hangcheck.instdone)); -if (acthd > ring->hangcheck.max_acthd) { - ring->hangcheck.max_acthd = acthd; -return HANGCHECK_ACTIVE ; - } -return HANGCHECK_ACTIVE_LOOP ; }if (!subunits_stuck (ring)) -return HANGCHECK_ACTIVE ; +return HANGCHECK_ACTIVE_LOOP ;return HANGCHECK_HUNG ; }
@@ -3117,7 +3111,9 @@ static void i915_hangcheck_elapsed(struct work_struct *work)* attempts across multiple batches. */ if (ring->hangcheck.score >0 ) - ring->hangcheck.score--; + ring->hangcheck.score -= HUNG +if (ring->hangcheck.score <0 ) + ring->hangcheck.score =0 ;/* Clear head and subunit states on seqno movement */ ring->hangcheck.acthd = ring->hangcheck.max_acthd =0 ;
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx