[RFCv2,12/14] drm/i915: factor out execlists_i915_pick_requests()

Submitted by Wang, Zhi A on Feb. 18, 2016, 11:42 a.m.

Details

Message ID 1455795741-3487-13-git-send-email-zhi.a.wang@intel.com
State New
Headers show
Series "gvt: Hacking i915 for GVT context requirement" ( rev: 1 ) in Intel GFX

Not browsing as part of any series.

Commit Message

Wang, Zhi A Feb. 18, 2016, 11:42 a.m.
This patch factors out the request picking logics from
execlists_context_unqueue(), with some fixes to makes checkpatch.pl happy.

No logic is changed.

Signed-off-by: Zhi Wang <zhi.a.wang@intel.com>
---
 drivers/gpu/drm/i915/intel_lrc.c | 50 +++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 19 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 07aa5da..1c0366a 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -450,10 +450,38 @@  static inline void execlists_context_status_change(
 			status, NULL);
 }
 
+static void execlists_i915_pick_requests(struct intel_engine_cs *ring,
+		struct drm_i915_gem_request **req0,
+		struct drm_i915_gem_request **req1)
+{
+	struct drm_i915_gem_request *cursor, *tmp;
+
+	*req0 = *req1 = NULL;
+
+	/* Try to read in pairs */
+	list_for_each_entry_safe(cursor, tmp, &ring->execlist_queue,
+			execlist_link) {
+		if (!*req0) {
+			*req0 = cursor;
+		} else if ((*req0)->ctx == cursor->ctx) {
+			/*
+			 * Same ctx: ignore first request, as second request
+			 * will update tail past first request's workload
+			 */
+			cursor->elsp_submitted = (*req0)->elsp_submitted;
+			list_move_tail(&(*req0)->execlist_link,
+					&ring->execlist_retired_req_list);
+			*req0 = cursor;
+		} else {
+			*req1 = cursor;
+			break;
+		}
+	}
+}
+
 static void execlists_context_unqueue(struct intel_engine_cs *ring)
 {
-	struct drm_i915_gem_request *req0 = NULL, *req1 = NULL;
-	struct drm_i915_gem_request *cursor = NULL, *tmp = NULL;
+	struct drm_i915_gem_request *req0, *req1;
 
 	assert_spin_locked(&ring->execlist_lock);
 
@@ -466,23 +494,7 @@  static void execlists_context_unqueue(struct intel_engine_cs *ring)
 	if (list_empty(&ring->execlist_queue))
 		return;
 
-	/* Try to read in pairs */
-	list_for_each_entry_safe(cursor, tmp, &ring->execlist_queue,
-				 execlist_link) {
-		if (!req0) {
-			req0 = cursor;
-		} else if (req0->ctx == cursor->ctx) {
-			/* Same ctx: ignore first request, as second request
-			 * will update tail past first request's workload */
-			cursor->elsp_submitted = req0->elsp_submitted;
-			list_move_tail(&req0->execlist_link,
-				       &ring->execlist_retired_req_list);
-			req0 = cursor;
-		} else {
-			req1 = cursor;
-			break;
-		}
-	}
+	execlists_i915_pick_requests(ring, &req0, &req1);
 
 	if (IS_GEN8(ring->dev) || IS_GEN9(ring->dev)) {
 		/*