Intel-GFX Archive mirror
 help / color / mirror / Atom feed
From: Nirmoy Das <nirmoy.das@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org,
	Nirmoy Das <nirmoy.das@intel.com>,
	John Harrison <John.C.Harrison@intel.com>,
	Tvrtko Ursulin <tursulin@ursulin.net>
Subject: [PATCH] drm/i915: Use for_each_child instead of manual for-loop
Date: Tue, 14 May 2024 12:50:31 +0200	[thread overview]
Message-ID: <20240514105031.22123-1-nirmoy.das@intel.com> (raw)

Simplify child iteration using for_each_child macro
instead of using manual for loop. There is no functional
change.

Cc: John Harrison <John.C.Harrison@intel.com>
Cc: Tvrtko Ursulin <tursulin@ursulin.net>
Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
---
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 64 ++++++++++---------
 1 file changed, 33 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index 0eaa1064242c..7e88d90e935b 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -1800,14 +1800,37 @@ __unwind_incomplete_requests(struct intel_context *ce)
 	spin_unlock_irqrestore(&sched_engine->lock, flags);
 }
 
-static void __guc_reset_context(struct intel_context *ce, intel_engine_mask_t stalled)
+static void guc_reset_context_state(struct intel_context *ce, intel_engine_mask_t stalled)
 {
-	bool guilty;
 	struct i915_request *rq;
-	unsigned long flags;
+	bool guilty = false;
 	u32 head;
-	int i, number_children = ce->parallel.number_children;
-	struct intel_context *parent = ce;
+
+	if (!intel_context_is_pinned(ce))
+		return;
+
+	rq = intel_context_get_active_request(ce);
+	if (!rq) {
+		head = ce->ring->tail;
+		goto out_replay;
+	}
+
+	if (i915_request_started(rq))
+		guilty = stalled & ce->engine->mask;
+
+	GEM_BUG_ON(i915_active_is_idle(&ce->active));
+	head = intel_ring_wrap(ce->ring, rq->head);
+
+	__i915_request_reset(rq, guilty);
+	i915_request_put(rq);
+out_replay:
+	guc_reset_state(ce, head, guilty);
+}
+
+static void __guc_reset_context(struct intel_context *ce, intel_engine_mask_t stalled)
+{
+	struct intel_context *child;
+	unsigned long flags;
 
 	GEM_BUG_ON(intel_context_is_child(ce));
 
@@ -1826,34 +1849,13 @@ static void __guc_reset_context(struct intel_context *ce, intel_engine_mask_t st
 	 * For each context in the relationship find the hanging request
 	 * resetting each context / request as needed
 	 */
-	for (i = 0; i < number_children + 1; ++i) {
-		if (!intel_context_is_pinned(ce))
-			goto next_context;
-
-		guilty = false;
-		rq = intel_context_get_active_request(ce);
-		if (!rq) {
-			head = ce->ring->tail;
-			goto out_replay;
-		}
-
-		if (i915_request_started(rq))
-			guilty = stalled & ce->engine->mask;
-
-		GEM_BUG_ON(i915_active_is_idle(&ce->active));
-		head = intel_ring_wrap(ce->ring, rq->head);
-
-		__i915_request_reset(rq, guilty);
-		i915_request_put(rq);
-out_replay:
-		guc_reset_state(ce, head, guilty);
-next_context:
-		if (i != number_children)
-			ce = list_next_entry(ce, parallel.child_link);
+	guc_reset_context_state(ce, stalled);
+	for_each_child(ce, child) {
+		guc_reset_context_state(child, stalled);
 	}
 
-	__unwind_incomplete_requests(parent);
-	intel_context_put(parent);
+	__unwind_incomplete_requests(ce);
+	intel_context_put(ce);
 }
 
 void wake_up_all_tlb_invalidate(struct intel_guc *guc)
-- 
2.42.0


             reply	other threads:[~2024-05-14 11:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-14 10:50 Nirmoy Das [this message]
2024-05-14 11:54 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use for_each_child instead of manual for-loop Patchwork
2024-05-14 12:01 ` ✓ Fi.CI.BAT: success " Patchwork
2024-05-15  0:54 ` ✗ Fi.CI.IGT: failure " Patchwork
2024-05-15  8:32 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Use for_each_child instead of manual for-loop (rev2) Patchwork
2024-05-15  8:39 ` ✓ Fi.CI.BAT: success " Patchwork
2024-05-15 15:48 ` ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240514105031.22123-1-nirmoy.das@intel.com \
    --to=nirmoy.das@intel.com \
    --cc=John.C.Harrison@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=tursulin@ursulin.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).