drm/i915: Exec buffer inserts watchdog commands
Subsystems (2)
RFC 13/13 drm/i915: Exec buffer inserts watchdog commands
Quoted 1 line
From
f71a7de85e9d81be3aa3962c8fe2557235ff21c1Mon Sep 17 00:00:00 2001
Message-Id: <f71a7de85e9d81be3aa3962c8fe2557235ff21c1.1387201899.git.ian.lister@intel.com>
In-Reply-To: <[email protected]>
References: <[email protected]>
From: ian-lister <[email protected]>
Date: Wed, 11 Dec 2013 11:25:44 +0000
Subject: [RFC 13/13] drm/i915: Exec buffer inserts watchdog commands
A start timer command is inserted before the batch buffer start command and a stop timer command is inserted afterwards. If the batch executes normally then the timer will be cancelled before it can fire, however if the batch buffer hangs then the watchdog timer will fire and i915_handle_error is called to complete the recovery work.
This patch requires the per-engine TDR patches.
--- drivers/gpu/drm/i915/i915_debugfs.c | 16 +++++++++++++--- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/i915/i915_irq.c | 1 + drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + 4 files changed, 37 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +13 -3
@@ -906,15 +906,23 @@ i915_ring_hangcheck_read(struct file *filp,* have hung and been reset since boot */ struct drm_device *dev = filp->private_data;drm_i915_private_t *dev_priv = dev->dev_private; -char buf[100 ]; +char buf[200 ];int len; len =scnprintf (buf,sizeof (buf), -"GPU=0x%08X,RCS=0x%08X,VCS=0x%08X,BCS=0x%08X\n" , +"GPU=0x%08X,RCS=0x%08X,VCS=0x%08X,BCS=0x%08X," +"RCS_T=0x%08x,VCS_T=0x%08x,BCS_T=0x%08x," +"RCS_W=0x%08x,VCS_W=0x%08x,BCS_W=0x%08x\n" , dev_priv->gpu_error.global_resets, dev_priv->ring[RCS ].hangcheck.total, dev_priv->ring[VCS ].hangcheck.total, - dev_priv->ring[BCS ].hangcheck.total); + dev_priv->ring[BCS ].hangcheck.total, + dev_priv->ring[RCS ].hangcheck.tdr_count, + dev_priv->ring[VCS ].hangcheck.tdr_count, + dev_priv->ring[BCS ].hangcheck.tdr_count, + dev_priv->ring[RCS ].hangcheck.watchdog_count, + dev_priv->ring[VCS ].hangcheck.watchdog_count, + dev_priv->ring[BCS ].hangcheck.watchdog_count);return simple_read_from_buffer (ubuf, max, ppos, buf, len); }
@@ -935,6 +943,8 @@ i915_ring_hangcheck_write(struct file *filp,for (i =0 ; i <I915_NUM_RINGS ; i++) {/* Reset the hangcheck counters */ dev_priv->ring[i].hangcheck.total =0 ; + dev_priv->ring[i].hangcheck.tdr_count =0 ; + dev_priv->ring[i].hangcheck.watchdog_count =0 ; } dev_priv->gpu_error.global_resets =0 ;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +22 -0
@@ -32,6 +32,7 @@#include "i915_trace.h" #include "intel_drv.h" #include <linux/dma_remapping.h> +#include "intel_ringbuffer.h" struct eb_vmas {struct list_head vmas;
@@ -1196,6 +1197,17 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, goto err; } +/* Start watchdog timer*/ +if ((args->flags &I915_EXEC_ENABLE_WATCHDOG ) && + i915_enable_watchdog && +intel_ring_watchdog_supported (ring)) { + + ret =intel_ring_start_watchdog (ring); + +if (ret) + goto err; + } + exec_start =i915_gem_obj_offset (batch_obj, vm) + args->batch_start_offset; exec_len = args->batch_len;
@@ -1220,6 +1232,16 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, goto err; } +/* Cancel watchdog timer */ +if ((args->flags &I915_EXEC_ENABLE_WATCHDOG ) && + i915_enable_watchdog && +intel_ring_watchdog_supported (ring)) { + + ret =intel_ring_stop_watchdog (ring); +if (ret) + goto err; + } +trace_i915_gem_ring_dispatch (ring,intel_ring_get_seqno (ring), flags);i915_gem_execbuffer_move_to_active (&eb->vmas, ring);
drivers/gpu/drm/i915/i915_irq.c +1 -0
@@ -2974,6 +2974,7 @@ static void i915_hangcheck_elapsed(unsigned long data) busy_count +=i915_hangcheck_ring_sample (ring);if (ring->hangcheck.score >FIRE ) { + ring->hangcheck.tdr_count++;DRM_ERROR ("Hang detected on %s\n" , ring->name);
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
@@ -72,6 +72,7 @@ struct intel_ring_hangcheck {u32 total;/* Total resets applied to this ring/engine*/ u32 last_head;/* Head value recorded at last hang */ u32 status_updated; +u32 tdr_count;/* Total TDR resets for this ring */ u32 watchdog_threshold;u32 watchdog_count;/* Total watchdog resets for this ring */ };
Signature · 1 line
1.8.5.1
Quoted 56 lines · Ian
From
f71a7de85e9d81be3aa3962c8fe2557235ff21c1Mon Sep 17 00:00:00 2001
Message-Id: <f71a7de85e9d81be3aa3962c8fe2557235ff21c1.1387201899.git.ian.lister@intel.com>
In-Reply-To: <[email protected]>
References: <[email protected]>
From: ian-lister <[email protected]>
Date: Wed, 11 Dec 2013 11:25:44 +0000
Subject: [RFC 13/13] drm/i915: Exec buffer inserts watchdog commandsA start timer command is inserted before the batch buffer start command and a stop timer command is inserted afterwards. If the batch executes normally then the timer will be cancelled before it can fire, however if the batch buffer hangs then the watchdog timer will fire and
i915_handle_erroris called to complete the recovery work.This patch requires the per-engine TDR patches.
Signed-off-by ian-lister <[email protected]>--- drivers/gpu/drm/i915/i915_debugfs.c | 16 +++++++++++++--- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 22 ++++++++++++++++++++++ drivers/gpu/drm/i915/i915_irq.c | 1 + drivers/gpu/drm/i915/intel_ringbuffer.h | 1 + 4 files changed, 37 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/i915_debugfs.c +11
-3@@ -906,15 +906,23 @@ i915_ring_hangcheck_read(struct file *filp,* have hung and been reset since boot */ struct drm_device *dev = filp->private_data;drm_i915_private_t *dev_priv = dev->dev_private; -char buf[100 ]; +char buf[200 ];int len; len =scnprintf (buf,sizeof (buf), -"GPU=0x%08X,RCS=0x%08X,VCS=0x%08X,BCS=0x%08X\n" , +"GPU=0x%08X,RCS=0x%08X,VCS=0x%08X,BCS=0x%08X," +"RCS_T=0x%08x,VCS_T=0x%08x,BCS_T=0x%08x," +"RCS_W=0x%08x,VCS_W=0x%08x,BCS_W=0x%08x\n" , dev_priv->gpu_error.global_resets, dev_priv->ring[RCS ].hangcheck.total, dev_priv->ring[VCS ].hangcheck.total, - dev_priv->ring[BCS ].hangcheck.total); + dev_priv->ring[BCS ].hangcheck.total, + dev_priv->ring[RCS ].hangcheck.tdr_count, + dev_priv->ring[VCS ].hangcheck.tdr_count, + dev_priv->ring[BCS ].hangcheck.tdr_count, + dev_priv->ring[RCS ].hangcheck.watchdog_count, + dev_priv->ring[VCS ].hangcheck.watchdog_count, + dev_priv->ring[BCS ].hangcheck.watchdog_count);return simple_read_from_buffer (ubuf, max, ppos, buf, len); }
drivers/gpu/drm/i915/i915_debugfs.c i915_ring_hangcheck_write(struct file *filp, · line 948
Quoted 6 lines
drivers/gpu/drm/i915/i915_debugfs.c +2
-0@@ -935,6 +943,8 @@ i915_ring_hangcheck_write(struct file *filp,for (i =0 ; i <I915_NUM_RINGS ; i++) {/* Reset the hangcheck counters */ dev_priv->ring[i].hangcheck.total =0 ; + dev_priv->ring[i].hangcheck.tdr_count =0 ; + dev_priv->ring[i].hangcheck.watchdog_count =0 ; }
Looks like unrelated debug code, needs to be extracted and shuffled into the right patch (or separate debug patch). There's more like this below.
Quoted 15 lines
drivers/gpu/drm/i915/i915_debugfs.c +0
-0dev_priv->gpu_error.global_resets =0 ;drivers/gpu/drm/i915/i915_gem_execbuffer.c +1
-0@@ -32,6 +32,7 @@#include "i915_trace.h" #include "intel_drv.h" #include <linux/dma_remapping.h> +#include "intel_ringbuffer.h" struct eb_vmas {struct list_head vmas;
drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_gem_do_execbuffer(struct drm_device *dev, void *data, · line 1203
Quoted 7 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +4
-0@@ -1196,6 +1197,17 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, goto err; } +/* Start watchdog timer*/ +if ((args->flags &I915_EXEC_ENABLE_WATCHDOG ) && + i915_enable_watchdog && +intel_ring_watchdog_supported (ring)) {
Imo just yell at userspace (with an -EINVAL) if it tries to use the watchdog support on unsupported rings. Which means we need a driver flag for this.
Also I don't see the value of of a module option for this (I presume i915_enable_watchdog is this) since this is purely opt-in from userspace.
Quoted 59 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +17
-0+ + ret =intel_ring_start_watchdog (ring); + +if (ret) + goto err; + } + exec_start =i915_gem_obj_offset (batch_obj, vm) + args->batch_start_offset; exec_len = args->batch_len;@@ -1220,6 +1232,16 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, goto err; } +/* Cancel watchdog timer */ +if ((args->flags &I915_EXEC_ENABLE_WATCHDOG ) && + i915_enable_watchdog && +intel_ring_watchdog_supported (ring)) { + + ret =intel_ring_stop_watchdog (ring); +if (ret) + goto err; + } +trace_i915_gem_ring_dispatch (ring,intel_ring_get_seqno (ring), flags);i915_gem_execbuffer_move_to_active (&eb->vmas, ring);drivers/gpu/drm/i915/i915_irq.c +1
-0@@ -2974,6 +2974,7 @@ static void i915_hangcheck_elapsed(unsigned long data) busy_count +=i915_hangcheck_ring_sample (ring);if (ring->hangcheck.score >FIRE ) { + ring->hangcheck.tdr_count++;DRM_ERROR ("Hang detected on %s\n" , ring->name);drivers/gpu/drm/i915/intel_ringbuffer.h +1
-0@@ -72,6 +72,7 @@ struct intel_ring_hangcheck {u32 total;/* Total resets applied to this ring/engine*/ u32 last_head;/* Head value recorded at last hang */ u32 status_updated; +u32 tdr_count;/* Total TDR resets for this ring */ u32 watchdog_threshold;u32 watchdog_count;/* Total watchdog resets for this ring */ };Signature · 7 lines
1.8.5.1 _______________________________________________ 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