History

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

Chris Wilson committed 10 years ago

Commit bc3d6741 parent ba6e0414 files · +29 −9Browse files

Unified · Split

4 files
  1. drivers/gpu/drm/i915/i915_drv.h +3 −1
  2. drivers/gpu/drm/i915/i915_gem_context.c +13 −0
  3. drivers/gpu/drm/i915/i915_gpu_error.c +12 −8
  4. include/uapi/drm/i915_drm.h +1 −0
drivers/gpu/drm/i915/i915_drv.h+3−1
@@ -475,6 +475,7 @@ struct drm_i915_error_state { · 474 unmodified lines
475475 struct timeval time;
476476
477477 char error_msg[128];
478+ bool simulated;
478479 int iommu;
479480 u32 reset_count;
480481 u32 suspend_count;
@@ -875,9 +876,10 @@ struct i915_gem_context { · 394 unmodified lines
875876
876877 /* Unique identifier for this context, used by the hw for tracking */
877878 unsigned long flags;
879+#define CONTEXT_NO_ZEROMAP BIT(0)
880+#define CONTEXT_NO_ERROR_CAPTURE BIT(1)
878881 unsigned hw_id;
879882 u32 user_handle;
880−#define CONTEXT_NO_ZEROMAP (1<<0)
881883
882884 u32 ggtt_alignment;
883885
drivers/gpu/drm/i915/i915_gem_context.c+13−0
@@ -1026,6 +1026,9 @@ int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data, · 1025 unmodified lines
10261026 else
10271027 args->value = to_i915(dev)->ggtt.base.total;
10281028 break;
1029+ case I915_CONTEXT_PARAM_NO_ERROR_CAPTURE:
1030+ args->value = !!(ctx->flags & CONTEXT_NO_ERROR_CAPTURE);
1031+ break;
10291032 default:
10301033 ret = -EINVAL;
10311034 break;
@@ -1071,6 +1074,16 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data, · 39 unmodified lines
10711074 ctx->flags |= args->value ? CONTEXT_NO_ZEROMAP : 0;
10721075 }
10731076 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;
10741087 default:
10751088 ret = -EINVAL;
10761089 break;
drivers/gpu/drm/i915/i915_gpu_error.c+12−8
@@ -1093,9 +1093,8 @@ static void i915_gem_record_rings(struct drm_i915_private *dev_priv, · 1092 unmodified lines
10931093 struct i915_address_space *vm;
10941094 struct intel_ringbuffer *rb;
10951095
1096− vm = request->ctx && request->ctx->ppgtt ?
1097− &request->ctx->ppgtt->base :
1098− &ggtt->base;
1096+ vm = request->ctx->ppgtt ?
1097+ &request->ctx->ppgtt->base : &ggtt->base;
10991098
11001099 /* We need to copy these to an anonymous buffer
11011100 * as the simplest method to avoid being overwritten
@@ -1123,6 +1122,9 @@ static void i915_gem_record_rings(struct drm_i915_private *dev_priv, · 21 unmodified lines
11231122 rcu_read_unlock();
11241123 }
11251124
1125+ error->simulated |=
1126+ request->ctx->flags & CONTEXT_NO_ERROR_CAPTURE;
1127+
11261128 rb = request->ringbuf;
11271129 error->ring[i].cpu_ring_head = rb->head;
11281130 error->ring[i].cpu_ring_tail = rb->tail;
@@ -1422,12 +1424,14 @@ void i915_capture_error_state(struct drm_i915_private *dev_priv, · 293 unmodified lines
14221424 i915_error_capture_msg(dev_priv, error, engine_mask, error_msg);
14231425 DRM_INFO("%s\n", error->error_msg);
14241426
1425− spin_lock_irqsave(&dev_priv->gpu_error.lock, flags);
1426− if (dev_priv->gpu_error.first_error == NULL) {
1427− dev_priv->gpu_error.first_error = error;
1428− error = NULL;
1427+ if (!error->simulated) {
1428+ spin_lock_irqsave(&dev_priv->gpu_error.lock, flags);
1429+ if (!dev_priv->gpu_error.first_error) {
1430+ dev_priv->gpu_error.first_error = error;
1431+ error = NULL;
1432+ }
1433+ spin_unlock_irqrestore(&dev_priv->gpu_error.lock, flags);
14291434 }
1430− spin_unlock_irqrestore(&dev_priv->gpu_error.lock, flags);
14311435
14321436 if (error) {
14331437 i915_error_state_free(&error->ref);
include/uapi/drm/i915_drm.h+1−0
@@ -1173,6 +1173,7 @@ struct drm_i915_gem_context_param { · 1172 unmodified lines
11731173 #define I915_CONTEXT_PARAM_BAN_PERIOD 0x1
11741174 #define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2
11751175 #define I915_CONTEXT_PARAM_GTT_SIZE 0x3
1176+#define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4
11761177 __u64 value;
11771178 };
11781179

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t