/** 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;
 
        /** Context related to this request */
        struct i915_hw_context *ctx;
 
+       /** Batch buffer related to this request if any */
+       struct drm_i915_gem_object *batch_obj;
+
        /** Time at which this request was emitted, in jiffies. */
        unsigned long emitted_jiffies;
 
 int __must_check i915_gem_idle(struct drm_device *dev);
 int __i915_add_request(struct intel_ring_buffer *ring,
                       struct drm_file *file,
+                      struct drm_i915_gem_object *batch_obj,
                       u32 *seqno);
 #define i915_add_request(ring, seqno) \
-       __i915_add_request(ring, NULL, seqno);
+       __i915_add_request(ring, NULL, NULL, seqno);
 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);
 
 
 int __i915_add_request(struct intel_ring_buffer *ring,
                       struct drm_file *file,
+                      struct drm_i915_gem_object *obj,
                       u32 *out_seqno)
 {
        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
 
        request->seqno = intel_ring_get_seqno(ring);
        request->ring = ring;
+       request->head = request_start;
        request->tail = request_ring_position;
        request->ctx = ring->last_context;
+       request->batch_obj = obj;
+
+       /* Whilst this request exists, batch_obj will be on the
+        * active_list, and so will hold the active reference. Only when this
+        * request is retired will the the batch_obj be moved onto the
+        * inactive_list and lose its active reference. Hence we do not need
+        * to explicitly hold another reference here.
+        */
 
        if (request->ctx)
                i915_gem_context_reference(request->ctx);
 
 static void
 i915_gem_execbuffer_retire_commands(struct drm_device *dev,
                                    struct drm_file *file,
-                                   struct intel_ring_buffer *ring)
+                                   struct intel_ring_buffer *ring,
+                                   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, file, NULL);
+       (void)__i915_add_request(ring, file, obj, NULL);
 }
 
 static int
        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);
+       i915_gem_execbuffer_retire_commands(dev, file, ring, batch_obj);
 
 err:
        eb_destroy(eb);