Skip to contentSkip to conversation

Remove the outstanding_lazy_request

PATCH In review [email protected] 5 participants 120 messages May 29, 2015 – Jun 24, 2015 Page 2 of 2

Subsystems (2)
lore
Share & tools
lore
#91 lore raw

Re: [PATCH 48/55] drm/i915: Add *_ring_begin() to request allocation

In reply to Daniel Vetter
Quoted 13 lines · Daniel Vetter
Quoted 11 lines · On Fri, May 29, 2015 at 05:44:09PM +0100, [email protected] wrote:

From: John Harrison <[email protected]>

Now that the *_ring_begin() functions no longer call the request allocation code, it is finally safe for the request allocation code to call *_ring_begin(). This is important to guarantee that the space reserved for the subsequent i915_add_request() call does actually get reserved.

v2: Renamed functions according to review feedback (Tomas Elf).

For: VIZ-5115

Quoted 7 lines

Still has my question open from the previos round:

http://mid.gmane.org/[email protected]

Note that this isn't all that unlikely with GuC mode since there the ringbuffer is substantially smaller (due to firmware limitations) than what we allocate ourselves right now.

Looking at this patch, I am still fundamentally opposed to reserving space for the request. Detecting a request that wraps and cancelling that request (after the appropriate WARN for the overlow) is trivial and such a rare case (as it is a programming error) that it should only be handled in the slow path.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#92 lore raw

Re: [PATCH 48/55] drm/i915: Add *_ring_begin() to request allocation

Quoted 22 lines · Chris Wilson
Quoted 13 lines · Daniel Vetter
Quoted 11 lines · On Fri, May 29, 2015 at 05:44:09PM +0100, [email protected] wrote:

From: John Harrison <[email protected]>

Now that the *_ring_begin() functions no longer call the request allocation code, it is finally safe for the request allocation code to call *_ring_begin(). This is important to guarantee that the space reserved for the subsequent i915_add_request() call does actually get reserved.

v2: Renamed functions according to review feedback (Tomas Elf).

For: VIZ-5115

Quoted 7 lines

Still has my question open from the previos round:

http://mid.gmane.org/[email protected]

Note that this isn't all that unlikely with GuC mode since there the ringbuffer is substantially smaller (due to firmware limitations) than what we allocate ourselves right now.

Quoted 5 lines

Looking at this patch, I am still fundamentally opposed to reserving space for the request. Detecting a request that wraps and cancelling that request (after the appropriate WARN for the overlow) is trivial and such a rare case (as it is a programming error) that it should only be handled in the slow path.

I thought the entire point here that we don't have request half-committed because the final request ringcmds didn't fit in. And that does require that we reserve a bit of space for that postamble.

I guess if it's too much (atm it's super-pessimistic due to ilk) we can make per-platform reservation limits to be really minimal.

Maybe we could go towards a rollback model longterm of rewingind the ringbuffer. But if there's no clear need I'd like to avoid that complexity.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#93 lore raw

Re: [PATCH 48/55] drm/i915: Add *_ring_begin() to request allocation

Quoted 33 lines · Daniel Vetter
Quoted 22 lines · Chris Wilson
Quoted 13 lines · Daniel Vetter
Quoted 11 lines · On Fri, May 29, 2015 at 05:44:09PM +0100, [email protected] wrote:

From: John Harrison <[email protected]>

Now that the *_ring_begin() functions no longer call the request allocation code, it is finally safe for the request allocation code to call *_ring_begin(). This is important to guarantee that the space reserved for the subsequent i915_add_request() call does actually get reserved.

v2: Renamed functions according to review feedback (Tomas Elf).

For: VIZ-5115

Quoted 7 lines

Still has my question open from the previos round:

http://mid.gmane.org/[email protected]

Note that this isn't all that unlikely with GuC mode since there the ringbuffer is substantially smaller (due to firmware limitations) than what we allocate ourselves right now.

Quoted 5 lines

Looking at this patch, I am still fundamentally opposed to reserving space for the request. Detecting a request that wraps and cancelling that request (after the appropriate WARN for the overlow) is trivial and such a rare case (as it is a programming error) that it should only be handled in the slow path.

I thought the entire point here that we don't have request half-committed because the final request ringcmds didn't fit in. And that does require that we reserve a bit of space for that postamble.

Quoted 6 lines

I guess if it's too much (atm it's super-pessimistic due to ilk) we can make per-platform reservation limits to be really minimal.

Maybe we could go towards a rollback model longterm of rewingind the ringbuffer. But if there's no clear need I'd like to avoid that complexity.

Even if you didn't like the rollback model which helps handling the partial state from context switches and what not, if you run out of ringspace you can set the GPU as wedged. Issuing a request that fills the entire ringbuffer is a programming bug that needs to be caught very early in development.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#94 lore raw

Re: [PATCH 48/55] drm/i915: Add *_ring_begin() to request allocation

Quoted 37 lines · Chris Wilson
Quoted 30 lines · Daniel Vetter
Quoted 17 lines · Chris Wilson
Quoted 16 lines · Daniel Vetter
Quoted 11 lines · On Fri, May 29, 2015 at 05:44:09PM +0100, [email protected] wrote:

From: John Harrison <[email protected]>

Now that the *_ring_begin() functions no longer call the request allocation code, it is finally safe for the request allocation code to call *_ring_begin(). This is important to guarantee that the space reserved for the subsequent i915_add_request() call does actually get reserved.

v2: Renamed functions according to review feedback (Tomas Elf).

For: VIZ-5115

Still has my question open from the previos round:

http://mid.gmane.org/[email protected]

Quoted 8 lines
Quoted 3 lines

Note that this isn't all that unlikely with GuC mode since there the ringbuffer is substantially smaller (due to firmware limitations) than what we allocate ourselves right now.

Looking at this patch, I am still fundamentally opposed to reserving space for the request. Detecting a request that wraps and cancelling that request (after the appropriate WARN for the overlow) is trivial and such a rare case (as it is a programming error) that it should only be handled in the slow path.

I thought the entire point here that we don't have request half-committed because the final request ringcmds didn't fit in. And that does require that we reserve a bit of space for that postamble.

Quoted 6 lines

I guess if it's too much (atm it's super-pessimistic due to ilk) we can make per-platform reservation limits to be really minimal.

Maybe we could go towards a rollback model longterm of rewingind the ringbuffer. But if there's no clear need I'd like to avoid that complexity.

Quoted 7 lines

Even if you didn't like the rollback model which helps handling the partial state from context switches and what not, if you run out of ringspace you can set the GPU as wedged. Issuing a request that fills the entire ringbuffer is a programming bug that needs to be caught very early in development.
-Chris

I'm still confused by what you are saying in the above referenced email. Part of it is about the sanity checks failing to handle the wrapping case correctly which has been fixed in the base reserve space patch (patch 2 in the series). The rest is either saying that you think we are potentially wrappping too early and wasting a few bytes of the ring buffer or that something is actually broken?

Point 2: 100 bytes of reserve, 160 bytes of execbuf and 200 bytes remaining. You seem to think this will fail somehow? Why? The wait_for_space(160) in the execbuf code will cause a wrap because the the 100 bytes for the add_request reservation is added on and the wait is actually being done for 260 bytes. So yes, we wrap earlier than would otherwise have been necessary but that is the only way to absolutely guarantee that the add_request() call cannot fail when trying to do the wrap itself.

As Chris says, if the driver is attempting to create a single request that fills the entire ringbuffer then that is a bug that should be caught as soon as possible. Even with a Guc, the ring buffer is not small compared to the size of requests the driver currently produces. Part of the scheduler work is to limit the number of batch buffers that a given application/context can have outstanding in the ring buffer at any given time in order to prevent starvation of the rest of the system by one badly behaved app. Thus completely filling a large ring buffer becomes impossible anyway - the application will be blocked before it gets that far.

Note that with the removal of the OLR, all requests now have a definite start and a definite end. Thus the scheme could be extended to provide rollback of the ring buffer. Each new request takes a note of the ring pointers at creation time. If the request is cancelled it can reset the pointers to where they were before. Thus all half submitted work is discarded. That is a much bigger semantic change however, so I would really like to get the bare minimum anti-OLR patch set in first before trying to do fancy extra features.

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#95 lore raw

Re: [PATCH 48/55] drm/i915: Add *_ring_begin() to request allocation

Quoted 6 lines · John Harrison

I'm still confused by what you are saying in the above referenced email. Part of it is about the sanity checks failing to handle the wrapping case correctly which has been fixed in the base reserve space patch (patch 2 in the series). The rest is either saying that you think we are potentially wrappping too early and wasting a few bytes of the ring buffer or that something is actually broken?

Yeah I didn't realize that this change was meant to fix the ring->reserved_tail check since I didn't make that connection. It is correct with that change, but the problem I see is that the correctness of that debug aid isn't assured locally: No we both need that check _and_ the correct handling of the reservation tracking at wrap-around. If the check just handles wrapping it'll robustly stay in working shape even when the wrapping behaviour changes.

Quoted 7 lines

Point 2: 100 bytes of reserve, 160 bytes of execbuf and 200 bytes remaining. You seem to think this will fail somehow? Why? The wait_for_space(160) in the execbuf code will cause a wrap because the the 100 bytes for the add_request reservation is added on and the wait is actually being done for 260 bytes. So yes, we wrap earlier than would otherwise have been necessary but that is the only way to absolutely guarantee that the add_request() call cannot fail when trying to do the wrap itself.

There's no problem except that it's wasteful. And I tried to explain that no unconditionally force-wrapping for the entire reservation is actually not needed, since the additional space needed to account for the eventual wrapping is bounded by a factor of 2. It's much less in practice since we split up the final request bits into multiple smaller intel_ring_begin. And if feels a bit wasteful to throw that space away (and make the gpu eat through MI_NOP) just because it makes caring for the worst-case harder. And with GuC the 160 dwords is actually a fairly substantial part of the ring.

Even more so when we completely switch to a transaction model for request, where we only need to wrap for individual commands and hence could place intel_ring_being per-cmd (which is mostly what we do already anyway).

Quoted 9 lines

As Chris says, if the driver is attempting to create a single request that fills the entire ringbuffer then that is a bug that should be caught as soon as possible. Even with a Guc, the ring buffer is not small compared to the size of requests the driver currently produces. Part of the scheduler work is to limit the number of batch buffers that a given application/context can have outstanding in the ring buffer at any given time in order to prevent starvation of the rest of the system by one badly behaved app. Thus completely filling a large ring buffer becomes impossible anyway - the application will be blocked before it gets that far.

My proposal for this reservation wrapping business would have been:
- Increase the reservation by 31 dwords (to account for the worst-case wrap in pc_render_add_request).
- Rework the reservation overflow WARN_ON in reserve_space_end to work correctly even when wrapping while the reservation has been in use.
- Move the addition of reserved_space below the point where we wrap the ring and only check against total free space, neglecting wrapping.
- Remove all other complications you've added.

Result is no forced wrapping for reservation and a debug check which should even survive random changes by monkeys since the logic for that check is fully contained within reserve_space_end. And for the check we should be able to reuse __intel_free_space.

If I'm reading things correctly this shouldn't have any effect outside of patch 2 and shouldn't cause any conflicts.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#96 lore raw

Re: [PATCH 48/55] drm/i915: Add *_ring_begin() to request allocation

Quoted 56 lines · Daniel Vetter
Quoted 6 lines · John Harrison

I'm still confused by what you are saying in the above referenced email. Part of it is about the sanity checks failing to handle the wrapping case correctly which has been fixed in the base reserve space patch (patch 2 in the series). The rest is either saying that you think we are potentially wrappping too early and wasting a few bytes of the ring buffer or that something is actually broken?

Yeah I didn't realize that this change was meant to fix the ring->reserved_tail check since I didn't make that connection. It is correct with that change, but the problem I see is that the correctness of that debug aid isn't assured locally: No we both need that check _and_ the correct handling of the reservation tracking at wrap-around. If the check just handles wrapping it'll robustly stay in working shape even when the wrapping behaviour changes.

Quoted 7 lines

Point 2: 100 bytes of reserve, 160 bytes of execbuf and 200 bytes remaining. You seem to think this will fail somehow? Why? The wait_for_space(160) in the execbuf code will cause a wrap because the the 100 bytes for the add_request reservation is added on and the wait is actually being done for 260 bytes. So yes, we wrap earlier than would otherwise have been necessary but that is the only way to absolutely guarantee that the add_request() call cannot fail when trying to do the wrap itself.

There's no problem except that it's wasteful. And I tried to explain that no unconditionally force-wrapping for the entire reservation is actually not needed, since the additional space needed to account for the eventual wrapping is bounded by a factor of 2. It's much less in practice since we split up the final request bits into multiple smaller intel_ring_begin. And if feels a bit wasteful to throw that space away (and make the gpu eat through MI_NOP) just because it makes caring for the worst-case harder. And with GuC the 160 dwords is actually a fairly substantial part of the ring.

Even more so when we completely switch to a transaction model for request, where we only need to wrap for individual commands and hence could place intel_ring_being per-cmd (which is mostly what we do already anyway).

Quoted 9 lines

As Chris says, if the driver is attempting to create a single request that fills the entire ringbuffer then that is a bug that should be caught as soon as possible. Even with a Guc, the ring buffer is not small compared to the size of requests the driver currently produces. Part of the scheduler work is to limit the number of batch buffers that a given application/context can have outstanding in the ring buffer at any given time in order to prevent starvation of the rest of the system by one badly behaved app. Thus completely filling a large ring buffer becomes impossible anyway - the application will be blocked before it gets that far.

My proposal for this reservation wrapping business would have been:
- Increase the reservation by 31 dwords (to account for the worst-case wrap in pc_render_add_request).
- Rework the reservation overflow WARN_ON in reserve_space_end to work correctly even when wrapping while the reservation has been in use.
- Move the addition of reserved_space below the point where we wrap the ring and only check against total free space, neglecting wrapping.
- Remove all other complications you've added.

Quoted 8 lines

Result is no forced wrapping for reservation and a debug check which should even survive random changes by monkeys since the logic for that check is fully contained within reserve_space_end. And for the check we should be able to reuse __intel_free_space.

If I'm reading things correctly this shouldn't have any effect outside of patch 2 and shouldn't cause any conflicts.
-Daniel

See new patch #2...

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#97 lore raw

PATCH 49/55 drm/i915: Remove the now obsolete intel_ring_get_request()

In reply to [email protected]

From: John Harrison <[email protected]>

Much of the driver has now been converted to passing requests around instead of rings/ringbufs/contexts. Thus the function for retreiving the request from a ring (i.e. the OLR) is no longer used and can be removed.

For: VIZ-5115

---
 drivers/gpu/drm/i915/intel_ringbuffer.h |    7 -------
 1 file changed, 7 deletions(-)
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -7
index f4633ca..9b1dab4 100644
@@ -441,13 +441,6 @@ static inline u32 intel_ring_get_tail(struct intel_ringbuffer *ringbuf)
 	return ringbuf->tail;
 }
 
-static inline struct drm_i915_gem_request *
-intel_ring_get_request(struct intel_engine_cs *ring)
-{
-	BUG_ON(ring->outstanding_lazy_request == NULL);
-	return ring->outstanding_lazy_request;
-}
-
 #define MIN_SPACE_FOR_ADD_REQUEST	128
 
 int intel_ring_reserve_space(struct drm_i915_gem_request *request);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#98 lore raw

PATCH 50/55 drm/i915: Remove the now obsolete 'outstanding_lazy_request'

In reply to [email protected]

From: John Harrison <[email protected]>

The outstanding_lazy_request is no longer used anywhere in the driver. Everything that was looking at it now has a request explicitly passed in from on high. Everything that was relying upon it behind the scenes is now explicitly creating/passing/submitting its own private request. Thus the OLR can be removed.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem.c            |   16 ++--------------
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |    4 +---
 drivers/gpu/drm/i915/intel_lrc.c           |    1 -
 drivers/gpu/drm/i915/intel_ringbuffer.c    |    8 --------
 drivers/gpu/drm/i915/intel_ringbuffer.h    |    4 ----
 5 files changed, 3 insertions(+), 30 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +2 -14
index 1261792..5aa0ad0 100644
@@ -1157,9 +1157,6 @@ i915_gem_check_olr(struct drm_i915_gem_request *req)
 {
 	WARN_ON(!mutex_is_locked(&req->ring->dev->struct_mutex));
 
-	if (req == req->ring->outstanding_lazy_request)
-		i915_add_request(req);
-
 	return 0;
 }
 
@@ -2488,8 +2485,6 @@ void __i915_add_request(struct drm_i915_gem_request *request,
 	dev_priv = ring->dev->dev_private;
 	ringbuf = request->ringbuf;
 
-	WARN_ON(request != ring->outstanding_lazy_request);
-
 	/*
 	 * To ensure that this call will not fail, space for its emissions
 	 * should already have been reserved in the ring buffer. Let the ring
@@ -2558,7 +2553,6 @@ void __i915_add_request(struct drm_i915_gem_request *request,
 	}
 
 	trace_i915_gem_request_add(request);
-	ring->outstanding_lazy_request = NULL;
 
 	i915_queue_hangcheck(ring->dev);
 
@@ -2647,8 +2641,7 @@ int i915_gem_request_alloc(struct intel_engine_cs *ring,
 	if (!req_out)
 		return -EINVAL;
 
-	if ((*req_out = ring->outstanding_lazy_request) != NULL)
-		return 0;
+	*req_out = NULL;
 
 	req = kmem_cache_zalloc(dev_priv->requests, GFP_KERNEL);
 	if (req == NULL)
@@ -2695,7 +2688,7 @@ int i915_gem_request_alloc(struct intel_engine_cs *ring,
 		return ret;
 	}
 
-	*req_out = ring->outstanding_lazy_request = req;
+	*req_out = req;
 	return 0;
 
 err:
@@ -2792,9 +2785,6 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,
 
 		i915_gem_request_retire(request);
 	}
-
-	/* This may not have been flushed before the reset, so clean it now */
-	i915_gem_request_assign(&ring->outstanding_lazy_request, NULL);
 }
 
 void i915_gem_restore_fences(struct drm_device *dev)
@@ -3350,8 +3340,6 @@ int i915_gpu_idle(struct drm_device *dev)
 			i915_add_request_no_flush(req);
 		}
 
-		WARN_ON(ring->outstanding_lazy_request);
-
 		ret = intel_ring_idle(ring);
 		if (ret)
 			return ret;
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -3
index 805d288..e868ac1 100644
@@ -1647,10 +1647,8 @@ err:
 	 * must be freed again. If it was submitted then it is being tracked
 	 * on the active request list and no clean up is required here.
 	 */
-	if (ret && params->request) {
+	if (ret && params->request)
 		i915_gem_request_cancel(params->request);
-		ring->outstanding_lazy_request = NULL;
-	}
 
 	mutex_unlock(&dev->struct_mutex);
 
drivers/gpu/drm/i915/intel_lrc.c +0 -1
index e164ac0..0421480 100644
@@ -1405,7 +1405,6 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *ring)
 
 	intel_logical_ring_stop(ring);
 	WARN_ON((I915_READ_MODE(ring) & MODE_IDLE) == 0);
-	i915_gem_request_assign(&ring->outstanding_lazy_request, NULL);
 
 	if (ring->cleanup)
 		ring->cleanup(ring);
drivers/gpu/drm/i915/intel_ringbuffer.c +0 -8
index 0ba5787..5858ade 100644
@@ -2091,7 +2091,6 @@ void intel_cleanup_ring_buffer(struct intel_engine_cs *ring)
 
 	intel_unpin_ringbuffer_obj(ringbuf);
 	intel_destroy_ringbuffer_obj(ringbuf);
-	i915_gem_request_assign(&ring->outstanding_lazy_request, NULL);
 
 	if (ring->cleanup)
 		ring->cleanup(ring);
@@ -2166,11 +2165,6 @@ int intel_ring_idle(struct intel_engine_cs *ring)
 {
 	struct drm_i915_gem_request *req;
 
-	/* We need to add any requests required to flush the objects and ring */
-	WARN_ON(ring->outstanding_lazy_request);
-	if (ring->outstanding_lazy_request)
-		i915_add_request(ring->outstanding_lazy_request);
-
 	/* Wait upon the last request to be completed */
 	if (list_empty(&ring->request_list))
 		return 0;
@@ -2326,8 +2320,6 @@ void intel_ring_init_seqno(struct intel_engine_cs *ring, u32 seqno)
 	struct drm_device *dev = ring->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
-	BUG_ON(ring->outstanding_lazy_request);
-
 	if (INTEL_INFO(dev)->gen == 6 || INTEL_INFO(dev)->gen == 7) {
 		I915_WRITE(RING_SYNC_0(ring->mmio_base), 0);
 		I915_WRITE(RING_SYNC_1(ring->mmio_base), 0);
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -4
index 9b1dab4..4f573b1 100644
@@ -269,10 +269,6 @@ struct  intel_engine_cs {
 	 */
 	struct list_head request_list;
 
-	/**
-	 * Do we have some not yet emitted requests outstanding?
-	 */
-	struct drm_i915_gem_request *outstanding_lazy_request;
 	bool gpu_caches_dirty;
 
 	wait_queue_head_t irq_queue;
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#99 lore raw

PATCH 51/55 drm/i915: Move the request/file and request/pid association to creation time

In reply to [email protected]

From: John Harrison <[email protected]>

In _i915_add_request(), the request is associated with a userland client. Specifically it is linked to the 'file' structure and the current user process is recorded. One problem here is that the current user process is not necessarily the same as when the request was submitted to the driver. This is especially true when the GPU scheduler arrives and decouples driver submission from hardware submission. Note also that it is only in the case where the add request comes from an execbuff call that there is a client to associate. Any other add request call is kernel only so does not need to do it.

This patch moves the client association into a separate function. This is then called from the execbuffer code path itself at a sensible time. It also removes the now redundant 'file' pointer from the add request parameter list.

An extra cleanup of the client association is also added to the request clean up code for the eventuality where the request is killed after association but before being submitted (e.g. due to out of memory error somewhere). Once the submission has happened, the request is on the request list and the regular request list removal will clear the association. Note that this still needs to happen at this point in time because the request might be kept floating around much longer (due to someone holding a reference count) and the client should not be worrying about this request after it has been retired.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h            |    7 ++--
 drivers/gpu/drm/i915/i915_gem.c            |   56 ++++++++++++++++++++--------
 drivers/gpu/drm/i915/i915_gem_execbuffer.c |    6 ++-
 3 files changed, 49 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -3
index f9b6517..18bfc84 100644
@@ -2199,6 +2199,8 @@ int i915_gem_request_alloc(struct intel_engine_cs *ring,
 			   struct drm_i915_gem_request **req_out);
 void i915_gem_request_cancel(struct drm_i915_gem_request *req);
 void i915_gem_request_free(struct kref *req_ref);
+int i915_gem_request_add_to_client(struct drm_i915_gem_request *req,
+				   struct drm_file *file);
 
 static inline uint32_t
 i915_gem_request_get_seqno(struct drm_i915_gem_request *req)
@@ -2864,13 +2866,12 @@ void i915_gem_cleanup_ringbuffer(struct drm_device *dev);
 int __must_check i915_gpu_idle(struct drm_device *dev);
 int __must_check i915_gem_suspend(struct drm_device *dev);
 void __i915_add_request(struct drm_i915_gem_request *req,
-			struct drm_file *file,
 			struct drm_i915_gem_object *batch_obj,
 			bool flush_caches);
 #define i915_add_request(req) \
-	__i915_add_request(req, NULL, NULL, true)
+	__i915_add_request(req, NULL, true)
 #define i915_add_request_no_flush(req) \
-	__i915_add_request(req, NULL, NULL, false)
+	__i915_add_request(req, NULL, false)
 int __i915_wait_request(struct drm_i915_gem_request *req,
 			unsigned reset_counter,
 			bool interruptible,
drivers/gpu/drm/i915/i915_gem.c +40 -16

98 lines not on this page · raw message

drivers/gpu/drm/i915/i915_gem_execbuffer.c +5 -1
index e868ac1..52139c6 100644
@@ -1058,7 +1058,7 @@ i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params)
 	params->ring->gpu_caches_dirty = true;
 
 	/* Add a breadcrumb for the completion of the batch buffer */
-	__i915_add_request(params->request, params->file, params->batch_obj, true);
+	__i915_add_request(params->request, params->batch_obj, true);
 }
 
 static int
@@ -1612,6 +1612,10 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
 	if (ret)
 		goto err_batch_unpin;
 
+	ret = i915_gem_request_add_to_client(params->request, file);
+	if (ret)
+		goto err_batch_unpin;
+
 	/*
 	 * Save assorted stuff away to pass through to *_submission().
 	 * NB: This data should be 'persistent' and not local as it will
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 51/55
#100 lore raw

Re: [PATCH 51/55] drm/i915: Move the request/file and request/pid association to creation time

Quoted 185 lines · On 29/05/2015 17:44, [email protected] wrote:

From: John Harrison <[email protected]>

In _i915_add_request(), the request is associated with a userland client. Specifically it is linked to the 'file' structure and the current user process is recorded. One problem here is that the current user process is not necessarily the same as when the request was submitted to the driver. This is especially true when the GPU scheduler arrives and decouples driver submission from hardware submission. Note also that it is only in the case where the add request comes from an execbuff call that there is a client to associate. Any other add request call is kernel only so does not need to do it.

This patch moves the client association into a separate function. This is then called from the execbuffer code path itself at a sensible time. It also removes the now redundant 'file' pointer from the add request parameter list.

An extra cleanup of the client association is also added to the request clean up code for the eventuality where the request is killed after association but before being submitted (e.g. due to out of memory error somewhere). Once the submission has happened, the request is on the request list and the regular request list removal will clear the association. Note that this still needs to happen at this point in time because the request might be kept floating around much longer (due to someone holding a reference count) and the client should not be worrying about this request after it has been retired.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h            |    7 ++--
  drivers/gpu/drm/i915/i915_gem.c            |   56 ++++++++++++++++++++--------
  drivers/gpu/drm/i915/i915_gem_execbuffer.c |    6 ++-
  3 files changed, 49 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +4 -3
index f9b6517..18bfc84 100644
@@ -2199,6 +2199,8 @@ int i915_gem_request_alloc(struct intel_engine_cs *ring,
  			   struct drm_i915_gem_request **req_out);
  void i915_gem_request_cancel(struct drm_i915_gem_request *req);
  void i915_gem_request_free(struct kref *req_ref);
+int i915_gem_request_add_to_client(struct drm_i915_gem_request *req,
+				   struct drm_file *file);
 
  static inline uint32_t
  i915_gem_request_get_seqno(struct drm_i915_gem_request *req)
@@ -2864,13 +2866,12 @@ void i915_gem_cleanup_ringbuffer(struct drm_device *dev);
  int __must_check i915_gpu_idle(struct drm_device *dev);
  int __must_check i915_gem_suspend(struct drm_device *dev);
  void __i915_add_request(struct drm_i915_gem_request *req,
-			struct drm_file *file,
  			struct drm_i915_gem_object *batch_obj,
  			bool flush_caches);
  #define i915_add_request(req) \
-	__i915_add_request(req, NULL, NULL, true)
+	__i915_add_request(req, NULL, true)
  #define i915_add_request_no_flush(req) \
-	__i915_add_request(req, NULL, NULL, false)
+	__i915_add_request(req, NULL, false)
  int __i915_wait_request(struct drm_i915_gem_request *req,
  			unsigned reset_counter,
  			bool interruptible,
drivers/gpu/drm/i915/i915_gem.c +40 -16
index 5aa0ad0..b8fe931 100644
@@ -1331,6 +1331,33 @@ out:
  	return ret;
  }
 
+int i915_gem_request_add_to_client(struct drm_i915_gem_request *req,
+				   struct drm_file *file)
+{
+	struct drm_i915_private *dev_private;
+	struct drm_i915_file_private *file_priv;
+
+	WARN_ON(!req || !file || req->file_priv);
+
+	if (!req || !file)
+		return -EINVAL;
+
+	if (req->file_priv)
+		return -EINVAL;
+
+	dev_private = req->ring->dev->dev_private;
+	file_priv = file->driver_priv;
+
+	spin_lock(&file_priv->mm.lock);
+	req->file_priv = file_priv;
+	list_add_tail(&req->client_list, &file_priv->mm.request_list);
+	spin_unlock(&file_priv->mm.lock);
+
+	req->pid = get_pid(task_pid(current));
+
+	return 0;
+}
+
  static inline void
  i915_gem_request_remove_from_client(struct drm_i915_gem_request *request)
  {
@@ -1343,6 +1370,9 @@ i915_gem_request_remove_from_client(struct drm_i915_gem_request *request)
  	list_del(&request->client_list);
  	request->file_priv = NULL;
  	spin_unlock(&file_priv->mm.lock);
+
+	put_pid(request->pid);
+	request->pid = NULL;
  }
 
  static void i915_gem_request_retire(struct drm_i915_gem_request *request)
@@ -1362,8 +1392,6 @@ static void i915_gem_request_retire(struct drm_i915_gem_request *request)
  	list_del_init(&request->list);
  	i915_gem_request_remove_from_client(request);
 
-	put_pid(request->pid);
-
  	i915_gem_request_unreference(request);
  }
 
@@ -2468,7 +2496,6 @@ i915_gem_get_seqno(struct drm_device *dev, u32 *seqno)
   * going to happen on the hardware. This would be a Bad Thing(tm).
   */
  void __i915_add_request(struct drm_i915_gem_request *request,
-			struct drm_file *file,
  			struct drm_i915_gem_object *obj,
  			bool flush_caches)
  {
@@ -2538,19 +2565,6 @@ void __i915_add_request(struct drm_i915_gem_request *request,
 
  	request->emitted_jiffies = jiffies;
  	list_add_tail(&request->list, &ring->request_list);
-	request->file_priv = NULL;
-
-	if (file) {
-		struct drm_i915_file_private *file_priv = file->driver_priv;
-
-		spin_lock(&file_priv->mm.lock);
-		request->file_priv = file_priv;
-		list_add_tail(&request->client_list,
-			      &file_priv->mm.request_list);
-		spin_unlock(&file_priv->mm.lock);
-
-		request->pid = get_pid(task_pid(current));
-	}
 
  	trace_i915_gem_request_add(request);
 
@@ -2616,6 +2630,9 @@ void i915_gem_request_free(struct kref *req_ref)
  						 typeof(*req), ref);
  	struct intel_context *ctx = req->ctx;
 
+	if (req->file_priv)
+		i915_gem_request_remove_from_client(req);
+
  	if (ctx) {
  		if (i915.enable_execlists) {
  			struct intel_engine_cs *ring = req->ring;
@@ -4320,6 +4337,13 @@ i915_gem_ring_throttle(struct drm_device *dev, struct drm_file *file)
  		if (time_after_eq(request->emitted_jiffies, recent_enough))
  			break;
 
+		/*
+		 * Note that the request might not have been submitted yet.
+		 * In which case emitted_jiffies will be zero.
+		 */
+		if (!request->emitted_jiffies)
+			continue;
+
  		target = request;
  	}
  	reset_counter = atomic_read(&dev_priv->gpu_error.reset_counter);
drivers/gpu/drm/i915/i915_gem_execbuffer.c +1 -1
index e868ac1..52139c6 100644
@@ -1058,7 +1058,7 @@ i915_gem_execbuffer_retire_commands(struct i915_execbuffer_params *params)
  	params->ring->gpu_caches_dirty = true;
 
  	/* Add a breadcrumb for the completion of the batch buffer */
-	__i915_add_request(params->request, params->file, params->batch_obj, true);
+	__i915_add_request(params->request, params->batch_obj, true);
  }
 
  static int

drivers/gpu/drm/i915/i915_gem_execbuffer.c i915_gem_do_execbuffer(struct drm_device *dev, void *data, · line 1621

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem_execbuffer.c +4 -0
@@ -1612,6 +1612,10 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
  	if (ret)
  		goto err_batch_unpin;
 
+	ret = i915_gem_request_add_to_client(params->request, file);
+	if (ret)
+		goto err_batch_unpin;
+
  	/*
  	 * Save assorted stuff away to pass through to *_submission().
  	 * NB: This data should be 'persistent' and not local as it will

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#101 lore raw

PATCH 52/55 drm/i915: Remove 'faked' request from LRC submission

In reply to [email protected]

From: John Harrison <[email protected]>

The LRC submission code requires a request for tracking purposes. It does not actually require that request to 'complete' it simply uses it for keeping hold of reference counts on contexts and such like.

Previously, the fall back path of polling for space in the ring would start by submitting any outstanding work that was sat in the buffer. This submission was not done as part of the request that that work was owned by because that would lead to complications with the request being submitted twice. Instead, a null request structure was passed in to the submit call and a fake one was created.

That fall back path has long since been obsoleted and has now been removed. Thus there is never any need to fake up a request structure. This patch removes that code. A couple of sanity check warnings are added as well, just in case.

For: VIZ-5115

---
 drivers/gpu/drm/i915/intel_lrc.c |   23 +++++------------------
 1 file changed, 5 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +5 -18
index 0421480..323a4a1 100644
@@ -549,29 +549,16 @@ static int execlists_context_queue(struct intel_engine_cs *ring,
 				   struct drm_i915_gem_request *request)
 {
 	struct drm_i915_gem_request *cursor;
-	struct drm_i915_private *dev_priv = ring->dev->dev_private;
 	int num_elements = 0;
 
 	if (to != ring->default_context)
 		intel_lr_context_pin(ring, to);
 
-	if (!request) {
-		/*
-		 * If there isn't a request associated with this submission,
-		 * create one as a temporary holder.
-		 */
-		request = kzalloc(sizeof(*request), GFP_KERNEL);
-		if (request == NULL)
-			return -ENOMEM;
-		request->ring = ring;
-		request->ctx = to;
-		kref_init(&request->ref);
-		request->uniq = dev_priv->request_uniq++;
-		i915_gem_context_reference(request->ctx);
-	} else {
-		i915_gem_request_reference(request);
-		WARN_ON(to != request->ctx);
-	}
+	WARN_ON(!request);
+	WARN_ON(to != request->ctx);
+
+	i915_gem_request_reference(request);
+
 	request->tail = tail;
 
 	spin_lock_irq(&ring->execlist_lock);
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#102 lore raw

PATCH 53/55 drm/i915: Update a bunch of LRC functions to take requests

In reply to [email protected]

From: John Harrison <[email protected]>

A bunch of the low level LRC functions were passing around ringbuf and ctx pairs. In a few cases, they took the r/c pair and a request as well. This is all quite messy and unnecesary. The context_queue() call is especially bad since the fake request code got removed - it takes a request and three extra things that must be extracted from the request and then it checks them against what it finds in the request. Removing all the derivable data makes the code much simpler all round.

This patch updates those functions to just take the request structure.

Note that logical_ring_wait_for_space now takes a request structure but already had a local request pointer that it uses to scan for something to wait on. To avoid confusion the local variable has been renamed 'target' (it is searching for a target request to do something with) and the parameter has been called req (to guarantee anything accidentally missed gets a compiler error).

v2: Updated commit message re wait_for_space (Tomas Elf review comment).

For: VIZ-5115

---
 drivers/gpu/drm/i915/intel_lrc.c |   66 +++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 37 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +29 -37
index 323a4a1..4ce809d 100644
@@ -543,23 +543,18 @@ void intel_lrc_irq_handler(struct intel_engine_cs *ring)
 		   ((u32)ring->next_context_status_buffer & 0x07) << 8);
 }
 
-static int execlists_context_queue(struct intel_engine_cs *ring,
-				   struct intel_context *to,
-				   u32 tail,
-				   struct drm_i915_gem_request *request)
+static int execlists_context_queue(struct drm_i915_gem_request *request)
 {
+	struct intel_engine_cs *ring = request->ring;
 	struct drm_i915_gem_request *cursor;
 	int num_elements = 0;
 
-	if (to != ring->default_context)
-		intel_lr_context_pin(ring, to);
-
-	WARN_ON(!request);
-	WARN_ON(to != request->ctx);
+	if (request->ctx != ring->default_context)
+		intel_lr_context_pin(ring, request->ctx);
 
 	i915_gem_request_reference(request);
 
-	request->tail = tail;
+	request->tail = request->ringbuf->tail;
 
 	spin_lock_irq(&ring->execlist_lock);
 
@@ -574,7 +569,7 @@ static int execlists_context_queue(struct intel_engine_cs *ring,
 					   struct drm_i915_gem_request,
 					   execlist_link);
 
-		if (to == tail_req->ctx) {
+		if (request->ctx == tail_req->ctx) {
 			WARN(tail_req->elsp_submitted != 0,
 				"More than 2 already-submitted reqs queued\n");
 			list_del(&tail_req->execlist_link);
@@ -658,12 +653,12 @@ int intel_logical_ring_alloc_request_extras(struct drm_i915_gem_request *request
 	return 0;
 }
 
-static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,
-				       struct intel_context *ctx,
+static int logical_ring_wait_for_space(struct drm_i915_gem_request *req,
 				       int bytes)
 {
-	struct intel_engine_cs *ring = ringbuf->ring;
-	struct drm_i915_gem_request *request;
+	struct intel_ringbuffer *ringbuf = req->ringbuf;
+	struct intel_engine_cs *ring = req->ring;
+	struct drm_i915_gem_request *target;
 	unsigned space;
 	int ret;
 
@@ -673,26 +668,26 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,
 	if (intel_ring_space(ringbuf) >= bytes)
 		return 0;
 
-	list_for_each_entry(request, &ring->request_list, list) {
+	list_for_each_entry(target, &ring->request_list, list) {
 		/*
 		 * The request queue is per-engine, so can contain requests
 		 * from multiple ringbuffers. Here, we must ignore any that
 		 * aren't from the ringbuffer we're considering.
 		 */
-		if (request->ringbuf != ringbuf)
+		if (target->ringbuf != ringbuf)
 			continue;
 
 		/* Would completion of this request free enough space? */
-		space = __intel_ring_space(request->postfix, ringbuf->tail,
+		space = __intel_ring_space(target->postfix, ringbuf->tail,
 					   ringbuf->size);
 		if (space >= bytes)
 			break;
 	}
 
-	if (WARN_ON(&request->list == &ring->request_list))
+	if (WARN_ON(&target->list == &ring->request_list))
 		return -ENOSPC;
 
-	ret = i915_wait_request(request);
+	ret = i915_wait_request(target);
 	if (ret)
 		return ret;
 
@@ -702,7 +697,7 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,
 
 /*
  * intel_logical_ring_advance_and_submit() - advance the tail and submit the workload
- * @ringbuf: Logical Ringbuffer to advance.
+ * @request: Request to advance the logical ringbuffer of.
  *
  * The tail is updated in our logical ringbuffer struct, not in the actual context. What
  * really happens during submission is that the context and current tail will be placed
@@ -710,23 +705,21 @@ static int logical_ring_wait_for_space(struct intel_ringbuffer *ringbuf,
  * point, the tail *inside* the context is updated and the ELSP written to.
  */
 static void
-intel_logical_ring_advance_and_submit(struct intel_ringbuffer *ringbuf,
-				      struct intel_context *ctx,
-				      struct drm_i915_gem_request *request)
+intel_logical_ring_advance_and_submit(struct drm_i915_gem_request *request)
 {
-	struct intel_engine_cs *ring = ringbuf->ring;
+	struct intel_engine_cs *ring = request->ring;
 
-	intel_logical_ring_advance(ringbuf);
+	intel_logical_ring_advance(request->ringbuf);
 
 	if (intel_ring_stopped(ring))
 		return;
 
-	execlists_context_queue(ring, ctx, ringbuf->tail, request);
+	execlists_context_queue(request);
 }
 
-static int logical_ring_wrap_buffer(struct intel_ringbuffer *ringbuf,
-				    struct intel_context *ctx)
+static int logical_ring_wrap_buffer(struct drm_i915_gem_request *req)
 {
+	struct intel_ringbuffer *ringbuf = req->ringbuf;
 	uint32_t __iomem *virt;
 	int rem = ringbuf->size - ringbuf->tail;
 
@@ -734,7 +727,7 @@ static int logical_ring_wrap_buffer(struct intel_ringbuffer *ringbuf,
 	WARN_ON(ringbuf->reserved_in_use);
 
 	if (ringbuf->space < rem) {
-		int ret = logical_ring_wait_for_space(ringbuf, ctx, rem);
+		int ret = logical_ring_wait_for_space(req, rem);
 
 		if (ret)
 			return ret;
@@ -751,22 +744,22 @@ static int logical_ring_wrap_buffer(struct intel_ringbuffer *ringbuf,
 	return 0;
 }
 
-static int logical_ring_prepare(struct intel_ringbuffer *ringbuf,
-				struct intel_context *ctx, int bytes)
+static int logical_ring_prepare(struct drm_i915_gem_request *req, int bytes)
 {
+	struct intel_ringbuffer *ringbuf = req->ringbuf;
 	int ret;
 
 	if (!ringbuf->reserved_in_use)
 		bytes += ringbuf->reserved_size;
 
 	if (unlikely(ringbuf->tail + bytes > ringbuf->effective_size)) {
-		ret = logical_ring_wrap_buffer(ringbuf, ctx);
+		ret = logical_ring_wrap_buffer(req);
 		if (unlikely(ret))
 			return ret;
 	}
 
 	if (unlikely(ringbuf->space < bytes)) {
-		ret = logical_ring_wait_for_space(ringbuf, ctx, bytes);
+		ret = logical_ring_wait_for_space(req, bytes);
 		if (unlikely(ret))
 			return ret;
 	}
@@ -801,8 +794,7 @@ static int intel_logical_ring_begin(struct drm_i915_gem_request *req,
 	if (ret)
 		return ret;
 
-	ret = logical_ring_prepare(req->ringbuf, req->ctx,
-				   num_dwords * sizeof(uint32_t));
+	ret = logical_ring_prepare(req, num_dwords * sizeof(uint32_t));
 	if (ret)
 		return ret;
 
@@ -1327,7 +1319,7 @@ static int gen8_emit_request(struct drm_i915_gem_request *request)
 	intel_logical_ring_emit(ringbuf, i915_gem_request_get_seqno(request));
 	intel_logical_ring_emit(ringbuf, MI_USER_INTERRUPT);
 	intel_logical_ring_emit(ringbuf, MI_NOOP);
-	intel_logical_ring_advance_and_submit(ringbuf, request->ctx, request);
+	intel_logical_ring_advance_and_submit(request);
 
 	/*
 	 * Here we add two extra NOOPs as padding to avoid
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#103 lore raw

PATCH 54/55 drm/i915: Remove the now obsolete 'i915_gem_check_olr()'

In reply to [email protected]

From: John Harrison <[email protected]>

As there is no OLR to check, the check_olr() function is now a no-op and can be removed.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_drv.h      |    1 -
 drivers/gpu/drm/i915/i915_gem.c      |   34 +---------------------------------
 drivers/gpu/drm/i915/intel_display.c |    6 ------
 3 files changed, 1 insertion(+), 40 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index 18bfc84..cb5bb4a 100644
@@ -2825,7 +2825,6 @@ bool i915_gem_retire_requests(struct drm_device *dev);
 void i915_gem_retire_requests_ring(struct intel_engine_cs *ring);
 int __must_check i915_gem_check_wedge(struct i915_gpu_error *error,
 				      bool interruptible);
-int __must_check i915_gem_check_olr(struct drm_i915_gem_request *req);
 
 static inline bool i915_reset_in_progress(struct i915_gpu_error *error)
 {
drivers/gpu/drm/i915/i915_gem.c +1 -33
index b8fe931..f825942 100644
@@ -1149,17 +1149,6 @@ i915_gem_check_wedge(struct i915_gpu_error *error,
 	return 0;
 }
 
-/*
- * Compare arbitrary request against outstanding lazy request. Emit on match.
- */
-int
-i915_gem_check_olr(struct drm_i915_gem_request *req)
-{
-	WARN_ON(!mutex_is_locked(&req->ring->dev->struct_mutex));
-
-	return 0;
-}
-
 static void fake_irq(unsigned long data)
 {
 	wake_up_process((struct task_struct *)data);
@@ -1440,10 +1429,6 @@ i915_wait_request(struct drm_i915_gem_request *req)
 	if (ret)
 		return ret;
 
-	ret = i915_gem_check_olr(req);
-	if (ret)
-		return ret;
-
 	ret = __i915_wait_request(req,
 				  atomic_read(&dev_priv->gpu_error.reset_counter),
 				  interruptible, NULL, NULL);
@@ -1543,10 +1528,6 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj,
 		if (req == NULL)
 			return 0;
 
-		ret = i915_gem_check_olr(req);
-		if (ret)
-			goto err;
-
 		requests[n++] = i915_gem_request_reference(req);
 	} else {
 		for (i = 0; i < I915_NUM_RINGS; i++) {
@@ -1556,10 +1537,6 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj,
 			if (req == NULL)
 				continue;
 
-			ret = i915_gem_check_olr(req);
-			if (ret)
-				goto err;
-
 			requests[n++] = i915_gem_request_reference(req);
 		}
 	}
@@ -1570,7 +1547,6 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj,
 					  NULL, rps);
 	mutex_lock(&dev->struct_mutex);
 
-err:
 	for (i = 0; i < n; i++) {
 		if (ret == 0)
 			i915_gem_object_retire_request(obj, requests[i]);
@@ -2987,7 +2963,7 @@ i915_gem_idle_work_handler(struct work_struct *work)
 static int
 i915_gem_object_flush_active(struct drm_i915_gem_object *obj)
 {
-	int ret, i;
+	int i;
 
 	if (!obj->active)
 		return 0;
@@ -3002,10 +2978,6 @@ i915_gem_object_flush_active(struct drm_i915_gem_object *obj)
 		if (list_empty(&req->list))
 			goto retire;
 
-		ret = i915_gem_check_olr(req);
-		if (ret)
-			return ret;
-
 		if (i915_gem_request_completed(req, true)) {
 			__i915_gem_request_retire__upto(req);
 retire:
@@ -3121,10 +3093,6 @@ __i915_gem_object_sync(struct drm_i915_gem_object *obj,
 	if (i915_gem_request_completed(from_req, true))
 		return 0;
 
-	ret = i915_gem_check_olr(from_req);
-	if (ret)
-		return ret;
-
 	if (!i915_semaphore_is_enabled(obj->base.dev)) {
 		struct drm_i915_private *i915 = to_i915(obj->base.dev);
 		ret = __i915_wait_request(from_req,
drivers/gpu/drm/i915/intel_display.c +0 -6
index 91e19d0..aca2215 100644
@@ -11243,12 +11243,6 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 		i915_gem_request_assign(&work->flip_queued_req,
 					obj->last_write_req);
 	} else {
-		if (obj->last_write_req) {
-			ret = i915_gem_check_olr(obj->last_write_req);
-			if (ret)
-				goto cleanup_unpin;
-		}
-
 		if (!request) {
 			ret = i915_gem_request_alloc(ring, ring->default_context, &request);
 			if (ret)
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 54/55
#104 lore raw

Re: [PATCH 54/55] drm/i915: Remove the now obsolete 'i915_gem_check_olr()'

Quoted 127 lines · On 29/05/2015 17:44, [email protected] wrote:

From: John Harrison <[email protected]>

As there is no OLR to check, the check_olr() function is now a no-op and can be removed.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_drv.h      |    1 -
  drivers/gpu/drm/i915/i915_gem.c      |   34 +---------------------------------
  drivers/gpu/drm/i915/intel_display.c |    6 ------
  3 files changed, 1 insertion(+), 40 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +0 -1
index 18bfc84..cb5bb4a 100644
@@ -2825,7 +2825,6 @@ bool i915_gem_retire_requests(struct drm_device *dev);
  void i915_gem_retire_requests_ring(struct intel_engine_cs *ring);
  int __must_check i915_gem_check_wedge(struct i915_gpu_error *error,
  				      bool interruptible);
-int __must_check i915_gem_check_olr(struct drm_i915_gem_request *req);
 
  static inline bool i915_reset_in_progress(struct i915_gpu_error *error)
  {
drivers/gpu/drm/i915/i915_gem.c +1 -33
index b8fe931..f825942 100644
@@ -1149,17 +1149,6 @@ i915_gem_check_wedge(struct i915_gpu_error *error,
  	return 0;
  }
 
-/*
- * Compare arbitrary request against outstanding lazy request. Emit on match.
- */
-int
-i915_gem_check_olr(struct drm_i915_gem_request *req)
-{
-	WARN_ON(!mutex_is_locked(&req->ring->dev->struct_mutex));
-
-	return 0;
-}
-
  static void fake_irq(unsigned long data)
  {
  	wake_up_process((struct task_struct *)data);
@@ -1440,10 +1429,6 @@ i915_wait_request(struct drm_i915_gem_request *req)
  	if (ret)
  		return ret;
 
-	ret = i915_gem_check_olr(req);
-	if (ret)
-		return ret;
-
  	ret = __i915_wait_request(req,
  				  atomic_read(&dev_priv->gpu_error.reset_counter),
  				  interruptible, NULL, NULL);
@@ -1543,10 +1528,6 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj,
  		if (req == NULL)
  			return 0;
 
-		ret = i915_gem_check_olr(req);
-		if (ret)
-			goto err;
-
  		requests[n++] = i915_gem_request_reference(req);
  	} else {
  		for (i = 0; i < I915_NUM_RINGS; i++) {
@@ -1556,10 +1537,6 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj,
  			if (req == NULL)
  				continue;
 
-			ret = i915_gem_check_olr(req);
-			if (ret)
-				goto err;
-
  			requests[n++] = i915_gem_request_reference(req);
  		}
  	}
@@ -1570,7 +1547,6 @@ i915_gem_object_wait_rendering__nonblocking(struct drm_i915_gem_object *obj,
  					  NULL, rps);
  	mutex_lock(&dev->struct_mutex);
 
-err:
  	for (i = 0; i < n; i++) {
  		if (ret == 0)
  			i915_gem_object_retire_request(obj, requests[i]);
@@ -2987,7 +2963,7 @@ i915_gem_idle_work_handler(struct work_struct *work)
  static int
  i915_gem_object_flush_active(struct drm_i915_gem_object *obj)
  {
-	int ret, i;
+	int i;
 
  	if (!obj->active)
  		return 0;
@@ -3002,10 +2978,6 @@ i915_gem_object_flush_active(struct drm_i915_gem_object *obj)
  		if (list_empty(&req->list))
  			goto retire;
 
-		ret = i915_gem_check_olr(req);
-		if (ret)
-			return ret;
-
  		if (i915_gem_request_completed(req, true)) {
  			__i915_gem_request_retire__upto(req);
  retire:
@@ -3121,10 +3093,6 @@ __i915_gem_object_sync(struct drm_i915_gem_object *obj,
  	if (i915_gem_request_completed(from_req, true))
  		return 0;
 
-	ret = i915_gem_check_olr(from_req);
-	if (ret)
-		return ret;
-
  	if (!i915_semaphore_is_enabled(obj->base.dev)) {
  		struct drm_i915_private *i915 = to_i915(obj->base.dev);
  		ret = __i915_wait_request(from_req,
drivers/gpu/drm/i915/intel_display.c +0 -0
index 91e19d0..aca2215 100644
@@ -11243,12 +11243,6 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
  		i915_gem_request_assign(&work->flip_queued_req,
  					obj->last_write_req);

drivers/gpu/drm/i915/intel_display.c static int intel_crtc_page_flip(struct drm_crtc *crtc, · line 11248

Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +0 -6
  	} else {
-		if (obj->last_write_req) {
-			ret = i915_gem_check_olr(obj->last_write_req);
-			if (ret)
-				goto cleanup_unpin;
-		}
-
  		if (!request) {
  			ret = i915_gem_request_alloc(ring, ring->default_context, &request);
  			if (ret)

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#105 lore raw

Re: [PATCH 54/55] drm/i915: Remove the now obsolete 'i915_gem_check_olr()'

In reply to [email protected]
Quoted 4 lines · On Fri, May 29, 2015 at 05:44:15PM +0100, [email protected] wrote:

From: John Harrison <[email protected]>

As there is no OLR to check, the check_olr() function is now a no-op and can be removed.

You ignored a genuine, and trivially easy to hit, compiler warning here. -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#106 lore raw

Re: [PATCH 54/55] drm/i915: Remove the now obsolete 'i915_gem_check_olr()'

Quoted 8 lines · Chris Wilson
Quoted 4 lines · On Fri, May 29, 2015 at 05:44:15PM +0100, [email protected] wrote:

From: John Harrison <[email protected]>

As there is no OLR to check, the check_olr() function is now a no-op and can be removed.

You ignored a genuine, and trivially easy to hit, compiler warning here. -Chris

Would you to care to elaborate? I have a local tweak to the makefile to enable warnings as errors, so it definitely builds cleanly for me. Maybe there is a merge issue with other changes since the tree that patch was against?

John.

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#107 lore raw

PATCH 55/55 drm/i915: Rename the somewhat reduced i915_gem_object_flush_active()

In reply to [email protected]

From: John Harrison <[email protected]>

The i915_gem_object_flush_active() call used to do lots. Over time it has done less and less. Now all it does check the various associated requests to see if they can be retired. Hence this patch renames the function and updates the comments around it to match the current operation.

For: VIZ-5115

---
 drivers/gpu/drm/i915/i915_gem.c |   18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +6 -12
index f825942..081cbbf 100644
@@ -2956,12 +2956,10 @@ i915_gem_idle_work_handler(struct work_struct *work)
 }
 
 /**
- * Ensures that an object will eventually get non-busy by flushing any required
- * write domains, emitting any outstanding lazy request and retiring and
- * completed requests.
+ * Check an object to see if any of it's associated requests can be retired.
  */
 static int
-i915_gem_object_flush_active(struct drm_i915_gem_object *obj)
+i915_gem_object_retire(struct drm_i915_gem_object *obj)
 {
 	int i;
 
@@ -3034,8 +3032,8 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
 		return -ENOENT;
 	}
 
-	/* Need to make sure the object gets inactive eventually. */
-	ret = i915_gem_object_flush_active(obj);
+	/* Check if the object is pending clean up. */
+	ret = i915_gem_object_retire(obj);
 	if (ret)
 		goto out;
 
@@ -4526,12 +4524,8 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
 		goto unlock;
 	}
 
-	/* Count all active objects as busy, even if they are currently not used
-	 * by the gpu. Users of this interface expect objects to eventually
-	 * become non-busy without any further actions, therefore emit any
-	 * necessary flushes here.
-	 */
-	ret = i915_gem_object_flush_active(obj);
+	/* Check if the object is pending clean up. */
+	ret = i915_gem_object_retire(obj);
 	if (ret)
 		goto unref;
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 55/55
#108 lore raw

Re: [PATCH 55/55] drm/i915: Rename the somewhat reduced i915_gem_object_flush_active()

Quoted 49 lines · On 29/05/2015 17:44, [email protected] wrote:

From: John Harrison <[email protected]>

The i915_gem_object_flush_active() call used to do lots. Over time it has done less and less. Now all it does check the various associated requests to see if they can be retired. Hence this patch renames the function and updates the comments around it to match the current operation.

For: VIZ-5115

---
  drivers/gpu/drm/i915/i915_gem.c |   18 ++++++------------
  1 file changed, 6 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +4 -7
index f825942..081cbbf 100644
@@ -2956,12 +2956,10 @@ i915_gem_idle_work_handler(struct work_struct *work)
  }
 
  /**
- * Ensures that an object will eventually get non-busy by flushing any required
- * write domains, emitting any outstanding lazy request and retiring and
- * completed requests.
+ * Check an object to see if any of it's associated requests can be retired.
   */
  static int
-i915_gem_object_flush_active(struct drm_i915_gem_object *obj)
+i915_gem_object_retire(struct drm_i915_gem_object *obj)
  {
  	int i;
 
@@ -3034,8 +3032,8 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
  		return -ENOENT;
  	}
 
-	/* Need to make sure the object gets inactive eventually. */
-	ret = i915_gem_object_flush_active(obj);
+	/* Check if the object is pending clean up. */
+	ret = i915_gem_object_retire(obj);
  	if (ret)
  		goto out;
 
@@ -4526,12 +4524,8 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
  		goto unlock;
  	}
 
-	/* Count all active objects as busy, even if they are currently not used

drivers/gpu/drm/i915/i915_gem.c i915_gem_busy_ioctl(struct drm_device *dev, void *data, · line 4531

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +2 -5
-	 * by the gpu. Users of this interface expect objects to eventually
-	 * become non-busy without any further actions, therefore emit any
-	 * necessary flushes here.
-	 */
-	ret = i915_gem_object_flush_active(obj);
+	/* Check if the object is pending clean up. */
+	ret = i915_gem_object_retire(obj);
  	if (ret)
  		goto unref;
 

Thanks,
Tomas

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#109 lore raw

Re: [PATCH 55/55] drm/i915: Rename the somewhat reduced i915_gem_object_flush_active()

In reply to [email protected]
Quoted 9 lines · On Fri, May 29, 2015 at 05:44:16PM +0100, [email protected] wrote:

From: John Harrison <[email protected]>

The i915_gem_object_flush_active() call used to do lots. Over time it has done less and less. Now all it does check the various associated requests to see if they can be retired. Hence this patch renames the function and updates the comments around it to match the current operation.

For: VIZ-5115

When rebasing patches and especially like here when also renaming them a bit please leave some indication of what you've changed. Took me a while to figure out where one of my pending comments from the previous round went too.

And please don't just "v2: rebase", but please add some indicators against what it conflicted if it's obvious.

Thanks, Daniel

Quoted 56 lines
---
 drivers/gpu/drm/i915/i915_gem.c |   18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +6 -12
index f825942..081cbbf 100644
@@ -2956,12 +2956,10 @@ i915_gem_idle_work_handler(struct work_struct *work)
 }
 
 /**
- * Ensures that an object will eventually get non-busy by flushing any required
- * write domains, emitting any outstanding lazy request and retiring and
- * completed requests.
+ * Check an object to see if any of it's associated requests can be retired.
  */
 static int
-i915_gem_object_flush_active(struct drm_i915_gem_object *obj)
+i915_gem_object_retire(struct drm_i915_gem_object *obj)
 {
 	int i;
 
@@ -3034,8 +3032,8 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
 		return -ENOENT;
 	}
 
-	/* Need to make sure the object gets inactive eventually. */
-	ret = i915_gem_object_flush_active(obj);
+	/* Check if the object is pending clean up. */
+	ret = i915_gem_object_retire(obj);
 	if (ret)
 		goto out;
 
@@ -4526,12 +4524,8 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
 		goto unlock;
 	}
 
-	/* Count all active objects as busy, even if they are currently not used
-	 * by the gpu. Users of this interface expect objects to eventually
-	 * become non-busy without any further actions, therefore emit any
-	 * necessary flushes here.
-	 */
-	ret = i915_gem_object_flush_active(obj);
+	/* Check if the object is pending clean up. */
+	ret = i915_gem_object_retire(obj);
 	if (ret)
 		goto unref;
 
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#110 lore raw

Re: [PATCH 55/55] drm/i915: Rename the somewhat reduced i915_gem_object_flush_active()

Quoted 11 lines · Daniel Vetter
Quoted 9 lines · On Fri, May 29, 2015 at 05:44:16PM +0100, [email protected] wrote:

From: John Harrison <[email protected]>

The i915_gem_object_flush_active() call used to do lots. Over time it has done less and less. Now all it does check the various associated requests to see if they can be retired. Hence this patch renames the function and updates the comments around it to match the current operation.

For: VIZ-5115

Quoted 7 lines

When rebasing patches and especially like here when also renaming them a bit please leave some indication of what you've changed. Took me a while to figure out where one of my pending comments from the previous round went too.

And please don't just "v2: rebase", but please add some indicators against what it conflicted if it's obvious.

This function doesn't do an unconditional retire - the new name is much worse since it is inconsistent with how requests retire. In my make GEM umpteen times faster patches, I repurposed this function for reporting the object's current activeness and called it bool i915_gem_oject_active()
- though that is probably better as i915_gem_object_is_active().
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#111 lore raw

Re: [PATCH 55/55] drm/i915: Rename the somewhat reduced i915_gem_object_flush_active()

Quoted 16 lines · Chris Wilson
Quoted 15 lines · Daniel Vetter
Quoted 9 lines · On Fri, May 29, 2015 at 05:44:16PM +0100, [email protected] wrote:

From: John Harrison <[email protected]>

The i915_gem_object_flush_active() call used to do lots. Over time it has done less and less. Now all it does check the various associated requests to see if they can be retired. Hence this patch renames the function and updates the comments around it to match the current operation.

For: VIZ-5115

When rebasing patches and especially like here when also renaming them a bit please leave some indication of what you've changed. Took me a while to figure out where one of my pending comments from the previous round went too.

Quoted 9 lines
Quoted 2 lines

And please don't just "v2: rebase", but please add some indicators against what it conflicted if it's obvious.

This function doesn't do an unconditional retire - the new name is much worse since it is inconsistent with how requests retire. In my make GEM umpteen times faster patches, I repurposed this function for reporting the object's current activeness and called it bool i915_gem_oject_active()
- though that is probably better as i915_gem_object_is_active().
-Chris

Retiring is generally not an unconditional operation. i915_gem_retire_requests[_ring]() does not forcefully retire all requests, it only retires stuff that has completed. Same here. It could be called i915_gem_object_check_retire() or some such if you prefer. Either way, it is better than i915_gem_object_flush_active() as that is referring to flushing out the OLR which no longer exists.

If you are adding other functionality back in then feel free to rename it again as appropriate. But as this patch series stands, the function is a 'retire completed work associated with this object' operation and really needs to be named accordingly.

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#112 lore raw

Re: [PATCH 55/55] drm/i915: Rename the somewhat reduced i915_gem_object_flush_active()

Quoted 27 lines · John Harrison
Quoted 16 lines · Chris Wilson
Quoted 15 lines · Daniel Vetter
Quoted 9 lines · On Fri, May 29, 2015 at 05:44:16PM +0100, [email protected] wrote:

From: John Harrison <[email protected]>

The i915_gem_object_flush_active() call used to do lots. Over time it has done less and less. Now all it does check the various associated requests to see if they can be retired. Hence this patch renames the function and updates the comments around it to match the current operation.

For: VIZ-5115

When rebasing patches and especially like here when also renaming them a bit please leave some indication of what you've changed. Took me a while to figure out where one of my pending comments from the previous round went too.

Quoted 9 lines
Quoted 2 lines

And please don't just "v2: rebase", but please add some indicators against what it conflicted if it's obvious.

This function doesn't do an unconditional retire - the new name is much worse since it is inconsistent with how requests retire. In my make GEM umpteen times faster patches, I repurposed this function for reporting the object's current activeness and called it bool i915_gem_oject_active()
- though that is probably better as i915_gem_object_is_active().
-Chris

Quoted 1 line

Retiring is generally not an unconditional operation.

In the code, I use <object>_retire to perform the retiring operation on that object. I can rename i915_gem_retire_requests if that makes you happier, but I don't think it needs to since retire_requests does not imply to me that all requests are retired, just some indefinite value (though positive indefinite at least!).
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#113 lore raw

Re: [PATCH 55/55] drm/i915: Rename the somewhat reduced i915_gem_object_flush_active()

Quoted 27 lines · Chris Wilson
Quoted 26 lines · John Harrison
Quoted 25 lines · Chris Wilson
Quoted 10 lines · Daniel Vetter
Quoted 9 lines · On Fri, May 29, 2015 at 05:44:16PM +0100, [email protected] wrote:

From: John Harrison <[email protected]>

The i915_gem_object_flush_active() call used to do lots. Over time it has done less and less. Now all it does check the various associated requests to see if they can be retired. Hence this patch renames the function and updates the comments around it to match the current operation.

For: VIZ-5115

Quoted 7 lines

When rebasing patches and especially like here when also renaming them a bit please leave some indication of what you've changed. Took me a while to figure out where one of my pending comments from the previous round went too.

And please don't just "v2: rebase", but please add some indicators against what it conflicted if it's obvious.

This function doesn't do an unconditional retire - the new name is much worse since it is inconsistent with how requests retire. In my make GEM umpteen times faster patches, I repurposed this function for reporting the object's current activeness and called it bool i915_gem_oject_active()
- though that is probably better as i915_gem_object_is_active().
-Chris

Quoted 8 lines
Quoted 1 line

Retiring is generally not an unconditional operation.

In the code, I use <object>_retire to perform the retiring operation on that object. I can rename i915_gem_retire_requests if that makes you happier, but I don't think it needs to since retire_requests does not imply to me that all requests are retired, just some indefinite value (though positive indefinite at least!).
-Chris

Fair enough. I guess I'm still thinking of the driver as it was when I first wrote the patch series which was before your re-write for read/read optimisations. Like I said, the exact new name isn't as important as at least giving it a new name. The old name is definitely not valid any more. Feel free to suggest something better.

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#114 lore raw

Re: [PATCH 55/55] drm/i915: Rename the somewhat reduced i915_gem_object_flush_active()

In reply to Daniel Vetter
Quoted 8 lines · Daniel Vetter
Quoted 7 lines · On Fri, May 29, 2015 at 05:44:16PM +0100, [email protected] wrote:

From: John Harrison <[email protected]>

The i915_gem_object_flush_active() call used to do lots. Over time it has done less and less. Now all it does check the various associated requests to see if they can be retired. Hence this patch renames the function and updates the comments around it to match the current operation.

Quoted 6 lines
Quoted 2 lines

For: VIZ-5115

When rebasing patches and especially like here when also renaming them a bit please leave some indication of what you've changed. Took me a while to figure out where one of my pending comments from the previous round went too.

The thing is that this isn't really a rebase of a previous patch. It is a completely different patch. The original version was removing this function entirely as it had become a trivial wrapper around a call to i915_gem_retire_requests_ring(). Whereas, some of Chris Wilson's work in the meantime has meant that it is now a non-trivial wrapper. Hence the function cannot be removed. However, it is not doing what its name or comment says. So this new patch is just renaming it and updating the comment to be more accurate. Thus the posted comments about the previous patch do not apply to this patch - the change being commented on is no longer being made.

Quoted 54 lines

And please don't just "v2: rebase", but please add some indicators against what it conflicted if it's obvious.

Thanks, Daniel

Quoted 49 lines
---
  drivers/gpu/drm/i915/i915_gem.c |   18 ++++++------------
  1 file changed, 6 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +6 -12
index f825942..081cbbf 100644
@@ -2956,12 +2956,10 @@ i915_gem_idle_work_handler(struct work_struct *work)
  }
 
  /**
- * Ensures that an object will eventually get non-busy by flushing any required
- * write domains, emitting any outstanding lazy request and retiring and
- * completed requests.
+ * Check an object to see if any of it's associated requests can be retired.
   */
  static int
-i915_gem_object_flush_active(struct drm_i915_gem_object *obj)
+i915_gem_object_retire(struct drm_i915_gem_object *obj)
  {
  	int i;
 
@@ -3034,8 +3032,8 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
  		return -ENOENT;
  	}
 
-	/* Need to make sure the object gets inactive eventually. */
-	ret = i915_gem_object_flush_active(obj);
+	/* Check if the object is pending clean up. */
+	ret = i915_gem_object_retire(obj);
  	if (ret)
  		goto out;
 
@@ -4526,12 +4524,8 @@ i915_gem_busy_ioctl(struct drm_device *dev, void *data,
  		goto unlock;
  	}
 
-	/* Count all active objects as busy, even if they are currently not used
-	 * by the gpu. Users of this interface expect objects to eventually
-	 * become non-busy without any further actions, therefore emit any
-	 * necessary flushes here.
-	 */
-	ret = i915_gem_object_flush_active(obj);
+	/* Check if the object is pending clean up. */
+	ret = i915_gem_object_retire(obj);
  	if (ret)
  		goto unref;
 
Quoted 7 lines
Quoted 7 lines
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#115 lore raw

PATCH 14/56 drm/i915: Make retire condition check for requests not objects

In reply to [email protected]

From: John Harrison <[email protected]>

A previous patch (read-read optimisation) changed the early exit condition in i915_gem_retire_requests_ring() from checking the request list to checking the active list. This assumes that all requests have objects associated with them which are placed on the active list. The removal of the OLR means that non-batch buffer work is no longer tagged onto the nearest batch buffer submission and thus there are requests going through the system which do not have objects associated with them. This can therefore lead to the situation where an outstanding request never gets retired.

This change reverts the early exit condition to check for requests. Given that the purpose of the function is to retire requests, this does seem to make much more sense.

For: VIZ-5190

---
 drivers/gpu/drm/i915/i915_gem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +1 -1
index 7117659..4c5a6cd 100644
@@ -2859,7 +2859,7 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
 {
 	WARN_ON(i915_verify_lists(ring->dev));
 
-	if (list_empty(&ring->active_list))
+	if (list_empty(&ring->request_list))
 		return;
 
 	/* Retire requests first as we use it above for the early return.
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#116 lore raw

Re: [PATCH 14/56] drm/i915: Make retire condition check for requests not objects

Note that this is a new patch to the series. The issue was found when debugging a problem with the conversion to struct fence that is still in progress. Basically, it was possible to get continuous TDR timeouts on the ECS ring because the start of day initialisation request never got retired and the TDR got confused by this.

This patch should therefore be included in the anti-OLR series as a new patch #14 (immediately before 'update i915_gpu_idle() to ...'). As that is the point at which non-batch buffer requests start to appear in the system.

Quoted 27 lines · On 04/06/2015 19:23, [email protected] wrote:

From: John Harrison <[email protected]>

A previous patch (read-read optimisation) changed the early exit condition in i915_gem_retire_requests_ring() from checking the request list to checking the active list. This assumes that all requests have objects associated with them which are placed on the active list. The removal of the OLR means that non-batch buffer work is no longer tagged onto the nearest batch buffer submission and thus there are requests going through the system which do not have objects associated with them. This can therefore lead to the situation where an outstanding request never gets retired.

This change reverts the early exit condition to check for requests. Given that the purpose of the function is to retire requests, this does seem to make much more sense.

For: VIZ-5190

---
  drivers/gpu/drm/i915/i915_gem.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index 7117659..4c5a6cd 100644

drivers/gpu/drm/i915/i915_gem.c i915_gem_retire_requests_ring(struct intel_engine_cs *ring) · line 2865

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem.c +1 -1
@@ -2859,7 +2859,7 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
  {
  	WARN_ON(i915_verify_lists(ring->dev));
 
-	if (list_empty(&ring->active_list))
+	if (list_empty(&ring->request_list))
  		return;
 
  	/* Retire requests first as we use it above for the early return.

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 14/56
#117 lore raw

Re: [PATCH 14/56] drm/i915: Make retire condition check for requests not objects

In reply to [email protected]
Quoted 28 lines · On 04/06/2015 19:23, [email protected] wrote:

From: John Harrison <[email protected]>

A previous patch (read-read optimisation) changed the early exit condition in i915_gem_retire_requests_ring() from checking the request list to checking the active list. This assumes that all requests have objects associated with them which are placed on the active list. The removal of the OLR means that non-batch buffer work is no longer tagged onto the nearest batch buffer submission and thus there are requests going through the system which do not have objects associated with them. This can therefore lead to the situation where an outstanding request never gets retired.

This change reverts the early exit condition to check for requests. Given that the purpose of the function is to retire requests, this does seem to make much more sense.

For: VIZ-5190

---
  drivers/gpu/drm/i915/i915_gem.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index 7117659..4c5a6cd 100644

drivers/gpu/drm/i915/i915_gem.c i915_gem_retire_requests_ring(struct intel_engine_cs *ring) · line 2865

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem.c +1 -1
@@ -2859,7 +2859,7 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
  {
  	WARN_ON(i915_verify_lists(ring->dev));
 
-	if (list_empty(&ring->active_list))
+	if (list_empty(&ring->request_list))
  		return;
 
  	/* Retire requests first as we use it above for the early return.

Note to whoever is integrating this patch: This patch can either be applied or we could drop the request_list check entirely. This according to Chris Wilson in the following conversation:

3:26:09 PM - ickle: we just kill the check
3:26:25 PM - ickle: the final function is just request_list + trace_request
3:26:37 PM - ickle: adding a test to save one isn't a great tradeoff
3:26:58 PM - siglesias has left the room (Quit: Ping timeout: 256 seconds).
3:27:28 PM - twnqx has left the room (Quit: Ping timeout: 272 seconds).
3:28:04 PM - tomas_elf: fine
3:28:20 PM - tomas_elf: anyway, good to know
3:29:32 PM - ickle: there's actually one more, it's also where the execlists_retire should be
3:30:48 PM - tomas_elf: maybe you can just submit a patch (unless you've already done so) that removes all of the references 3:31:09 PM - JohnHarrison Joryn
3:31:23 PM - ickle: there's like a backlog of 50 patches before we even get to that point
3:31:29 PM - tomas_elf: ok, cool
3:31:51 PM - tomas_elf: at any rate, JohnHarrison's patch can be accepted either with the request_list check or no check at all 3:33:14 PM - ickle: I thought vsyrjala sent the patch to completely kill it along with a bug citation 3:34:50 PM - doome_ [[email protected]] entered the room.
3:35:25 PM - ickle: 0aedb1626566efd72b369c01992ee7413c82a0c5
3:35:39 PM - darkbasic_ [[email protected]] entered the room.
3:36:13 PM - darkbasic has left the room (Quit: Read error: Connection reset by peer).
3:39:05 PM - tomas_elf: has it been merged?
3:39:43 PM - ickle: it is in drm-intel-fixes
3:40:02 PM - tomas_elf: ah, ok

As long as the active_list check is removed since it breaks things.

Thanks,
Tomas
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#118 lore raw

Re: [PATCH 14/56] drm/i915: Make retire condition check for requests not objects

Quoted 70 lines · Tomas Elf
Quoted 28 lines · On 04/06/2015 19:23, [email protected] wrote:

From: John Harrison <[email protected]>

A previous patch (read-read optimisation) changed the early exit condition in i915_gem_retire_requests_ring() from checking the request list to checking the active list. This assumes that all requests have objects associated with them which are placed on the active list. The removal of the OLR means that non-batch buffer work is no longer tagged onto the nearest batch buffer submission and thus there are requests going through the system which do not have objects associated with them. This can therefore lead to the situation where an outstanding request never gets retired.

This change reverts the early exit condition to check for requests. Given that the purpose of the function is to retire requests, this does seem to make much more sense.

For: VIZ-5190

---
 drivers/gpu/drm/i915/i915_gem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index 7117659..4c5a6cd 100644

drivers/gpu/drm/i915/i915_gem.c i915_gem_retire_requests_ring(struct intel_engine_cs *ring) · line 2865

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem.c +1 -1
@@ -2859,7 +2859,7 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
 {
 	WARN_ON(i915_verify_lists(ring->dev));
 
-	if (list_empty(&ring->active_list))
+	if (list_empty(&ring->request_list))
 		return;
 
 	/* Retire requests first as we use it above for the early return.

Note to whoever is integrating this patch: This patch can either be applied or we could drop the request_list check entirely. This according to Chris Wilson in the following conversation:

3:26:09 PM - ickle: we just kill the check
3:26:25 PM - ickle: the final function is just request_list + trace_request 3:26:37 PM - ickle: adding a test to save one isn't a great tradeoff 3:26:58 PM - siglesias has left the room (Quit: Ping timeout: 256 seconds). 3:27:28 PM - twnqx has left the room (Quit: Ping timeout: 272 seconds). 3:28:04 PM - tomas_elf: fine
3:28:20 PM - tomas_elf: anyway, good to know
3:29:32 PM - ickle: there's actually one more, it's also where the execlists_retire should be
3:30:48 PM - tomas_elf: maybe you can just submit a patch (unless you've already done so) that removes all of the references
3:31:09 PM - JohnHarrison Joryn
3:31:23 PM - ickle: there's like a backlog of 50 patches before we even get to that point
3:31:29 PM - tomas_elf: ok, cool
3:31:51 PM - tomas_elf: at any rate, JohnHarrison's patch can be accepted either with the request_list check or no check at all
3:33:14 PM - ickle: I thought vsyrjala sent the patch to completely kill it along with a bug citation
3:34:50 PM - doome_ [[email protected]] entered the room. 3:35:25 PM - ickle: 0aedb1626566efd72b369c01992ee7413c82a0c5 3:35:39 PM - darkbasic_ [[email protected]] entered the room. 3:36:13 PM - darkbasic has left the room (Quit: Read error: Connection reset by peer).
3:39:05 PM - tomas_elf: has it been merged?
3:39:43 PM - ickle: it is in drm-intel-fixes
3:40:02 PM - tomas_elf: ah, ok

Quoted 3 lines

As long as the active_list check is removed since it breaks things.

Jani already picked up Ville's version of this for dinf:

commit 11ee9615f9bbc9c0c2dbd9f5eb275459b76f032a

Author: Ville Syrjälä <[email protected]>
Date:   Thu May 28 18:32:36 2015 +0300

drm/i915: Don't skip request retirement if the active list is empty

We should be covered here I think.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#119 lore raw
In reply to [email protected]
Quoted 91 lines · On Fri, May 29, 2015 at 05:43:21PM +0100, [email protected] wrote:

From: John Harrison <[email protected]>

The driver tracks GPU work using request structures. Unfortunately, this tracking is not currently explicit but is done by means of a catch-all request that floats around in the background hoovering up work until it gets submitted. This background request (ring->outstanding_lazy_request or OLR) is created at the point of actually writing to the ring rather than when a particular piece of GPU work is started. This scheme sort of hangs together but causes a number of issues. It can mean that multiple pieces of independent work are lumped together in the same request or that work is not officially submitted until much later than it was created.

This patch series completely removes the OLR and explicitly tracks each piece of work with it's own personal request structure from start to submission.

The patch set seems to fix the "'gem_ringfill --r render' + ctrl-c straight after boot" issue logged as BZ:88865. I haven't done any analysis of that particular issue but the descriptions I've seen appear to blame an inconsistent or mangled OLR.

Note also that by the end of this series, a number of differences between the legacy and execlist code paths have been removed. For example add_request() and emit_request() now have the same signature thus could be merged back to a single function pointer. Merging some of these together would also allow the removal of a bunch of 'if(execlists)' tests where the difference is simply to call the legacy function or the execlist one.

v2: Rebased to newer nightly tree, fixed up a few minor issues, added two extra patches - one to move the LRC ring begin around in the vein of other recent reshuffles, the other to clean up some issues with i915_add_request().

v3: Large re-work due to feedback from code review. Some patches have been removed, extra ones have been added and others have been changed significantly. It is recommended that all patches are reviewed from scratch rather than assuming only certain ones have changed and need re-inspecting. The exceptions are where the 'reviewed-by' tag has been kept because that patch was not significantly affected.

v4: Further updates due to review feedback and rebasing on top of significant changes to the underlying tree.

[Patches against drm-intel-nightly tree fetched 22/05/2015]

John Harrison (55):
drm/i915: Re-instate request->uniq becuase it is extremely useful drm/i915: Reserve ring buffer space for i915_add_request() commands drm/i915: i915_add_request must not fail
drm/i915: Early alloc request in execbuff
drm/i915: Set context in request from creation even in legacy mode drm/i915: Merged the many do_execbuf() parameters into a structure drm/i915: Simplify i915_gem_execbuffer_retire_commands() parameters drm/i915: Update alloc_request to return the allocated request drm/i915: Add request to execbuf params and add explicit cleanup drm/i915: Update the dispatch tracepoint to use params->request drm/i915: Update move_to_gpu() to take a request structure drm/i915: Update execbuffer_move_to_active() to take a request structure drm/i915: Add flag to i915_add_request() to skip the cache flush drm/i915: Update i915_gpu_idle() to manage its own request drm/i915: Split i915_ppgtt_init_hw() in half - generic and per ring drm/i915: Moved the for_each_ring loop outside of i915_gem_context_enable() drm/i915: Don't tag kernel batches as user batches
drm/i915: Add explicit request management to i915_gem_init_hw() drm/i915: Update ppgtt_init_ring() & context_enable() to take requests drm/i915: Update i915_switch_context() to take a request structure drm/i915: Update do_switch() to take a request structure drm/i915: Update deferred context creation to do explicit request management drm/i915: Update init_context() to take a request structure drm/i915: Update render_state_init() to take a request structure drm/i915: Update i915_gem_object_sync() to take a request structure drm/i915: Update overlay code to do explicit request management drm/i915: Update queue_flip() to take a request structure drm/i915: Update add_request() to take a request structure drm/i915: Update [vma|object]_move_to_active() to take request structures drm/i915: Update l3_remap to take a request structure
drm/i915: Update mi_set_context() to take a request structure drm/i915: Update a bunch of execbuffer helpers to take request structures drm/i915: Update workarounds_emit() to take request structures drm/i915: Update flush_all_caches() to take request structures drm/i915: Update switch_mm() to take a request structure drm/i915: Update ring->flush() to take a requests structure drm/i915: Update some flush helpers to take request structures drm/i915: Update ring->emit_flush() to take a request structure drm/i915: Update ring->add_request() to take a request structure drm/i915: Update ring->emit_request() to take a request structure drm/i915: Update ring->dispatch_execbuffer() to take a request structure drm/i915: Update ring->emit_bb_start() to take a request structure drm/i915: Update ring->sync_to() to take a request structure drm/i915: Update ring->signal() to take a request structure drm/i915: Update cacheline_align() to take a request structure drm/i915: Update intel_ring_begin() to take a request structure drm/i915: Update intel_logical_ring_begin() to take a request structure

Quoted 8 lines

drm/i915: Add *_ring_begin() to request allocation
drm/i915: Remove the now obsolete intel_ring_get_request() drm/i915: Remove the now obsolete 'outstanding_lazy_request' drm/i915: Move the request/file and request/pid association to creation time drm/i915: Remove 'faked' request from LRC submission
drm/i915: Update a bunch of LRC functions to take requests drm/i915: Remove the now obsolete 'i915_gem_check_olr()' drm/i915: Rename the somewhat reduced i915_gem_object_flush_active()

Applied the entire series except patch 1 (we seem to have managed making tracepoints abi and I'm chickening out of this, or well don't want to block the olr removal on it and so rebased a few patches that conflicted). And the last two since the very last is superseeded and the second last seems to not deconfuse with the new function names after read/read.

Thanks, Daniel

Quoted 27 lines
 drivers/gpu/drm/i915/i915_drv.h              |   77 +++---
 drivers/gpu/drm/i915/i915_gem.c              |  368 ++++++++++++++++----------
 drivers/gpu/drm/i915/i915_gem_context.c      |   78 +++---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c   |  128 +++++----
 drivers/gpu/drm/i915/i915_gem_gtt.c          |   59 +++--
 drivers/gpu/drm/i915/i915_gem_gtt.h          |    3 +-
 drivers/gpu/drm/i915/i915_gem_render_state.c |   15 +-
 drivers/gpu/drm/i915/i915_gem_render_state.h |    2 +-
 drivers/gpu/drm/i915/i915_trace.h            |   41 +--
 drivers/gpu/drm/i915/intel_display.c         |   60 +++--
 drivers/gpu/drm/i915/intel_drv.h             |    3 +-
 drivers/gpu/drm/i915/intel_fbdev.c           |    2 +-
 drivers/gpu/drm/i915/intel_lrc.c             |  265 +++++++++----------
 drivers/gpu/drm/i915/intel_lrc.h             |   16 +-
 drivers/gpu/drm/i915/intel_overlay.c         |   63 +++--
 drivers/gpu/drm/i915/intel_ringbuffer.c      |  303 +++++++++++++--------
 drivers/gpu/drm/i915/intel_ringbuffer.h      |   53 ++--
 17 files changed, 876 insertions(+), 660 deletions(-)
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx