diff mbox

[2/2] drm/i915: add context into request struct

Message ID 1367502488-4108-2-git-send-email-mika.kuoppala@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mika Kuoppala May 2, 2013, 1:48 p.m. UTC
Storing context reference into request struct
allows us to inspect context and its associated
objects when requests are retired.

Both ppgtt and arb robustness work will need
this.

Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h |    3 +++
 drivers/gpu/drm/i915/i915_gem.c |   24 ++++++++++++++++++------
 2 files changed, 21 insertions(+), 6 deletions(-)

Comments

Ben Widawsky May 4, 2013, 12:07 a.m. UTC | #1
On Thu, May 02, 2013 at 04:48:08PM +0300, Mika Kuoppala wrote:
> Storing context reference into request struct
> allows us to inspect context and its associated
> objects when requests are retired.
> 
> Both ppgtt and arb robustness work will need
> this.
> 
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>

Both 1&2 are:
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>

You should add your sob to 1, since you modified it (slightly), and
maybe run them both my Chris to make sure he approves as well.

Thanks a lot of reworking the series to this order :D

[snip]
Daniel Vetter May 6, 2013, 9:22 a.m. UTC | #2
On Fri, May 03, 2013 at 05:07:42PM -0700, Ben Widawsky wrote:
> On Thu, May 02, 2013 at 04:48:08PM +0300, Mika Kuoppala wrote:
> > Storing context reference into request struct
> > allows us to inspect context and its associated
> > objects when requests are retired.
> > 
> > Both ppgtt and arb robustness work will need
> > this.
> > 
> > Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
> 
> Both 1&2 are:
> Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
> 
> You should add your sob to 1, since you modified it (slightly), and
> maybe run them both my Chris to make sure he approves as well.
> 
> Thanks a lot of reworking the series to this order :D

Both patches merged to dinq, thanks.
-Daniel
Mika Kuoppala May 6, 2013, 9:28 a.m. UTC | #3
Ben Widawsky <ben@bwidawsk.net> writes:

> On Thu, May 02, 2013 at 04:48:08PM +0300, Mika Kuoppala wrote:
>> Storing context reference into request struct
>> allows us to inspect context and its associated
>> objects when requests are retired.
>> 
>> Both ppgtt and arb robustness work will need
>> this.
>> 
>> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
>
> Both 1&2 are:
> Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
>
> You should add your sob to 1, since you modified it (slightly), and
> maybe run them both my Chris to make sure he approves as well.

I took 1/2 from:
http://cgit.freedesktop.org/~bwidawsk/drm-intel/commit/?h=ppgtt-ctx&id=5e266650d53d42ebbc8c22f2846c8ed87d747b21

and i don't remember intentionally modifying it. Is there some merge fallout I
missed? I couldn't spot any diff to original.

-Mika
Ben Widawsky May 7, 2013, 5:12 a.m. UTC | #4
On Mon, May 06, 2013 at 12:28:18PM +0300, Mika Kuoppala wrote:
> Ben Widawsky <ben@bwidawsk.net> writes:
> 
> > On Thu, May 02, 2013 at 04:48:08PM +0300, Mika Kuoppala wrote:
> >> Storing context reference into request struct
> >> allows us to inspect context and its associated
> >> objects when requests are retired.
> >> 
> >> Both ppgtt and arb robustness work will need
> >> this.
> >> 
> >> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
> >
> > Both 1&2 are:
> > Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
> >
> > You should add your sob to 1, since you modified it (slightly), and
> > maybe run them both my Chris to make sure he approves as well.
> 
> I took 1/2 from:
> http://cgit.freedesktop.org/~bwidawsk/drm-intel/commit/?h=ppgtt-ctx&id=5e266650d53d42ebbc8c22f2846c8ed87d747b21
> 
> and i don't remember intentionally modifying it. Is there some merge fallout I
> missed? I couldn't spot any diff to original.
> 
> -Mika

Ah, I see. The original patch from Chris had all 4 args to add request.
My patch had already fixed it :-D
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 3ac71db..ca0b0ce 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1270,6 +1270,9 @@  struct drm_i915_gem_request {
 	/** Postion in the ringbuffer of the end of the request */
 	u32 tail;
 
+	/** Context related to this request */
+	struct i915_hw_context *ctx;
+
 	/** Time at which this request was emitted, in jiffies. */
 	unsigned long emitted_jiffies;
 
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 6be940e..8a81d1a 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2042,6 +2042,11 @@  i915_add_request(struct intel_ring_buffer *ring,
 	request->seqno = intel_ring_get_seqno(ring);
 	request->ring = ring;
 	request->tail = request_ring_position;
+	request->ctx = ring->last_context;
+
+	if (request->ctx)
+		i915_gem_context_reference(request->ctx);
+
 	request->emitted_jiffies = jiffies;
 	was_empty = list_empty(&ring->request_list);
 	list_add_tail(&request->list, &ring->request_list);
@@ -2094,6 +2099,17 @@  i915_gem_request_remove_from_client(struct drm_i915_gem_request *request)
 	spin_unlock(&file_priv->mm.lock);
 }
 
+static void i915_gem_free_request(struct drm_i915_gem_request *request)
+{
+	list_del(&request->list);
+	i915_gem_request_remove_from_client(request);
+
+	if (request->ctx)
+		i915_gem_context_unreference(request->ctx);
+
+	kfree(request);
+}
+
 static void i915_gem_reset_ring_lists(struct drm_i915_private *dev_priv,
 				      struct intel_ring_buffer *ring)
 {
@@ -2104,9 +2120,7 @@  static void i915_gem_reset_ring_lists(struct drm_i915_private *dev_priv,
 					   struct drm_i915_gem_request,
 					   list);
 
-		list_del(&request->list);
-		i915_gem_request_remove_from_client(request);
-		kfree(request);
+		i915_gem_free_request(request);
 	}
 
 	while (!list_empty(&ring->active_list)) {
@@ -2198,9 +2212,7 @@  i915_gem_retire_requests_ring(struct intel_ring_buffer *ring)
 		 */
 		ring->last_retired_head = request->tail;
 
-		list_del(&request->list);
-		i915_gem_request_remove_from_client(request);
-		kfree(request);
+		i915_gem_free_request(request);
 	}
 
 	/* Move any buffers on the active list that are no longer referenced