Skip to contentSkip to conversation

Convert requests to use struct fence

PATCH In review [email protected] 4 participants 19 messages Jun 16, 2016 – Jun 30, 2016

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

v10 cover Convert requests to use struct fence

From: John Harrison <[email protected]>

There is a construct in the linux kernel called 'struct fence' that is intended to keep track of work that is executed on hardware. I.e. it solves the basic problem that the drivers 'struct drm_i915_gem_request' is trying to address. The request structure does quite a lot more than simply track the execution progress so is very definitely still required. However, the basic completion status side could be updated to use the ready made fence implementation and gain all the advantages that provides.

Using the struct fence object also has the advantage that the fence can be used outside of the i915 driver (by other drivers or by userland applications). That is the basis of the dma-buff synchronisation API and allows asynchronous tracking of work completion. In this case, it allows applications to be signalled directly when a batch buffer completes without having to make an IOCTL call into the driver.

Note that in order to allow the full fence API to be used (e.g. merging multiple fences together), the driver needs to provide an incrementing timeline for the fence. Currently this timeline is specific to the fence code as it must be per context. There is future work planned to make the driver's internal seqno value also be per context rather than driver global (VIZ-7443). Once this is done the fence specific timeline code can be dropped in favour of just using the driver's seqno value.

This is work that was planned since the conversion of the driver from being seqno value based to being request structure based. This patch series does that work.

An IGT test to exercise the fence support from user land is in progress and will follow. Android already makes extensive use of fences for display composition. Real world linux usage is planned in the form of Jesse's page table sharing / bufferless execbuf support. There is also a plan that Wayland (and others) could make use of it in a similar manner to Android.

v2: Updated for review comments by various people and to add support for Android style 'native sync'.

v3: Updated from review comments by Tvrtko Ursulin. Also moved sync framework out of staging and improved request completion handling.

v4: Fixed patch tag (should have been PATCH not RFC). Corrected ownership of one patch which had passed through many hands before reaching me. Fixed a bug introduced in v3 and updated for review comments.

v5: Removed de-staging and further updates to Android sync code. The de-stage is now being handled by someone else. The sync integration to the i915 driver will be a separate patch set that can only land after the external de-stage has been completed.

Assorted changes based on review comments and style checker fixes. Most significant change is fixing up the fake lost interrupt support for the 'drv_missed_irq_hang' IGT test and improving the wait request latency.

v6: Updated to newer nigthly and resolved conflicts around updates to the wait_request optimisations.

v7: Updated to newer nightly and resolved conflicts around massive ring -> engine rename and interface change to get_seqno(). Also fixed up a race condition issue with stale request pointers in file client lists and added a minor optimisation to not acquire spinlocks when a list is empty and does not need processing.

v8: Updated to yet another nightly and resolved the merge conflicts. Dropped 'delay freeing of requests' patch as no longer needed to due changes in request clean up code. Likewise with the deferred processing of the fence signalling. Also moved the fence timeline patch to before the fence conversion. It now means the timeline is initially added with no actual user but also means the fence conversion patch does not need to add a horrid hack timeline which is then removed again in a subsequent patch.

Added support for possible RCU usage of fence object (Review comments by Maarten Lankhorst).

v9: Updated to another newer nightly (changes to context structure naming).

Moved the request completion processing out of the interrupt handler and into a worker thread (Chris Wilson).

v10: Removed obsolete fields from timeline structure and a couple of functions. Corrected some comments and debug prints. Removed duplicate rcu_head field from request - there is already one in the fence structure for this exact purpose. Improved/added some comments and WARNs. Changed to an un-ordered work queue to allow parallel processing of different engines. Also set the high priority flag for reduced latency. Removed some unnecessary checks for invalid seqno values. Moved a spinlock release a few lines later to make the 'locked' parameter of i915_gem_request_enable_interrupt redundant and removed it. Also shuffled the function around in the file so as to make it static and remove it from the header file. Corrected the use of fence_signal_locked() to fence_signal() in the retire code. Dropped the irq save part of the spin lock calls in the notify code as this is no longer called from the ISR. Changed the call of i915_gem_retire_requests_ring() in the reset cleanup code to i915_gem_request_notify() instead as the former is just duplicating a lot of operations. Dropped the 'is_empty' flag from trace_i915_gem_request_notify() as it is now redundant - 'seqno == 0' is equivalent.
[Review comments from Maarten Lankhorst & Tvrtko Ursulin]

Added extra checks and re-instated the lazy_coherency flag to the call of i915_gem_request_notify() from i915_gem_retire_requests_ring() on the grounds that it happens lots and lots and mostly does not actually need to do anything.

Updated for yet more nightly changes (u64 for fence context).

[Patches against drm-intel-nightly tree fetched 09/06/2016]

John Harrison (6):
drm/i915: Add per context timelines for fence objects drm/i915: Convert requests to use struct fence
drm/i915: Removed now redundant parameter to i915_gem_request_completed() drm/i915: Interrupt driven fences
drm/i915: Updated request structure tracing
drm/i915: Cache last IRQ seqno to reduce IRQ overhead

 drivers/gpu/drm/i915/i915_debugfs.c     |   7 +-
 drivers/gpu/drm/i915/i915_dma.c         |  14 +-
 drivers/gpu/drm/i915/i915_drv.h         |  61 ++---
 drivers/gpu/drm/i915/i915_gem.c         | 412 ++++++++++++++++++++++++++++++--
 drivers/gpu/drm/i915/i915_gem_context.c |  16 ++
 drivers/gpu/drm/i915/i915_irq.c         |   3 +-
 drivers/gpu/drm/i915/i915_trace.h       |   6 +-
 drivers/gpu/drm/i915/intel_display.c    |   2 +-
 drivers/gpu/drm/i915/intel_lrc.c        |  14 ++
 drivers/gpu/drm/i915/intel_pm.c         |   4 +-
 drivers/gpu/drm/i915/intel_ringbuffer.c |   6 +
 drivers/gpu/drm/i915/intel_ringbuffer.h |  12 +
 12 files changed, 492 insertions(+), 65 deletions(-)
Signature · 6 lines
1.9.1

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

PATCH v10 1/6 drm/i915: Add per context timelines for fence objects

From: John Harrison <[email protected]>

The purpose of this patch series is to convert the requst structure to use fence objects for the underlying completion tracking. The fence object requires a sequence number. The ultimate aim is to use the same sequence number as for the request itself (or rather, to remove the request's seqno field and just use the fence's value throughout the driver). However, this is not currently possible and so this patch introduces a separate numbering scheme as an intermediate step.

A major advantage of using the fence object is that it can be passed outside of the i915 driver and used externally. The fence API allows for various operations such as combining multiple fences. This requires that fence seqnos within a single fence context be guaranteed in-order. The GPU scheduler that is coming can re-order request execution but not within a single GPU context. Thus the fence context must be tied to the i915 context (and the engine within the context as each engine runs asynchronously).

On the other hand, the driver as a whole currently only works with request seqnos that are allocated from a global in-order timeline. It will require a fair chunk of re-work to allow multiple independent seqno timelines to be used. Hence the introduction of a temporary, fence specific timeline. Once the work to update the rest of the driver has been completed then the request can use the fence seqno instead.

v2: New patch in series.

v3: Renamed/retyped timeline structure fields after review comments by Tvrtko Ursulin.

Added context information to the timeline's name string for better identification in debugfs output.

v5: Line wrapping and other white space fixes to keep style checker happy.

v7: Updated to newer nightly (lots of ring -> engine renaming).

v8: Moved to earlier in patch series so no longer needs to remove the quick hack timeline that was being added before.

v9: Updated to another newer nightly (changes to context structure naming). Also updated commit message to match previous changes.

v10: Removed obsolete fields from timeline structure and a couple of functions. Corrected some comments and debug prints. [Review comments from Maarten Lankhorst & Tvrtko Ursulin]

Updated to yet more nightly changes (u64 for fence context).

For: VIZ-5190

Cc Tvrtko Ursulin <[email protected]>
Cc Maarten Lankhorst <[email protected]>
---
 drivers/gpu/drm/i915/i915_drv.h         | 10 +++++++++
 drivers/gpu/drm/i915/i915_gem.c         | 36 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_gem_context.c | 16 +++++++++++++++
 drivers/gpu/drm/i915/intel_lrc.c        |  8 ++++++++
 4 files changed, 70 insertions(+)
drivers/gpu/drm/i915/i915_drv.h +10 -0
index 53d9e3f..ca67b45 100644
@@ -831,6 +831,15 @@ struct i915_ctx_hang_stats {
 	bool banned;
 };
 
+struct i915_fence_timeline {
+	char     name[32];
+	u64      fence_context;
+	unsigned next;
+};
+
+int i915_create_fence_timeline(struct i915_gem_context *ctx,
+			       struct intel_engine_cs *ring);
+
 /* This must match up with the value previously used for execbuf2.rsvd1. */
 #define DEFAULT_CONTEXT_HANDLE 0
 
@@ -875,6 +884,7 @@ struct i915_gem_context {
 		u64 lrc_desc;
 		int pin_count;
 		bool initialised;
+		struct i915_fence_timeline fence_timeline;
 	} engine[I915_NUM_ENGINES];
 
 	struct list_head link;
drivers/gpu/drm/i915/i915_gem.c +36 -0
index 57aa8a4..a3fdcf9 100644
@@ -2772,6 +2772,42 @@ void i915_gem_request_free(struct kref *req_ref)
 	kmem_cache_free(req->i915->requests, req);
 }
 
+int i915_create_fence_timeline(struct i915_gem_context *ctx,
+			       struct intel_engine_cs *engine)
+{
+	struct i915_fence_timeline *timeline;
+
+	timeline = &ctx->engine[engine->id].fence_timeline;
+
+	WARN_ON(timeline->name[0]);
+
+	timeline->fence_context = fence_context_alloc(1);
+
+	/*
+	 * Start the timeline from seqno 1 as zero is a special value
+	 * that is reserved for invalid sync points.
+	 */
+	timeline->next = 1;
+
+	snprintf(timeline->name, sizeof(timeline->name), "%lld>%s:%d",
+		 timeline->fence_context, engine->name, ctx->user_handle);
+
+	return 0;
+}
+
+unsigned i915_fence_timeline_get_next_seqno(struct i915_fence_timeline *timeline)
+{
+	unsigned seqno;
+
+	seqno = timeline->next;
+
+	/* Reserve zero for invalid */
+	if (++timeline->next == 0)
+		timeline->next = 1;
+
+	return seqno;
+}
+
 static inline int
 __i915_gem_request_alloc(struct intel_engine_cs *engine,
 			 struct i915_gem_context *ctx,
drivers/gpu/drm/i915/i915_gem_context.c +16 -0
index d0e7fc6..1971d8a 100644
@@ -320,6 +320,22 @@ i915_gem_create_context(struct drm_device *dev,
 	if (IS_ERR(ctx))
 		return ctx;
 
+	if (!i915.enable_execlists) {
+		struct intel_engine_cs *engine;
+
+		/* Create a per context timeline for fences */
+		for_each_engine(engine, to_i915(dev)) {
+			int ret = i915_create_fence_timeline(ctx, engine);
+			if (ret) {
+				DRM_ERROR("Fence timeline creation failed for legacy %s: %p/%d\n",
+					  engine->name, ctx, ctx->user_handle);
+				idr_remove(&file_priv->context_idr, ctx->user_handle);
+				i915_gem_context_unreference(ctx);
+				return ERR_PTR(ret);
+			}
+		}
+	}
+
 	if (USES_FULL_PPGTT(dev)) {
 		struct i915_hw_ppgtt *ppgtt = i915_ppgtt_create(dev, file_priv);
 
drivers/gpu/drm/i915/intel_lrc.c +8 -0
index 4fad830..dedb3f8 100644
@@ -2539,6 +2539,14 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
 		goto error_ringbuf;
 	}
 
+	/* Create a per context timeline for fences */
+	ret = i915_create_fence_timeline(ctx, engine);
+	if (ret) {
+		DRM_ERROR("Fence timeline creation failed for %s, ctx %p/%d\n",
+			  engine->name, ctx, ctx->user_handle);
+		goto error_ringbuf;
+	}
+
 	ce->ringbuf = ringbuf;
 	ce->state = ctx_obj;
 	ce->initialised = engine->init_context == NULL;
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v10 1/6
#2 lore raw

Re: [PATCH v10 1/6] drm/i915: Add per context timelines for fence objects

Op 16-06-16 om 14:54 schreef [email protected]:

Quoted 50 lines

From: John Harrison <[email protected]>

The purpose of this patch series is to convert the requst structure to use fence objects for the underlying completion tracking. The fence object requires a sequence number. The ultimate aim is to use the same sequence number as for the request itself (or rather, to remove the request's seqno field and just use the fence's value throughout the driver). However, this is not currently possible and so this patch introduces a separate numbering scheme as an intermediate step.

A major advantage of using the fence object is that it can be passed outside of the i915 driver and used externally. The fence API allows for various operations such as combining multiple fences. This requires that fence seqnos within a single fence context be guaranteed in-order. The GPU scheduler that is coming can re-order request execution but not within a single GPU context. Thus the fence context must be tied to the i915 context (and the engine within the context as each engine runs asynchronously).

On the other hand, the driver as a whole currently only works with request seqnos that are allocated from a global in-order timeline. It will require a fair chunk of re-work to allow multiple independent seqno timelines to be used. Hence the introduction of a temporary, fence specific timeline. Once the work to update the rest of the driver has been completed then the request can use the fence seqno instead.

v2: New patch in series.

v3: Renamed/retyped timeline structure fields after review comments by Tvrtko Ursulin.

Added context information to the timeline's name string for better identification in debugfs output.

v5: Line wrapping and other white space fixes to keep style checker happy.

v7: Updated to newer nightly (lots of ring -> engine renaming).

v8: Moved to earlier in patch series so no longer needs to remove the quick hack timeline that was being added before.

v9: Updated to another newer nightly (changes to context structure naming). Also updated commit message to match previous changes.

v10: Removed obsolete fields from timeline structure and a couple of functions. Corrected some comments and debug prints. [Review comments from Maarten Lankhorst & Tvrtko Ursulin]

Quoted 6 lines

Updated to yet more nightly changes (u64 for fence context).

For: VIZ-5190

Cc Tvrtko Ursulin <[email protected]>
Cc Maarten Lankhorst <[email protected]>

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

#3 lore raw

PATCH v10 2/6 drm/i915: Convert requests to use struct fence

In reply to [email protected]

From: John Harrison <[email protected]>

There is a construct in the linux kernel called 'struct fence' that is intended to keep track of work that is executed on hardware. I.e. it solves the basic problem that the drivers 'struct drm_i915_gem_request' is trying to address. The request structure does quite a lot more than simply track the execution progress so is very definitely still required. However, the basic completion status side could be updated to use the ready made fence implementation and gain all the advantages that provides.

This patch makes the first step of integrating a struct fence into the request. It replaces the explicit reference count with that of the fence. It also replaces the 'is completed' test with the fence's equivalent. Currently, that simply chains on to the original request implementation. A future patch will improve this.

v3: Updated after review comments by Tvrtko Ursulin. Added fence context/seqno pair to the debugfs request info. Renamed fence 'driver name' to just 'i915'. Removed BUG_ONs.

v5: Changed seqno format in debugfs to %x rather than %u as that is apparently the preferred appearance. Line wrapped some long lines to keep the style checker happy.

v6: Updated to newer nigthly and resolved conflicts. The biggest issue was with the re-worked busy spin precursor to waiting on a request. In particular, the addition of a 'request_started' helper function. This has no corresponding concept within the fence framework. However, it is only ever used in one place and the whole point of that place is to always directly read the seqno for absolutely lowest latency possible. So the simple solution is to just make the seqno test explicit at that point now rather than later in the series (it was previously being done anyway when fences become interrupt driven).

v7: Rebased to newer nightly - lots of ring -> engine renaming and interface change to get_seqno().

v8: Rebased to newer nightly - no longer needs to worry about mutex locking in the request free code path. Moved to after fence timeline patch so no longer needs to add a horrid hack timeline.

Removed commented out code block. Added support for possible RCU usage of fence object (Review comments by Maarten Lankhorst).

v10: Removed duplicate rcu_head field from request - there is already one in the fence structure for this exact purpose. Improved/added some comments. [Review comments from Maarten Lankhorst & Tvrtko Ursulin]

Updated for yet more nightly changes (u64 for fence context).

For: VIZ-5190

---
 drivers/gpu/drm/i915/i915_debugfs.c     |   5 +-
 drivers/gpu/drm/i915/i915_drv.h         |  42 +++++--------
 drivers/gpu/drm/i915/i915_gem.c         | 107 +++++++++++++++++++++++++++++---
 drivers/gpu/drm/i915/intel_lrc.c        |   1 +
 drivers/gpu/drm/i915/intel_ringbuffer.c |   1 +
 drivers/gpu/drm/i915/intel_ringbuffer.h |   7 +++
 6 files changed, 125 insertions(+), 38 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +3 -2
index e4f2c55..7afa254 100644
@@ -767,11 +767,12 @@ static int i915_gem_request_info(struct seq_file *m, void *data)
 			task = NULL;
 			if (req->pid)
 				task = pid_task(req->pid, PIDTYPE_PID);
-			seq_printf(m, "    %x @ %d: %s [%d]\n",
+			seq_printf(m, "    %x @ %d: %s [%d], fence = %llx:%x\n",
 				   req->seqno,
 				   (int) (jiffies - req->emitted_jiffies),
 				   task ? task->comm : "<unknown>",
-				   task ? task->pid : -1);
+				   task ? task->pid : -1,
+				   req->fence.context, req->fence.seqno);
 			rcu_read_unlock();
 		}
 
drivers/gpu/drm/i915/i915_drv.h +14 -28

84 lines not on this page · raw message

drivers/gpu/drm/i915/i915_gem.c +99 -8

157 lines not on this page · raw message

drivers/gpu/drm/i915/intel_lrc.c +1 -0
index dedb3f8..b59ef1e 100644
@@ -2073,6 +2073,7 @@ logical_ring_setup(struct drm_device *dev, enum intel_engine_id id)
 	INIT_LIST_HEAD(&engine->buffers);
 	INIT_LIST_HEAD(&engine->execlist_queue);
 	spin_lock_init(&engine->execlist_lock);
+	spin_lock_init(&engine->fence_lock);
 
 	tasklet_init(&engine->irq_tasklet,
 		     intel_lrc_irq_handler, (unsigned long)engine);
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -0
index cf8d0bf..df36da7 100644
@@ -2326,6 +2326,7 @@ static int intel_init_ring_buffer(struct drm_device *dev,
 	INIT_LIST_HEAD(&engine->request_list);
 	INIT_LIST_HEAD(&engine->execlist_queue);
 	INIT_LIST_HEAD(&engine->buffers);
+	spin_lock_init(&engine->fence_lock);
 	i915_gem_batch_pool_init(dev, &engine->batch_pool);
 	memset(engine->semaphore.sync_seqno, 0,
 	       sizeof(engine->semaphore.sync_seqno));
drivers/gpu/drm/i915/intel_ringbuffer.h +7 -0
index b33c876..01f3df6 100644
@@ -345,6 +345,13 @@ struct intel_engine_cs {
 	 * to encode the command length in the header).
 	 */
 	u32 (*get_cmd_length_mask)(u32 cmd_header);
+
+	/*
+	 * This spinlock is used by the fence implementation internally. Note,
+	 * it can be acquire from interrupt context so all usage must be IRQ
+	 * safe.
+	 */
+	spinlock_t fence_lock;
 };
 
 static inline bool
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v10 2/6
#4 lore raw

Re: [PATCH v10 2/6] drm/i915: Convert requests to use struct fence

Op 16-06-16 om 14:54 schreef [email protected]:

Quoted 42 lines

From: John Harrison <[email protected]>

There is a construct in the linux kernel called 'struct fence' that is intended to keep track of work that is executed on hardware. I.e. it solves the basic problem that the drivers 'struct drm_i915_gem_request' is trying to address. The request structure does quite a lot more than simply track the execution progress so is very definitely still required. However, the basic completion status side could be updated to use the ready made fence implementation and gain all the advantages that provides.

This patch makes the first step of integrating a struct fence into the request. It replaces the explicit reference count with that of the fence. It also replaces the 'is completed' test with the fence's equivalent. Currently, that simply chains on to the original request implementation. A future patch will improve this.

v3: Updated after review comments by Tvrtko Ursulin. Added fence context/seqno pair to the debugfs request info. Renamed fence 'driver name' to just 'i915'. Removed BUG_ONs.

v5: Changed seqno format in debugfs to %x rather than %u as that is apparently the preferred appearance. Line wrapped some long lines to keep the style checker happy.

v6: Updated to newer nigthly and resolved conflicts. The biggest issue was with the re-worked busy spin precursor to waiting on a request. In particular, the addition of a 'request_started' helper function. This has no corresponding concept within the fence framework. However, it is only ever used in one place and the whole point of that place is to always directly read the seqno for absolutely lowest latency possible. So the simple solution is to just make the seqno test explicit at that point now rather than later in the series (it was previously being done anyway when fences become interrupt driven).

v7: Rebased to newer nightly - lots of ring -> engine renaming and interface change to get_seqno().

v8: Rebased to newer nightly - no longer needs to worry about mutex locking in the request free code path. Moved to after fence timeline patch so no longer needs to add a horrid hack timeline.

Quoted 8 lines

Removed commented out code block. Added support for possible RCU usage of fence object (Review comments by Maarten Lankhorst).

v10: Removed duplicate rcu_head field from request - there is already one in the fence structure for this exact purpose. Improved/added some comments. [Review comments from Maarten Lankhorst & Tvrtko Ursulin]

Updated for yet more nightly changes (u64 for fence context).

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

#5 lore raw

PATCH v10 3/6 drm/i915: Removed now redundant parameter to i915_gem_request_completed()

In reply to [email protected]

From: John Harrison <[email protected]>

The change to the implementation of i915_gem_request_completed() means that the lazy coherency flag is no longer used. This can now be removed to simplify the interface.

v6: Updated to newer nightly and resolved conflicts.

v7: Updated to newer nightly (lots of ring -> engine renaming).

For: VIZ-5190

---
 drivers/gpu/drm/i915/i915_debugfs.c  |  2 +-
 drivers/gpu/drm/i915/i915_drv.h      |  3 +--
 drivers/gpu/drm/i915/i915_gem.c      | 14 +++++++-------
 drivers/gpu/drm/i915/intel_display.c |  2 +-
 drivers/gpu/drm/i915/intel_pm.c      |  4 ++--
 5 files changed, 12 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
index 7afa254..1bfcee2 100644
@@ -663,7 +663,7 @@ static int i915_gem_pageflip_info(struct seq_file *m, void *data)
 					   i915_gem_request_get_seqno(work->flip_queued_req),
 					   dev_priv->next_seqno,
 					   engine->get_seqno(engine),
-					   i915_gem_request_completed(work->flip_queued_req, true));
+					   i915_gem_request_completed(work->flip_queued_req));
 			} else
 				seq_printf(m, "Flip not associated with any ring\n");
 			seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n",
drivers/gpu/drm/i915/i915_drv.h +1 -2
index de3897b..d753457 100644
@@ -2458,8 +2458,7 @@ struct drm_i915_gem_request * __must_check
 i915_gem_request_alloc(struct intel_engine_cs *engine,
 		       struct i915_gem_context *ctx);
 
-static inline bool i915_gem_request_completed(struct drm_i915_gem_request *req,
-					      bool lazy_coherency)
+static inline bool i915_gem_request_completed(struct drm_i915_gem_request *req)
 {
 	return fence_is_signaled(&req->fence);
 }
drivers/gpu/drm/i915/i915_gem.c +7 -7
index 853f847..9a55b87 100644
@@ -1264,7 +1264,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req,
 	if (list_empty(&req->list))
 		return 0;
 
-	if (i915_gem_request_completed(req, true))
+	if (i915_gem_request_completed(req))
 		return 0;
 
 	timeout_expire = 0;
@@ -1315,7 +1315,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req,
 			break;
 		}
 
-		if (i915_gem_request_completed(req, false)) {
+		if (i915_gem_request_completed(req)) {
 			ret = 0;
 			break;
 		}
@@ -2994,7 +2994,7 @@ i915_gem_find_active_request(struct intel_engine_cs *engine)
 	struct drm_i915_gem_request *request;
 
 	list_for_each_entry(request, &engine->request_list, list) {
-		if (i915_gem_request_completed(request, false))
+		if (i915_gem_request_completed(request))
 			continue;
 
 		return request;
@@ -3126,7 +3126,7 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *engine)
 					   struct drm_i915_gem_request,
 					   list);
 
-		if (!i915_gem_request_completed(request, true))
+		if (!i915_gem_request_completed(request))
 			break;
 
 		i915_gem_request_retire(request);
@@ -3150,7 +3150,7 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *engine)
 	}
 
 	if (unlikely(engine->trace_irq_req &&
-		     i915_gem_request_completed(engine->trace_irq_req, true))) {
+		     i915_gem_request_completed(engine->trace_irq_req))) {
 		engine->irq_put(engine);
 		i915_gem_request_assign(&engine->trace_irq_req, NULL);
 	}
@@ -3248,7 +3248,7 @@ i915_gem_object_flush_active(struct drm_i915_gem_object *obj)
 		if (req == NULL)
 			continue;
 
-		if (i915_gem_request_completed(req, true))
+		if (i915_gem_request_completed(req))
 			i915_gem_object_retire__read(obj, i);
 	}
 
@@ -3356,7 +3356,7 @@ __i915_gem_object_sync(struct drm_i915_gem_object *obj,
 	if (to == from)
 		return 0;
 
-	if (i915_gem_request_completed(from_req, true))
+	if (i915_gem_request_completed(from_req))
 		return 0;
 
 	if (!i915_semaphore_is_enabled(to_i915(obj->base.dev))) {
drivers/gpu/drm/i915/intel_display.c +1 -1
index 094cac5..9a8d799 100644
@@ -11592,7 +11592,7 @@ static bool __pageflip_stall_check_cs(struct drm_i915_private *dev_priv,
 	vblank = intel_crtc_get_vblank_counter(intel_crtc);
 	if (work->flip_ready_vblank == 0) {
 		if (work->flip_queued_req &&
-		    !i915_gem_request_completed(work->flip_queued_req, true))
+		    !i915_gem_request_completed(work->flip_queued_req))
 			return false;
 
 		work->flip_ready_vblank = vblank;
drivers/gpu/drm/i915/intel_pm.c +2 -2
index 658a756..e518d21 100644
@@ -7713,7 +7713,7 @@ static void __intel_rps_boost_work(struct work_struct *work)
 	struct request_boost *boost = container_of(work, struct request_boost, work);
 	struct drm_i915_gem_request *req = boost->req;
 
-	if (!i915_gem_request_completed(req, true))
+	if (!i915_gem_request_completed(req))
 		gen6_rps_boost(req->i915, NULL, req->emitted_jiffies);
 
 	i915_gem_request_unreference(req);
@@ -7727,7 +7727,7 @@ void intel_queue_rps_boost_for_request(struct drm_i915_gem_request *req)
 	if (req == NULL || INTEL_GEN(req->i915) < 6)
 		return;
 
-	if (i915_gem_request_completed(req, true))
+	if (i915_gem_request_completed(req))
 		return;
 
 	boost = kmalloc(sizeof(*boost), GFP_ATOMIC);
Signature · 6 lines
1.9.1

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

PATCH v10 4/6 drm/i915: Interrupt driven fences

In reply to [email protected]

From: John Harrison <[email protected]>

The intended usage model for struct fence is that the signalled status should be set on demand rather than polled. That is, there should not be a need for a 'signaled' function to be called everytime the status is queried. Instead, 'something' should be done to enable a signal callback from the hardware which will update the state directly. In the case of requests, this is the seqno update interrupt. The idea is that this callback will only be enabled on demand when something actually tries to wait on the fence.

This change removes the polling test and replaces it with the callback scheme. Each fence is added to a 'please poke me' list at the start of i915_add_request(). The interrupt handler (via a deferred work queue) then scans through the 'poke me' list when a new seqno pops out and signals any matching fence/request. The fence is then removed from the list so the entire request stack does not need to be scanned every time. The fence is added to the list before the commands to generate the seqno interrupt are added to the ring. Thus the sequence is guaranteed to be race free if the interrupt is already enabled.

Note that the interrupt is only enabled on demand (i.e. when __wait_request() is called). Thus there is still a potential race when enabling the interrupt as the request may already have completed. However, this is simply solved by calling the interrupt processing code immediately after enabling the interrupt and thereby checking for already completed requests.

Lastly, the ring clean up code has the possibility to cancel outstanding requests (e.g. because TDR has reset the ring). These requests will never get signalled and so must be removed from the signal list manually. This is done by setting a 'cancelled' flag and then calling the regular notify/retire code path rather than attempting to duplicate the list manipulatation and clean up code in multiple places. This also avoids any race condition where the cancellation request might occur after/during the completion interrupt actually arriving.

v2: Updated to take advantage of the request unreference no longer requiring the mutex lock.

v3: Move the signal list processing around to prevent unsubmitted requests being added to the list. This was occurring on Android because the native sync implementation calls the fence->enable_signalling API immediately on fence creation.

Updated after review comments by Tvrtko Ursulin. Renamed list nodes to 'link' instead of 'list'. Added support for returning an error code on a cancelled fence. Update list processing to be more efficient/safer with respect to spinlocks.

v5: Made i915_gem_request_submit a static as it is only ever called from one place.

Fixed up the low latency wait optimisation. The time delay between the seqno value being to memory and the drive's ISR running can be significant, at least for the wait request micro-benchmark. This can be greatly improved by explicitly checking for seqno updates in the pre-wait busy poll loop. Also added some documentation comments to the busy poll code.

Fixed up support for the faking of lost interrupts (test_irq_rings/missed_irq_rings). That is, there is an IGT test that tells the driver to loose interrupts deliberately and then check that everything still works as expected (albeit much slower).

Updates from review comments: use non IRQ-save spinlocking, early exit on WARN and improved comments (Tvrtko Ursulin).

v6: Updated to newer nigthly and resolved conflicts around the wait_request busy spin optimisation. Also fixed a race condition between this early exit path and the regular completion path.

v7: Updated to newer nightly - lots of ring -> engine renaming plus an interface change on get_seqno(). Also added a list_empty() check before acquring spinlocks and doing list processing.

v8: Updated to newer nightly - changes to request clean up code mean non of the deferred free mess is needed any more.

v9: Moved the request completion processing out of the interrupt handler and into a worker thread (Chris Wilson).

v10: Changed to an un-ordered work queue to allow parallel processing of different engines. Also set the high priority flag for reduced latency. Removed some unnecessary checks for invalid seqno values. Improved/added some comments and WARNs. Moved a spinlock release a few lines later to make the 'locked' parameter of i915_gem_request_enable_interrupt redundant and removed it. Also shuffled the function around in the file so as to make it static and remove it from the header file. Corrected the use of fence_signal_locked() to fence_signal() in the retire code. Dropped the irq save part of the spin lock calls in the notify code as this is no longer called from the ISR. Changed the call of i915_gem_retire_requests_ring() in the reset cleanup code to i915_gem_request_notify() instead as the former is just duplicating a lot of operations.
[Review comments from Maarten Lankhorst & Tvrtko Ursulin]

Made the call to _notify() from _retire_requests_ring() conditional on interrupts not being enabled as it is only a race condition work around for that case.

Re-instated the lazy_coherency flag (but now on the _notify() function) to reduce the overhead of retire_requests_ring() calling _notify() lots and lots (even with the above check).

Updated for yet more nightly changes (u64 for fence context).

For: VIZ-5190

Cc Tvrtko Ursulin <[email protected]>
Cc Maarten Lankhorst <[email protected]>
---
 drivers/gpu/drm/i915/i915_dma.c         |  14 +-
 drivers/gpu/drm/i915/i915_drv.h         |  10 ++
 drivers/gpu/drm/i915/i915_gem.c         | 248 +++++++++++++++++++++++++++++---
 drivers/gpu/drm/i915/i915_irq.c         |   2 +
 drivers/gpu/drm/i915/intel_lrc.c        |   5 +
 drivers/gpu/drm/i915/intel_ringbuffer.c |   5 +
 drivers/gpu/drm/i915/intel_ringbuffer.h |  10 +-
 7 files changed, 271 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +13 -1
index 07edaed..298d447 100644
@@ -1019,9 +1019,18 @@ static int i915_workqueues_init(struct drm_i915_private *dev_priv)
 	if (dev_priv->wq == NULL)
 		goto out_err;
 
+	/*
+	 * Making this work queue un-ordered means that request notifications
+	 * for different engines can be processed in parallel across multiple
+	 * CPU cores (if available).
+	 */
+	dev_priv->req_wq = alloc_workqueue("i915-rq", WQ_HIGHPRI, I915_NUM_ENGINES);
+	if (dev_priv->req_wq == NULL)
+		goto out_free_wq;
+
 	dev_priv->hotplug.dp_wq = alloc_ordered_workqueue("i915-dp", 0);
 	if (dev_priv->hotplug.dp_wq == NULL)
-		goto out_free_wq;
+		goto out_free_req_wq;
 
 	dev_priv->gpu_error.hangcheck_wq =
 		alloc_ordered_workqueue("i915-hangcheck", 0);
@@ -1032,6 +1041,8 @@ static int i915_workqueues_init(struct drm_i915_private *dev_priv)
 
 out_free_dp_wq:
 	destroy_workqueue(dev_priv->hotplug.dp_wq);
+out_free_req_wq:
+	destroy_workqueue(dev_priv->req_wq);
 out_free_wq:
 	destroy_workqueue(dev_priv->wq);
 out_err:
@@ -1044,6 +1055,7 @@ static void i915_workqueues_cleanup(struct drm_i915_private *dev_priv)
 {
 	destroy_workqueue(dev_priv->gpu_error.hangcheck_wq);
 	destroy_workqueue(dev_priv->hotplug.dp_wq);
+	destroy_workqueue(dev_priv->req_wq);
 	destroy_workqueue(dev_priv->wq);
 }
 
drivers/gpu/drm/i915/i915_drv.h +10 -0
index d753457..8a26db5 100644
@@ -1849,6 +1849,9 @@ struct drm_i915_private {
 	 */
 	struct workqueue_struct *wq;
 
+	/* Work queue for request completion processing */
+	struct workqueue_struct *req_wq;
+
 	/* Display functions */
 	struct drm_i915_display_funcs display;
 
@@ -2356,6 +2359,10 @@ struct drm_i915_gem_request {
 	 * Underlying object for implementing the signal/wait stuff.
 	 */
 	struct fence fence;
+	struct list_head signal_link;
+	bool cancelled;
+	bool irq_enabled;
+	bool signal_requested;
 
 	/** On Which ring this request was generated */
 	struct drm_i915_private *i915;
@@ -2457,6 +2464,9 @@ struct drm_i915_gem_request {
 struct drm_i915_gem_request * __must_check
 i915_gem_request_alloc(struct intel_engine_cs *engine,
 		       struct i915_gem_context *ctx);
+void i915_gem_request_notify(struct intel_engine_cs *ring, bool fence_locked,
+			     bool lazy_coherency);
+void i915_gem_request_worker(struct work_struct *work);
 
 static inline bool i915_gem_request_completed(struct drm_i915_gem_request *req)
 {
drivers/gpu/drm/i915/i915_gem.c +229 -19

354 lines not on this page · raw message

drivers/gpu/drm/i915/i915_irq.c +2 -0
index 72c04d6..c5024e7 100644
@@ -982,6 +982,8 @@ static void notify_ring(struct intel_engine_cs *engine)
 	trace_i915_gem_request_notify(engine);
 	engine->user_interrupts++;
 
+	queue_work(engine->i915->req_wq, &engine->request_work);
+
 	wake_up_all(&engine->irq_queue);
 }
 
drivers/gpu/drm/i915/intel_lrc.c +5 -0
index b59ef1e..6fbb05e 100644
@@ -1922,6 +1922,8 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *engine)
 
 	dev_priv = engine->i915;
 
+	cancel_work_sync(&engine->request_work);
+
 	if (engine->buffer) {
 		intel_logical_ring_stop(engine);
 		WARN_ON((I915_READ_MODE(engine) & MODE_IDLE) == 0);
@@ -2070,6 +2072,7 @@ logical_ring_setup(struct drm_device *dev, enum intel_engine_id id)
 
 	INIT_LIST_HEAD(&engine->active_list);
 	INIT_LIST_HEAD(&engine->request_list);
+	INIT_LIST_HEAD(&engine->fence_signal_list);
 	INIT_LIST_HEAD(&engine->buffers);
 	INIT_LIST_HEAD(&engine->execlist_queue);
 	spin_lock_init(&engine->execlist_lock);
@@ -2078,6 +2081,8 @@ logical_ring_setup(struct drm_device *dev, enum intel_engine_id id)
 	tasklet_init(&engine->irq_tasklet,
 		     intel_lrc_irq_handler, (unsigned long)engine);
 
+	INIT_WORK(&engine->request_work, i915_gem_request_worker);
+
 	logical_ring_init_platform_invariants(engine);
 	logical_ring_default_vfuncs(engine);
 	logical_ring_default_irqs(engine, info->irq_shift);
drivers/gpu/drm/i915/intel_ringbuffer.c +5 -0
index df36da7..b2aea2b 100644
@@ -2326,6 +2326,7 @@ static int intel_init_ring_buffer(struct drm_device *dev,
 	INIT_LIST_HEAD(&engine->request_list);
 	INIT_LIST_HEAD(&engine->execlist_queue);
 	INIT_LIST_HEAD(&engine->buffers);
+	INIT_LIST_HEAD(&engine->fence_signal_list);
 	spin_lock_init(&engine->fence_lock);
 	i915_gem_batch_pool_init(dev, &engine->batch_pool);
 	memset(engine->semaphore.sync_seqno, 0,
@@ -2333,6 +2334,8 @@ static int intel_init_ring_buffer(struct drm_device *dev,
 
 	init_waitqueue_head(&engine->irq_queue);
 
+	INIT_WORK(&engine->request_work, i915_gem_request_worker);
+
 	ringbuf = intel_engine_create_ringbuffer(engine, 32 * PAGE_SIZE);
 	if (IS_ERR(ringbuf)) {
 		ret = PTR_ERR(ringbuf);
@@ -2379,6 +2382,8 @@ void intel_cleanup_engine(struct intel_engine_cs *engine)
 
 	dev_priv = engine->i915;
 
+	cancel_work_sync(&engine->request_work);
+
 	if (engine->buffer) {
 		intel_stop_engine(engine);
 		WARN_ON(!IS_GEN2(dev_priv) && (I915_READ_MODE(engine) & MODE_IDLE) == 0);
drivers/gpu/drm/i915/intel_ringbuffer.h +7 -3
index 01f3df6..9e79fbd 100644
@@ -347,11 +347,15 @@ struct intel_engine_cs {
 	u32 (*get_cmd_length_mask)(u32 cmd_header);
 
 	/*
-	 * This spinlock is used by the fence implementation internally. Note,
-	 * it can be acquire from interrupt context so all usage must be IRQ
-	 * safe.
+	 * This spinlock is used by the fence implementation internally and by
+	 * the i915 driver for operations on the fence_signal_list and on fences
+	 * in general. Note, it can be acquire from interrupt context so all
+	 * usage must be IRQ safe.
 	 */
 	spinlock_t fence_lock;
+	struct list_head fence_signal_list;
+
+	struct work_struct request_work;
 };
 
 static inline bool
Signature · 6 lines
1.9.1

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

PATCH v10 4/6 drm/i915: Interrupt driven fences

From: John Harrison <[email protected]>

The intended usage model for struct fence is that the signalled status should be set on demand rather than polled. That is, there should not be a need for a 'signaled' function to be called everytime the status is queried. Instead, 'something' should be done to enable a signal callback from the hardware which will update the state directly. In the case of requests, this is the seqno update interrupt. The idea is that this callback will only be enabled on demand when something actually tries to wait on the fence.

This change removes the polling test and replaces it with the callback scheme. Each fence is added to a 'please poke me' list at the start of i915_add_request(). The interrupt handler (via a deferred work queue) then scans through the 'poke me' list when a new seqno pops out and signals any matching fence/request. The fence is then removed from the list so the entire request stack does not need to be scanned every time. The fence is added to the list before the commands to generate the seqno interrupt are added to the ring. Thus the sequence is guaranteed to be race free if the interrupt is already enabled.

Note that the interrupt is only enabled on demand (i.e. when __wait_request() is called). Thus there is still a potential race when enabling the interrupt as the request may already have completed. However, this is simply solved by calling the interrupt processing code immediately after enabling the interrupt and thereby checking for already completed requests.

Lastly, the ring clean up code has the possibility to cancel outstanding requests (e.g. because TDR has reset the ring). These requests will never get signalled and so must be removed from the signal list manually. This is done by setting a 'cancelled' flag and then calling the regular notify/retire code path rather than attempting to duplicate the list manipulatation and clean up code in multiple places. This also avoids any race condition where the cancellation request might occur after/during the completion interrupt actually arriving.

v2: Updated to take advantage of the request unreference no longer requiring the mutex lock.

v3: Move the signal list processing around to prevent unsubmitted requests being added to the list. This was occurring on Android because the native sync implementation calls the fence->enable_signalling API immediately on fence creation.

Updated after review comments by Tvrtko Ursulin. Renamed list nodes to 'link' instead of 'list'. Added support for returning an error code on a cancelled fence. Update list processing to be more efficient/safer with respect to spinlocks.

v5: Made i915_gem_request_submit a static as it is only ever called from one place.

Fixed up the low latency wait optimisation. The time delay between the seqno value being to memory and the drive's ISR running can be significant, at least for the wait request micro-benchmark. This can be greatly improved by explicitly checking for seqno updates in the pre-wait busy poll loop. Also added some documentation comments to the busy poll code.

Fixed up support for the faking of lost interrupts (test_irq_rings/missed_irq_rings). That is, there is an IGT test that tells the driver to loose interrupts deliberately and then check that everything still works as expected (albeit much slower).

Updates from review comments: use non IRQ-save spinlocking, early exit on WARN and improved comments (Tvrtko Ursulin).

v6: Updated to newer nigthly and resolved conflicts around the wait_request busy spin optimisation. Also fixed a race condition between this early exit path and the regular completion path.

v7: Updated to newer nightly - lots of ring -> engine renaming plus an interface change on get_seqno(). Also added a list_empty() check before acquring spinlocks and doing list processing.

v8: Updated to newer nightly - changes to request clean up code mean non of the deferred free mess is needed any more.

v9: Moved the request completion processing out of the interrupt handler and into a worker thread (Chris Wilson).

v10: Changed to an un-ordered work queue to allow parallel processing of different engines. Also set the high priority flag for reduced latency. Removed some unnecessary checks for invalid seqno values. Improved/added some comments and WARNs. Moved a spinlock release a few lines later to make the 'locked' parameter of i915_gem_request_enable_interrupt redundant and removed it. Also shuffled the function around in the file so as to make it static and remove it from the header file. Corrected the use of fence_signal_locked() to fence_signal() in the retire code. Dropped the irq save part of the spin lock calls in the notify code as this is no longer called from the ISR. Changed the call of i915_gem_retire_requests_ring() in the reset cleanup code to i915_gem_request_notify() instead as the former is just duplicating a lot of operations.
[Review comments from Maarten Lankhorst & Tvrtko Ursulin]

Made the call to _notify() from _retire_requests_ring() conditional on interrupts not being enabled as it is only a race condition work around for that case. Also re-instated the lazy_coherency flag (but now on the _notify() function) to reduce the overhead of _retire_requests_ring() calling _notify() lots and lots (even with the anti-interrupt check).

Updated for yet more nightly changes (u64 for fence context).

v10b: Re-ordered the fence signal and IRQ release in _notify() to fix a race condition when disabling interrupts. Also, moved the wake_up_all() call from the IRQ handler to the worker thread to prevent the wake up of waiting threads from overtaking the signalling of the request.

For: VIZ-5190

Cc Tvrtko Ursulin <[email protected]>
Cc Maarten Lankhorst <[email protected]>
---
 drivers/gpu/drm/i915/i915_dma.c         |  14 +-
 drivers/gpu/drm/i915/i915_drv.h         |  10 ++
 drivers/gpu/drm/i915/i915_gem.c         | 250 +++++++++++++++++++++++++++++---
 drivers/gpu/drm/i915/i915_irq.c         |   2 +-
 drivers/gpu/drm/i915/intel_lrc.c        |   5 +
 drivers/gpu/drm/i915/intel_ringbuffer.c |   5 +
 drivers/gpu/drm/i915/intel_ringbuffer.h |  10 +-
 7 files changed, 272 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +13 -1
index 07edaed..298d447 100644
@@ -1019,9 +1019,18 @@ static int i915_workqueues_init(struct drm_i915_private *dev_priv)
 	if (dev_priv->wq == NULL)
 		goto out_err;
 
+	/*
+	 * Making this work queue un-ordered means that request notifications
+	 * for different engines can be processed in parallel across multiple
+	 * CPU cores (if available).
+	 */
+	dev_priv->req_wq = alloc_workqueue("i915-rq", WQ_HIGHPRI, I915_NUM_ENGINES);
+	if (dev_priv->req_wq == NULL)
+		goto out_free_wq;
+
 	dev_priv->hotplug.dp_wq = alloc_ordered_workqueue("i915-dp", 0);
 	if (dev_priv->hotplug.dp_wq == NULL)
-		goto out_free_wq;
+		goto out_free_req_wq;
 
 	dev_priv->gpu_error.hangcheck_wq =
 		alloc_ordered_workqueue("i915-hangcheck", 0);
@@ -1032,6 +1041,8 @@ static int i915_workqueues_init(struct drm_i915_private *dev_priv)
 
 out_free_dp_wq:
 	destroy_workqueue(dev_priv->hotplug.dp_wq);
+out_free_req_wq:
+	destroy_workqueue(dev_priv->req_wq);
 out_free_wq:
 	destroy_workqueue(dev_priv->wq);
 out_err:
@@ -1044,6 +1055,7 @@ static void i915_workqueues_cleanup(struct drm_i915_private *dev_priv)
 {
 	destroy_workqueue(dev_priv->gpu_error.hangcheck_wq);
 	destroy_workqueue(dev_priv->hotplug.dp_wq);
+	destroy_workqueue(dev_priv->req_wq);
 	destroy_workqueue(dev_priv->wq);
 }
 
drivers/gpu/drm/i915/i915_drv.h +10 -0
index d753457..8a26db5 100644
@@ -1849,6 +1849,9 @@ struct drm_i915_private {
 	 */
 	struct workqueue_struct *wq;
 
+	/* Work queue for request completion processing */
+	struct workqueue_struct *req_wq;
+
 	/* Display functions */
 	struct drm_i915_display_funcs display;
 
@@ -2356,6 +2359,10 @@ struct drm_i915_gem_request {
 	 * Underlying object for implementing the signal/wait stuff.
 	 */
 	struct fence fence;
+	struct list_head signal_link;
+	bool cancelled;
+	bool irq_enabled;
+	bool signal_requested;
 
 	/** On Which ring this request was generated */
 	struct drm_i915_private *i915;
@@ -2457,6 +2464,9 @@ struct drm_i915_gem_request {
 struct drm_i915_gem_request * __must_check
 i915_gem_request_alloc(struct intel_engine_cs *engine,
 		       struct i915_gem_context *ctx);
+void i915_gem_request_notify(struct intel_engine_cs *ring, bool fence_locked,
+			     bool lazy_coherency);
+void i915_gem_request_worker(struct work_struct *work);
 
 static inline bool i915_gem_request_completed(struct drm_i915_gem_request *req)
 {
drivers/gpu/drm/i915/i915_gem.c +231 -19

356 lines not on this page · raw message

drivers/gpu/drm/i915/i915_irq.c +1 -1
index 72c04d6..8d1a28e 100644
@@ -982,7 +982,7 @@ static void notify_ring(struct intel_engine_cs *engine)
 	trace_i915_gem_request_notify(engine);
 	engine->user_interrupts++;
 
-	wake_up_all(&engine->irq_queue);
+	queue_work(engine->i915->req_wq, &engine->request_work);
 }
 
 static void vlv_c0_read(struct drm_i915_private *dev_priv,
drivers/gpu/drm/i915/intel_lrc.c +5 -0
index b59ef1e..6fbb05e 100644
@@ -1922,6 +1922,8 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *engine)
 
 	dev_priv = engine->i915;
 
+	cancel_work_sync(&engine->request_work);
+
 	if (engine->buffer) {
 		intel_logical_ring_stop(engine);
 		WARN_ON((I915_READ_MODE(engine) & MODE_IDLE) == 0);
@@ -2070,6 +2072,7 @@ logical_ring_setup(struct drm_device *dev, enum intel_engine_id id)
 
 	INIT_LIST_HEAD(&engine->active_list);
 	INIT_LIST_HEAD(&engine->request_list);
+	INIT_LIST_HEAD(&engine->fence_signal_list);
 	INIT_LIST_HEAD(&engine->buffers);
 	INIT_LIST_HEAD(&engine->execlist_queue);
 	spin_lock_init(&engine->execlist_lock);
@@ -2078,6 +2081,8 @@ logical_ring_setup(struct drm_device *dev, enum intel_engine_id id)
 	tasklet_init(&engine->irq_tasklet,
 		     intel_lrc_irq_handler, (unsigned long)engine);
 
+	INIT_WORK(&engine->request_work, i915_gem_request_worker);
+
 	logical_ring_init_platform_invariants(engine);
 	logical_ring_default_vfuncs(engine);
 	logical_ring_default_irqs(engine, info->irq_shift);
drivers/gpu/drm/i915/intel_ringbuffer.c +5 -0
index df36da7..b2aea2b 100644
@@ -2326,6 +2326,7 @@ static int intel_init_ring_buffer(struct drm_device *dev,
 	INIT_LIST_HEAD(&engine->request_list);
 	INIT_LIST_HEAD(&engine->execlist_queue);
 	INIT_LIST_HEAD(&engine->buffers);
+	INIT_LIST_HEAD(&engine->fence_signal_list);
 	spin_lock_init(&engine->fence_lock);
 	i915_gem_batch_pool_init(dev, &engine->batch_pool);
 	memset(engine->semaphore.sync_seqno, 0,
@@ -2333,6 +2334,8 @@ static int intel_init_ring_buffer(struct drm_device *dev,
 
 	init_waitqueue_head(&engine->irq_queue);
 
+	INIT_WORK(&engine->request_work, i915_gem_request_worker);
+
 	ringbuf = intel_engine_create_ringbuffer(engine, 32 * PAGE_SIZE);
 	if (IS_ERR(ringbuf)) {
 		ret = PTR_ERR(ringbuf);
@@ -2379,6 +2382,8 @@ void intel_cleanup_engine(struct intel_engine_cs *engine)
 
 	dev_priv = engine->i915;
 
+	cancel_work_sync(&engine->request_work);
+
 	if (engine->buffer) {
 		intel_stop_engine(engine);
 		WARN_ON(!IS_GEN2(dev_priv) && (I915_READ_MODE(engine) & MODE_IDLE) == 0);
drivers/gpu/drm/i915/intel_ringbuffer.h +7 -3
index 01f3df6..9e79fbd 100644
@@ -347,11 +347,15 @@ struct intel_engine_cs {
 	u32 (*get_cmd_length_mask)(u32 cmd_header);
 
 	/*
-	 * This spinlock is used by the fence implementation internally. Note,
-	 * it can be acquire from interrupt context so all usage must be IRQ
-	 * safe.
+	 * This spinlock is used by the fence implementation internally and by
+	 * the i915 driver for operations on the fence_signal_list and on fences
+	 * in general. Note, it can be acquire from interrupt context so all
+	 * usage must be IRQ safe.
 	 */
 	spinlock_t fence_lock;
+	struct list_head fence_signal_list;
+
+	struct work_struct request_work;
 };
 
 static inline bool
Signature · 6 lines
1.9.1

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

Re: [PATCH v10b 4/6] drm/i915: Interrupt driven fences

Quoted 106 lines · On 17/06/16 12:05, [email protected] wrote:

From: John Harrison <[email protected]>

The intended usage model for struct fence is that the signalled status should be set on demand rather than polled. That is, there should not be a need for a 'signaled' function to be called everytime the status is queried. Instead, 'something' should be done to enable a signal callback from the hardware which will update the state directly. In the case of requests, this is the seqno update interrupt. The idea is that this callback will only be enabled on demand when something actually tries to wait on the fence.

This change removes the polling test and replaces it with the callback scheme. Each fence is added to a 'please poke me' list at the start of i915_add_request(). The interrupt handler (via a deferred work queue) then scans through the 'poke me' list when a new seqno pops out and signals any matching fence/request. The fence is then removed from the list so the entire request stack does not need to be scanned every time. The fence is added to the list before the commands to generate the seqno interrupt are added to the ring. Thus the sequence is guaranteed to be race free if the interrupt is already enabled.

Note that the interrupt is only enabled on demand (i.e. when __wait_request() is called). Thus there is still a potential race when enabling the interrupt as the request may already have completed. However, this is simply solved by calling the interrupt processing code immediately after enabling the interrupt and thereby checking for already completed requests.

Lastly, the ring clean up code has the possibility to cancel outstanding requests (e.g. because TDR has reset the ring). These requests will never get signalled and so must be removed from the signal list manually. This is done by setting a 'cancelled' flag and then calling the regular notify/retire code path rather than attempting to duplicate the list manipulatation and clean up code in multiple places. This also avoids any race condition where the cancellation request might occur after/during the completion interrupt actually arriving.

v2: Updated to take advantage of the request unreference no longer requiring the mutex lock.

v3: Move the signal list processing around to prevent unsubmitted requests being added to the list. This was occurring on Android because the native sync implementation calls the fence->enable_signalling API immediately on fence creation.

Updated after review comments by Tvrtko Ursulin. Renamed list nodes to 'link' instead of 'list'. Added support for returning an error code on a cancelled fence. Update list processing to be more efficient/safer with respect to spinlocks.

v5: Made i915_gem_request_submit a static as it is only ever called from one place.

Fixed up the low latency wait optimisation. The time delay between the seqno value being to memory and the drive's ISR running can be significant, at least for the wait request micro-benchmark. This can be greatly improved by explicitly checking for seqno updates in the pre-wait busy poll loop. Also added some documentation comments to the busy poll code.

Fixed up support for the faking of lost interrupts (test_irq_rings/missed_irq_rings). That is, there is an IGT test that tells the driver to loose interrupts deliberately and then check that everything still works as expected (albeit much slower).

Updates from review comments: use non IRQ-save spinlocking, early exit on WARN and improved comments (Tvrtko Ursulin).

v6: Updated to newer nigthly and resolved conflicts around the wait_request busy spin optimisation. Also fixed a race condition between this early exit path and the regular completion path.

v7: Updated to newer nightly - lots of ring -> engine renaming plus an interface change on get_seqno(). Also added a list_empty() check before acquring spinlocks and doing list processing.

v8: Updated to newer nightly - changes to request clean up code mean non of the deferred free mess is needed any more.

v9: Moved the request completion processing out of the interrupt handler and into a worker thread (Chris Wilson).

v10: Changed to an un-ordered work queue to allow parallel processing of different engines. Also set the high priority flag for reduced latency. Removed some unnecessary checks for invalid seqno values. Improved/added some comments and WARNs. Moved a spinlock release a few lines later to make the 'locked' parameter of i915_gem_request_enable_interrupt redundant and removed it. Also shuffled the function around in the file so as to make it static and remove it from the header file. Corrected the use of fence_signal_locked() to fence_signal() in the retire code. Dropped the irq save part of the spin lock calls in the notify code as this is no longer called from the ISR. Changed the call of i915_gem_retire_requests_ring() in the reset cleanup code to i915_gem_request_notify() instead as the former is just duplicating a lot of operations.
[Review comments from Maarten Lankhorst & Tvrtko Ursulin]

Made the call to _notify() from _retire_requests_ring() conditional on interrupts not being enabled as it is only a race condition work around for that case. Also re-instated the lazy_coherency flag (but now on the _notify() function) to reduce the overhead of _retire_requests_ring() calling _notify() lots and lots (even with the anti-interrupt check).

Quoted 6 lines

Updated for yet more nightly changes (u64 for fence context).

v10b: Re-ordered the fence signal and IRQ release in _notify() to fix a race condition when disabling interrupts. Also, moved the wake_up_all() call from the IRQ handler to the worker thread to prevent the wake up of waiting threads from overtaking the signalling of the request.

I was concerned by the second part of this change which will increase the wake-up latency for the waiters and has asked John do do some quick low-level (gem_latency) testing.

Preliminary results were a bit strange with small batches experiencing the expected slowdown but large one being significantly faster.

Since he is out this week I will try and run some more benchmarks on this.

To re-iterate, concern is moving the wake_up_all(&engine->irq_queue) from notify_ring (hard irq) to the fence notify worker. This adds one additional scheduling wakeup latency to the waiters which use the i915 API.

Regards,

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

#9 lore raw

Re: [PATCH v10b 4/6] drm/i915: Interrupt driven fences

Quoted 120 lines · Tvrtko Ursulin
Quoted 106 lines · On 17/06/16 12:05, [email protected] wrote:

From: John Harrison <[email protected]>

The intended usage model for struct fence is that the signalled status should be set on demand rather than polled. That is, there should not be a need for a 'signaled' function to be called everytime the status is queried. Instead, 'something' should be done to enable a signal callback from the hardware which will update the state directly. In the case of requests, this is the seqno update interrupt. The idea is that this callback will only be enabled on demand when something actually tries to wait on the fence.

This change removes the polling test and replaces it with the callback scheme. Each fence is added to a 'please poke me' list at the start of i915_add_request(). The interrupt handler (via a deferred work queue) then scans through the 'poke me' list when a new seqno pops out and signals any matching fence/request. The fence is then removed from the list so the entire request stack does not need to be scanned every time. The fence is added to the list before the commands to generate the seqno interrupt are added to the ring. Thus the sequence is guaranteed to be race free if the interrupt is already enabled.

Note that the interrupt is only enabled on demand (i.e. when __wait_request() is called). Thus there is still a potential race when enabling the interrupt as the request may already have completed. However, this is simply solved by calling the interrupt processing code immediately after enabling the interrupt and thereby checking for already completed requests.

Lastly, the ring clean up code has the possibility to cancel outstanding requests (e.g. because TDR has reset the ring). These requests will never get signalled and so must be removed from the signal list manually. This is done by setting a 'cancelled' flag and then calling the regular notify/retire code path rather than attempting to duplicate the list manipulatation and clean up code in multiple places. This also avoids any race condition where the cancellation request might occur after/during the completion interrupt actually arriving.

v2: Updated to take advantage of the request unreference no longer requiring the mutex lock.

v3: Move the signal list processing around to prevent unsubmitted requests being added to the list. This was occurring on Android because the native sync implementation calls the fence->enable_signalling API immediately on fence creation.

Updated after review comments by Tvrtko Ursulin. Renamed list nodes to 'link' instead of 'list'. Added support for returning an error code on a cancelled fence. Update list processing to be more efficient/safer with respect to spinlocks.

v5: Made i915_gem_request_submit a static as it is only ever called from one place.

Fixed up the low latency wait optimisation. The time delay between the seqno value being to memory and the drive's ISR running can be significant, at least for the wait request micro-benchmark. This can be greatly improved by explicitly checking for seqno updates in the pre-wait busy poll loop. Also added some documentation comments to the busy poll code.

Fixed up support for the faking of lost interrupts (test_irq_rings/missed_irq_rings). That is, there is an IGT test that tells the driver to loose interrupts deliberately and then check that everything still works as expected (albeit much slower).

Updates from review comments: use non IRQ-save spinlocking, early exit on WARN and improved comments (Tvrtko Ursulin).

v6: Updated to newer nigthly and resolved conflicts around the wait_request busy spin optimisation. Also fixed a race condition between this early exit path and the regular completion path.

v7: Updated to newer nightly - lots of ring -> engine renaming plus an interface change on get_seqno(). Also added a list_empty() check before acquring spinlocks and doing list processing.

v8: Updated to newer nightly - changes to request clean up code mean non of the deferred free mess is needed any more.

v9: Moved the request completion processing out of the interrupt handler and into a worker thread (Chris Wilson).

v10: Changed to an un-ordered work queue to allow parallel processing of different engines. Also set the high priority flag for reduced latency. Removed some unnecessary checks for invalid seqno values. Improved/added some comments and WARNs. Moved a spinlock release a few lines later to make the 'locked' parameter of i915_gem_request_enable_interrupt redundant and removed it. Also shuffled the function around in the file so as to make it static and remove it from the header file. Corrected the use of fence_signal_locked() to fence_signal() in the retire code. Dropped the irq save part of the spin lock calls in the notify code as this is no longer called from the ISR. Changed the call of i915_gem_retire_requests_ring() in the reset cleanup code to i915_gem_request_notify() instead as the former is just duplicating a lot of operations.
[Review comments from Maarten Lankhorst & Tvrtko Ursulin]

Made the call to _notify() from _retire_requests_ring() conditional on interrupts not being enabled as it is only a race condition work around for that case. Also re-instated the lazy_coherency flag (but now on the _notify() function) to reduce the overhead of _retire_requests_ring() calling _notify() lots and lots (even with the anti-interrupt check).

Quoted 7 lines

Updated for yet more nightly changes (u64 for fence context).

v10b: Re-ordered the fence signal and IRQ release in _notify() to fix a race
condition when disabling interrupts. Also, moved the wake_up_all() call from the IRQ handler to the worker thread to prevent the wake up of waiting threads from overtaking the signalling of the request.

I was concerned by the second part of this change which will increase the wake-up latency for the waiters and has asked John do do some quick low-level (gem_latency) testing.

Quoted 8 lines

Preliminary results were a bit strange with small batches experiencing the expected slowdown but large one being significantly faster.

Since he is out this week I will try and run some more benchmarks on this.

To re-iterate, concern is moving the wake_up_all(&engine->irq_queue) from notify_ring (hard irq) to the fence notify worker. This adds one additional scheduling wakeup latency to the waiters which use the i915 API.

Okay, benchmarking is done and good news first.

SynMark2 and GfxBench show probably only noise on almost all tests. What regresses is OglBatch[567] between 2-5%, OglMultithread by 10%, OglDrvState by 2% and OglDrvCtx by 30%.

As far as I remember those are not important in general so that is good.

But as expected low-level testing with gem_latency, with three sets of batches, zero length, 100 NOPs and 1000 NOPs show on average 5-6% less throughput and around 18% worse wakeup latency.

Regards,

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

#10 lore raw

Re: [PATCH v10b 4/6] drm/i915: Interrupt driven fences

Quoted 135 lines · Tvrtko Ursulin
Quoted 120 lines · Tvrtko Ursulin
Quoted 106 lines · On 17/06/16 12:05, [email protected] wrote:

From: John Harrison <[email protected]>

The intended usage model for struct fence is that the signalled status should be set on demand rather than polled. That is, there should not be a need for a 'signaled' function to be called everytime the status is queried. Instead, 'something' should be done to enable a signal callback from the hardware which will update the state directly. In the case of requests, this is the seqno update interrupt. The idea is that this callback will only be enabled on demand when something actually tries to wait on the fence.

This change removes the polling test and replaces it with the callback scheme. Each fence is added to a 'please poke me' list at the start of i915_add_request(). The interrupt handler (via a deferred work queue) then scans through the 'poke me' list when a new seqno pops out and signals any matching fence/request. The fence is then removed from the list so the entire request stack does not need to be scanned every time. The fence is added to the list before the commands to generate the seqno interrupt are added to the ring. Thus the sequence is guaranteed to be race free if the interrupt is already enabled.

Note that the interrupt is only enabled on demand (i.e. when __wait_request() is called). Thus there is still a potential race when enabling the interrupt as the request may already have completed. However, this is simply solved by calling the interrupt processing code immediately after enabling the interrupt and thereby checking for already completed requests.

Lastly, the ring clean up code has the possibility to cancel outstanding requests (e.g. because TDR has reset the ring). These requests will never get signalled and so must be removed from the signal list manually. This is done by setting a 'cancelled' flag and then calling the regular notify/retire code path rather than attempting to duplicate the list manipulatation and clean up code in multiple places. This also avoids any race condition where the cancellation request might occur after/during the completion interrupt actually arriving.

v2: Updated to take advantage of the request unreference no longer requiring the mutex lock.

v3: Move the signal list processing around to prevent unsubmitted requests being added to the list. This was occurring on Android because the native sync implementation calls the fence->enable_signalling API immediately on fence creation.

Updated after review comments by Tvrtko Ursulin. Renamed list nodes to 'link' instead of 'list'. Added support for returning an error code on a cancelled fence. Update list processing to be more efficient/safer with respect to spinlocks.

v5: Made i915_gem_request_submit a static as it is only ever called from one place.

Fixed up the low latency wait optimisation. The time delay between the seqno value being to memory and the drive's ISR running can be significant, at least for the wait request micro-benchmark. This can be greatly improved by explicitly checking for seqno updates in the pre-wait busy poll loop. Also added some documentation comments to the busy poll code.

Fixed up support for the faking of lost interrupts (test_irq_rings/missed_irq_rings). That is, there is an IGT test that tells the driver to loose interrupts deliberately and then check that everything still works as expected (albeit much slower).

Updates from review comments: use non IRQ-save spinlocking, early exit on WARN and improved comments (Tvrtko Ursulin).

v6: Updated to newer nigthly and resolved conflicts around the wait_request busy spin optimisation. Also fixed a race condition between this early exit path and the regular completion path.

v7: Updated to newer nightly - lots of ring -> engine renaming plus an interface change on get_seqno(). Also added a list_empty() check before acquring spinlocks and doing list processing.

v8: Updated to newer nightly - changes to request clean up code mean non of the deferred free mess is needed any more.

v9: Moved the request completion processing out of the interrupt handler and into a worker thread (Chris Wilson).

v10: Changed to an un-ordered work queue to allow parallel processing of different engines. Also set the high priority flag for reduced latency. Removed some unnecessary checks for invalid seqno values. Improved/added some comments and WARNs. Moved a spinlock release a few lines later to make the 'locked' parameter of i915_gem_request_enable_interrupt redundant and removed it. Also shuffled the function around in the file so as to make it static and remove it from the header file. Corrected the use of fence_signal_locked() to fence_signal() in the retire code. Dropped the irq save part of the spin lock calls in the notify code as this is no longer called from the ISR. Changed the call of i915_gem_retire_requests_ring() in the reset cleanup code to i915_gem_request_notify() instead as the former is just duplicating a lot of operations.
[Review comments from Maarten Lankhorst & Tvrtko Ursulin]

Made the call to _notify() from _retire_requests_ring() conditional on interrupts not being enabled as it is only a race condition work around for that case. Also re-instated the lazy_coherency flag (but now on the _notify() function) to reduce the overhead of _retire_requests_ring() calling _notify() lots and lots (even with the anti-interrupt check).

Quoted 7 lines

Updated for yet more nightly changes (u64 for fence context).

v10b: Re-ordered the fence signal and IRQ release in _notify() to fix a race
condition when disabling interrupts. Also, moved the wake_up_all() call from the IRQ handler to the worker thread to prevent the wake up of waiting threads from overtaking the signalling of the request.

I was concerned by the second part of this change which will increase the wake-up latency for the waiters and has asked John do do some quick low-level (gem_latency) testing.

Quoted 8 lines

Preliminary results were a bit strange with small batches experiencing the expected slowdown but large one being significantly faster.

Since he is out this week I will try and run some more benchmarks on this.

To re-iterate, concern is moving the wake_up_all(&engine->irq_queue) from notify_ring (hard irq) to the fence notify worker. This adds one additional scheduling wakeup latency to the waiters which use the i915 API.

Okay, benchmarking is done and good news first.

SynMark2 and GfxBench show probably only noise on almost all tests. What regresses is OglBatch[567] between 2-5%, OglMultithread by 10%, OglDrvState by 2% and OglDrvCtx by 30%.

Quoted 7 lines

As far as I remember those are not important in general so that is good.

But as expected low-level testing with gem_latency, with three sets of batches, zero length, 100 NOPs and 1000 NOPs show on average 5-6% less throughput and around 18% worse wakeup latency.

Regards,

Tvrtko

Have only done a brief test so far but moving the wake up earlier again seems to fix the latency problems.

Maarten, do you have any other comments to add on this patch? If I repost it with Tvrtko's issues resolved will you be happy to r-b it?

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

#11 lore raw

PATCH v10 4/6 drm/i915: Interrupt driven fences

From: John Harrison <[email protected]>

The intended usage model for struct fence is that the signalled status should be set on demand rather than polled. That is, there should not be a need for a 'signaled' function to be called everytime the status is queried. Instead, 'something' should be done to enable a signal callback from the hardware which will update the state directly. In the case of requests, this is the seqno update interrupt. The idea is that this callback will only be enabled on demand when something actually tries to wait on the fence.

This change removes the polling test and replaces it with the callback scheme. Each fence is added to a 'please poke me' list at the start of i915_add_request(). The interrupt handler (via a deferred work queue) then scans through the 'poke me' list when a new seqno pops out and signals any matching fence/request. The fence is then removed from the list so the entire request stack does not need to be scanned every time. The fence is added to the list before the commands to generate the seqno interrupt are added to the ring. Thus the sequence is guaranteed to be race free if the interrupt is already enabled.

Note that the interrupt is only enabled on demand (i.e. when __wait_request() is called). Thus there is still a potential race when enabling the interrupt as the request may already have completed. However, this is simply solved by calling the interrupt processing code immediately after enabling the interrupt and thereby checking for already completed requests.

Lastly, the ring clean up code has the possibility to cancel outstanding requests (e.g. because TDR has reset the ring). These requests will never get signalled and so must be removed from the signal list manually. This is done by setting a 'cancelled' flag and then calling the regular notify/retire code path rather than attempting to duplicate the list manipulatation and clean up code in multiple places. This also avoids any race condition where the cancellation request might occur after/during the completion interrupt actually arriving.

v2: Updated to take advantage of the request unreference no longer requiring the mutex lock.

v3: Move the signal list processing around to prevent unsubmitted requests being added to the list. This was occurring on Android because the native sync implementation calls the fence->enable_signalling API immediately on fence creation.

Updated after review comments by Tvrtko Ursulin. Renamed list nodes to 'link' instead of 'list'. Added support for returning an error code on a cancelled fence. Update list processing to be more efficient/safer with respect to spinlocks.

v5: Made i915_gem_request_submit a static as it is only ever called from one place.

Fixed up the low latency wait optimisation. The time delay between the seqno value being to memory and the drive's ISR running can be significant, at least for the wait request micro-benchmark. This can be greatly improved by explicitly checking for seqno updates in the pre-wait busy poll loop. Also added some documentation comments to the busy poll code.

Fixed up support for the faking of lost interrupts (test_irq_rings/missed_irq_rings). That is, there is an IGT test that tells the driver to loose interrupts deliberately and then check that everything still works as expected (albeit much slower).

Updates from review comments: use non IRQ-save spinlocking, early exit on WARN and improved comments (Tvrtko Ursulin).

v6: Updated to newer nigthly and resolved conflicts around the wait_request busy spin optimisation. Also fixed a race condition between this early exit path and the regular completion path.

v7: Updated to newer nightly - lots of ring -> engine renaming plus an interface change on get_seqno(). Also added a list_empty() check before acquring spinlocks and doing list processing.

v8: Updated to newer nightly - changes to request clean up code mean non of the deferred free mess is needed any more.

v9: Moved the request completion processing out of the interrupt handler and into a worker thread (Chris Wilson).

v10: Changed to an un-ordered work queue to allow parallel processing of different engines. Also set the high priority flag for reduced latency. Removed some unnecessary checks for invalid seqno values. Improved/added some comments and WARNs. Moved a spinlock release a few lines later to make the 'locked' parameter of i915_gem_request_enable_interrupt redundant and removed it. Also shuffled the function around in the file so as to make it static and remove it from the header file. Corrected the use of fence_signal_locked() to fence_signal() in the retire code. Dropped the irq save part of the spin lock calls in the notify code as this is no longer called from the ISR. Changed the call of i915_gem_retire_requests_ring() in the reset cleanup code to i915_gem_request_notify() instead as the former is just duplicating a lot of operations.
[Review comments from Maarten Lankhorst & Tvrtko Ursulin]

Made the call to _notify() from _retire_requests_ring() conditional on interrupts not being enabled as it is only a race condition work around for that case. Also re-instated the lazy_coherency flag (but now on the _notify() function) to reduce the overhead of _retire_requests_ring() calling _notify() lots and lots (even with the anti-interrupt check).

Updated for yet more nightly changes (u64 for fence context).

v10b: Re-ordered the fence signal and IRQ release in _notify() to fix a race condition when disabling interrupts. Also, moved the wake_up_all() call from the IRQ handler to the worker thread to prevent the wake up of waiting threads from overtaking the signalling of the request.

v10c: Put the wake_up_all() back into the IRQ handler to fix regression in gem_latency times (IGT benchmark).

For: VIZ-5190

Cc Tvrtko Ursulin <[email protected]>
Cc Maarten Lankhorst <[email protected]>
---
 drivers/gpu/drm/i915/i915_dma.c         |  14 +-
 drivers/gpu/drm/i915/i915_drv.h         |  10 ++
 drivers/gpu/drm/i915/i915_gem.c         | 250 +++++++++++++++++++++++++++++---
 drivers/gpu/drm/i915/i915_irq.c         |   2 +
 drivers/gpu/drm/i915/intel_lrc.c        |   5 +
 drivers/gpu/drm/i915/intel_ringbuffer.c |   5 +
 drivers/gpu/drm/i915/intel_ringbuffer.h |  10 +-
 7 files changed, 273 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +13 -1
index 07edaed..298d447 100644
@@ -1019,9 +1019,18 @@ static int i915_workqueues_init(struct drm_i915_private *dev_priv)
 	if (dev_priv->wq == NULL)
 		goto out_err;
 
+	/*
+	 * Making this work queue un-ordered means that request notifications
+	 * for different engines can be processed in parallel across multiple
+	 * CPU cores (if available).
+	 */
+	dev_priv->req_wq = alloc_workqueue("i915-rq", WQ_HIGHPRI, I915_NUM_ENGINES);
+	if (dev_priv->req_wq == NULL)
+		goto out_free_wq;
+
 	dev_priv->hotplug.dp_wq = alloc_ordered_workqueue("i915-dp", 0);
 	if (dev_priv->hotplug.dp_wq == NULL)
-		goto out_free_wq;
+		goto out_free_req_wq;
 
 	dev_priv->gpu_error.hangcheck_wq =
 		alloc_ordered_workqueue("i915-hangcheck", 0);
@@ -1032,6 +1041,8 @@ static int i915_workqueues_init(struct drm_i915_private *dev_priv)
 
 out_free_dp_wq:
 	destroy_workqueue(dev_priv->hotplug.dp_wq);
+out_free_req_wq:
+	destroy_workqueue(dev_priv->req_wq);
 out_free_wq:
 	destroy_workqueue(dev_priv->wq);
 out_err:
@@ -1044,6 +1055,7 @@ static void i915_workqueues_cleanup(struct drm_i915_private *dev_priv)
 {
 	destroy_workqueue(dev_priv->gpu_error.hangcheck_wq);
 	destroy_workqueue(dev_priv->hotplug.dp_wq);
+	destroy_workqueue(dev_priv->req_wq);
 	destroy_workqueue(dev_priv->wq);
 }
 
drivers/gpu/drm/i915/i915_drv.h +10 -0
index d753457..8a26db5 100644
@@ -1849,6 +1849,9 @@ struct drm_i915_private {
 	 */
 	struct workqueue_struct *wq;
 
+	/* Work queue for request completion processing */
+	struct workqueue_struct *req_wq;
+
 	/* Display functions */
 	struct drm_i915_display_funcs display;
 
@@ -2356,6 +2359,10 @@ struct drm_i915_gem_request {
 	 * Underlying object for implementing the signal/wait stuff.
 	 */
 	struct fence fence;
+	struct list_head signal_link;
+	bool cancelled;
+	bool irq_enabled;
+	bool signal_requested;
 
 	/** On Which ring this request was generated */
 	struct drm_i915_private *i915;
@@ -2457,6 +2464,9 @@ struct drm_i915_gem_request {
 struct drm_i915_gem_request * __must_check
 i915_gem_request_alloc(struct intel_engine_cs *engine,
 		       struct i915_gem_context *ctx);
+void i915_gem_request_notify(struct intel_engine_cs *ring, bool fence_locked,
+			     bool lazy_coherency);
+void i915_gem_request_worker(struct work_struct *work);
 
 static inline bool i915_gem_request_completed(struct drm_i915_gem_request *req)
 {
drivers/gpu/drm/i915/i915_gem.c +231 -19

356 lines not on this page · raw message

drivers/gpu/drm/i915/i915_irq.c +2 -0
index 72c04d6..c5024e7 100644
@@ -982,6 +982,8 @@ static void notify_ring(struct intel_engine_cs *engine)
 	trace_i915_gem_request_notify(engine);
 	engine->user_interrupts++;
 
+	queue_work(engine->i915->req_wq, &engine->request_work);
+
 	wake_up_all(&engine->irq_queue);
 }
 
drivers/gpu/drm/i915/intel_lrc.c +5 -0
index b59ef1e..6fbb05e 100644
@@ -1922,6 +1922,8 @@ void intel_logical_ring_cleanup(struct intel_engine_cs *engine)
 
 	dev_priv = engine->i915;
 
+	cancel_work_sync(&engine->request_work);
+
 	if (engine->buffer) {
 		intel_logical_ring_stop(engine);
 		WARN_ON((I915_READ_MODE(engine) & MODE_IDLE) == 0);
@@ -2070,6 +2072,7 @@ logical_ring_setup(struct drm_device *dev, enum intel_engine_id id)
 
 	INIT_LIST_HEAD(&engine->active_list);
 	INIT_LIST_HEAD(&engine->request_list);
+	INIT_LIST_HEAD(&engine->fence_signal_list);
 	INIT_LIST_HEAD(&engine->buffers);
 	INIT_LIST_HEAD(&engine->execlist_queue);
 	spin_lock_init(&engine->execlist_lock);
@@ -2078,6 +2081,8 @@ logical_ring_setup(struct drm_device *dev, enum intel_engine_id id)
 	tasklet_init(&engine->irq_tasklet,
 		     intel_lrc_irq_handler, (unsigned long)engine);
 
+	INIT_WORK(&engine->request_work, i915_gem_request_worker);
+
 	logical_ring_init_platform_invariants(engine);
 	logical_ring_default_vfuncs(engine);
 	logical_ring_default_irqs(engine, info->irq_shift);
drivers/gpu/drm/i915/intel_ringbuffer.c +5 -0
index df36da7..b2aea2b 100644
@@ -2326,6 +2326,7 @@ static int intel_init_ring_buffer(struct drm_device *dev,
 	INIT_LIST_HEAD(&engine->request_list);
 	INIT_LIST_HEAD(&engine->execlist_queue);
 	INIT_LIST_HEAD(&engine->buffers);
+	INIT_LIST_HEAD(&engine->fence_signal_list);
 	spin_lock_init(&engine->fence_lock);
 	i915_gem_batch_pool_init(dev, &engine->batch_pool);
 	memset(engine->semaphore.sync_seqno, 0,
@@ -2333,6 +2334,8 @@ static int intel_init_ring_buffer(struct drm_device *dev,
 
 	init_waitqueue_head(&engine->irq_queue);
 
+	INIT_WORK(&engine->request_work, i915_gem_request_worker);
+
 	ringbuf = intel_engine_create_ringbuffer(engine, 32 * PAGE_SIZE);
 	if (IS_ERR(ringbuf)) {
 		ret = PTR_ERR(ringbuf);
@@ -2379,6 +2382,8 @@ void intel_cleanup_engine(struct intel_engine_cs *engine)
 
 	dev_priv = engine->i915;
 
+	cancel_work_sync(&engine->request_work);
+
 	if (engine->buffer) {
 		intel_stop_engine(engine);
 		WARN_ON(!IS_GEN2(dev_priv) && (I915_READ_MODE(engine) & MODE_IDLE) == 0);
drivers/gpu/drm/i915/intel_ringbuffer.h +7 -3
index 01f3df6..9e79fbd 100644
@@ -347,11 +347,15 @@ struct intel_engine_cs {
 	u32 (*get_cmd_length_mask)(u32 cmd_header);
 
 	/*
-	 * This spinlock is used by the fence implementation internally. Note,
-	 * it can be acquire from interrupt context so all usage must be IRQ
-	 * safe.
+	 * This spinlock is used by the fence implementation internally and by
+	 * the i915 driver for operations on the fence_signal_list and on fences
+	 * in general. Note, it can be acquire from interrupt context so all
+	 * usage must be IRQ safe.
 	 */
 	spinlock_t fence_lock;
+	struct list_head fence_signal_list;
+
+	struct work_struct request_work;
 };
 
 static inline bool
Signature · 6 lines
1.9.1

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

PATCH v10 5/6 drm/i915: Updated request structure tracing

In reply to [email protected]

From: John Harrison <[email protected]>

Added the '_complete' trace event which occurs when a fence/request is signaled as complete. Also moved the notify event from the IRQ handler code to inside the notify function itself.

v3: Added the current ring seqno to the notify trace point.

v5: Line wrapping to keep the style checker happy.

v7: Updated to newer nightly (lots of ring -> engine renaming).

v10: Dropped the 'is_empty' flag from trace_i915_gem_request_notify() as it is now redundant - 'seqno == 0' is equivalent. [Review comments from Tvrtko Ursulin]

For: VIZ-5190

---
 drivers/gpu/drm/i915/i915_gem.c   | 9 +++++++--
 drivers/gpu/drm/i915/i915_irq.c   | 1 -
 drivers/gpu/drm/i915/i915_trace.h | 6 +++---
 3 files changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +7 -2
index a2c761b..d7b88b1 100644
@@ -2967,8 +2967,10 @@ void i915_gem_request_notify(struct intel_engine_cs *engine, bool fence_locked,
 	 * not-empty. And a false not-empty is not an issue - it would just be
 	 * the same as not doing the early exit test at all.
 	 */
-	if (list_empty(&engine->fence_signal_list))
+	if (list_empty(&engine->fence_signal_list)) {
+		trace_i915_gem_request_notify(engine, 0);
 		return;
+	}
 
 	if (!fence_locked)
 		spin_lock_irq(&engine->fence_lock);
@@ -2976,6 +2978,7 @@ void i915_gem_request_notify(struct intel_engine_cs *engine, bool fence_locked,
 	if (!lazy_coherency && engine->irq_seqno_barrier)
 		engine->irq_seqno_barrier(engine);
 	seqno = engine->get_seqno(engine);
+	trace_i915_gem_request_notify(engine, seqno);
 
 	list_for_each_entry_safe(req, req_next, &engine->fence_signal_list, signal_link) {
 		if (!req->cancelled && !i915_seqno_passed(seqno, req->seqno))
@@ -2987,8 +2990,10 @@ void i915_gem_request_notify(struct intel_engine_cs *engine, bool fence_locked,
 		 */
 		list_del_init(&req->signal_link);
 
-		if (!req->cancelled)
+		if (!req->cancelled) {
 			fence_signal_locked(&req->fence);
+			trace_i915_gem_request_complete(req);
+		}
 
 		if (req->irq_enabled) {
 			req->engine->irq_put(req->engine);
drivers/gpu/drm/i915/i915_irq.c +0 -1
index c5024e7..57b4ac8 100644
@@ -979,7 +979,6 @@ static void notify_ring(struct intel_engine_cs *engine)
 	if (!intel_engine_initialized(engine))
 		return;
 
-	trace_i915_gem_request_notify(engine);
 	engine->user_interrupts++;
 
 	queue_work(engine->i915->req_wq, &engine->request_work);
drivers/gpu/drm/i915/i915_trace.h +3 -3
index 6768db0..ef4c573 100644
@@ -546,8 +546,8 @@ DEFINE_EVENT(i915_gem_request, i915_gem_request_add,
 );
 
 TRACE_EVENT(i915_gem_request_notify,
-	    TP_PROTO(struct intel_engine_cs *engine),
-	    TP_ARGS(engine),
+	    TP_PROTO(struct intel_engine_cs *engine, uint32_t seqno),
+	    TP_ARGS(engine, seqno),
 
 	    TP_STRUCT__entry(
 			     __field(u32, dev)
@@ -558,7 +558,7 @@ TRACE_EVENT(i915_gem_request_notify,
 	    TP_fast_assign(
 			   __entry->dev = engine->i915->dev->primary->index;
 			   __entry->ring = engine->id;
-			   __entry->seqno = engine->get_seqno(engine);
+			   __entry->seqno = seqno;
 			   ),
 
 	    TP_printk("dev=%u, ring=%u, seqno=%u",
Signature · 6 lines
1.9.1

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

PATCH v10 5/6 drm/i915: Updated request structure tracing

From: John Harrison <[email protected]>

Added the '_complete' trace event which occurs when a fence/request is signaled as complete. Also moved the notify event from the IRQ handler code to inside the notify function itself.

v3: Added the current ring seqno to the notify trace point.

v5: Line wrapping to keep the style checker happy.

v7: Updated to newer nightly (lots of ring -> engine renaming).

v10: Dropped the 'is_empty' flag from trace_i915_gem_request_notify() as it is now redundant - 'seqno == 0' is equivalent. [Review comments from Tvrtko Ursulin]

v10b: Re-based due to change in previous patch.

For: VIZ-5190

---
 drivers/gpu/drm/i915/i915_gem.c   | 9 +++++++--
 drivers/gpu/drm/i915/i915_irq.c   | 1 -
 drivers/gpu/drm/i915/i915_trace.h | 6 +++---
 3 files changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +7 -2
index 866afef..a876a65 100644
@@ -2969,8 +2969,10 @@ void i915_gem_request_notify(struct intel_engine_cs *engine, bool fence_locked,
 	 * not-empty. And a false not-empty is not an issue - it would just be
 	 * the same as not doing the early exit test at all.
 	 */
-	if (list_empty(&engine->fence_signal_list))
+	if (list_empty(&engine->fence_signal_list)) {
+		trace_i915_gem_request_notify(engine, 0);
 		return;
+	}
 
 	if (!fence_locked)
 		spin_lock_irq(&engine->fence_lock);
@@ -2978,6 +2980,7 @@ void i915_gem_request_notify(struct intel_engine_cs *engine, bool fence_locked,
 	if (!lazy_coherency && engine->irq_seqno_barrier)
 		engine->irq_seqno_barrier(engine);
 	seqno = engine->get_seqno(engine);
+	trace_i915_gem_request_notify(engine, seqno);
 
 	list_for_each_entry_safe(req, req_next, &engine->fence_signal_list, signal_link) {
 		if (!req->cancelled && !i915_seqno_passed(seqno, req->seqno))
@@ -2994,8 +2997,10 @@ void i915_gem_request_notify(struct intel_engine_cs *engine, bool fence_locked,
 			req->irq_enabled = false;
 		}
 
-		if (!req->cancelled)
+		if (!req->cancelled) {
 			fence_signal_locked(&req->fence);
+			trace_i915_gem_request_complete(req);
+		}
 
 		i915_gem_request_unreference(req);
 	}
drivers/gpu/drm/i915/i915_irq.c +0 -1
index 8d1a28e..b994266 100644
@@ -979,7 +979,6 @@ static void notify_ring(struct intel_engine_cs *engine)
 	if (!intel_engine_initialized(engine))
 		return;
 
-	trace_i915_gem_request_notify(engine);
 	engine->user_interrupts++;
 
 	queue_work(engine->i915->req_wq, &engine->request_work);
drivers/gpu/drm/i915/i915_trace.h +3 -3
index 6768db0..ef4c573 100644
@@ -546,8 +546,8 @@ DEFINE_EVENT(i915_gem_request, i915_gem_request_add,
 );
 
 TRACE_EVENT(i915_gem_request_notify,
-	    TP_PROTO(struct intel_engine_cs *engine),
-	    TP_ARGS(engine),
+	    TP_PROTO(struct intel_engine_cs *engine, uint32_t seqno),
+	    TP_ARGS(engine, seqno),
 
 	    TP_STRUCT__entry(
 			     __field(u32, dev)
@@ -558,7 +558,7 @@ TRACE_EVENT(i915_gem_request_notify,
 	    TP_fast_assign(
 			   __entry->dev = engine->i915->dev->primary->index;
 			   __entry->ring = engine->id;
-			   __entry->seqno = engine->get_seqno(engine);
+			   __entry->seqno = seqno;
 			   ),
 
 	    TP_printk("dev=%u, ring=%u, seqno=%u",
Signature · 6 lines
1.9.1

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

PATCH v10 6/6 drm/i915: Cache last IRQ seqno to reduce IRQ overhead

In reply to [email protected]

From: John Harrison <[email protected]>

The notify function can be called many times without the seqno changing. Some are to prevent races due to the requirement of not enabling interrupts until requested. However, when interrupts are enabled the IRQ handler can be called multiple times without the ring's seqno value changing. E.g. two interrupts are generated by batch buffers completing in quick succession, the first call to the handler processes both completions but the handler still gets executed a second time. This patch reduces the overhead of these extra calls by caching the last processed seqno value and early exiting if it has not changed.

v3: New patch for series.

v5: Added comment about last_irq_seqno usage due to code review feedback (Tvrtko Ursulin).

v6: Minor update to resolve a race condition with the wait_request optimisation.

v7: Updated to newer nightly - lots of ring -> engine renaming plus an interface change to get_seqno().

v10: Renamed the cached variable as it is no longer used at IRQ time. [Review comment from Tvrtko Ursulin]

For: VIZ-5190

Cc Maarten Lankhorst <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c         | 26 ++++++++++++++++++++++----
 drivers/gpu/drm/i915/intel_ringbuffer.h |  1 +
 2 files changed, 23 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +22 -4
index d7b88b1..405b1b7 100644
@@ -1382,6 +1382,7 @@ out:
 			 * request has not actually been fully processed yet.
 			 */
 			spin_lock_irq(&req->engine->fence_lock);
+			req->engine->last_notify_seqno = 0;
 			i915_gem_request_notify(req->engine, true, true);
 			spin_unlock_irq(&req->engine->fence_lock);
 		}
@@ -2628,9 +2629,12 @@ i915_gem_init_seqno(struct drm_i915_private *dev_priv, u32 seqno)
 	i915_gem_retire_requests(dev_priv);
 
 	/* Finally reset hw state */
-	for_each_engine(engine, dev_priv)
+	for_each_engine(engine, dev_priv) {
 		intel_ring_init_seqno(engine, seqno);
 
+		engine->last_notify_seqno = 0;
+	}
+
 	return 0;
 }
 
@@ -2972,13 +2976,24 @@ void i915_gem_request_notify(struct intel_engine_cs *engine, bool fence_locked,
 		return;
 	}
 
-	if (!fence_locked)
-		spin_lock_irq(&engine->fence_lock);
-
+	/*
+	 * Check for a new seqno. If it hasn't actually changed then early
+	 * exit without even grabbing the spinlock. Note that this is safe
+	 * because any corruption of last_notify_seqno merely results in doing
+	 * the full processing when there is potentially no work to be done.
+	 * It can never lead to not processing work that does need to happen.
+	 */
 	if (!lazy_coherency && engine->irq_seqno_barrier)
 		engine->irq_seqno_barrier(engine);
 	seqno = engine->get_seqno(engine);
 	trace_i915_gem_request_notify(engine, seqno);
+	if (seqno == engine->last_notify_seqno)
+		return;
+
+	if (!fence_locked)
+		spin_lock_irq(&engine->fence_lock);
+
+	engine->last_notify_seqno = seqno;
 
 	list_for_each_entry_safe(req, req_next, &engine->fence_signal_list, signal_link) {
 		if (!req->cancelled && !i915_seqno_passed(seqno, req->seqno))
@@ -3270,7 +3285,10 @@ static void i915_gem_reset_engine_cleanup(struct drm_i915_private *dev_priv,
 	/*
 	 * Make sure that any requests that were on the signal pending list also
 	 * get cleaned up.
+	 * NB: The seqno cache must be cleared first otherwise the notify call
+	 * will simply return immediately.
 	 */
+	engine->last_notify_seqno = 0;
 	i915_gem_request_notify(engine, false, false);
 
 	/* Having flushed all requests from all queues, we know that all
drivers/gpu/drm/i915/intel_ringbuffer.h +1 -0
index 9e79fbd..929f2f2 100644
@@ -354,6 +354,7 @@ struct intel_engine_cs {
 	 */
 	spinlock_t fence_lock;
 	struct list_head fence_signal_list;
+	uint32_t last_notify_seqno;
 
 	struct work_struct request_work;
 };
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v10 6/6
#15 lore raw

Re: [PATCH v10 6/6] drm/i915: Cache last IRQ seqno to reduce IRQ overhead

Op 16-06-16 om 14:54 schreef [email protected]:

Quoted 24 lines

From: John Harrison <[email protected]>

The notify function can be called many times without the seqno changing. Some are to prevent races due to the requirement of not enabling interrupts until requested. However, when interrupts are enabled the IRQ handler can be called multiple times without the ring's seqno value changing. E.g. two interrupts are generated by batch buffers completing in quick succession, the first call to the handler processes both completions but the handler still gets executed a second time. This patch reduces the overhead of these extra calls by caching the last processed seqno value and early exiting if it has not changed.

v3: New patch for series.

v5: Added comment about last_irq_seqno usage due to code review feedback (Tvrtko Ursulin).

v6: Minor update to resolve a race condition with the wait_request optimisation.

v7: Updated to newer nightly - lots of ring -> engine renaming plus an interface change to get_seqno().

Quoted 7 lines

v10: Renamed the cached variable as it is no longer used at IRQ time. [Review comment from Tvrtko Ursulin]

For: VIZ-5190

Cc Maarten Lankhorst <[email protected]>
Cc Tvrtko Ursulin <[email protected]>

I think it would be useful to add in the commit message that this happens in most cases.

From your earlier mail:

"Doing the cache check hits the early exit approx 98% of the time when running GLBenchmark. Although the vast majority of duplicate calls are from having to call the notify function from i915_gem_retire_requests_ring() and that being called at least once for every execbuf IOCTL (possibly multiple times). I have just made a couple of tweaks to further reduce the number of these calls and their impact, but there are still a lot of them."

If added,

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

#16 lore raw

✗ Ro.CI.BAT: failure for Convert requests to use struct fence (rev7)

In reply to [email protected]
== Series Details ==

== Series Details ==

Series: Convert requests to use struct fence (rev7)
URL : https://patchwork.freedesktop.org/series/1068/
State : failure

== Summary ==

Series 1068v7 Convert requests to use struct fence
http://patchwork.freedesktop.org/api/1.0/series/1068/revisions/7/mbox

Test drv_module_reload_basic:

                dmesg-warn -> DMESG-FAIL (ro-skl3-i5-6260u)
                pass       -> DMESG-FAIL (ro-bdw-i7-5557U)
                pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
                pass       -> DMESG-FAIL (ro-bdw-i5-5250u)
Test gem_ctx_switch:
        Subgroup basic-default:
                pass       -> DMESG-WARN (ro-skl3-i5-6260u)
Test gem_exec_flush:
        Subgroup basic-batch-kernel-default-cmd:
                pass       -> DMESG-FAIL (ro-ivb-i7-3770)
                pass       -> DMESG-FAIL (ro-ivb2-i7-3770)
                pass       -> DMESG-FAIL (ro-hsw-i3-4010u)
        Subgroup basic-batch-kernel-default-uc:
                pass       -> DMESG-FAIL (ro-ivb-i7-3770)
                pass       -> DMESG-FAIL (ro-ivb2-i7-3770)
                pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
                pass       -> DMESG-FAIL (ro-snb-i7-2620M)
                pass       -> DMESG-FAIL (ro-hsw-i3-4010u)
        Subgroup basic-batch-kernel-default-wb:
                pass       -> DMESG-FAIL (ro-ivb-i7-3770)
                pass       -> DMESG-FAIL (ro-ivb2-i7-3770)
                pass       -> DMESG-FAIL (ro-bdw-i7-5600u)
                pass       -> DMESG-FAIL (ro-snb-i7-2620M)
                pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
        Subgroup basic-uc-ro-default:
                pass       -> DMESG-WARN (ro-ivb2-i7-3770)
                pass       -> DMESG-WARN (ro-bdw-i7-5600u)
                pass       -> DMESG-WARN (ro-snb-i7-2620M)
                pass       -> DMESG-WARN (fi-bdw-i7-5557u)
        Subgroup basic-uc-rw-default:
                pass       -> DMESG-WARN (ro-ivb-i7-3770)
        Subgroup basic-wb-prw-default:
                pass       -> DMESG-WARN (ro-hsw-i7-4770r)
        Subgroup basic-wb-rw-default:
                pass       -> DMESG-WARN (ro-hsw-i3-4010u)
Test gem_exec_nop:
        Subgroup basic:
                pass       -> DMESG-WARN (ro-bdw-i7-5600u)
                pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
                pass       -> DMESG-WARN (ro-snb-i7-2620M)
                pass       -> DMESG-WARN (ro-hsw-i3-4010u)
Test gem_exec_parallel:
        Subgroup basic:
                pass       -> DMESG-FAIL (ro-byt-n2820)
                pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
Test gem_exec_parse:
        Subgroup basic-allowed:
                pass       -> DMESG-WARN (ro-byt-n2820)
Test gem_exec_store:
        Subgroup basic-all:
                pass       -> DMESG-FAIL (ro-bdw-i7-5600u)
                pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
        Subgroup basic-default:
                pass       -> DMESG-FAIL (ro-ivb-i7-3770)
                pass       -> DMESG-FAIL (ro-ivb2-i7-3770)
                pass       -> DMESG-FAIL (ro-snb-i7-2620M)
                pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
        Subgroup basic-render:
                pass       -> DMESG-FAIL (ro-ivb2-i7-3770)
                pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
Test gem_exec_suspend:
        Subgroup basic-s3:
                pass       -> DMESG-WARN (ro-ivb2-i7-3770)
Test gem_linear_blits:
        Subgroup basic:
                pass       -> DMESG-WARN (ro-byt-n2820)
                pass       -> DMESG-WARN (ro-bdw-i7-5557U)
                pass       -> DMESG-WARN (ro-ilk1-i5-650)
                pass       -> DMESG-WARN (ro-snb-i7-2620M)
Test gem_render_linear_blits:
        Subgroup basic:
                pass       -> DMESG-WARN (ro-bdw-i7-5600u)
Test gem_render_tiled_blits:
        Subgroup basic:
                pass       -> DMESG-WARN (ro-hsw-i7-4770r)
                pass       -> DMESG-WARN (ro-bdw-i7-5557U)
                pass       -> DMESG-WARN (fi-bdw-i7-5557u)
Test gem_ringfill:
        Subgroup basic-default:
                pass       -> DMESG-WARN (ro-ivb-i7-3770)
                pass       -> DMESG-WARN (ro-hsw-i7-4770r)
                pass       -> DMESG-WARN (ro-bdw-i7-5600u)
                pass       -> DMESG-WARN (ro-snb-i7-2620M)
                pass       -> DMESG-WARN (ro-hsw-i3-4010u)
        Subgroup basic-default-interruptible:
                pass       -> DMESG-WARN (ro-byt-n2820)
Test gem_storedw_loop:
        Subgroup basic-default:
                pass       -> DMESG-WARN (ro-byt-n2820)
                pass       -> DMESG-WARN (ro-bdw-i5-5250u)
Test gem_sync:
        Subgroup basic-all:
                pass       -> DMESG-FAIL (ro-skl3-i5-6260u)
                pass       -> DMESG-FAIL (ro-bdw-i7-5557U)
        Subgroup basic-each:
                pass       -> DMESG-FAIL (ro-bdw-i7-5557U)

WARNING: Long output truncated
fi-hsw-i7-4770k failed to connect after reboot
fi-skl-i5-6260u failed to connect after reboot
fi-skl-i7-6700k failed to connect after reboot
fi-snb-i7-2600 failed to connect after reboot

Results at /archive/results/CI_IGT_test/RO_Patchwork_1194/

3eb202e drm-intel-nightly: 2016y-06m-16d-12h-38m-37s UTC integration manifest fcfac14 drm/i915: Cache last IRQ seqno to reduce IRQ overhead 978b5f3 drm/i915: Updated request structure tracing
52e3f6e drm/i915: Interrupt driven fences
1c01513 drm/i915: Removed now redundant parameter to i915_gem_request_completed() a20d461 drm/i915: Convert requests to use struct fence
c15b593 drm/i915: Add per context timelines for fence objects

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

#17 lore raw

Re: ✗ Ro.CI.BAT: failure for Convert requests to use struct fence (rev7)

Two race conditions showed up during the CI BAT testing. I did manage to reproduce it locally as well but only after many runs of the BAT suite. Annoyingly, it was rare enough not to be noticed before letting the BAT farm run lots of tests across lots of different machines. And of course, at that point it fired lots and lots!

A new patch 4/6 has just been posted which fixes the races. I have also reposted patch 5 as that hits a merge conflict otherwise. With the fixed patch, I now get a clean CI BAT run via trybot:
https://patchwork.freedesktop.org/series/8821/

== Series Details ==

Series: Convert requests to use struct fence (rev2)
URL :https://patchwork.freedesktop.org/series/8821/
State : success

== Summary ==

Series 8821v2 Convert requests to use struct fence
http://patchwork.freedesktop.org/api/1.0/series/8821/revisions/2/mbox

ro-bdw-i5-5250u  total:213  pass:197  dwarn:1   dfail:0   fail:0   skip:15
ro-bdw-i7-5557U  total:213  pass:198  dwarn:0   dfail:0   fail:0   skip:15
ro-bdw-i7-5600u  total:213  pass:185  dwarn:0   dfail:0   fail:0   skip:28
ro-bsw-n3050     total:213  pass:172  dwarn:0   dfail:0   fail:2   skip:39
ro-byt-n2820     total:213  pass:173  dwarn:0   dfail:0   fail:3   skip:37
ro-hsw-i3-4010u  total:213  pass:190  dwarn:0   dfail:0   fail:0   skip:23
ro-hsw-i7-4770r  total:213  pass:190  dwarn:0   dfail:0   fail:0   skip:23
ro-ilk-i7-620lm  total:213  pass:150  dwarn:0   dfail:0   fail:1   skip:62
ro-ilk1-i5-650   total:208  pass:150  dwarn:0   dfail:0   fail:1   skip:57
ro-ivb-i7-3770   total:213  pass:181  dwarn:0   dfail:0   fail:0   skip:32
ro-ivb2-i7-3770  total:213  pass:185  dwarn:0   dfail:0   fail:0   skip:28
ro-skl3-i5-6260u total:213  pass:201  dwarn:1   dfail:0   fail:0   skip:11
ro-snb-i7-2620M  total:213  pass:174  dwarn:0   dfail:0   fail:1   skip:38

Results at /archive/results/CI_IGT_test/RO_Private_186/

828cccf drm-intel-nightly: 2016y-06m-17d-09h-38m-29s UTC integration manifest 50125bb drm/i915: Cache last IRQ seqno to reduce IRQ overhead dc710ef drm/i915: Updated request structure tracing
56a46ab drm/i915: Interrupt driven fences
10d6362 drm/i915: Removed now redundant parameter to i915_gem_request_completed() 2815c46 drm/i915: Convert requests to use struct fence
162e19f drm/i915: Add per context timelines for fence objects

Quoted 116 lines · Patchwork

== Series Details ==

Series: Convert requests to use struct fence (rev7)
URL : https://patchwork.freedesktop.org/series/1068/
State : failure

== Summary ==

Series 1068v7 Convert requests to use struct fence
http://patchwork.freedesktop.org/api/1.0/series/1068/revisions/7/mbox

Test drv_module_reload_basic:

                 dmesg-warn -> DMESG-FAIL (ro-skl3-i5-6260u)
                 pass       -> DMESG-FAIL (ro-bdw-i7-5557U)
                 pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
                 pass       -> DMESG-FAIL (ro-bdw-i5-5250u)
Test gem_ctx_switch:
         Subgroup basic-default:
                 pass       -> DMESG-WARN (ro-skl3-i5-6260u)
Test gem_exec_flush:
         Subgroup basic-batch-kernel-default-cmd:
                 pass       -> DMESG-FAIL (ro-ivb-i7-3770)
                 pass       -> DMESG-FAIL (ro-ivb2-i7-3770)
                 pass       -> DMESG-FAIL (ro-hsw-i3-4010u)
         Subgroup basic-batch-kernel-default-uc:
                 pass       -> DMESG-FAIL (ro-ivb-i7-3770)
                 pass       -> DMESG-FAIL (ro-ivb2-i7-3770)
                 pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
                 pass       -> DMESG-FAIL (ro-snb-i7-2620M)
                 pass       -> DMESG-FAIL (ro-hsw-i3-4010u)
         Subgroup basic-batch-kernel-default-wb:
                 pass       -> DMESG-FAIL (ro-ivb-i7-3770)
                 pass       -> DMESG-FAIL (ro-ivb2-i7-3770)
                 pass       -> DMESG-FAIL (ro-bdw-i7-5600u)
                 pass       -> DMESG-FAIL (ro-snb-i7-2620M)
                 pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
         Subgroup basic-uc-ro-default:
                 pass       -> DMESG-WARN (ro-ivb2-i7-3770)
                 pass       -> DMESG-WARN (ro-bdw-i7-5600u)
                 pass       -> DMESG-WARN (ro-snb-i7-2620M)
                 pass       -> DMESG-WARN (fi-bdw-i7-5557u)
         Subgroup basic-uc-rw-default:
                 pass       -> DMESG-WARN (ro-ivb-i7-3770)
         Subgroup basic-wb-prw-default:
                 pass       -> DMESG-WARN (ro-hsw-i7-4770r)
         Subgroup basic-wb-rw-default:
                 pass       -> DMESG-WARN (ro-hsw-i3-4010u)
Test gem_exec_nop:
         Subgroup basic:
                 pass       -> DMESG-WARN (ro-bdw-i7-5600u)
                 pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
                 pass       -> DMESG-WARN (ro-snb-i7-2620M)
                 pass       -> DMESG-WARN (ro-hsw-i3-4010u)
Test gem_exec_parallel:
         Subgroup basic:
                 pass       -> DMESG-FAIL (ro-byt-n2820)
                 pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
Test gem_exec_parse:
         Subgroup basic-allowed:
                 pass       -> DMESG-WARN (ro-byt-n2820)
Test gem_exec_store:
         Subgroup basic-all:
                 pass       -> DMESG-FAIL (ro-bdw-i7-5600u)
                 pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
         Subgroup basic-default:
                 pass       -> DMESG-FAIL (ro-ivb-i7-3770)
                 pass       -> DMESG-FAIL (ro-ivb2-i7-3770)
                 pass       -> DMESG-FAIL (ro-snb-i7-2620M)
                 pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
         Subgroup basic-render:
                 pass       -> DMESG-FAIL (ro-ivb2-i7-3770)
                 pass       -> DMESG-FAIL (fi-bdw-i7-5557u)
Test gem_exec_suspend:
         Subgroup basic-s3:
                 pass       -> DMESG-WARN (ro-ivb2-i7-3770)
Test gem_linear_blits:
         Subgroup basic:
                 pass       -> DMESG-WARN (ro-byt-n2820)
                 pass       -> DMESG-WARN (ro-bdw-i7-5557U)
                 pass       -> DMESG-WARN (ro-ilk1-i5-650)
                 pass       -> DMESG-WARN (ro-snb-i7-2620M)
Test gem_render_linear_blits:
         Subgroup basic:
                 pass       -> DMESG-WARN (ro-bdw-i7-5600u)
Test gem_render_tiled_blits:
         Subgroup basic:
                 pass       -> DMESG-WARN (ro-hsw-i7-4770r)
                 pass       -> DMESG-WARN (ro-bdw-i7-5557U)
                 pass       -> DMESG-WARN (fi-bdw-i7-5557u)
Test gem_ringfill:
         Subgroup basic-default:
                 pass       -> DMESG-WARN (ro-ivb-i7-3770)
                 pass       -> DMESG-WARN (ro-hsw-i7-4770r)
                 pass       -> DMESG-WARN (ro-bdw-i7-5600u)
                 pass       -> DMESG-WARN (ro-snb-i7-2620M)
                 pass       -> DMESG-WARN (ro-hsw-i3-4010u)
         Subgroup basic-default-interruptible:
                 pass       -> DMESG-WARN (ro-byt-n2820)
Test gem_storedw_loop:
         Subgroup basic-default:
                 pass       -> DMESG-WARN (ro-byt-n2820)
                 pass       -> DMESG-WARN (ro-bdw-i5-5250u)
Test gem_sync:
         Subgroup basic-all:
                 pass       -> DMESG-FAIL (ro-skl3-i5-6260u)
                 pass       -> DMESG-FAIL (ro-bdw-i7-5557U)
         Subgroup basic-each:
                 pass       -> DMESG-FAIL (ro-bdw-i7-5557U)

WARNING: Long output truncated
fi-hsw-i7-4770k failed to connect after reboot
fi-skl-i5-6260u failed to connect after reboot
fi-skl-i7-6700k failed to connect after reboot
fi-snb-i7-2600 failed to connect after reboot

Results at /archive/results/CI_IGT_test/RO_Patchwork_1194/

Quoted 8 lines

3eb202e drm-intel-nightly: 2016y-06m-16d-12h-38m-37s UTC integration manifest fcfac14 drm/i915: Cache last IRQ seqno to reduce IRQ overhead 978b5f3 drm/i915: Updated request structure tracing
52e3f6e drm/i915: Interrupt driven fences
1c01513 drm/i915: Removed now redundant parameter to i915_gem_request_completed() a20d461 drm/i915: Convert requests to use struct fence
c15b593 drm/i915: Add per context timelines for fence objects

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

#18 lore raw

✗ Ro.CI.BAT: failure for Convert requests to use struct fence (rev9)

In reply to [email protected]
== Series Details ==

== Series Details ==

Series: Convert requests to use struct fence (rev9)
URL : https://patchwork.freedesktop.org/series/1068/
State : failure

== Summary ==

Applying: drm/i915: Add per context timelines for fence objects
fatal: sha1 information is lacking or useless (drivers/gpu/drm/i915/i915_gem.c).
error: could not build fake ancestor
Patch failed at 0001 drm/i915: Add per context timelines for fence objects The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

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