Error state improvements
Subsystems (2)
cover Error state improvements
Reworked series based on review comments raised in thread:
[email protected]
-Mika
Chris Wilson (2):
drm/i915: Rely on accurate request tracking for finding hung batches drm/i915: Record pid/comm of hanging task
Mika Kuoppala (4):
drm/i915: Add error code into error state
drm/i915: Add reason for capture in error state
drm/i915: Add reset count to error state
drm/i915: Add suspend count to error state
drivers/gpu/drm/i915/i915_debugfs.c | 5 +- drivers/gpu/drm/i915/i915_drv.c | 2 + drivers/gpu/drm/i915/i915_drv.h | 22 ++- drivers/gpu/drm/i915/i915_gem.c | 11 +- drivers/gpu/drm/i915/i915_gpu_error.c | 272 +++++++++++++++++---------------- drivers/gpu/drm/i915/i915_irq.c | 46 ++++-- 6 files changed, 204 insertions(+), 154 deletions(-)
Signature · 1 line
1.7.9.5
PATCH 1/6 drm/i915: Rely on accurate request tracking for finding hung batches
From: Chris Wilson <[email protected]>
In the past, it was possible to have multiple batches per request due to a stray signal or ENOMEM. As a result we had to scan each active object (filtered by those having the COMMAND domain) for the one that contained the ACTHD pointer. This was then made more complicated by the introduction of ppgtt, whereby ACTHD then pointed into the address space of the context and so also needed to be taken into account.
This is a fairly robust approach (though the implementation is a little fragile and depends upon the per-generation setup, registers and parameters). However, due to the requirements for hangstats, we needed a robust method for associating batches with a particular request and having that we can rely upon it for finding the associated batch object for error capture.
If the batch buffer tracking is not robust enough, that should become apparent quite quickly through an erroneous error capture. That should also help to make sure that the runtime reporting to userspace is robust. It also means that we then report the oldest incomplete batch on each ring, which can be useful for determining the state of userspace at the time of a hang.
v2: Use i915_gem_find_active_request (Mika)
v3: remove check for ring->get_seqno, split long lines (Ben)
v4: check that context is available (Chris)
checkpatch warnings fixed
--- drivers/gpu/drm/i915/i915_drv.h | 3 ++ drivers/gpu/drm/i915/i915_gem.c | 10 +++-- drivers/gpu/drm/i915/i915_gpu_error.c | 72 ++++++--------------------------- 3 files changed, 21 insertions(+), 64 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +3 -0
@@ -2155,6 +2155,9 @@ i915_gem_object_unpin_fence(struct drm_i915_gem_object *obj) } } +struct drm_i915_gem_request * +i915_gem_find_active_request (struct intel_ring_buffer *ring); +bool i915_gem_retire_requests (struct drm_device *dev);void i915_gem_retire_requests_ring (struct intel_ring_buffer *ring); int __must_check i915_gem_check_wedge(struct i915_gpu_error *error,
drivers/gpu/drm/i915/i915_gem.c +6 -4
@@ -2303,11 +2303,13 @@ static void i915_gem_free_request(struct drm_i915_gem_request *request)kfree (request); } -static struct drm_i915_gem_request * -i915_gem_find_first_non_complete (struct intel_ring_buffer *ring) +struct drm_i915_gem_request * +i915_gem_find_active_request (struct intel_ring_buffer *ring) {struct drm_i915_gem_request *request; -const u32 completed_seqno = ring->get_seqno (ring, false); +u32 completed_seqno; + + completed_seqno = ring->get_seqno (ring, false);list_for_each_entry (request, &ring->request_list, list) {if (i915_seqno_passed (completed_seqno, request->seqno))
@@ -2325,7 +2327,7 @@ static void i915_gem_reset_ring_status(struct drm_i915_private *dev_priv,struct drm_i915_gem_request *request;bool ring_hung; - request =i915_gem_find_first_non_complete (ring); + request =i915_gem_find_active_request (ring);if (request ==NULL )return ;
drivers/gpu/drm/i915/i915_gpu_error.c +12 -60
91 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 2/6 drm/i915: Record pid/comm of hanging task
In reply to Mika KuoppalaFrom: Chris Wilson <[email protected]>
After finding the guilty batch and request, we can use it to find the process that submitted the batch and then add the culprit into the error state.
This is a slightly different approach from Ben's in that instead of adding the extra information into the struct i915_hw_context, we use the information already captured in struct drm_file which is then referenced from the request.
v2: Also capture the workaround buffer for gen2, so that we can compare
its contents against the intended batch for the active request.
v3: Rebase (Mika)
v4: Check for null context (Chris)
checkpatch warnings fixed
--- drivers/gpu/drm/i915/i915_drv.h | 6 +- drivers/gpu/drm/i915/i915_gem.c | 1 + drivers/gpu/drm/i915/i915_gpu_error.c | 136 +++++++++++++++++++-------------- 3 files changed, 86 insertions(+), 57 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +5 -1
@@ -360,7 +360,7 @@ struct drm_i915_error_state {int page_count;u32 gtt_offset;u32 *pages[0 ]; - } *ringbuffer, *batchbuffer, *ctx, *hws_page; + } *ringbuffer, *batchbuffer, *wa_batchbuffer, *ctx, *hws_page;struct drm_i915_error_request {long jiffies;
@@ -375,6 +375,9 @@ struct drm_i915_error_state {u32 pp_dir_base; }; } vm_info; + +pid_t pid; +char comm[TASK_COMM_LEN ]; } ring[I915_NUM_RINGS ];struct drm_i915_error_buffer {u32 size;
@@ -1791,6 +1794,7 @@ struct drm_i915_gem_request {struct drm_i915_file_private {struct drm_i915_private *dev_priv; +struct drm_file *file;struct {spinlock_t lock;
drivers/gpu/drm/i915/i915_gem.c +1 -0
@@ -4862,6 +4862,7 @@ int i915_gem_open(struct drm_device *dev, struct drm_file *file) file->driver_priv = file_priv; file_priv->dev_priv = dev->dev_private; + file_priv->file = file;spin_lock_init (&file_priv->mm.lock);INIT_LIST_HEAD (&file_priv->mm.request_list);
drivers/gpu/drm/i915/i915_gpu_error.c +80 -56
179 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 3/6 drm/i915: Add error code into error state
In reply to Mika Kuoppalacommit 011cf577b2531dfbd2254bd9ec147ad71471abaf
Author: Ben Widawsky <[email protected]> Date: Tue Feb 4 12:18:55 2014 +0000
drm/i915: Generate a hang error code
added error code debug into dmesg. Store this also with error state to make matching dmesg logs and error states easier.
As we need to have full ring state for error code generation, do full capture always, print hang message into log and then decide if we need to keep the error state.
--- drivers/gpu/drm/i915/i915_drv.h | 2 ++ drivers/gpu/drm/i915/i915_gpu_error.c | 61 ++++++++++++++++++++------------- 2 files changed, 40 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -303,6 +303,8 @@ struct drm_i915_error_state {struct kref ref;struct timeval time; +char error_msg[128 ]; +/* Generic register state */ u32 eir;u32 pgtbl_er;
drivers/gpu/drm/i915/i915_gpu_error.c +38 -23
117 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 4/6 drm/i915: Add reason for capture in error state
In reply to Mika KuoppalaWe capture error state not only when the GPU hangs but also on other situations as in interrupt errors and in situations where we can kick things forward without GPU reset. There will be log entry on most of these cases. But as error state capture might be only thing we have, if dmesg was not captured. Or as in GEN4 case, interrupt error can trigger error state capture without log entry, the exact reason why capture was made is hard to decipher.
v2: Split out the the error code stuff to separate patch (Ben)
References: https://bugs.freedesktop.org/show_bug.cgi?id=74193
--- drivers/gpu/drm/i915/i915_debugfs.c | 5 ++-- drivers/gpu/drm/i915/i915_drv.h | 7 +++-- drivers/gpu/drm/i915/i915_gpu_error.c | 27 ++++++++++++++----- drivers/gpu/drm/i915/i915_irq.c | 46 +++++++++++++++++++++------------ 4 files changed, 58 insertions(+), 27 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +2 -3
@@ -3167,9 +3167,8 @@ i915_wedged_set(void *data, u64 val) {struct drm_device *dev = data; -DRM_INFO ("Manually setting wedged to %llu\n" , val); -i915_handle_error (dev, val); - +i915_handle_error (dev, val, +"Manually setting wedged to %llu" , val);return 0 ; }
drivers/gpu/drm/i915/i915_drv.h +5 -2
@@ -2002,7 +2002,9 @@ extern void intel_console_resume(struct work_struct *work);/* i915_irq.c */ void i915_queue_hangcheck (struct drm_device *dev); -void i915_handle_error (struct drm_device *dev,bool wedged); +__printf(3, 4) +void i915_handle_error (struct drm_device *dev,bool wedged, +const char *fmt, ...);void gen6_set_pm_mask (struct drm_i915_private *dev_priv,u32 pm_iir,int new_delay);
@@ -2479,7 +2481,8 @@ static inline void i915_error_state_buf_release( {kfree (eb->buf); } -void i915_capture_error_state (struct drm_device *dev); +void i915_capture_error_state (struct drm_device *dev,bool wedge, +const char *error_msg);void i915_error_state_get (struct drm_device *dev,struct i915_error_state_file_priv *error_priv);void i915_error_state_put (struct i915_error_state_file_priv *error_priv);
drivers/gpu/drm/i915/i915_gpu_error.c +21 -6
@@ -1094,16 +1094,30 @@ static void i915_capture_reg_state(struct drm_i915_private *dev_priv, }static void i915_error_capture_msg (struct drm_device *dev, -struct drm_i915_error_state *error) +struct drm_i915_error_state *error, +bool wedged, +const char *error_msg) {struct drm_i915_private *dev_priv = dev->dev_private;u32 ecode; -int ring_id =-1 ; +int ring_id =-1 , len; ecode =i915_error_generate_code (dev_priv, error, &ring_id); -scnprintf (error->error_msg,sizeof (error->error_msg), -"GPU HANG: ecode %d:0x%08x" , ring_id, ecode); + len =scnprintf (error->error_msg,sizeof (error->error_msg), +"GPU HANG: ecode %d:0x%08x" , ring_id, ecode); + +if (ring_id !=-1 && error->ring[ring_id].pid !=-1 ) + len +=scnprintf (error->error_msg + len, +sizeof (error->error_msg) - len, +", in %s [%d]" , + error->ring[ring_id].comm, + error->ring[ring_id].pid); + +scnprintf (error->error_msg + len,sizeof (error->error_msg) - len, +", reason: %s, action: %s" , + error_msg, + wedged ?"reset" :"continue" ); }/**
@@ -1115,7 +1129,8 @@ static void i915_error_capture_msg(struct drm_device *dev,* out a structure which becomes available in debugfs for user level tools * to pick up. */ -void i915_capture_error_state (struct drm_device *dev) +void i915_capture_error_state (struct drm_device *dev,bool wedged, +const char *error_msg) {static bool warned;struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1141,7 +1156,7 @@ void i915_capture_error_state(struct drm_device *dev) error->overlay =intel_overlay_capture_error_state (dev); error->display =intel_display_capture_error_state (dev); -i915_error_capture_msg (dev, error); +i915_error_capture_msg (dev, error, wedged, error_msg);DRM_INFO ("%s\n" , error->error_msg);spin_lock_irqsave (&dev_priv->gpu_error.lock, flags);
drivers/gpu/drm/i915/i915_irq.c +30 -16
103 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH 5/6 drm/i915: Add reset count to error state
In reply to Mika KuoppalaBy default we keep only the error state from first hang. However some sneaky user might have cleared the first error state and we assume mistakenly that it is from first hang. As sometimes this matters, it is better to explicitly store the reset count.
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_gpu_error.c | 8 ++++++++ 2 files changed, 9 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -304,6 +304,7 @@ struct drm_i915_error_state {struct timeval time;char error_msg[128 ]; +u32 reset_count;/* Generic register state */ u32 eir;
drivers/gpu/drm/i915/i915_gpu_error.c +8 -0
@@ -347,6 +347,7 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m, error->ring[i].pid); } } +err_printf (m,"Reset count: %u\n" , error->reset_count);err_printf (m,"PCI ID: 0x%04x\n" , dev->pdev->device);err_printf (m,"EIR: 0x%08x\n" , error->eir);err_printf (m,"IER: 0x%08x\n" , error->ier);
@@ -1120,6 +1121,12 @@ static void i915_error_capture_msg(struct drm_device *dev, wedged ? "reset" : "continue"); } +static void i915_capture_gen_state (struct drm_i915_private *dev_priv, +struct drm_i915_error_state *error) +{ + error->reset_count =i915_reset_count (&dev_priv->gpu_error); +} +/** * i915_capture_error_state - capture an error record for later analysis * @dev: drm device
@@ -1146,6 +1153,7 @@ void i915_capture_error_state(struct drm_device *dev, bool wedged,kref_init (&error->ref); +i915_capture_gen_state (dev_priv, error);i915_capture_reg_state (dev_priv, error);i915_gem_capture_buffers (dev_priv, error);i915_gem_record_fences (dev, error);
Signature · 1 line
1.7.9.5
PATCH 6/6 drm/i915: Add suspend count to error state
In reply to Mika KuoppalaFor example if we get bug reports with similar error states and suspend count is always 1, that might lead the Sherlocks to right general direction.
--- drivers/gpu/drm/i915/i915_drv.c | 2 ++ drivers/gpu/drm/i915/i915_drv.h | 3 +++ drivers/gpu/drm/i915/i915_gpu_error.c | 2 ++ 3 files changed, 7 insertions(+)
drivers/gpu/drm/i915/i915_drv.c +2 -0
@@ -477,6 +477,8 @@ static int i915_drm_freeze(struct drm_device *dev)intel_fbdev_set_suspend (dev,FBINFO_STATE_SUSPENDED );console_unlock (); + dev_priv->suspend_count++; +return 0 ; }
drivers/gpu/drm/i915/i915_drv.h +3 -0
@@ -305,6 +305,7 @@ struct drm_i915_error_state {char error_msg[128 ];u32 reset_count; +u32 suspend_count;/* Generic register state */ u32 eir;
@@ -1600,6 +1601,8 @@ typedef struct drm_i915_private {struct i915_dri1_state dri1;/* Old ums support infrastructure, same warning applies. */ struct i915_ums_state ums; + +u32 suspend_count; } drm_i915_private_t;static inline struct drm_i915_private *to_i915 (const struct drm_device *dev)
drivers/gpu/drm/i915/i915_gpu_error.c +2 -0
@@ -348,6 +348,7 @@ int i915_error_state_to_str(struct drm_i915_error_state_buf *m, } }err_printf (m,"Reset count: %u\n" , error->reset_count); +err_printf (m,"Suspend count: %u\n" , error->suspend_count);err_printf (m,"PCI ID: 0x%04x\n" , dev->pdev->device);err_printf (m,"EIR: 0x%08x\n" , error->eir);err_printf (m,"IER: 0x%08x\n" , error->ier);
@@ -1125,6 +1126,7 @@ static void i915_capture_gen_state(struct drm_i915_private *dev_priv, struct drm_i915_error_state *error) { error->reset_count =i915_reset_count (&dev_priv->gpu_error); + error->suspend_count = dev_priv->suspend_count; }/**
Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx