aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-07-04 03:08:39 -0400
committerChris Wilson <chris@chris-wilson.co.uk>2016-07-04 03:18:24 -0400
commitbc3d674462e5df5f2b33adbfcaad9edff8b827f4 (patch)
tree460d103dfe6aff22a478b05644e84d44814ae21d
parentba6e0418064de8c4dee914a5eb8574affe19e6f5 (diff)
drm/i915: Allow userspace to request no-error-capture upon GPU hangs
igt likes to inject GPU hangs into its command streams. However, as we expect these hangs, we don't actually want them recorded in the dmesg output or stored in the i915_error_state (usually). To accommodate this allow userspace to set a flag on the context that any hang emanating from that context will not be recorded. We still do the error capture (otherwise how do we find the guilty context and know its intent?) as part of the reason for random GPU hang injection is to exercise the race conditions between the error capture and normal execution. v2: Split out the request->ringbuf error capture changes. v3: Move the flag defines next to the intel_context->flags definition Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Dave Gordon <david.s.gordon@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1467616119-4093-9-git-send-email-chris@chris-wilson.co.uk
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h4
-rw-r--r--drivers/gpu/drm/i915/i915_gem_context.c13
-rw-r--r--drivers/gpu/drm/i915/i915_gpu_error.c20
-rw-r--r--include/uapi/drm/i915_drm.h1
4 files changed, 29 insertions, 9 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 488891853cb5..251a08d8808d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -475,6 +475,7 @@ struct drm_i915_error_state {
475 struct timeval time; 475 struct timeval time;
476 476
477 char error_msg[128]; 477 char error_msg[128];
478 bool simulated;
478 int iommu; 479 int iommu;
479 u32 reset_count; 480 u32 reset_count;
480 u32 suspend_count; 481 u32 suspend_count;
@@ -875,9 +876,10 @@ struct i915_gem_context {
875 876
876 /* Unique identifier for this context, used by the hw for tracking */ 877 /* Unique identifier for this context, used by the hw for tracking */
877 unsigned long flags; 878 unsigned long flags;
879#define CONTEXT_NO_ZEROMAP BIT(0)
880#define CONTEXT_NO_ERROR_CAPTURE BIT(1)
878 unsigned hw_id; 881 unsigned hw_id;
879 u32 user_handle; 882 u32 user_handle;
880#define CONTEXT_NO_ZEROMAP (1<<0)
881 883
882 u32 ggtt_alignment; 884 u32 ggtt_alignment;
883 885
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 3a6594b70900..8e952b1a31b3 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -1026,6 +1026,9 @@ int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data,
1026 else 1026 else
1027 args->value = to_i915(dev)->ggtt.base.total; 1027 args->value = to_i915(dev)->ggtt.base.total;
1028 break; 1028 break;
1029 case I915_CONTEXT_PARAM_NO_ERROR_CAPTURE:
1030 args->value = !!(ctx->flags & CONTEXT_NO_ERROR_CAPTURE);
1031 break;
1029 default: 1032 default:
1030 ret = -EINVAL; 1033 ret = -EINVAL;
1031 break; 1034 break;
@@ -1071,6 +1074,16 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data,
1071 ctx->flags |= args->value ? CONTEXT_NO_ZEROMAP : 0; 1074 ctx->flags |= args->value ? CONTEXT_NO_ZEROMAP : 0;
1072 } 1075 }
1073 break; 1076 break;
1077 case I915_CONTEXT_PARAM_NO_ERROR_CAPTURE:
1078 if (args->size) {
1079 ret = -EINVAL;
1080 } else {
1081 if (args->value)
1082 ctx->flags |= CONTEXT_NO_ERROR_CAPTURE;
1083 else
1084 ctx->flags &= ~CONTEXT_NO_ERROR_CAPTURE;
1085 }
1086 break;
1074 default: 1087 default:
1075 ret = -EINVAL; 1088 ret = -EINVAL;
1076 break; 1089 break;
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index 1be63590a7fe..c6e05cccbedf 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -1093,9 +1093,8 @@ static void i915_gem_record_rings(struct drm_i915_private *dev_priv,
1093 struct i915_address_space *vm; 1093 struct i915_address_space *vm;
1094 struct intel_ringbuffer *rb; 1094 struct intel_ringbuffer *rb;
1095 1095
1096 vm = request->ctx && request->ctx->ppgtt ? 1096 vm = request->ctx->ppgtt ?
1097 &request->ctx->ppgtt->base : 1097 &request->ctx->ppgtt->base : &ggtt->base;
1098 &ggtt->base;
1099 1098
1100 /* We need to copy these to an anonymous buffer 1099 /* We need to copy these to an anonymous buffer
1101 * as the simplest method to avoid being overwritten 1100 * as the simplest method to avoid being overwritten
@@ -1123,6 +1122,9 @@ static void i915_gem_record_rings(struct drm_i915_private *dev_priv,
1123 rcu_read_unlock(); 1122 rcu_read_unlock();
1124 } 1123 }
1125 1124
1125 error->simulated |=
1126 request->ctx->flags & CONTEXT_NO_ERROR_CAPTURE;
1127
1126 rb = request->ringbuf; 1128 rb = request->ringbuf;
1127 error->ring[i].cpu_ring_head = rb->head; 1129 error->ring[i].cpu_ring_head = rb->head;
1128 error->ring[i].cpu_ring_tail = rb->tail; 1130 error->ring[i].cpu_ring_tail = rb->tail;
@@ -1422,12 +1424,14 @@ void i915_capture_error_state(struct drm_i915_private *dev_priv,
1422 i915_error_capture_msg(dev_priv, error, engine_mask, error_msg); 1424 i915_error_capture_msg(dev_priv, error, engine_mask, error_msg);
1423 DRM_INFO("%s\n", error->error_msg); 1425 DRM_INFO("%s\n", error->error_msg);
1424 1426
1425 spin_lock_irqsave(&dev_priv->gpu_error.lock, flags); 1427 if (!error->simulated) {
1426 if (dev_priv->gpu_error.first_error == NULL) { 1428 spin_lock_irqsave(&dev_priv->gpu_error.lock, flags);
1427 dev_priv->gpu_error.first_error = error; 1429 if (!dev_priv->gpu_error.first_error) {
1428 error = NULL; 1430 dev_priv->gpu_error.first_error = error;
1431 error = NULL;
1432 }
1433 spin_unlock_irqrestore(&dev_priv->gpu_error.lock, flags);
1429 } 1434 }
1430 spin_unlock_irqrestore(&dev_priv->gpu_error.lock, flags);
1431 1435
1432 if (error) { 1436 if (error) {
1433 i915_error_state_free(&error->ref); 1437 i915_error_state_free(&error->ref);
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index a642bbc7777d..d7e81a3886fd 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -1173,6 +1173,7 @@ struct drm_i915_gem_context_param {
1173#define I915_CONTEXT_PARAM_BAN_PERIOD 0x1 1173#define I915_CONTEXT_PARAM_BAN_PERIOD 0x1
1174#define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2 1174#define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2
1175#define I915_CONTEXT_PARAM_GTT_SIZE 0x3 1175#define I915_CONTEXT_PARAM_GTT_SIZE 0x3
1176#define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4
1176 __u64 value; 1177 __u64 value;
1177}; 1178};
1178 1179