diff options
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_execbuffer.c | 16 | ||||
-rw-r--r-- | include/drm/i915_drm.h | 8 |
2 files changed, 23 insertions, 1 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c index 974a9f1068a3..f32d02464bce 100644 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c | |||
@@ -1044,6 +1044,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, | |||
1044 | struct drm_i915_gem_object *batch_obj; | 1044 | struct drm_i915_gem_object *batch_obj; |
1045 | struct drm_clip_rect *cliprects = NULL; | 1045 | struct drm_clip_rect *cliprects = NULL; |
1046 | struct intel_ring_buffer *ring; | 1046 | struct intel_ring_buffer *ring; |
1047 | u32 ctx_id = i915_execbuffer2_get_context_id(*args); | ||
1047 | u32 exec_start, exec_len; | 1048 | u32 exec_start, exec_len; |
1048 | u32 seqno; | 1049 | u32 seqno; |
1049 | u32 mask; | 1050 | u32 mask; |
@@ -1065,9 +1066,19 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, | |||
1065 | break; | 1066 | break; |
1066 | case I915_EXEC_BSD: | 1067 | case I915_EXEC_BSD: |
1067 | ring = &dev_priv->ring[VCS]; | 1068 | ring = &dev_priv->ring[VCS]; |
1069 | if (ctx_id != 0) { | ||
1070 | DRM_DEBUG("Ring %s doesn't support contexts\n", | ||
1071 | ring->name); | ||
1072 | return -EPERM; | ||
1073 | } | ||
1068 | break; | 1074 | break; |
1069 | case I915_EXEC_BLT: | 1075 | case I915_EXEC_BLT: |
1070 | ring = &dev_priv->ring[BCS]; | 1076 | ring = &dev_priv->ring[BCS]; |
1077 | if (ctx_id != 0) { | ||
1078 | DRM_DEBUG("Ring %s doesn't support contexts\n", | ||
1079 | ring->name); | ||
1080 | return -EPERM; | ||
1081 | } | ||
1071 | break; | 1082 | break; |
1072 | default: | 1083 | default: |
1073 | DRM_DEBUG("execbuf with unknown ring: %d\n", | 1084 | DRM_DEBUG("execbuf with unknown ring: %d\n", |
@@ -1261,6 +1272,10 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data, | |||
1261 | goto err; | 1272 | goto err; |
1262 | } | 1273 | } |
1263 | 1274 | ||
1275 | ret = i915_switch_context(ring, file, ctx_id); | ||
1276 | if (ret) | ||
1277 | goto err; | ||
1278 | |||
1264 | trace_i915_gem_ring_dispatch(ring, seqno); | 1279 | trace_i915_gem_ring_dispatch(ring, seqno); |
1265 | 1280 | ||
1266 | exec_start = batch_obj->gtt_offset + args->batch_start_offset; | 1281 | exec_start = batch_obj->gtt_offset + args->batch_start_offset; |
@@ -1367,6 +1382,7 @@ i915_gem_execbuffer(struct drm_device *dev, void *data, | |||
1367 | exec2.num_cliprects = args->num_cliprects; | 1382 | exec2.num_cliprects = args->num_cliprects; |
1368 | exec2.cliprects_ptr = args->cliprects_ptr; | 1383 | exec2.cliprects_ptr = args->cliprects_ptr; |
1369 | exec2.flags = I915_EXEC_RENDER; | 1384 | exec2.flags = I915_EXEC_RENDER; |
1385 | i915_execbuffer2_set_context_id(exec2, 0); | ||
1370 | 1386 | ||
1371 | ret = i915_gem_do_execbuffer(dev, data, file, &exec2, exec2_list); | 1387 | ret = i915_gem_do_execbuffer(dev, data, file, &exec2, exec2_list); |
1372 | if (!ret) { | 1388 | if (!ret) { |
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h index 5da73244486a..8cc70837f929 100644 --- a/include/drm/i915_drm.h +++ b/include/drm/i915_drm.h | |||
@@ -663,13 +663,19 @@ struct drm_i915_gem_execbuffer2 { | |||
663 | #define I915_EXEC_CONSTANTS_ABSOLUTE (1<<6) | 663 | #define I915_EXEC_CONSTANTS_ABSOLUTE (1<<6) |
664 | #define I915_EXEC_CONSTANTS_REL_SURFACE (2<<6) /* gen4/5 only */ | 664 | #define I915_EXEC_CONSTANTS_REL_SURFACE (2<<6) /* gen4/5 only */ |
665 | __u64 flags; | 665 | __u64 flags; |
666 | __u64 rsvd1; | 666 | __u64 rsvd1; /* now used for context info */ |
667 | __u64 rsvd2; | 667 | __u64 rsvd2; |
668 | }; | 668 | }; |
669 | 669 | ||
670 | /** Resets the SO write offset registers for transform feedback on gen7. */ | 670 | /** Resets the SO write offset registers for transform feedback on gen7. */ |
671 | #define I915_EXEC_GEN7_SOL_RESET (1<<8) | 671 | #define I915_EXEC_GEN7_SOL_RESET (1<<8) |
672 | 672 | ||
673 | #define I915_EXEC_CONTEXT_ID_MASK (0xffffffff) | ||
674 | #define i915_execbuffer2_set_context_id(eb2, context) \ | ||
675 | (eb2).rsvd1 = context & I915_EXEC_CONTEXT_ID_MASK | ||
676 | #define i915_execbuffer2_get_context_id(eb2) \ | ||
677 | ((eb2).rsvd1 & I915_EXEC_CONTEXT_ID_MASK) | ||
678 | |||
673 | struct drm_i915_gem_pin { | 679 | struct drm_i915_gem_pin { |
674 | /** Handle of the buffer to be pinned. */ | 680 | /** Handle of the buffer to be pinned. */ |
675 | __u32 handle; | 681 | __u32 handle; |