@@ -1263,9 +1263,15 @@ struct drm_i915_gem_request {
/** GEM sequence number associated with this request. */
uint32_t seqno;
- /** Postion in the ringbuffer of the end of the request */
+ /** Position in the ringbuffer of the start of the request */
+ u32 head;
+
+ /** Position in the ringbuffer of the end of the request */
u32 tail;
+ /** Batch buffer related to this request if any */
+ struct drm_i915_gem_object *batch_obj;
+
/** Context related to this request */
struct i915_hw_context *ctx;
@@ -1658,9 +1664,10 @@ int __must_check i915_gem_idle(struct drm_device *dev);
int _i915_add_request(struct intel_ring_buffer *ring,
u32 *seqno,
struct drm_file *file,
- struct i915_hw_context *ctx);
+ struct i915_hw_context *ctx,
+ struct drm_i915_gem_object *batch_obj);
#define i915_add_request(ring, seqno) \
- _i915_add_request(ring, seqno, NULL, NULL)
+ _i915_add_request(ring, seqno, NULL, NULL, NULL)
int __must_check i915_wait_seqno(struct intel_ring_buffer *ring,
uint32_t seqno);
int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
@@ -2002,14 +2002,16 @@ i915_gem_get_seqno(struct drm_device *dev, u32 *seqno)
int _i915_add_request(struct intel_ring_buffer *ring,
u32 *out_seqno,
struct drm_file *file,
- struct i915_hw_context *ctx)
+ struct i915_hw_context *ctx,
+ struct drm_i915_gem_object *obj)
{
drm_i915_private_t *dev_priv = ring->dev->dev_private;
struct drm_i915_gem_request *request;
- u32 request_ring_position;
+ u32 request_ring_position, request_start;
int was_empty;
int ret;
+ request_start = intel_ring_get_tail(ring);
/*
* Emit any outstanding flushes - execbuf can fail to emit the flush
* after having emitted the batchbuffer command. Hence we need to fix
@@ -2041,7 +2043,9 @@ int _i915_add_request(struct intel_ring_buffer *ring,
request->seqno = intel_ring_get_seqno(ring);
request->ring = ring;
+ request->head = request_start;
request->tail = request_ring_position;
+ request->batch_obj = obj;
request->ctx = ctx;
if (request->ctx)
@@ -797,13 +797,14 @@ static void
i915_gem_execbuffer_retire_commands(struct drm_device *dev,
struct drm_file *file,
struct intel_ring_buffer *ring,
- struct i915_hw_context *ctx)
+ struct i915_hw_context *ctx,
+ struct drm_i915_gem_object *obj)
{
/* Unconditionally force add_request to emit a full flush. */
ring->gpu_caches_dirty = true;
/* Add a breadcrumb for the completion of the batch buffer */
- (void)_i915_add_request(ring, NULL, file, ctx);
+ (void)_i915_add_request(ring, NULL, file, ctx, obj);
}
static int
@@ -1078,7 +1079,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
trace_i915_gem_ring_dispatch(ring, intel_ring_get_seqno(ring), flags);
i915_gem_execbuffer_move_to_active(&eb->objects, ring);
- i915_gem_execbuffer_retire_commands(dev, file, ring, ctx);
+ i915_gem_execbuffer_retire_commands(dev, file, ring, ctx, batch_obj);
err:
eb_destroy(eb);
In order to track down a batch buffer and context which caused the ring to hang, store reference to bo and context into the request struct. Request can also cause gpu to hang after the batch in the flush section in the ring. To detect this add start of the flush portion offset into the request. Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com> --- drivers/gpu/drm/i915/i915_drv.h | 13 ++++++++++--- drivers/gpu/drm/i915/i915_gem.c | 8 ++++++-- drivers/gpu/drm/i915/i915_gem_execbuffer.c | 7 ++++--- 3 files changed, 20 insertions(+), 8 deletions(-)