Skip to contentSkip to conversation

Allow error capture without a request & fix locking issues

PATCH Superseded [email protected] 4 participants 22 messages Jan 20, 2023 – Jan 25, 2023

Subsystems (2)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover Allow error capture without a request & fix locking issues

From: John Harrison <[email protected]>

It is technically possible to get a hung context without a valid request. In such a situation, try to provide as much information in the error capture as possible rather than just aborting and capturing nothing.

Similarly, in the case of an engine reset failure the GuC is not able to report the guilty context. So try a manual search instead of reporting nothing.

While doing all this, it was noticed that the locking was broken in a number of places when searching for hung requests and dumping request info. So fix all that up as well.

v2: Tidy up code flow in error capture. Reword some comments/messages. (review feedback from Tvrtko)
Also fix up request locking issues from earlier changes noticed during code review of this change.
v3: Fix some potential null pointer derefs and a reference leak. Add new patch to refactor the duplicated hung request search code into a common backend agnostic wrapper function and use the correct spinlocks for the correct lists. Also tweak some of the patch descriptions for better accuracy.
v4: Shuffle some code around to more appropriate source files. Fix potential leak of GuC capture object after code flow re-org and pull improved info message earlier (Daniele). Also rename the GuC capture object to be more consistent.

John Harrison (7):
drm/i915: Fix request locking during error capture & debugfs dump drm/i915: Fix up locking around dumping requests lists drm/i915: Allow error capture without a request drm/i915: Allow error capture of a pending request drm/i915/guc: Look for a guilty context when an engine reset fails drm/i915/guc: Add a debug print on GuC triggered reset drm/i915/guc: Rename GuC register state capture node to be more
obvious

 drivers/gpu/drm/i915/gt/intel_context.c       |  4 +-
 drivers/gpu/drm/i915/gt/intel_context.h       |  3 +-
 drivers/gpu/drm/i915/gt/intel_engine.h        |  4 +-
 drivers/gpu/drm/i915/gt/intel_engine_cs.c     | 74 ++++++++-------
 .../drm/i915/gt/intel_execlists_submission.c  | 27 ++++++
 .../drm/i915/gt/intel_execlists_submission.h  |  4 +
 .../gpu/drm/i915/gt/uc/intel_guc_capture.c    |  8 +-
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 35 ++++++-
 drivers/gpu/drm/i915/i915_gpu_error.c         | 92 ++++++++++---------
 drivers/gpu/drm/i915/i915_gpu_error.h         |  2 +-
 10 files changed, 160 insertions(+), 93 deletions(-)
Signature · 1 line
2.39.0
#1 lore raw

PATCH v4 1/7 drm/i915: Fix request locking during error capture & debugfs dump

From: John Harrison <[email protected]>

When GuC support was added to error capture, the locking around the request object was broken. Fix it up.

The context based search manages the spinlocking around the search internally. So it needs to grab the reference count internally as well. The execlist only request based search relies on external locking, so it needs an external reference count but within the spinlock not outside it.

The only other caller of the context based search is the code for dumping engine state to debugfs. That code wasn't previously getting an explicit reference at all as it does everything while holding the execlist specific spinlock. So, that needs updaing as well as that spinlock doesn't help when using GuC submission. Rather than trying to conditionally get/put depending on submission model, just change it to always do the get/put.

In addition, intel_guc_find_hung_context() was not acquiring the correct spinlock before searching the request list. So fix that up too. While at it, add some extra whitespace padding for readability.

v2: Explicitly document adding an extra blank line in some dense code (Andy Shevchenko). Fix multiple potential null pointer derefs in case of no request found (some spotted by Tvrtko, but there was more!). Also fix a leaked request in case of !started and another in __guc_reset_context now that intel_context_find_active_request is actually reference counting the returned request.
v3: Add a _get suffix to intel_context_find_active_request now that it grabs a reference (Daniele).

Fixes dc0dad365c5e ("drm/i915/guc: Fix for error capture after full GPU reset with GuC")
Fixes 573ba126aef3 ("drm/i915/guc: Capture error state on context reset")
Cc Matthew Brost <[email protected]>
Cc John Harrison <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Andrzej Hajda <[email protected]>
Cc Matthew Auld <[email protected]>
Cc Matt Roper <[email protected]>
Cc Umesh Nerlige Ramappa <[email protected]>
Cc Michael Cheng <[email protected]>
Cc Lucas De Marchi <[email protected]>
Cc Tejas Upadhyay <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Alan Previn <[email protected]>
Cc Bruce Chang <[email protected]>
---
 drivers/gpu/drm/i915/gt/intel_context.c           |  4 +++-
 drivers/gpu/drm/i915/gt/intel_context.h           |  3 +--
 drivers/gpu/drm/i915/gt/intel_engine_cs.c         |  6 +++++-
 drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 14 +++++++++++++-
 drivers/gpu/drm/i915/i915_gpu_error.c             | 13 ++++++-------
 5 files changed, 28 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/gt/intel_context.c +3 -1
index e94365b08f1ef..4285c1c71fa12 100644
@@ -528,7 +528,7 @@ struct i915_request *intel_context_create_request(struct intel_context *ce)
 	return rq;
 }
 
-struct i915_request *intel_context_find_active_request(struct intel_context *ce)
+struct i915_request *intel_context_find_active_request_get(struct intel_context *ce)
 {
 	struct intel_context *parent = intel_context_to_parent(ce);
 	struct i915_request *rq, *active = NULL;
@@ -552,6 +552,8 @@ struct i915_request *intel_context_find_active_request(struct intel_context *ce)
 
 		active = rq;
 	}
+	if (active)
+		active = i915_request_get_rcu(active);
 	spin_unlock_irqrestore(&parent->guc_state.lock, flags);
 
 	return active;
drivers/gpu/drm/i915/gt/intel_context.h +1 -2
index fb62b7b8cbcda..ccc80c6607ca8 100644
@@ -268,8 +268,7 @@ int intel_context_prepare_remote_request(struct intel_context *ce,
 
 struct i915_request *intel_context_create_request(struct intel_context *ce);
 
-struct i915_request *
-intel_context_find_active_request(struct intel_context *ce);
+struct i915_request *intel_context_find_active_request_get(struct intel_context *ce);
 
 static inline bool intel_context_is_barrier(const struct intel_context *ce)
 {
drivers/gpu/drm/i915/gt/intel_engine_cs.c +5 -1
index 922f1bb22dc68..fbc0a81617e89 100644
@@ -2237,9 +2237,11 @@ static void engine_dump_active_requests(struct intel_engine_cs *engine, struct d
 	if (guc) {
 		ce = intel_engine_get_hung_context(engine);
 		if (ce)
-			hung_rq = intel_context_find_active_request(ce);
+			hung_rq = intel_context_find_active_request_get(ce);
 	} else {
 		hung_rq = intel_engine_execlist_find_hung_request(engine);
+		if (hung_rq)
+			hung_rq = i915_request_get_rcu(hung_rq);
 	}
 
 	if (hung_rq)
@@ -2250,6 +2252,8 @@ static void engine_dump_active_requests(struct intel_engine_cs *engine, struct d
 	else
 		intel_engine_dump_active_requests(&engine->sched_engine->requests,
 						  hung_rq, m);
+	if (hung_rq)
+		i915_request_put(hung_rq);
 }
 
 void intel_engine_dump(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +13 -1
index b436dd7f12e42..ad4b2848b0f83 100644
@@ -1702,7 +1702,7 @@ static void __guc_reset_context(struct intel_context *ce, intel_engine_mask_t st
 			goto next_context;
 
 		guilty = false;
-		rq = intel_context_find_active_request(ce);
+		rq = intel_context_find_active_request_get(ce);
 		if (!rq) {
 			head = ce->ring->tail;
 			goto out_replay;
@@ -1715,6 +1715,7 @@ static void __guc_reset_context(struct intel_context *ce, intel_engine_mask_t st
 		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:
@@ -4820,6 +4821,8 @@ void intel_guc_find_hung_context(struct intel_engine_cs *engine)
 
 	xa_lock_irqsave(&guc->context_lookup, flags);
 	xa_for_each(&guc->context_lookup, index, ce) {
+		bool found;
+
 		if (!kref_get_unless_zero(&ce->ref))
 			continue;
 
@@ -4836,10 +4839,18 @@ void intel_guc_find_hung_context(struct intel_engine_cs *engine)
 				goto next;
 		}
 
+		found = false;
+		spin_lock(&ce->guc_state.lock);
 		list_for_each_entry(rq, &ce->guc_state.requests, sched.link) {
 			if (i915_test_request_state(rq) != I915_REQUEST_ACTIVE)
 				continue;
 
+			found = true;
+			break;
+		}
+		spin_unlock(&ce->guc_state.lock);
+
+		if (found) {
 			intel_engine_set_hung_context(engine, ce);
 
 			/* Can only cope with one hang at a time... */
@@ -4847,6 +4858,7 @@ void intel_guc_find_hung_context(struct intel_engine_cs *engine)
 			xa_lock(&guc->context_lookup);
 			goto done;
 		}
+
 next:
 		intel_context_put(ce);
 		xa_lock(&guc->context_lookup);
drivers/gpu/drm/i915/i915_gpu_error.c +6 -7
index 9d5d5a397b64e..5c73dfa2fb3f6 100644
@@ -1607,7 +1607,7 @@ capture_engine(struct intel_engine_cs *engine,
 	ce = intel_engine_get_hung_context(engine);
 	if (ce) {
 		intel_engine_clear_hung_context(engine);
-		rq = intel_context_find_active_request(ce);
+		rq = intel_context_find_active_request_get(ce);
 		if (!rq || !i915_request_started(rq))
 			goto no_request_capture;
 	} else {
@@ -1618,21 +1618,18 @@ capture_engine(struct intel_engine_cs *engine,
 		if (!intel_uc_uses_guc_submission(&engine->gt->uc)) {
 			spin_lock_irqsave(&engine->sched_engine->lock, flags);
 			rq = intel_engine_execlist_find_hung_request(engine);
+			if (rq)
+				rq = i915_request_get_rcu(rq);
 			spin_unlock_irqrestore(&engine->sched_engine->lock,
 					       flags);
 		}
 	}
-	if (rq)
-		rq = i915_request_get_rcu(rq);
-
 	if (!rq)
 		goto no_request_capture;
 
 	capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);
-	if (!capture) {
-		i915_request_put(rq);
+	if (!capture)
 		goto no_request_capture;
-	}
 	if (dump_flags & CORE_DUMP_FLAG_IS_GUC_CAPTURE)
 		intel_guc_capture_get_matching_node(engine->gt, ee, ce);
 
@@ -1642,6 +1639,8 @@ capture_engine(struct intel_engine_cs *engine,
 	return ee;
 
 no_request_capture:
+	if (rq)
+		i915_request_put(rq);
 	kfree(ee);
 	return NULL;
 }
Signature · 1 line
2.39.0
#2 lore raw

Re: [PATCH v4 1/7] drm/i915: Fix request locking during error capture & debugfs dump

Quoted 19 lines · On 20/01/2023 23:28, [email protected] wrote:

From: John Harrison <[email protected]>

When GuC support was added to error capture, the locking around the request object was broken. Fix it up.

The context based search manages the spinlocking around the search internally. So it needs to grab the reference count internally as well. The execlist only request based search relies on external locking, so it needs an external reference count but within the spinlock not outside it.

The only other caller of the context based search is the code for dumping engine state to debugfs. That code wasn't previously getting an explicit reference at all as it does everything while holding the execlist specific spinlock. So, that needs updaing as well as that spinlock doesn't help when using GuC submission. Rather than trying to conditionally get/put depending on submission model, just change it to always do the get/put.

Quoted 3 lines

In addition, intel_guc_find_hung_context() was not acquiring the correct spinlock before searching the request list. So fix that up too. While at it, add some extra whitespace padding for readability.

Is this part splittable into a separate patch?

Quoted 46 lines

v2: Explicitly document adding an extra blank line in some dense code (Andy Shevchenko). Fix multiple potential null pointer derefs in case of no request found (some spotted by Tvrtko, but there was more!). Also fix a leaked request in case of !started and another in __guc_reset_context now that intel_context_find_active_request is actually reference counting the returned request.
v3: Add a _get suffix to intel_context_find_active_request now that it grabs a reference (Daniele).

Fixes dc0dad365c5e ("drm/i915/guc: Fix for error capture after full GPU reset with GuC")
Fixes 573ba126aef3 ("drm/i915/guc: Capture error state on context reset")
Cc Matthew Brost <[email protected]>
Cc John Harrison <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Andrzej Hajda <[email protected]>
Cc Matthew Auld <[email protected]>
Cc Matt Roper <[email protected]>
Cc Umesh Nerlige Ramappa <[email protected]>
Cc Michael Cheng <[email protected]>
Cc Lucas De Marchi <[email protected]>
Cc Tejas Upadhyay <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Alan Previn <[email protected]>
Cc Bruce Chang <[email protected]>
---
  drivers/gpu/drm/i915/gt/intel_context.c           |  4 +++-
  drivers/gpu/drm/i915/gt/intel_context.h           |  3 +--
  drivers/gpu/drm/i915/gt/intel_engine_cs.c         |  6 +++++-
  drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 14 +++++++++++++-
  drivers/gpu/drm/i915/i915_gpu_error.c             | 13 ++++++-------
  5 files changed, 28 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/gt/intel_context.c +0 -0
index e94365b08f1ef..4285c1c71fa12 100644

drivers/gpu/drm/i915/gt/intel_context.c struct i915_request *intel_context_create_request(struct intel_context *ce) · line 531

Quoted 5 lines
drivers/gpu/drm/i915/gt/intel_context.c +1 -1
@@ -528,7 +528,7 @@ struct i915_request *intel_context_create_request(struct intel_context *ce)
  	return rq;
  }
 
-struct i915_request *intel_context_find_active_request(struct intel_context *ce)
+struct i915_request *intel_context_find_active_request_get(struct intel_context *ce)

TBH I don't "dig" this name, it's a bit on the long side and feels out of character. I won't insist it be changed, but if get really has to be included in the name I would be happy with intel_context_get_active_request().

Quoted 44 lines
drivers/gpu/drm/i915/gt/intel_context.c +2 -0
  {
  	struct intel_context *parent = intel_context_to_parent(ce);
  	struct i915_request *rq, *active = NULL;
@@ -552,6 +552,8 @@ struct i915_request *intel_context_find_active_request(struct intel_context *ce)
 
  		active = rq;
  	}
+	if (active)
+		active = i915_request_get_rcu(active);
  	spin_unlock_irqrestore(&parent->guc_state.lock, flags);
 
  	return active;
drivers/gpu/drm/i915/gt/intel_context.h +1 -2
index fb62b7b8cbcda..ccc80c6607ca8 100644
@@ -268,8 +268,7 @@ int intel_context_prepare_remote_request(struct intel_context *ce,
 
  struct i915_request *intel_context_create_request(struct intel_context *ce);
 
-struct i915_request *
-intel_context_find_active_request(struct intel_context *ce);
+struct i915_request *intel_context_find_active_request_get(struct intel_context *ce);
 
  static inline bool intel_context_is_barrier(const struct intel_context *ce)
  {
drivers/gpu/drm/i915/gt/intel_engine_cs.c +3 -1
index 922f1bb22dc68..fbc0a81617e89 100644
@@ -2237,9 +2237,11 @@ static void engine_dump_active_requests(struct intel_engine_cs *engine, struct d
  	if (guc) {
  		ce = intel_engine_get_hung_context(engine);
  		if (ce)
-			hung_rq = intel_context_find_active_request(ce);
+			hung_rq = intel_context_find_active_request_get(ce);
  	} else {
  		hung_rq = intel_engine_execlist_find_hung_request(engine);
+		if (hung_rq)
+			hung_rq = i915_request_get_rcu(hung_rq);
  	}
 
  	if (hung_rq)

drivers/gpu/drm/i915/gt/intel_engine_cs.c static void engine_dump_active_requests(struct intel_engine_cs *engine, struct d · line 2256

Quoted 5 lines
drivers/gpu/drm/i915/gt/intel_engine_cs.c +2 -0
@@ -2250,6 +2252,8 @@ static void engine_dump_active_requests(struct intel_engine_cs *engine, struct d
  	else
  		intel_engine_dump_active_requests(&engine->sched_engine->requests,
  						  hung_rq, m);
+	if (hung_rq)
+		i915_request_put(hung_rq);

Argh... this is so horrible - not your patch - but the existing state of GuC backend was plugged in. I honestly don't know what to suggest here at this point... Above we have:

	if (guc)
		intel_guc_dump_active_requests(engine, hung_rq, m);
	else
		intel_engine_dump_active_requests(&engine->sched_engine->requests,
						  hung_rq, m);

As per your analysis the execlists code wants one lock held over that, especially when it calls intel_engine_dump_active_requests, which the GuC backed will also call from intel_guc_dump_active_requests (!) just needs a different lock held around it.

Is the lock held by intel_engine_dump over the call to engine_dump_active_requests truly useless in case of GuC? Or just wrong scope (too wide)?

Quoted 74 lines
drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -0
  }
 
  void intel_engine_dump(struct intel_engine_cs *engine,
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +13 -1
index b436dd7f12e42..ad4b2848b0f83 100644
@@ -1702,7 +1702,7 @@ static void __guc_reset_context(struct intel_context *ce, intel_engine_mask_t st
  			goto next_context;
 
  		guilty = false;
-		rq = intel_context_find_active_request(ce);
+		rq = intel_context_find_active_request_get(ce);
  		if (!rq) {
  			head = ce->ring->tail;
  			goto out_replay;
@@ -1715,6 +1715,7 @@ static void __guc_reset_context(struct intel_context *ce, intel_engine_mask_t st
  		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:
@@ -4820,6 +4821,8 @@ void intel_guc_find_hung_context(struct intel_engine_cs *engine)
 
  	xa_lock_irqsave(&guc->context_lookup, flags);
  	xa_for_each(&guc->context_lookup, index, ce) {
+		bool found;
+
  		if (!kref_get_unless_zero(&ce->ref))
  			continue;
 
@@ -4836,10 +4839,18 @@ void intel_guc_find_hung_context(struct intel_engine_cs *engine)
  				goto next;
  		}
 
+		found = false;
+		spin_lock(&ce->guc_state.lock);
  		list_for_each_entry(rq, &ce->guc_state.requests, sched.link) {
  			if (i915_test_request_state(rq) != I915_REQUEST_ACTIVE)
  				continue;
 
+			found = true;
+			break;
+		}
+		spin_unlock(&ce->guc_state.lock);
+
+		if (found) {
  			intel_engine_set_hung_context(engine, ce);
 
  			/* Can only cope with one hang at a time... */
@@ -4847,6 +4858,7 @@ void intel_guc_find_hung_context(struct intel_engine_cs *engine)
  			xa_lock(&guc->context_lookup);
  			goto done;
  		}
+
  next:
  		intel_context_put(ce);
  		xa_lock(&guc->context_lookup);
drivers/gpu/drm/i915/i915_gpu_error.c +1 -1
index 9d5d5a397b64e..5c73dfa2fb3f6 100644
@@ -1607,7 +1607,7 @@ capture_engine(struct intel_engine_cs *engine,
  	ce = intel_engine_get_hung_context(engine);
  	if (ce) {
  		intel_engine_clear_hung_context(engine);
-		rq = intel_context_find_active_request(ce);
+		rq = intel_context_find_active_request_get(ce);
  		if (!rq || !i915_request_started(rq))
  			goto no_request_capture;
  	} else {

drivers/gpu/drm/i915/i915_gpu_error.c capture_engine(struct intel_engine_cs *engine, · line 1624

Quoted 7 lines
drivers/gpu/drm/i915/i915_gpu_error.c +2 -0
@@ -1618,21 +1618,18 @@ capture_engine(struct intel_engine_cs *engine,
  		if (!intel_uc_uses_guc_submission(&engine->gt->uc)) {
  			spin_lock_irqsave(&engine->sched_engine->lock, flags);
  			rq = intel_engine_execlist_find_hung_request(engine);
+			if (rq)
+				rq = i915_request_get_rcu(rq);
  			spin_unlock_irqrestore(&engine->sched_engine->lock,
  					       flags);

Is it possible to consolidate this block with the one in engine_dump_active_requests? They seem identical..

	guc = intel_uc_uses_guc_submission(&engine->gt->uc);
	if (guc) {
		ce = intel_engine_get_hung_context(engine);
		if (ce)
			hung_rq = intel_context_find_active_request(ce);
	} else {
		hung_rq = intel_engine_execlist_find_hung_request(engine);
	}

vs

	ce = intel_engine_get_hung_context(engine);
	if (ce) {
		intel_engine_clear_hung_context(engine);
		rq = intel_context_find_active_request(ce);
		if (!rq || !i915_request_started(rq))
			goto no_request_capture;
	} else {
		/*
		 * Getting here with GuC enabled means it is a forced error capture
		 * with no actual hang. So, no need to attempt the execlist search.
		 */
		if (!intel_uc_uses_guc_submission(&engine->gt->uc)) {
			spin_lock_irqsave(&engine->sched_engine->lock, flags);
			rq = intel_engine_execlist_find_hung_request(engine);
			spin_unlock_irqrestore(&engine->sched_engine->lock,
					       flags);
		}
	}

We'd need a backend agnostic helper like:

intel_engine_get_hung_request(...)
{
...

	guc = intel_uc_uses_guc_submission(&engine->gt->uc);
	if (guc) {
		ce = intel_engine_get_hung_context(engine);
		if (ce)
			hung_rq = intel_context_find_active_request(ce);
	} else {
		hung_rq = intel_engine_execlist_find_hung_request(engine);
	}

If locking can be untangled to work correctly for both callers.

Looks like I can't do a quick review on this but need to set aside a larger chunk of time. I'll try tomorrow.

Regards,

Tvrtko

Quoted 26 lines
drivers/gpu/drm/i915/i915_gpu_error.c +3 -6
  		}
  	}
-	if (rq)
-		rq = i915_request_get_rcu(rq);
-
  	if (!rq)
  		goto no_request_capture;
 
  	capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);
-	if (!capture) {
-		i915_request_put(rq);
+	if (!capture)
  		goto no_request_capture;
-	}
  	if (dump_flags & CORE_DUMP_FLAG_IS_GUC_CAPTURE)
  		intel_guc_capture_get_matching_node(engine->gt, ee, ce);
 
@@ -1642,6 +1639,8 @@ capture_engine(struct intel_engine_cs *engine,
  	return ee;
 
  no_request_capture:
+	if (rq)
+		i915_request_put(rq);
  	kfree(ee);
  	return NULL;
  }
#3 lore raw

Re: [PATCH v4 1/7] drm/i915: Fix request locking during error capture & debugfs dump

Quoted 20 lines · Tvrtko Ursulin
Quoted 19 lines · On 20/01/2023 23:28, [email protected] wrote:

From: John Harrison <[email protected]>

When GuC support was added to error capture, the locking around the request object was broken. Fix it up.

The context based search manages the spinlocking around the search internally. So it needs to grab the reference count internally as well. The execlist only request based search relies on external locking, so it needs an external reference count but within the spinlock not outside it.

The only other caller of the context based search is the code for dumping engine state to debugfs. That code wasn't previously getting an explicit reference at all as it does everything while holding the execlist specific spinlock. So, that needs updaing as well as that spinlock doesn't help when using GuC submission. Rather than trying to conditionally get/put depending on submission model, just change it to always do the get/put.

Quoted 5 lines
Quoted 3 lines

In addition, intel_guc_find_hung_context() was not acquiring the correct spinlock before searching the request list. So fix that up too. While at it, add some extra whitespace padding for readability.

Is this part splittable into a separate patch?

I guess it could but it seems closely related to all the other locking fix ups in this patch.

Quoted 42 lines
Quoted 42 lines

v2: Explicitly document adding an extra blank line in some dense code (Andy Shevchenko). Fix multiple potential null pointer derefs in case of no request found (some spotted by Tvrtko, but there was more!). Also fix a leaked request in case of !started and another in __guc_reset_context now that intel_context_find_active_request is actually reference counting the returned request.
v3: Add a _get suffix to intel_context_find_active_request now that it grabs a reference (Daniele).

Fixes dc0dad365c5e ("drm/i915/guc: Fix for error capture after full GPU reset with GuC")
Fixes 573ba126aef3 ("drm/i915/guc: Capture error state on context reset")
Cc Matthew Brost <[email protected]>
Cc John Harrison <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Andrzej Hajda <[email protected]>
Cc Matthew Auld <[email protected]>
Cc Matt Roper <[email protected]>
Cc Umesh Nerlige Ramappa <[email protected]>
Cc Michael Cheng <[email protected]>
Cc Lucas De Marchi <[email protected]>
Cc Tejas Upadhyay <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Aravind Iddamsetty <[email protected]>
Cc Alan Previn <[email protected]>
Cc Bruce Chang <[email protected]>

---
  drivers/gpu/drm/i915/gt/intel_context.c           |  4 +++- drivers/gpu/drm/i915/gt/intel_context.h           |  3 +-- drivers/gpu/drm/i915/gt/intel_engine_cs.c         |  6 +++++- drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 14 +++++++++++++- drivers/gpu/drm/i915/i915_gpu_error.c             | 13 ++++++-------

  5 files changed, 28 insertions(+), 12 deletions(-)
Quoted 13 lines

drivers/gpu/drm/i915/gt/intel_context.c struct i915_request · line 533

Quoted 11 lines
drivers/gpu/drm/i915/gt/intel_context.c +1 -0
index e94365b08f1ef..4285c1c71fa12 100644
@@ -528,7 +528,7 @@ struct i915_request 
 *intel_context_create_request(struct intel_context *ce)
       return rq;
   }
   -struct i915_request *intel_context_find_active_request(struct intel_context *ce)
+struct i915_request *intel_context_find_active_request_get(struct 
 intel_context *ce)

TBH I don't "dig" this name, it's a bit on the long side and feels out of character. I won't insist it be changed, but if get really has to be included in the name I would be happy with intel_context_get_active_request().

Personally, I see the 'find' component as meaning it is a search not just a dereference of an existing pointer and therefore being a useful part of the name. I don't think there is a simple name that encapsulates everything that is going on here. But I don't feel too strongly about it if you really think the shorter version is better.

One could add some kerneldoc... but it would be almost the only function in the whole of intel_context.h with such. Not sure if that is intentional because "obviously it should be obvious what a function is doing by reading the code and documentation is a waste of space that gets out of date and inaccurate" and we aren't meant to kerneldoc internal behaviour or if it's just the general lack of documentation for any driver code.

Quoted 52 lines
Quoted 43 lines
drivers/gpu/drm/i915/gt/intel_context.c +0 -0
   {

      struct intel_context *parent = intel_context_to_parent(ce); struct i915_request *rq, *active = NULL;

drivers/gpu/drm/i915/gt/intel_context.c +2 -0
@@ -552,6 +552,8 @@ struct i915_request 
 *intel_context_find_active_request(struct intel_context *ce)
             active = rq;
       }
+    if (active)
+        active = i915_request_get_rcu(active);
       spin_unlock_irqrestore(&parent->guc_state.lock, flags);
         return active;
drivers/gpu/drm/i915/gt/intel_context.h +0 -0
index fb62b7b8cbcda..ccc80c6607ca8 100644
@@ -268,8 +268,7 @@ int intel_context_prepare_remote_request(struct 
 intel_context *ce,
     struct i915_request *intel_context_create_request(struct intel_context *ce);

  -struct i915_request *

drivers/gpu/drm/i915/gt/intel_context.h +1 -1
-intel_context_find_active_request(struct intel_context *ce);
+struct i915_request *intel_context_find_active_request_get(struct 

intel_context *ce);
    static inline bool intel_context_is_barrier(const struct intel_context *ce) {

drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -0
index 922f1bb22dc68..fbc0a81617e89 100644
@@ -2237,9 +2237,11 @@ static void engine_dump_active_requests(struct 

intel_engine_cs *engine, struct d
      if (guc) {
          ce = intel_engine_get_hung_context(engine);
          if (ce)
-            hung_rq = intel_context_find_active_request(ce); +            hung_rq = intel_context_find_active_request_get(ce); } else {
          hung_rq = intel_engine_execlist_find_hung_request(engine); +        if (hung_rq)
+            hung_rq = i915_request_get_rcu(hung_rq);
      }
        if (hung_rq)

drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -0
@@ -2250,6 +2252,8 @@ static void engine_dump_active_requests(struct 
Quoted 6 lines

intel_engine_cs *engine, struct d
      else intel_engine_dump_active_requests(&engine->sched_engine->requests, hung_rq, m);
+    if (hung_rq)
+        i915_request_put(hung_rq);

Argh... this is so horrible - not your patch - but the existing state of GuC backend was plugged in. I honestly don't know what to suggest here at this point... Above we have:

Quoted 7 lines

    if (guc)
        intel_guc_dump_active_requests(engine, hung_rq, m); else intel_engine_dump_active_requests(&engine->sched_engine->requests, hung_rq, m);

As per your analysis the execlists code wants one lock held over that, especially when it calls intel_engine_dump_active_requests, which the GuC backed will also call from intel_guc_dump_active_requests (!) just needs a different lock held around it.

Because the lock is effectively the backend implementation lock, not a top level driver global lock. So each backend has its own private lock around its own private data. It just so happens that both backends have a vaguely common list of tracked requests that can therefore be dumped by a common helper, even though the lists are managed completely differently.

Quoted 2 lines

Is the lock held by intel_engine_dump over the call to engine_dump_active_requests truly useless in case of GuC? Or just wrong scope (too wide)?

Basically, yes. So far as I can tell, it is useless. It is locking a list that is only used by the execlist backend. The whole thing is a mess. Execlists was the only way to be and so ruled the universe. Then GuC came along and said 'hang on, that doesn't work for me'. Much horridness ensued.

Roll on Xe with it's correct layering...

Quoted 72 lines
Quoted 72 lines

  }
    void intel_engine_dump(struct intel_engine_cs *engine,

drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +0 -0
index b436dd7f12e42..ad4b2848b0f83 100644
@@ -1702,7 +1702,7 @@ static void __guc_reset_context(struct 

intel_context *ce, intel_engine_mask_t st
              goto next_context;
            guilty = false;
-        rq = intel_context_find_active_request(ce); +        rq = intel_context_find_active_request_get(ce); if (!rq) {
              head = ce->ring->tail;
              goto out_replay;

drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +0 -0
@@ -1715,6 +1715,7 @@ static void __guc_reset_context(struct 

intel_context *ce, intel_engine_mask_t st 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:

drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +2 -0
@@ -4820,6 +4821,8 @@ void intel_guc_find_hung_context(struct 
 intel_engine_cs *engine)
         xa_lock_irqsave(&guc->context_lookup, flags);
       xa_for_each(&guc->context_lookup, index, ce) {
+        bool found;
+
           if (!kref_get_unless_zero(&ce->ref))
               continue;
   @@ -4836,10 +4839,18 @@ void intel_guc_find_hung_context(struct intel_engine_cs *engine)

                  goto next;
          }
  +        found = false;
+        spin_lock(&ce->guc_state.lock); list_for_each_entry(rq, &ce->guc_state.requests, sched.link) { if (i915_test_request_state(rq) != I915_REQUEST_ACTIVE) continue;
  +            found = true;
+            break;
+        }
+        spin_unlock(&ce->guc_state.lock);
+
+        if (found) {
              intel_engine_set_hung_context(engine, ce);
                /* Can only cope with one hang at a time... */

drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +1 -0
@@ -4847,6 +4858,7 @@ void intel_guc_find_hung_context(struct 
 intel_engine_cs *engine)
               xa_lock(&guc->context_lookup);
               goto done;
           }
+

  next:
          intel_context_put(ce);
          xa_lock(&guc->context_lookup);

drivers/gpu/drm/i915/i915_gpu_error.c +1 -1
index 9d5d5a397b64e..5c73dfa2fb3f6 100644
@@ -1607,7 +1607,7 @@ capture_engine(struct intel_engine_cs *engine,
       ce = intel_engine_get_hung_context(engine);
       if (ce) {
           intel_engine_clear_hung_context(engine);
-        rq = intel_context_find_active_request(ce);
+        rq = intel_context_find_active_request_get(ce);
           if (!rq || !i915_request_started(rq))
               goto no_request_capture;
       } else {
@@ -1618,21 +1618,18 @@ capture_engine(struct intel_engine_cs *engine,
           if (!intel_uc_uses_guc_submission(&engine->gt->uc)) {
Quoted 8 lines

drivers/gpu/drm/i915/i915_gpu_error.c capture_engine(struct intel_engine_cs *engine, · line 1624

Quoted 6 lines
drivers/gpu/drm/i915/i915_gpu_error.c +2 -0
 spin_lock_irqsave(&engine->sched_engine->lock, flags);
               rq = intel_engine_execlist_find_hung_request(engine);
+            if (rq)
+                rq = i915_request_get_rcu(rq);
 spin_unlock_irqrestore(&engine->sched_engine->lock,
                              flags);

Is it possible to consolidate this block with the one in engine_dump_active_requests? They seem identical..

You mean as per the next patch that replaces both blocks with a common helper function - intel_engine_get_hung_entity?

Quoted 2 lines

<snip>
If locking can be untangled to work correctly for both callers.

The next patch reworks the debugfs dump code to have correct and minimal locking. That allows the search to be extracted into a common helper.

John.

Quoted 30 lines

Looks like I can't do a quick review on this but need to set aside a larger chunk of time. I'll try tomorrow.

Regards,

Tvrtko

Quoted 23 lines
drivers/gpu/drm/i915/i915_gpu_error.c +1 -6
           }
       }
-    if (rq)
-        rq = i915_request_get_rcu(rq);
-
       if (!rq)
           goto no_request_capture;
         capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);
-    if (!capture) {
-        i915_request_put(rq);
+    if (!capture)
           goto no_request_capture;
-    }
       if (dump_flags & CORE_DUMP_FLAG_IS_GUC_CAPTURE)
           intel_guc_capture_get_matching_node(engine->gt, ee, ce);
   @@ -1642,6 +1639,8 @@ capture_engine(struct intel_engine_cs *engine,
       return ee;

    no_request_capture:
+    if (rq)
+        i915_request_put(rq);
      kfree(ee);
      return NULL;
  }

#4 lore raw

Re: [PATCH v4 1/7] drm/i915: Fix request locking during error capture & debugfs dump

In reply to Tvrtko Ursulin
Quoted 10 lines · Tvrtko Ursulin
Quoted 7 lines · On 20/01/2023 23:28, [email protected] wrote:

From: John Harrison <[email protected]>

<snip>

  -struct i915_request *intel_context_find_active_request(struct intel_context *ce) +struct i915_request *intel_context_find_active_request_get(struct intel_context *ce)

TBH I don't "dig" this name, it's a bit on the long side and feels out of character. I won't insist it be changed, but if get really has to be included in the name I would be happy with intel_context_get_active_request().

Daniele sided with you on this one. Will use your naming.

John.

#5 lore raw

PATCH v4 2/7 drm/i915: Fix up locking around dumping requests lists

In reply to [email protected]

From: John Harrison <[email protected]>

The debugfs dump of requests was confused about what state requires the execlist lock versus the GuC lock. There was also a bunch of duplicated messy code between it and the error capture code.

So refactor the hung request search into a re-usable function. And reduce the span of the execlist state lock to only the execlist specific code paths. In order to do that, also move the report of hold count (which is an execlist only concept) from the top level dump function to the lower level execlist specific function. Also, move the execlist specific code into the execlist source file.

v2: Rename some functions and move to more appropriate files (Daniele).

---
 drivers/gpu/drm/i915/gt/intel_engine.h        |  4 +-
 drivers/gpu/drm/i915/gt/intel_engine_cs.c     | 74 +++++++++----------
 .../drm/i915/gt/intel_execlists_submission.c  | 27 +++++++
 .../drm/i915/gt/intel_execlists_submission.h  |  4 +
 drivers/gpu/drm/i915/i915_gpu_error.c         | 26 +------
 5 files changed, 73 insertions(+), 62 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine.h +2 -2
index 0e24af5efee9c..b58c30ac8ef02 100644
@@ -250,8 +250,8 @@ void intel_engine_dump_active_requests(struct list_head *requests,
 ktime_t intel_engine_get_busy_time(struct intel_engine_cs *engine,
 				   ktime_t *now);
 
-struct i915_request *
-intel_engine_execlist_find_hung_request(struct intel_engine_cs *engine);
+void intel_engine_get_hung_entity(struct intel_engine_cs *engine,
+				  struct intel_context **ce, struct i915_request **rq);
 
 u32 intel_engine_context_size(struct intel_gt *gt, u8 class);
 struct intel_context *
drivers/gpu/drm/i915/gt/intel_engine_cs.c +37 -37

128 lines not on this page · raw message

drivers/gpu/drm/i915/gt/intel_execlists_submission.c +27 -0
index 18ffe55282e59..05995c8577bef 100644
@@ -4150,6 +4150,33 @@ void intel_execlists_show_requests(struct intel_engine_cs *engine,
 	spin_unlock_irqrestore(&sched_engine->lock, flags);
 }
 
+static unsigned long list_count(struct list_head *list)
+{
+	struct list_head *pos;
+	unsigned long count = 0;
+
+	list_for_each(pos, list)
+		count++;
+
+	return count;
+}
+
+void intel_execlist_dump_active_requests(struct intel_engine_cs *engine,
+					 struct i915_request *hung_rq,
+					 struct drm_printer *m)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&engine->sched_engine->lock, flags);
+
+	intel_engine_dump_active_requests(&engine->sched_engine->requests, hung_rq, m);
+
+	drm_printf(m, "\tOn hold?: %lu\n",
+		   list_count(&engine->sched_engine->hold));
+
+	spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
+}
+
 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
 #include "selftest_execlists.c"
 #endif
drivers/gpu/drm/i915/gt/intel_execlists_submission.h +4 -0
index a1aa92c983a51..cb07488a03764 100644
@@ -32,6 +32,10 @@ void intel_execlists_show_requests(struct intel_engine_cs *engine,
 							int indent),
 				   unsigned int max);
 
+void intel_execlist_dump_active_requests(struct intel_engine_cs *engine,
+					 struct i915_request *hung_rq,
+					 struct drm_printer *m);
+
 bool
 intel_engine_in_execlists_submission_mode(const struct intel_engine_cs *engine);
 
drivers/gpu/drm/i915/i915_gpu_error.c +3 -23
index 5c73dfa2fb3f6..b20bd6365615b 100644
@@ -1596,35 +1596,15 @@ capture_engine(struct intel_engine_cs *engine,
 {
 	struct intel_engine_capture_vma *capture = NULL;
 	struct intel_engine_coredump *ee;
-	struct intel_context *ce;
+	struct intel_context *ce = NULL;
 	struct i915_request *rq = NULL;
-	unsigned long flags;
 
 	ee = intel_engine_coredump_alloc(engine, ALLOW_FAIL, dump_flags);
 	if (!ee)
 		return NULL;
 
-	ce = intel_engine_get_hung_context(engine);
-	if (ce) {
-		intel_engine_clear_hung_context(engine);
-		rq = intel_context_find_active_request_get(ce);
-		if (!rq || !i915_request_started(rq))
-			goto no_request_capture;
-	} else {
-		/*
-		 * Getting here with GuC enabled means it is a forced error capture
-		 * with no actual hang. So, no need to attempt the execlist search.
-		 */
-		if (!intel_uc_uses_guc_submission(&engine->gt->uc)) {
-			spin_lock_irqsave(&engine->sched_engine->lock, flags);
-			rq = intel_engine_execlist_find_hung_request(engine);
-			if (rq)
-				rq = i915_request_get_rcu(rq);
-			spin_unlock_irqrestore(&engine->sched_engine->lock,
-					       flags);
-		}
-	}
-	if (!rq)
+	intel_engine_get_hung_entity(engine, &ce, &rq);
+	if (!rq || !i915_request_started(rq))
 		goto no_request_capture;
 
 	capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);
Signature · 1 line
2.39.0
#6 lore raw

Re: [PATCH v4 2/7] drm/i915: Fix up locking around dumping requests lists

Quoted 13 lines · On 1/20/2023 15:28, [email protected] wrote:

From: John Harrison <[email protected]>

The debugfs dump of requests was confused about what state requires the execlist lock versus the GuC lock. There was also a bunch of duplicated messy code between it and the error capture code.

So refactor the hung request search into a re-usable function. And reduce the span of the execlist state lock to only the execlist specific code paths. In order to do that, also move the report of hold count (which is an execlist only concept) from the top level dump function to the lower level execlist specific function. Also, move the execlist specific code into the execlist source file.

Quoted 3 lines

v2: Rename some functions and move to more appropriate files (Daniele).

Fixes dc0dad365c5e ("drm/i915/guc: Fix for error capture after full GPU reset with GuC")
Cc John Harrison <[email protected]>
Cc Matthew Brost <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Daniele Ceraolo Spurio <[email protected]>
Cc Matt Roper <[email protected]>
Cc Umesh Nerlige Ramappa <[email protected]>
Cc Michael Cheng <[email protected]>
Cc Lucas De Marchi <[email protected]>
Cc Bruce Chang <[email protected]>
Cc Alan Previn <[email protected]>
Cc Matthew Auld <[email protected]>

John.

#7 lore raw

Re: [Intel-gfx] [PATCH v4 2/7] drm/i915: Fix up locking around dumping requests lists

In reply to [email protected]
Quoted 6 lines · On 20/01/2023 23:28, [email protected] wrote:

From: John Harrison <[email protected]>

The debugfs dump of requests was confused about what state requires the execlist lock versus the GuC lock. There was also a bunch of duplicated messy code between it and the error capture code.

Quoted 8 lines

So refactor the hung request search into a re-usable function. And reduce the span of the execlist state lock to only the execlist specific code paths. In order to do that, also move the report of hold count (which is an execlist only concept) from the top level dump function to the lower level execlist specific function. Also, move the execlist specific code into the execlist source file.

v2: Rename some functions and move to more appropriate files (Daniele).

Continuing from yesterday where you pointed out 2/7 exists, after I declared capitulation on 1/7.. I think this refactor makes sense and definitely improves things a lot.

On the high level I am only unsure if the patch split could be improved. There seem to be three separate things, correct me if I missed something:

1) Locking fix in intel_guc_find_hung_context
2) Ref counting change throughout
3) Locking refactor / helper consolidation

(Or 2 and 3 swapped around, not sure.)

That IMO might be a bit easier to read because first patch wouldn't have two logical changes in it. Maybe easier to backport too if it comes to that?

On the low level it all looks fine to me - hopefully Daniele can do a detailed pass.

Regards,

Tvrtko

P.S. Only that intel_context_find_active_request_get hurts my eyes, and inflates the diff. I wouldn't rename it but if you guys insist okay.

Quoted 259 lines
---
  drivers/gpu/drm/i915/gt/intel_engine.h        |  4 +-
  drivers/gpu/drm/i915/gt/intel_engine_cs.c     | 74 +++++++++----------
  .../drm/i915/gt/intel_execlists_submission.c  | 27 +++++++
  .../drm/i915/gt/intel_execlists_submission.h  |  4 +
  drivers/gpu/drm/i915/i915_gpu_error.c         | 26 +------
  5 files changed, 73 insertions(+), 62 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine.h +2 -2
index 0e24af5efee9c..b58c30ac8ef02 100644
@@ -250,8 +250,8 @@ void intel_engine_dump_active_requests(struct list_head *requests,
  ktime_t intel_engine_get_busy_time(struct intel_engine_cs *engine,
  				   ktime_t *now);
 
-struct i915_request *
-intel_engine_execlist_find_hung_request(struct intel_engine_cs *engine);
+void intel_engine_get_hung_entity(struct intel_engine_cs *engine,
+				  struct intel_context **ce, struct i915_request **rq);
 
  u32 intel_engine_context_size(struct intel_gt *gt, u8 class);
  struct intel_context *
drivers/gpu/drm/i915/gt/intel_engine_cs.c +37 -37
index fbc0a81617e89..1d77e27801bce 100644
@@ -2114,17 +2114,6 @@ static void print_request_ring(struct drm_printer *m, struct i915_request *rq)
  	}
  }
 
-static unsigned long list_count(struct list_head *list)
-{
-	struct list_head *pos;
-	unsigned long count = 0;
-
-	list_for_each(pos, list)
-		count++;
-
-	return count;
-}
-
  static unsigned long read_ul(void *p, size_t x)
  {
  	return *(unsigned long *)(p + x);
@@ -2216,11 +2205,11 @@ void intel_engine_dump_active_requests(struct list_head *requests,
  	}
  }
 
-static void engine_dump_active_requests(struct intel_engine_cs *engine, struct drm_printer *m)
+static void engine_dump_active_requests(struct intel_engine_cs *engine,
+					struct drm_printer *m)
  {
+	struct intel_context *hung_ce = NULL;
  	struct i915_request *hung_rq = NULL;
-	struct intel_context *ce;
-	bool guc;
 
  	/*
  	 * No need for an engine->irq_seqno_barrier() before the seqno reads.
@@ -2229,29 +2218,20 @@ static void engine_dump_active_requests(struct intel_engine_cs *engine, struct d
  	 * But the intention here is just to report an instantaneous snapshot
  	 * so that's fine.
  	 */
-	lockdep_assert_held(&engine->sched_engine->lock);
+	intel_engine_get_hung_entity(engine, &hung_ce, &hung_rq);
 
  	drm_printf(m, "\tRequests:\n");
 
-	guc = intel_uc_uses_guc_submission(&engine->gt->uc);
-	if (guc) {
-		ce = intel_engine_get_hung_context(engine);
-		if (ce)
-			hung_rq = intel_context_find_active_request_get(ce);
-	} else {
-		hung_rq = intel_engine_execlist_find_hung_request(engine);
-		if (hung_rq)
-			hung_rq = i915_request_get_rcu(hung_rq);
-	}
-
  	if (hung_rq)
  		engine_dump_request(hung_rq, m, "\t\thung");
+	else if (hung_ce)
+		drm_printf(m, "\t\tGot hung ce but no hung rq!\n");
 
-	if (guc)
+	if (intel_uc_uses_guc_submission(&engine->gt->uc))
  		intel_guc_dump_active_requests(engine, hung_rq, m);
  	else
-		intel_engine_dump_active_requests(&engine->sched_engine->requests,
-						  hung_rq, m);
+		intel_execlist_dump_active_requests(engine, hung_rq, m);
+
  	if (hung_rq)
  		i915_request_put(hung_rq);
  }
@@ -2263,7 +2243,6 @@ void intel_engine_dump(struct intel_engine_cs *engine,
  	struct i915_gpu_error * const error = &engine->i915->gpu_error;
  	struct i915_request *rq;
  	intel_wakeref_t wakeref;
-	unsigned long flags;
  	ktime_t dummy;
 
  	if (header) {
@@ -2300,13 +2279,8 @@ void intel_engine_dump(struct intel_engine_cs *engine,
  		   i915_reset_count(error));
  	print_properties(engine, m);
 
-	spin_lock_irqsave(&engine->sched_engine->lock, flags);
  	engine_dump_active_requests(engine, m);
 
-	drm_printf(m, "\tOn hold?: %lu\n",
-		   list_count(&engine->sched_engine->hold));
-	spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
-
  	drm_printf(m, "\tMMIO base:  0x%08x\n", engine->mmio_base);
  	wakeref = intel_runtime_pm_get_if_in_use(engine->uncore->rpm);
  	if (wakeref) {
@@ -2352,8 +2326,7 @@ intel_engine_create_virtual(struct intel_engine_cs **siblings,
  	return siblings[0]->cops->create_virtual(siblings, count, flags);
  }
 
-struct i915_request *
-intel_engine_execlist_find_hung_request(struct intel_engine_cs *engine)
+static struct i915_request *engine_execlist_find_hung_request(struct intel_engine_cs *engine)
  {
  	struct i915_request *request, *active = NULL;
 
@@ -2405,6 +2378,33 @@ intel_engine_execlist_find_hung_request(struct intel_engine_cs *engine)
  	return active;
  }
 
+void intel_engine_get_hung_entity(struct intel_engine_cs *engine,
+				  struct intel_context **ce, struct i915_request **rq)
+{
+	unsigned long flags;
+
+	*ce = intel_engine_get_hung_context(engine);
+	if (*ce) {
+		intel_engine_clear_hung_context(engine);
+
+		*rq = intel_context_find_active_request_get(*ce);
+		return;
+	}
+
+	/*
+	 * Getting here with GuC enabled means it is a forced error capture
+	 * with no actual hang. So, no need to attempt the execlist search.
+	 */
+	if (intel_uc_uses_guc_submission(&engine->gt->uc))
+		return;
+
+	spin_lock_irqsave(&engine->sched_engine->lock, flags);
+	*rq = engine_execlist_find_hung_request(engine);
+	if (*rq)
+		*rq = i915_request_get_rcu(*rq);
+	spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
+}
+
  void xehp_enable_ccs_engines(struct intel_engine_cs *engine)
  {
  	/*
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +27 -0
index 18ffe55282e59..05995c8577bef 100644
@@ -4150,6 +4150,33 @@ void intel_execlists_show_requests(struct intel_engine_cs *engine,
  	spin_unlock_irqrestore(&sched_engine->lock, flags);
  }
 
+static unsigned long list_count(struct list_head *list)
+{
+	struct list_head *pos;
+	unsigned long count = 0;
+
+	list_for_each(pos, list)
+		count++;
+
+	return count;
+}
+
+void intel_execlist_dump_active_requests(struct intel_engine_cs *engine,
+					 struct i915_request *hung_rq,
+					 struct drm_printer *m)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&engine->sched_engine->lock, flags);
+
+	intel_engine_dump_active_requests(&engine->sched_engine->requests, hung_rq, m);
+
+	drm_printf(m, "\tOn hold?: %lu\n",
+		   list_count(&engine->sched_engine->hold));
+
+	spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
+}
+
  #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
  #include "selftest_execlists.c"
  #endif
drivers/gpu/drm/i915/gt/intel_execlists_submission.h +4 -0
index a1aa92c983a51..cb07488a03764 100644
@@ -32,6 +32,10 @@ void intel_execlists_show_requests(struct intel_engine_cs *engine,
  							int indent),
  				   unsigned int max);
 
+void intel_execlist_dump_active_requests(struct intel_engine_cs *engine,
+					 struct i915_request *hung_rq,
+					 struct drm_printer *m);
+
  bool
  intel_engine_in_execlists_submission_mode(const struct intel_engine_cs *engine);
 
drivers/gpu/drm/i915/i915_gpu_error.c +3 -23
index 5c73dfa2fb3f6..b20bd6365615b 100644
@@ -1596,35 +1596,15 @@ capture_engine(struct intel_engine_cs *engine,
  {
  	struct intel_engine_capture_vma *capture = NULL;
  	struct intel_engine_coredump *ee;
-	struct intel_context *ce;
+	struct intel_context *ce = NULL;
  	struct i915_request *rq = NULL;
-	unsigned long flags;
 
  	ee = intel_engine_coredump_alloc(engine, ALLOW_FAIL, dump_flags);
  	if (!ee)
  		return NULL;
 
-	ce = intel_engine_get_hung_context(engine);
-	if (ce) {
-		intel_engine_clear_hung_context(engine);
-		rq = intel_context_find_active_request_get(ce);
-		if (!rq || !i915_request_started(rq))
-			goto no_request_capture;
-	} else {
-		/*
-		 * Getting here with GuC enabled means it is a forced error capture
-		 * with no actual hang. So, no need to attempt the execlist search.
-		 */
-		if (!intel_uc_uses_guc_submission(&engine->gt->uc)) {
-			spin_lock_irqsave(&engine->sched_engine->lock, flags);
-			rq = intel_engine_execlist_find_hung_request(engine);
-			if (rq)
-				rq = i915_request_get_rcu(rq);
-			spin_unlock_irqrestore(&engine->sched_engine->lock,
-					       flags);
-		}
-	}
-	if (!rq)
+	intel_engine_get_hung_entity(engine, &ce, &rq);
+	if (!rq || !i915_request_started(rq))
  		goto no_request_capture;
 
  	capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);
#8 lore raw

Re: [Intel-gfx] [PATCH v4 2/7] drm/i915: Fix up locking around dumping requests lists

Quoted 14 lines · Tvrtko Ursulin
Quoted 13 lines · On 20/01/2023 23:28, [email protected] wrote:

From: John Harrison <[email protected]>

The debugfs dump of requests was confused about what state requires the execlist lock versus the GuC lock. There was also a bunch of duplicated messy code between it and the error capture code.

So refactor the hung request search into a re-usable function. And reduce the span of the execlist state lock to only the execlist specific code paths. In order to do that, also move the report of hold count (which is an execlist only concept) from the top level dump function to the lower level execlist specific function. Also, move the execlist specific code into the execlist source file.

Quoted 7 lines
Quoted 1 line

v2: Rename some functions and move to more appropriate files (Daniele).

Continuing from yesterday where you pointed out 2/7 exists, after I declared capitulation on 1/7.. I think this refactor makes sense and definitely improves things a lot.

On the high level I am only unsure if the patch split could be improved. There seem to be three separate things, correct me if I missed something:

1) Locking fix in intel_guc_find_hung_context

This is the change already it's own patch - #1/7. Can't really split that one up any further. Changing the internal GuC code requires changing the external common code to match.

Quoted 2 lines

2) Ref counting change throughout
3) Locking refactor / helper consolidation

These two being the changes in this patch - #2/7, yes?

The problem is that the reference counting fixes can only be done once the code has been refactored/reordered. And the refactor/reorder can only be done if the reference counting is fixed. I guess there would be some way to do the re-order first but it would require making even more of a mess of the spinlock activity to keep it all correct around that intermediate stage. So I don't think it would noticeably simplify the patch.

Quoted 4 lines

(Or 2 and 3 swapped around, not sure.)

That IMO might be a bit easier to read because first patch wouldn't have two logical changes in it. Maybe easier to backport too if it comes to that?

I'm not seeing 'two logical changes' in the first patch. Patch #1 fixes the reference counting of finding the hung request. That involves adding a reference count internally within the spinlock on the GuC side and moving the external reference count to within the spinlock on the execlist side and then doing a put in all cases. That really is a single change. It can't be split without either a) introducing a get/put mis-match bug or b) making the code really ugly as an intermediate (while still leaving one or other side broken).

John.

Quoted 263 lines

On the low level it all looks fine to me - hopefully Daniele can do a detailed pass.

Regards,

Tvrtko

P.S. Only that intel_context_find_active_request_get hurts my eyes, and inflates the diff. I wouldn't rename it but if you guys insist okay.

Quoted 254 lines

---
  drivers/gpu/drm/i915/gt/intel_engine.h        |  4 +- drivers/gpu/drm/i915/gt/intel_engine_cs.c     | 74 +++++++++---------- .../drm/i915/gt/intel_execlists_submission.c  | 27 +++++++ .../drm/i915/gt/intel_execlists_submission.h  |  4 + drivers/gpu/drm/i915/i915_gpu_error.c         | 26 +------

  5 files changed, 73 insertions(+), 62 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine.h +0 -0
index 0e24af5efee9c..b58c30ac8ef02 100644
@@ -250,8 +250,8 @@ void intel_engine_dump_active_requests(struct 
 list_head *requests,
   ktime_t intel_engine_get_busy_time(struct intel_engine_cs *engine,
                      ktime_t *now);

  -struct i915_request * -intel_engine_execlist_find_hung_request(struct intel_engine_cs *engine);
+void intel_engine_get_hung_entity(struct intel_engine_cs *engine, +                  struct intel_context **ce, struct i915_request **rq); u32 intel_engine_context_size(struct intel_gt *gt, u8 class); struct intel_context *

drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -10
index fbc0a81617e89..1d77e27801bce 100644
@@ -2114,17 +2114,6 @@ static void print_request_ring(struct 
 drm_printer *m, struct i915_request *rq)
       }
   }
   -static unsigned long list_count(struct list_head *list)
-{
-    struct list_head *pos;
-    unsigned long count = 0;
-
-    list_for_each(pos, list)
-        count++;
-
-    return count;
-}
-
   static unsigned long read_ul(void *p, size_t x)
   {

      return *(unsigned long *)(p + x);

drivers/gpu/drm/i915/gt/intel_engine_cs.c +3 -2
@@ -2216,11 +2205,11 @@ void intel_engine_dump_active_requests(struct 
 list_head *requests,
       }
   }
   -static void engine_dump_active_requests(struct intel_engine_cs *engine, struct drm_printer *m)
+static void engine_dump_active_requests(struct intel_engine_cs *engine,
+                    struct drm_printer *m)
   {
+    struct intel_context *hung_ce = NULL;
       struct i915_request *hung_rq = NULL;
-    struct intel_context *ce;
-    bool guc;
         /*
        * No need for an engine->irq_seqno_barrier() before the seqno reads.
@@ -2229,29 +2218,20 @@ static void 

engine_dump_active_requests(struct intel_engine_cs *engine, struct d
       * But the intention here is just to report an instantaneous snapshot
       * so that's fine.
       */
-    lockdep_assert_held(&engine->sched_engine->lock);
+    intel_engine_get_hung_entity(engine, &hung_ce, &hung_rq); drm_printf(m, "\tRequests:\n");
  -    guc = intel_uc_uses_guc_submission(&engine->gt->uc);
-    if (guc) {
-        ce = intel_engine_get_hung_context(engine);
-        if (ce)
-            hung_rq = intel_context_find_active_request_get(ce); -    } else {
-        hung_rq = intel_engine_execlist_find_hung_request(engine); -        if (hung_rq)
-            hung_rq = i915_request_get_rcu(hung_rq);
-    }
-
      if (hung_rq)
          engine_dump_request(hung_rq, m, "\t\thung");
+    else if (hung_ce)
+        drm_printf(m, "\t\tGot hung ce but no hung rq!\n");
  -    if (guc)
+    if (intel_uc_uses_guc_submission(&engine->gt->uc)) intel_guc_dump_active_requests(engine, hung_rq, m); else
- intel_engine_dump_active_requests(&engine->sched_engine->requests, -                          hung_rq, m);
+        intel_execlist_dump_active_requests(engine, hung_rq, m); +
      if (hung_rq)
          i915_request_put(hung_rq);
  }

drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -4
@@ -2263,7 +2243,6 @@ void intel_engine_dump(struct intel_engine_cs 
 *engine,
       struct i915_gpu_error * const error = &engine->i915->gpu_error;
       struct i915_request *rq;
       intel_wakeref_t wakeref;
-    unsigned long flags;
       ktime_t dummy;
         if (header) {
@@ -2300,13 +2279,8 @@ void intel_engine_dump(struct intel_engine_cs 
 *engine,
              i915_reset_count(error));
       print_properties(engine, m);
   -    spin_lock_irqsave(&engine->sched_engine->lock, flags);
       engine_dump_active_requests(engine, m);
   -    drm_printf(m, "\tOn hold?: %lu\n",
-           list_count(&engine->sched_engine->hold));
- spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
-
       drm_printf(m, "\tMMIO base:  0x%08x\n", engine->mmio_base);
       wakeref = intel_runtime_pm_get_if_in_use(engine->uncore->rpm);

      if (wakeref) {

drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -0
@@ -2352,8 +2326,7 @@ intel_engine_create_virtual(struct 
 intel_engine_cs **siblings,
       return siblings[0]->cops->create_virtual(siblings, count, flags);
   }

  -struct i915_request *

drivers/gpu/drm/i915/gt/intel_engine_cs.c +1 -1
-intel_engine_execlist_find_hung_request(struct intel_engine_cs *engine)
+static struct i915_request *engine_execlist_find_hung_request(struct 

intel_engine_cs *engine)
  {
      struct i915_request *request, *active = NULL;
  @@ -2405,6 +2378,33 @@ intel_engine_execlist_find_hung_request(struct intel_engine_cs *engine) return active;
  }
  +void intel_engine_get_hung_entity(struct intel_engine_cs *engine,
+                  struct intel_context **ce, struct i915_request **rq)

drivers/gpu/drm/i915/gt/intel_engine_cs.c +25 -0
+{
+    unsigned long flags;
+
+    *ce = intel_engine_get_hung_context(engine);
+    if (*ce) {
+        intel_engine_clear_hung_context(engine);
+
+        *rq = intel_context_find_active_request_get(*ce);
+        return;
+    }
+
+    /*
+     * Getting here with GuC enabled means it is a forced error capture
+     * with no actual hang. So, no need to attempt the execlist search.
+     */
+    if (intel_uc_uses_guc_submission(&engine->gt->uc))
+        return;
+
+    spin_lock_irqsave(&engine->sched_engine->lock, flags);
+    *rq = engine_execlist_find_hung_request(engine);
+    if (*rq)
+        *rq = i915_request_get_rcu(*rq);
+ spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
+}
+

  void xehp_enable_ccs_engines(struct intel_engine_cs *engine) {
      /*

drivers/gpu/drm/i915/gt/intel_execlists_submission.c +26 -0
index 18ffe55282e59..05995c8577bef 100644
@@ -4150,6 +4150,33 @@ void intel_execlists_show_requests(struct 
 intel_engine_cs *engine,
       spin_unlock_irqrestore(&sched_engine->lock, flags);
   }
   +static unsigned long list_count(struct list_head *list)
+{
+    struct list_head *pos;
+    unsigned long count = 0;
+
+    list_for_each(pos, list)
+        count++;
+
+    return count;
+}
+
+void intel_execlist_dump_active_requests(struct intel_engine_cs 
 *engine,
+                     struct i915_request *hung_rq,
+                     struct drm_printer *m)
+{
+    unsigned long flags;
+
+    spin_lock_irqsave(&engine->sched_engine->lock, flags);
+
+ intel_engine_dump_active_requests(&engine->sched_engine->requests, 
 hung_rq, m);
+
+    drm_printf(m, "\tOn hold?: %lu\n",
+           list_count(&engine->sched_engine->hold));
+
+ spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
+}
+

  #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
  #include "selftest_execlists.c"
  #endif

drivers/gpu/drm/i915/gt/intel_execlists_submission.h +3 -0
index a1aa92c983a51..cb07488a03764 100644
@@ -32,6 +32,10 @@ void intel_execlists_show_requests(struct 
 intel_engine_cs *engine,
                               int indent),
                      unsigned int max);
   +void intel_execlist_dump_active_requests(struct intel_engine_cs *engine,
+                     struct i915_request *hung_rq,
+                     struct drm_printer *m);
+

  bool
  intel_engine_in_execlists_submission_mode(const struct intel_engine_cs *engine); diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c index 5c73dfa2fb3f6..b20bd6365615b 100644

drivers/gpu/drm/i915/i915_gpu_error.c +1 -10
@@ -1596,35 +1596,15 @@ capture_engine(struct intel_engine_cs *engine,
   {
       struct intel_engine_capture_vma *capture = NULL;
       struct intel_engine_coredump *ee;
-    struct intel_context *ce;
+    struct intel_context *ce = NULL;
       struct i915_request *rq = NULL;
-    unsigned long flags;
         ee = intel_engine_coredump_alloc(engine, ALLOW_FAIL, dump_flags);
       if (!ee)
           return NULL;
   -    ce = intel_engine_get_hung_context(engine);
-    if (ce) {
-        intel_engine_clear_hung_context(engine);
-        rq = intel_context_find_active_request_get(ce);
-        if (!rq || !i915_request_started(rq))
-            goto no_request_capture;
-    } else {
-        /*
-         * Getting here with GuC enabled means it is a forced error 

capture
-         * with no actual hang. So, no need to attempt the execlist search.
-         */
-        if (!intel_uc_uses_guc_submission(&engine->gt->uc)) {
- spin_lock_irqsave(&engine->sched_engine->lock, flags);
-            rq = intel_engine_execlist_find_hung_request(engine); -            if (rq)
-                rq = i915_request_get_rcu(rq);
- spin_unlock_irqrestore(&engine->sched_engine->lock,
-                           flags);
-        }
-    }
-    if (!rq)
+    intel_engine_get_hung_entity(engine, &ce, &rq);
+    if (!rq || !i915_request_started(rq))
          goto no_request_capture;
        capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);

#9 lore raw

Re: [Intel-gfx] [PATCH v4 2/7] drm/i915: Fix up locking around dumping requests lists

Quoted 28 lines · John Harrison
Quoted 14 lines · Tvrtko Ursulin
Quoted 13 lines · On 20/01/2023 23:28, [email protected] wrote:

From: John Harrison <[email protected]>

The debugfs dump of requests was confused about what state requires the execlist lock versus the GuC lock. There was also a bunch of duplicated messy code between it and the error capture code.

So refactor the hung request search into a re-usable function. And reduce the span of the execlist state lock to only the execlist specific code paths. In order to do that, also move the report of hold count (which is an execlist only concept) from the top level dump function to the lower level execlist specific function. Also, move the execlist specific code into the execlist source file.

Quoted 7 lines
Quoted 1 line

v2: Rename some functions and move to more appropriate files (Daniele).

Continuing from yesterday where you pointed out 2/7 exists, after I declared capitulation on 1/7.. I think this refactor makes sense and definitely improves things a lot.

On the high level I am only unsure if the patch split could be improved. There seem to be three separate things, correct me if I missed something:

1) Locking fix in intel_guc_find_hung_context

This is the change already it's own patch - #1/7. Can't really split that one up any further. Changing the internal GuC code requires changing the external common code to match.

Quoted 2 lines

2) Ref counting change throughout
3) Locking refactor / helper consolidation

These two being the changes in this patch - #2/7, yes?

Quoted 7 lines

The problem is that the reference counting fixes can only be done once the code has been refactored/reordered. And the refactor/reorder can only be done if the reference counting is fixed. I guess there would be some way to do the re-order first but it would require making even more of a mess of the spinlock activity to keep it all correct around that intermediate stage. So I don't think it would noticeably simplify the patch.

Quoted 4 lines

(Or 2 and 3 swapped around, not sure.)

That IMO might be a bit easier to read because first patch wouldn't have two logical changes in it. Maybe easier to backport too if it comes to that?

I'm not seeing 'two logical changes' in the first patch. Patch #1 fixes the reference counting of finding the hung request. That involves adding a reference count internally within the spinlock on the GuC side and moving the external reference count to within the spinlock on the execlist side and then doing a put in all cases. That really is a single change. It can't be split without either a) introducing a get/put mis-match bug or b) making the code really ugly as an intermediate (while still leaving one or other side broken).

I was thinking this part is wholy standalone:

@@ -4820,6 +4821,8 @@ void intel_guc_find_hung_context(struct intel_engine_cs *engine)

xa_lock_irqsave(&guc->context_lookup, flags); xa_for_each(&guc->context_lookup, index, ce) {
+ bool found;
+
if (!kref_get_unless_zero(&ce->ref))
continue;

@@ -4836,10 +4839,18 @@ void intel_guc_find_hung_context(struct intel_engine_cs *engine)
goto next;
}

+ found = false;
+ spin_lock(&ce->guc_state.lock);
list_for_each_entry(rq, &ce->guc_state.requests, sched.link) {
if (i915_test_request_state(rq) != I915_REQUEST_ACTIVE)
continue;

+ found = true;
+ break;
+ }
+ spin_unlock(&ce->guc_state.lock);
+
+ if (found) {
intel_engine_set_hung_context(engine, ce);

/* Can only cope with one hang at a time... */
@@ -4847,6 +4858,7 @@ void intel_guc_find_hung_context(struct intel_engine_cs *engine)
xa_lock(&guc->context_lookup);
goto done;
}
+
next:
intel_context_put(ce);
xa_lock(&guc->context_lookup);

Am I missing something?

Regards,

Tvrtko

Quoted 267 lines

John.

Quoted 263 lines

On the low level it all looks fine to me - hopefully Daniele can do a detailed pass.

Regards,

Tvrtko

P.S. Only that intel_context_find_active_request_get hurts my eyes, and inflates the diff. I wouldn't rename it but if you guys insist okay.

Quoted 254 lines

---
  drivers/gpu/drm/i915/gt/intel_engine.h        |  4 +- drivers/gpu/drm/i915/gt/intel_engine_cs.c     | 74 +++++++++---------- .../drm/i915/gt/intel_execlists_submission.c  | 27 +++++++ .../drm/i915/gt/intel_execlists_submission.h  |  4 + drivers/gpu/drm/i915/i915_gpu_error.c         | 26 +------

  5 files changed, 73 insertions(+), 62 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine.h +0 -0
index 0e24af5efee9c..b58c30ac8ef02 100644
@@ -250,8 +250,8 @@ void intel_engine_dump_active_requests(struct 
 list_head *requests,
   ktime_t intel_engine_get_busy_time(struct intel_engine_cs *engine,
                      ktime_t *now);

  -struct i915_request * -intel_engine_execlist_find_hung_request(struct intel_engine_cs *engine);
+void intel_engine_get_hung_entity(struct intel_engine_cs *engine, +                  struct intel_context **ce, struct i915_request **rq); u32 intel_engine_context_size(struct intel_gt *gt, u8 class); struct intel_context *

drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -10
index fbc0a81617e89..1d77e27801bce 100644
@@ -2114,17 +2114,6 @@ static void print_request_ring(struct 
 drm_printer *m, struct i915_request *rq)
       }
   }
   -static unsigned long list_count(struct list_head *list)
-{
-    struct list_head *pos;
-    unsigned long count = 0;
-
-    list_for_each(pos, list)
-        count++;
-
-    return count;
-}
-
   static unsigned long read_ul(void *p, size_t x)
   {

      return *(unsigned long *)(p + x);

drivers/gpu/drm/i915/gt/intel_engine_cs.c +3 -2
@@ -2216,11 +2205,11 @@ void intel_engine_dump_active_requests(struct 
 list_head *requests,
       }
   }
   -static void engine_dump_active_requests(struct intel_engine_cs *engine, struct drm_printer *m)
+static void engine_dump_active_requests(struct intel_engine_cs *engine,
+                    struct drm_printer *m)
   {
+    struct intel_context *hung_ce = NULL;
       struct i915_request *hung_rq = NULL;
-    struct intel_context *ce;
-    bool guc;
         /*
        * No need for an engine->irq_seqno_barrier() before the seqno reads.
@@ -2229,29 +2218,20 @@ static void 

engine_dump_active_requests(struct intel_engine_cs *engine, struct d
       * But the intention here is just to report an instantaneous snapshot
       * so that's fine.
       */
-    lockdep_assert_held(&engine->sched_engine->lock);
+    intel_engine_get_hung_entity(engine, &hung_ce, &hung_rq); drm_printf(m, "\tRequests:\n");
  -    guc = intel_uc_uses_guc_submission(&engine->gt->uc);
-    if (guc) {
-        ce = intel_engine_get_hung_context(engine);
-        if (ce)
-            hung_rq = intel_context_find_active_request_get(ce); -    } else {
-        hung_rq = intel_engine_execlist_find_hung_request(engine); -        if (hung_rq)
-            hung_rq = i915_request_get_rcu(hung_rq);
-    }
-
      if (hung_rq)
          engine_dump_request(hung_rq, m, "\t\thung");
+    else if (hung_ce)
+        drm_printf(m, "\t\tGot hung ce but no hung rq!\n");
  -    if (guc)
+    if (intel_uc_uses_guc_submission(&engine->gt->uc)) intel_guc_dump_active_requests(engine, hung_rq, m); else
- intel_engine_dump_active_requests(&engine->sched_engine->requests, -                          hung_rq, m);
+        intel_execlist_dump_active_requests(engine, hung_rq, m); +
      if (hung_rq)
          i915_request_put(hung_rq);
  }

drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -4
@@ -2263,7 +2243,6 @@ void intel_engine_dump(struct intel_engine_cs 
 *engine,
       struct i915_gpu_error * const error = &engine->i915->gpu_error;
       struct i915_request *rq;
       intel_wakeref_t wakeref;
-    unsigned long flags;
       ktime_t dummy;
         if (header) {
@@ -2300,13 +2279,8 @@ void intel_engine_dump(struct intel_engine_cs 
 *engine,
              i915_reset_count(error));
       print_properties(engine, m);
   -    spin_lock_irqsave(&engine->sched_engine->lock, flags);
       engine_dump_active_requests(engine, m);
   -    drm_printf(m, "\tOn hold?: %lu\n",
-           list_count(&engine->sched_engine->hold));
- spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
-
       drm_printf(m, "\tMMIO base:  0x%08x\n", engine->mmio_base);
       wakeref = intel_runtime_pm_get_if_in_use(engine->uncore->rpm);

      if (wakeref) {

drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -0
@@ -2352,8 +2326,7 @@ intel_engine_create_virtual(struct 
 intel_engine_cs **siblings,
       return siblings[0]->cops->create_virtual(siblings, count, flags);
   }

  -struct i915_request *

drivers/gpu/drm/i915/gt/intel_engine_cs.c +1 -1
-intel_engine_execlist_find_hung_request(struct intel_engine_cs *engine)
+static struct i915_request *engine_execlist_find_hung_request(struct 

intel_engine_cs *engine)
  {
      struct i915_request *request, *active = NULL;
  @@ -2405,6 +2378,33 @@ intel_engine_execlist_find_hung_request(struct intel_engine_cs *engine) return active;
  }
  +void intel_engine_get_hung_entity(struct intel_engine_cs *engine,
+                  struct intel_context **ce, struct i915_request **rq)

drivers/gpu/drm/i915/gt/intel_engine_cs.c +25 -0
+{
+    unsigned long flags;
+
+    *ce = intel_engine_get_hung_context(engine);
+    if (*ce) {
+        intel_engine_clear_hung_context(engine);
+
+        *rq = intel_context_find_active_request_get(*ce);
+        return;
+    }
+
+    /*
+     * Getting here with GuC enabled means it is a forced error capture
+     * with no actual hang. So, no need to attempt the execlist search.
+     */
+    if (intel_uc_uses_guc_submission(&engine->gt->uc))
+        return;
+
+    spin_lock_irqsave(&engine->sched_engine->lock, flags);
+    *rq = engine_execlist_find_hung_request(engine);
+    if (*rq)
+        *rq = i915_request_get_rcu(*rq);
+ spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
+}
+

  void xehp_enable_ccs_engines(struct intel_engine_cs *engine) {
      /*

drivers/gpu/drm/i915/gt/intel_execlists_submission.c +26 -0
index 18ffe55282e59..05995c8577bef 100644
@@ -4150,6 +4150,33 @@ void intel_execlists_show_requests(struct 
 intel_engine_cs *engine,
       spin_unlock_irqrestore(&sched_engine->lock, flags);
   }
   +static unsigned long list_count(struct list_head *list)
+{
+    struct list_head *pos;
+    unsigned long count = 0;
+
+    list_for_each(pos, list)
+        count++;
+
+    return count;
+}
+
+void intel_execlist_dump_active_requests(struct intel_engine_cs 
 *engine,
+                     struct i915_request *hung_rq,
+                     struct drm_printer *m)
+{
+    unsigned long flags;
+
+    spin_lock_irqsave(&engine->sched_engine->lock, flags);
+
+ intel_engine_dump_active_requests(&engine->sched_engine->requests, 
 hung_rq, m);
+
+    drm_printf(m, "\tOn hold?: %lu\n",
+           list_count(&engine->sched_engine->hold));
+
+ spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
+}
+

  #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
  #include "selftest_execlists.c"
  #endif

drivers/gpu/drm/i915/gt/intel_execlists_submission.h +3 -0
index a1aa92c983a51..cb07488a03764 100644
@@ -32,6 +32,10 @@ void intel_execlists_show_requests(struct 
 intel_engine_cs *engine,
                               int indent),
                      unsigned int max);
   +void intel_execlist_dump_active_requests(struct intel_engine_cs *engine,
+                     struct i915_request *hung_rq,
+                     struct drm_printer *m);
+

  bool
  intel_engine_in_execlists_submission_mode(const struct intel_engine_cs *engine); diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c index 5c73dfa2fb3f6..b20bd6365615b 100644

drivers/gpu/drm/i915/i915_gpu_error.c +1 -10
@@ -1596,35 +1596,15 @@ capture_engine(struct intel_engine_cs *engine,
   {
       struct intel_engine_capture_vma *capture = NULL;
       struct intel_engine_coredump *ee;
-    struct intel_context *ce;
+    struct intel_context *ce = NULL;
       struct i915_request *rq = NULL;
-    unsigned long flags;
         ee = intel_engine_coredump_alloc(engine, ALLOW_FAIL, dump_flags);
       if (!ee)
           return NULL;
   -    ce = intel_engine_get_hung_context(engine);
-    if (ce) {
-        intel_engine_clear_hung_context(engine);
-        rq = intel_context_find_active_request_get(ce);
-        if (!rq || !i915_request_started(rq))
-            goto no_request_capture;
-    } else {
-        /*
-         * Getting here with GuC enabled means it is a forced error 

capture
-         * with no actual hang. So, no need to attempt the execlist search.
-         */
-        if (!intel_uc_uses_guc_submission(&engine->gt->uc)) {
- spin_lock_irqsave(&engine->sched_engine->lock, flags);
-            rq = intel_engine_execlist_find_hung_request(engine); -            if (rq)
-                rq = i915_request_get_rcu(rq);
- spin_unlock_irqrestore(&engine->sched_engine->lock,
-                           flags);
-        }
-    }
-    if (!rq)
+    intel_engine_get_hung_entity(engine, &ce, &rq);
+    if (!rq || !i915_request_started(rq))
          goto no_request_capture;
        capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);

#10 lore raw

Re: [Intel-gfx] [PATCH v4 2/7] drm/i915: Fix up locking around dumping requests lists

Quoted 79 lines · Tvrtko Ursulin
Quoted 28 lines · John Harrison
Quoted 14 lines · Tvrtko Ursulin
Quoted 13 lines · On 20/01/2023 23:28, [email protected] wrote:

From: John Harrison <[email protected]>

The debugfs dump of requests was confused about what state requires the execlist lock versus the GuC lock. There was also a bunch of duplicated messy code between it and the error capture code.

So refactor the hung request search into a re-usable function. And reduce the span of the execlist state lock to only the execlist specific code paths. In order to do that, also move the report of hold count (which is an execlist only concept) from the top level dump function to the lower level execlist specific function. Also, move the execlist specific code into the execlist source file.

Quoted 7 lines
Quoted 1 line

v2: Rename some functions and move to more appropriate files (Daniele).

Continuing from yesterday where you pointed out 2/7 exists, after I declared capitulation on 1/7.. I think this refactor makes sense and definitely improves things a lot.

On the high level I am only unsure if the patch split could be improved. There seem to be three separate things, correct me if I missed something:

1) Locking fix in intel_guc_find_hung_context

This is the change already it's own patch - #1/7. Can't really split that one up any further. Changing the internal GuC code requires changing the external common code to match.

Quoted 2 lines

2) Ref counting change throughout
3) Locking refactor / helper consolidation

These two being the changes in this patch - #2/7, yes?

Quoted 7 lines

The problem is that the reference counting fixes can only be done once the code has been refactored/reordered. And the refactor/reorder can only be done if the reference counting is fixed. I guess there would be some way to do the re-order first but it would require making even more of a mess of the spinlock activity to keep it all correct around that intermediate stage. So I don't think it would noticeably simplify the patch.

Quoted 4 lines

(Or 2 and 3 swapped around, not sure.)

That IMO might be a bit easier to read because first patch wouldn't have two logical changes in it. Maybe easier to backport too if it comes to that?

I'm not seeing 'two logical changes' in the first patch. Patch #1 fixes the reference counting of finding the hung request. That involves adding a reference count internally within the spinlock on the GuC side and moving the external reference count to within the spinlock on the execlist side and then doing a put in all cases. That really is a single change. It can't be split without either a) introducing a get/put mis-match bug or b) making the code really ugly as an intermediate (while still leaving one or other side broken).

I was thinking this part is wholy standalone:

(quoted diff) +10 -0
@@ -4820,6 +4821,8 @@ void intel_guc_find_hung_context(struct 
 intel_engine_cs *engine)
 
      xa_lock_irqsave(&guc->context_lookup, flags);
      xa_for_each(&guc->context_lookup, index, ce) {
+        bool found;
+
          if (!kref_get_unless_zero(&ce->ref))
              continue;
@@ -4836,10 +4839,18 @@ void intel_guc_find_hung_context(struct 
 intel_engine_cs *engine)
                  goto next;
          }
 
+        found = false;
+        spin_lock(&ce->guc_state.lock);
          list_for_each_entry(rq, &ce->guc_state.requests, sched.link) {
              if (i915_test_request_state(rq) != I915_REQUEST_ACTIVE)
                  continue;
 
+            found = true;
+            break;
+        }
+        spin_unlock(&ce->guc_state.lock);
+
+        if (found) {
              intel_engine_set_hung_context(engine, ce);
 

             /* Can only cope with one hang at a time... */

(quoted diff) +1 -0
@@ -4847,6 +4858,7 @@ void intel_guc_find_hung_context(struct 
 intel_engine_cs *engine)
              xa_lock(&guc->context_lookup);
              goto done;
          }
+

 next:
         intel_context_put(ce);
         xa_lock(&guc->context_lookup);

Quoted 1 line

Am I missing something?

Doh.

Yes, I guess that part is stand alone. I was getting myself confused and thinking that was part of moving a get inside the spinlock. But you are right, that part is just about using the correct spinlock for that loop.

So yeah, I can split that chunk out to a separate patch. But that is splitting patch #1 into #1a and #1b. It doesn't help with patch #2. Which is the one I though you were complaining about being too complex. Which it is :(. But I'm really not seeing anyway to simplify it given how much of a mess the code is in.

John.

Quoted 279 lines

Regards,

Tvrtko

Quoted 274 lines

John.

Quoted 270 lines

On the low level it all looks fine to me - hopefully Daniele can do a detailed pass.

Regards,

Tvrtko

P.S. Only that intel_context_find_active_request_get hurts my eyes, and inflates the diff. I wouldn't rename it but if you guys insist okay.

Quoted 261 lines

---
  drivers/gpu/drm/i915/gt/intel_engine.h        |  4 +- drivers/gpu/drm/i915/gt/intel_engine_cs.c     | 74
+++++++++----------
  .../drm/i915/gt/intel_execlists_submission.c  | 27 +++++++ .../drm/i915/gt/intel_execlists_submission.h  |  4 + drivers/gpu/drm/i915/i915_gpu_error.c         | 26 +------

  5 files changed, 73 insertions(+), 62 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine.h +0 -0
index 0e24af5efee9c..b58c30ac8ef02 100644
@@ -250,8 +250,8 @@ void intel_engine_dump_active_requests(struct 
 list_head *requests,
   ktime_t intel_engine_get_busy_time(struct intel_engine_cs *engine,
                      ktime_t *now);

  -struct i915_request * -intel_engine_execlist_find_hung_request(struct intel_engine_cs *engine);
+void intel_engine_get_hung_entity(struct intel_engine_cs *engine, +                  struct intel_context **ce, struct i915_request **rq);
    u32 intel_engine_context_size(struct intel_gt *gt, u8 class); struct intel_context *

drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -10
index fbc0a81617e89..1d77e27801bce 100644
@@ -2114,17 +2114,6 @@ static void print_request_ring(struct 
 drm_printer *m, struct i915_request *rq)
       }
   }
   -static unsigned long list_count(struct list_head *list)
-{
-    struct list_head *pos;
-    unsigned long count = 0;
-
-    list_for_each(pos, list)
-        count++;
-
-    return count;
-}
-
   static unsigned long read_ul(void *p, size_t x)
   {

      return *(unsigned long *)(p + x);

drivers/gpu/drm/i915/gt/intel_engine_cs.c +3 -2
@@ -2216,11 +2205,11 @@ void 
 intel_engine_dump_active_requests(struct list_head *requests,
       }
   }
   -static void engine_dump_active_requests(struct intel_engine_cs *engine, struct drm_printer *m)
+static void engine_dump_active_requests(struct intel_engine_cs 
 *engine,
+                    struct drm_printer *m)
   {
+    struct intel_context *hung_ce = NULL;
       struct i915_request *hung_rq = NULL;
-    struct intel_context *ce;
-    bool guc;
         /*

       * No need for an engine->irq_seqno_barrier() before the seqno reads.

drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -0
@@ -2229,29 +2218,20 @@ static void 

engine_dump_active_requests(struct intel_engine_cs *engine, struct d
       * But the intention here is just to report an instantaneous snapshot
       * so that's fine.
       */
- lockdep_assert_held(&engine->sched_engine->lock);
+    intel_engine_get_hung_entity(engine, &hung_ce, &hung_rq); drm_printf(m, "\tRequests:\n");
  -    guc = intel_uc_uses_guc_submission(&engine->gt->uc);
-    if (guc) {
-        ce = intel_engine_get_hung_context(engine);
-        if (ce)
-            hung_rq = intel_context_find_active_request_get(ce); -    } else {
-        hung_rq = intel_engine_execlist_find_hung_request(engine); -        if (hung_rq)
-            hung_rq = i915_request_get_rcu(hung_rq);
-    }
-
      if (hung_rq)
          engine_dump_request(hung_rq, m, "\t\thung");
+    else if (hung_ce)
+        drm_printf(m, "\t\tGot hung ce but no hung rq!\n");
  -    if (guc)
+    if (intel_uc_uses_guc_submission(&engine->gt->uc)) intel_guc_dump_active_requests(engine, hung_rq, m); else
- intel_engine_dump_active_requests(&engine->sched_engine->requests, -                          hung_rq, m);
+        intel_execlist_dump_active_requests(engine, hung_rq, m); +
      if (hung_rq)
          i915_request_put(hung_rq);
  }

drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -4
@@ -2263,7 +2243,6 @@ void intel_engine_dump(struct intel_engine_cs 
 *engine,
       struct i915_gpu_error * const error = &engine->i915->gpu_error;
       struct i915_request *rq;
       intel_wakeref_t wakeref;
-    unsigned long flags;
       ktime_t dummy;
         if (header) {
@@ -2300,13 +2279,8 @@ void intel_engine_dump(struct 
 intel_engine_cs *engine,
              i915_reset_count(error));
       print_properties(engine, m);
   - spin_lock_irqsave(&engine->sched_engine->lock, flags);
       engine_dump_active_requests(engine, m);
   -    drm_printf(m, "\tOn hold?: %lu\n",
- list_count(&engine->sched_engine->hold));
- spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
-
       drm_printf(m, "\tMMIO base:  0x%08x\n", engine->mmio_base);
       wakeref = intel_runtime_pm_get_if_in_use(engine->uncore->rpm);

      if (wakeref) {

drivers/gpu/drm/i915/gt/intel_engine_cs.c +0 -0
@@ -2352,8 +2326,7 @@ intel_engine_create_virtual(struct 
 intel_engine_cs **siblings,
       return siblings[0]->cops->create_virtual(siblings, count, flags);
   }

  -struct i915_request *
-intel_engine_execlist_find_hung_request(struct intel_engine_cs
*engine)
+static struct i915_request
*engine_execlist_find_hung_request(struct intel_engine_cs *engine)
  {
      struct i915_request *request, *active = NULL;
  @@ -2405,6 +2378,33 @@ intel_engine_execlist_find_hung_request(struct intel_engine_cs *engine) return active;
  }
  +void intel_engine_get_hung_entity(struct intel_engine_cs *engine,
+                  struct intel_context **ce, struct i915_request
**rq)

drivers/gpu/drm/i915/gt/intel_engine_cs.c +13 -0
+{
+    unsigned long flags;
+
+    *ce = intel_engine_get_hung_context(engine);
+    if (*ce) {
+        intel_engine_clear_hung_context(engine);
+
+        *rq = intel_context_find_active_request_get(*ce);
+        return;
+    }
+
+    /*
+     * Getting here with GuC enabled means it is a forced error 

capture
+     * with no actual hang. So, no need to attempt the execlist search.
+     */
+    if (intel_uc_uses_guc_submission(&engine->gt->uc)) +        return;

drivers/gpu/drm/i915/gt/intel_engine_cs.c +8 -0
+
+ spin_lock_irqsave(&engine->sched_engine->lock, flags);
+    *rq = engine_execlist_find_hung_request(engine);
+    if (*rq)
+        *rq = i915_request_get_rcu(*rq);
+ spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
+}
+

  void xehp_enable_ccs_engines(struct intel_engine_cs *engine) {
      /*

drivers/gpu/drm/i915/gt/intel_execlists_submission.c +26 -0
index 18ffe55282e59..05995c8577bef 100644
@@ -4150,6 +4150,33 @@ void intel_execlists_show_requests(struct 
 intel_engine_cs *engine,
       spin_unlock_irqrestore(&sched_engine->lock, flags);
   }
   +static unsigned long list_count(struct list_head *list)
+{
+    struct list_head *pos;
+    unsigned long count = 0;
+
+    list_for_each(pos, list)
+        count++;
+
+    return count;
+}
+
+void intel_execlist_dump_active_requests(struct intel_engine_cs 
 *engine,
+                     struct i915_request *hung_rq,
+                     struct drm_printer *m)
+{
+    unsigned long flags;
+
+ spin_lock_irqsave(&engine->sched_engine->lock, flags);
+
+ 
 intel_engine_dump_active_requests(&engine->sched_engine->requests, hung_rq, m);
+
+    drm_printf(m, "\tOn hold?: %lu\n",
+ list_count(&engine->sched_engine->hold));
+
+ spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
+}
+

  #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
  #include "selftest_execlists.c"
  #endif

drivers/gpu/drm/i915/gt/intel_execlists_submission.h +3 -0
index a1aa92c983a51..cb07488a03764 100644
@@ -32,6 +32,10 @@ void intel_execlists_show_requests(struct 
 intel_engine_cs *engine,
                               int indent),
                      unsigned int max);
   +void intel_execlist_dump_active_requests(struct intel_engine_cs *engine,
+                     struct i915_request *hung_rq,
+                     struct drm_printer *m);
+

  bool
  intel_engine_in_execlists_submission_mode(const struct intel_engine_cs *engine); diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c index 5c73dfa2fb3f6..b20bd6365615b 100644

drivers/gpu/drm/i915/i915_gpu_error.c +1 -10
@@ -1596,35 +1596,15 @@ capture_engine(struct intel_engine_cs *engine,
   {
       struct intel_engine_capture_vma *capture = NULL;
       struct intel_engine_coredump *ee;
-    struct intel_context *ce;
+    struct intel_context *ce = NULL;
       struct i915_request *rq = NULL;
-    unsigned long flags;
         ee = intel_engine_coredump_alloc(engine, ALLOW_FAIL, dump_flags);
       if (!ee)
           return NULL;
   -    ce = intel_engine_get_hung_context(engine);
-    if (ce) {
-        intel_engine_clear_hung_context(engine);
-        rq = intel_context_find_active_request_get(ce);
-        if (!rq || !i915_request_started(rq))
-            goto no_request_capture;
-    } else {
-        /*
-         * Getting here with GuC enabled means it is a forced 

error capture
-         * with no actual hang. So, no need to attempt the execlist search.
-         */
-        if (!intel_uc_uses_guc_submission(&engine->gt->uc)) {
- spin_lock_irqsave(&engine->sched_engine->lock, flags);
-            rq = intel_engine_execlist_find_hung_request(engine); -            if (rq)
-                rq = i915_request_get_rcu(rq);
- spin_unlock_irqrestore(&engine->sched_engine->lock,
-                           flags);
-        }
-    }
-    if (!rq)
+    intel_engine_get_hung_entity(engine, &ce, &rq);
+    if (!rq || !i915_request_started(rq))
          goto no_request_capture;
        capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);

Reviewed-by on v4 2/7
#11 lore raw

Re: [Intel-gfx] [PATCH v4 2/7] drm/i915: Fix up locking around dumping requests lists

In reply to [email protected]
Quoted 188 lines · On 1/20/2023 3:28 PM, [email protected] wrote:

From: John Harrison <[email protected]>

The debugfs dump of requests was confused about what state requires the execlist lock versus the GuC lock. There was also a bunch of duplicated messy code between it and the error capture code.

So refactor the hung request search into a re-usable function. And reduce the span of the execlist state lock to only the execlist specific code paths. In order to do that, also move the report of hold count (which is an execlist only concept) from the top level dump function to the lower level execlist specific function. Also, move the execlist specific code into the execlist source file.

v2: Rename some functions and move to more appropriate files (Daniele).

---
  drivers/gpu/drm/i915/gt/intel_engine.h        |  4 +-
  drivers/gpu/drm/i915/gt/intel_engine_cs.c     | 74 +++++++++----------
  .../drm/i915/gt/intel_execlists_submission.c  | 27 +++++++
  .../drm/i915/gt/intel_execlists_submission.h  |  4 +
  drivers/gpu/drm/i915/i915_gpu_error.c         | 26 +------
  5 files changed, 73 insertions(+), 62 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine.h +2 -2
index 0e24af5efee9c..b58c30ac8ef02 100644
@@ -250,8 +250,8 @@ void intel_engine_dump_active_requests(struct list_head *requests,
  ktime_t intel_engine_get_busy_time(struct intel_engine_cs *engine,
  				   ktime_t *now);
 
-struct i915_request *
-intel_engine_execlist_find_hung_request(struct intel_engine_cs *engine);
+void intel_engine_get_hung_entity(struct intel_engine_cs *engine,
+				  struct intel_context **ce, struct i915_request **rq);
 
  u32 intel_engine_context_size(struct intel_gt *gt, u8 class);
  struct intel_context *
drivers/gpu/drm/i915/gt/intel_engine_cs.c +37 -37
index fbc0a81617e89..1d77e27801bce 100644
@@ -2114,17 +2114,6 @@ static void print_request_ring(struct drm_printer *m, struct i915_request *rq)
  	}
  }
 
-static unsigned long list_count(struct list_head *list)
-{
-	struct list_head *pos;
-	unsigned long count = 0;
-
-	list_for_each(pos, list)
-		count++;
-
-	return count;
-}
-
  static unsigned long read_ul(void *p, size_t x)
  {
  	return *(unsigned long *)(p + x);
@@ -2216,11 +2205,11 @@ void intel_engine_dump_active_requests(struct list_head *requests,
  	}
  }
 
-static void engine_dump_active_requests(struct intel_engine_cs *engine, struct drm_printer *m)
+static void engine_dump_active_requests(struct intel_engine_cs *engine,
+					struct drm_printer *m)
  {
+	struct intel_context *hung_ce = NULL;
  	struct i915_request *hung_rq = NULL;
-	struct intel_context *ce;
-	bool guc;
 
  	/*
  	 * No need for an engine->irq_seqno_barrier() before the seqno reads.
@@ -2229,29 +2218,20 @@ static void engine_dump_active_requests(struct intel_engine_cs *engine, struct d
  	 * But the intention here is just to report an instantaneous snapshot
  	 * so that's fine.
  	 */
-	lockdep_assert_held(&engine->sched_engine->lock);
+	intel_engine_get_hung_entity(engine, &hung_ce, &hung_rq);
 
  	drm_printf(m, "\tRequests:\n");
 
-	guc = intel_uc_uses_guc_submission(&engine->gt->uc);
-	if (guc) {
-		ce = intel_engine_get_hung_context(engine);
-		if (ce)
-			hung_rq = intel_context_find_active_request_get(ce);
-	} else {
-		hung_rq = intel_engine_execlist_find_hung_request(engine);
-		if (hung_rq)
-			hung_rq = i915_request_get_rcu(hung_rq);
-	}
-
  	if (hung_rq)
  		engine_dump_request(hung_rq, m, "\t\thung");
+	else if (hung_ce)
+		drm_printf(m, "\t\tGot hung ce but no hung rq!\n");
 
-	if (guc)
+	if (intel_uc_uses_guc_submission(&engine->gt->uc))
  		intel_guc_dump_active_requests(engine, hung_rq, m);
  	else
-		intel_engine_dump_active_requests(&engine->sched_engine->requests,
-						  hung_rq, m);
+		intel_execlist_dump_active_requests(engine, hung_rq, m);
+
  	if (hung_rq)
  		i915_request_put(hung_rq);
  }
@@ -2263,7 +2243,6 @@ void intel_engine_dump(struct intel_engine_cs *engine,
  	struct i915_gpu_error * const error = &engine->i915->gpu_error;
  	struct i915_request *rq;
  	intel_wakeref_t wakeref;
-	unsigned long flags;
  	ktime_t dummy;
 
  	if (header) {
@@ -2300,13 +2279,8 @@ void intel_engine_dump(struct intel_engine_cs *engine,
  		   i915_reset_count(error));
  	print_properties(engine, m);
 
-	spin_lock_irqsave(&engine->sched_engine->lock, flags);
  	engine_dump_active_requests(engine, m);
 
-	drm_printf(m, "\tOn hold?: %lu\n",
-		   list_count(&engine->sched_engine->hold));
-	spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
-
  	drm_printf(m, "\tMMIO base:  0x%08x\n", engine->mmio_base);
  	wakeref = intel_runtime_pm_get_if_in_use(engine->uncore->rpm);
  	if (wakeref) {
@@ -2352,8 +2326,7 @@ intel_engine_create_virtual(struct intel_engine_cs **siblings,
  	return siblings[0]->cops->create_virtual(siblings, count, flags);
  }
 
-struct i915_request *
-intel_engine_execlist_find_hung_request(struct intel_engine_cs *engine)
+static struct i915_request *engine_execlist_find_hung_request(struct intel_engine_cs *engine)
  {
  	struct i915_request *request, *active = NULL;
 
@@ -2405,6 +2378,33 @@ intel_engine_execlist_find_hung_request(struct intel_engine_cs *engine)
  	return active;
  }
 
+void intel_engine_get_hung_entity(struct intel_engine_cs *engine,
+				  struct intel_context **ce, struct i915_request **rq)
+{
+	unsigned long flags;
+
+	*ce = intel_engine_get_hung_context(engine);
+	if (*ce) {
+		intel_engine_clear_hung_context(engine);
+
+		*rq = intel_context_find_active_request_get(*ce);
+		return;
+	}
+
+	/*
+	 * Getting here with GuC enabled means it is a forced error capture
+	 * with no actual hang. So, no need to attempt the execlist search.
+	 */
+	if (intel_uc_uses_guc_submission(&engine->gt->uc))
+		return;
+
+	spin_lock_irqsave(&engine->sched_engine->lock, flags);
+	*rq = engine_execlist_find_hung_request(engine);
+	if (*rq)
+		*rq = i915_request_get_rcu(*rq);
+	spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
+}
+
  void xehp_enable_ccs_engines(struct intel_engine_cs *engine)
  {
  	/*
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +2 -0
index 18ffe55282e59..05995c8577bef 100644
@@ -4150,6 +4150,33 @@ void intel_execlists_show_requests(struct intel_engine_cs *engine,
  	spin_unlock_irqrestore(&sched_engine->lock, flags);
  }
 
+static unsigned long list_count(struct list_head *list)
+{

drivers/gpu/drm/i915/gt/intel_execlists_submission.c void intel_execlists_show_requests(struct intel_engine_cs *engine, · line 4164

Quoted 10 lines
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +10 -0
+	struct list_head *pos;
+	unsigned long count = 0;
+
+	list_for_each(pos, list)
+		count++;
+
+	return count;
+}
+
+void intel_execlist_dump_active_requests(struct intel_engine_cs *engine,

nit: we usually use "execlists" and not "execlist". Apart from this the patch LGTM.

Daniele

Quoted 76 lines
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +15 -0
+					 struct i915_request *hung_rq,
+					 struct drm_printer *m)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&engine->sched_engine->lock, flags);
+
+	intel_engine_dump_active_requests(&engine->sched_engine->requests, hung_rq, m);
+
+	drm_printf(m, "\tOn hold?: %lu\n",
+		   list_count(&engine->sched_engine->hold));
+
+	spin_unlock_irqrestore(&engine->sched_engine->lock, flags);
+}
+
  #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
  #include "selftest_execlists.c"
  #endif
drivers/gpu/drm/i915/gt/intel_execlists_submission.h +4 -0
index a1aa92c983a51..cb07488a03764 100644
@@ -32,6 +32,10 @@ void intel_execlists_show_requests(struct intel_engine_cs *engine,
  							int indent),
  				   unsigned int max);
 
+void intel_execlist_dump_active_requests(struct intel_engine_cs *engine,
+					 struct i915_request *hung_rq,
+					 struct drm_printer *m);
+
  bool
  intel_engine_in_execlists_submission_mode(const struct intel_engine_cs *engine);
 
drivers/gpu/drm/i915/i915_gpu_error.c +3 -23
index 5c73dfa2fb3f6..b20bd6365615b 100644
@@ -1596,35 +1596,15 @@ capture_engine(struct intel_engine_cs *engine,
  {
  	struct intel_engine_capture_vma *capture = NULL;
  	struct intel_engine_coredump *ee;
-	struct intel_context *ce;
+	struct intel_context *ce = NULL;
  	struct i915_request *rq = NULL;
-	unsigned long flags;
 
  	ee = intel_engine_coredump_alloc(engine, ALLOW_FAIL, dump_flags);
  	if (!ee)
  		return NULL;
 
-	ce = intel_engine_get_hung_context(engine);
-	if (ce) {
-		intel_engine_clear_hung_context(engine);
-		rq = intel_context_find_active_request_get(ce);
-		if (!rq || !i915_request_started(rq))
-			goto no_request_capture;
-	} else {
-		/*
-		 * Getting here with GuC enabled means it is a forced error capture
-		 * with no actual hang. So, no need to attempt the execlist search.
-		 */
-		if (!intel_uc_uses_guc_submission(&engine->gt->uc)) {
-			spin_lock_irqsave(&engine->sched_engine->lock, flags);
-			rq = intel_engine_execlist_find_hung_request(engine);
-			if (rq)
-				rq = i915_request_get_rcu(rq);
-			spin_unlock_irqrestore(&engine->sched_engine->lock,
-					       flags);
-		}
-	}
-	if (!rq)
+	intel_engine_get_hung_entity(engine, &ce, &rq);
+	if (!rq || !i915_request_started(rq))
  		goto no_request_capture;
 
  	capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);
#12 lore raw

PATCH v4 3/7 drm/i915: Allow error capture without a request

In reply to [email protected]

From: John Harrison <[email protected]>

There was a report of error captures occurring without any hung context being indicated despite the capture being initiated by a 'hung context notification' from GuC. The problem was not reproducible. However, it is possible to happen if the context in question has no active requests. For example, if the hang was in the context switch itself then the breadcrumb write would have occurred and the KMD would see an idle context.

In the interests of attempting to provide as much information as possible about a hang, it seems wise to include the engine info regardless of whether a request was found or not. As opposed to just prentending there was no hang at all.

So update the error capture code to always record engine information if a context is given. Which means updating record_context() to take a context instead of a request (which it only ever used to find the context anyway). And split the request agnostic parts of intel_engine_coredump_add_request() out into a seaprate function.

v2: Remove a duplicate 'if' statement (Umesh) and fix a put of a null pointer.
v3: Tidy up request locking code flow (Tvrtko)
v4: Pull in improved info message from next patch and fix up potential leak of GuC register state (Daniele)

---
 drivers/gpu/drm/i915/i915_gpu_error.c | 74 ++++++++++++++++++---------
 1 file changed, 50 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/i915_gpu_error.c +50 -24
index b20bd6365615b..225f1b11a6b93 100644
@@ -1370,14 +1370,14 @@ static void engine_record_execlists(struct intel_engine_coredump *ee)
 }
 
 static bool record_context(struct i915_gem_context_coredump *e,
-			   const struct i915_request *rq)
+			   struct intel_context *ce)
 {
 	struct i915_gem_context *ctx;
 	struct task_struct *task;
 	bool simulated;
 
 	rcu_read_lock();
-	ctx = rcu_dereference(rq->context->gem_context);
+	ctx = rcu_dereference(ce->gem_context);
 	if (ctx && !kref_get_unless_zero(&ctx->ref))
 		ctx = NULL;
 	rcu_read_unlock();
@@ -1396,8 +1396,8 @@ static bool record_context(struct i915_gem_context_coredump *e,
 	e->guilty = atomic_read(&ctx->guilty_count);
 	e->active = atomic_read(&ctx->active_count);
 
-	e->total_runtime = intel_context_get_total_runtime_ns(rq->context);
-	e->avg_runtime = intel_context_get_avg_runtime_ns(rq->context);
+	e->total_runtime = intel_context_get_total_runtime_ns(ce);
+	e->avg_runtime = intel_context_get_avg_runtime_ns(ce);
 
 	simulated = i915_gem_context_no_error_capture(ctx);
 
@@ -1532,15 +1532,37 @@ intel_engine_coredump_alloc(struct intel_engine_cs *engine, gfp_t gfp, u32 dump_
 	return ee;
 }
 
+static struct intel_engine_capture_vma *
+engine_coredump_add_context(struct intel_engine_coredump *ee,
+			    struct intel_context *ce,
+			    gfp_t gfp)
+{
+	struct intel_engine_capture_vma *vma = NULL;
+
+	ee->simulated |= record_context(&ee->context, ce);
+	if (ee->simulated)
+		return NULL;
+
+	/*
+	 * We need to copy these to an anonymous buffer
+	 * as the simplest method to avoid being overwritten
+	 * by userspace.
+	 */
+	vma = capture_vma(vma, ce->ring->vma, "ring", gfp);
+	vma = capture_vma(vma, ce->state, "HW context", gfp);
+
+	return vma;
+}
+
 struct intel_engine_capture_vma *
 intel_engine_coredump_add_request(struct intel_engine_coredump *ee,
 				  struct i915_request *rq,
 				  gfp_t gfp)
 {
-	struct intel_engine_capture_vma *vma = NULL;
+	struct intel_engine_capture_vma *vma;
 
-	ee->simulated |= record_context(&ee->context, rq);
-	if (ee->simulated)
+	vma = engine_coredump_add_context(ee, rq->context, gfp);
+	if (!vma)
 		return NULL;
 
 	/*
@@ -1550,8 +1572,6 @@ intel_engine_coredump_add_request(struct intel_engine_coredump *ee,
 	 */
 	vma = capture_vma_snapshot(vma, rq->batch_res, gfp, "batch");
 	vma = capture_user(vma, rq, gfp);
-	vma = capture_vma(vma, rq->ring->vma, "ring", gfp);
-	vma = capture_vma(vma, rq->context->state, "HW context", gfp);
 
 	ee->rq_head = rq->head;
 	ee->rq_post = rq->postfix;
@@ -1604,25 +1624,31 @@ capture_engine(struct intel_engine_cs *engine,
 		return NULL;
 
 	intel_engine_get_hung_entity(engine, &ce, &rq);
-	if (!rq || !i915_request_started(rq))
-		goto no_request_capture;
+	if (rq && !i915_request_started(rq)) {
+		drm_info(&engine->gt->i915->drm, "Got hung context on %s with active request %lld:%lld [0x%04X] not yet started\n",
+			 engine->name, rq->fence.context, rq->fence.seqno, ce->guc_id.id);
+		i915_request_put(rq);
+		rq = NULL;
+	}
 
-	capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);
-	if (!capture)
-		goto no_request_capture;
-	if (dump_flags & CORE_DUMP_FLAG_IS_GUC_CAPTURE)
-		intel_guc_capture_get_matching_node(engine->gt, ee, ce);
+	if (rq) {
+		capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);
+		i915_request_put(rq);
+	} else if (ce) {
+		capture = engine_coredump_add_context(ee, ce, ATOMIC_MAYFAIL);
+	}
 
-	intel_engine_coredump_add_vma(ee, capture, compress);
-	i915_request_put(rq);
+	if (capture) {
+		intel_engine_coredump_add_vma(ee, capture, compress);
 
-	return ee;
+		if (dump_flags & CORE_DUMP_FLAG_IS_GUC_CAPTURE)
+			intel_guc_capture_get_matching_node(engine->gt, ee, ce);
+	} else {
+		kfree(ee);
+		ee = NULL;
+	}
 
-no_request_capture:
-	if (rq)
-		i915_request_put(rq);
-	kfree(ee);
-	return NULL;
+	return ee;
 }
 
 static void
Signature · 1 line
2.39.0
Reviewed-by on v4 3/7
#13 lore raw

Re: [Intel-gfx] [PATCH v4 3/7] drm/i915: Allow error capture without a request

Quoted 21 lines · On 1/20/2023 3:28 PM, [email protected] wrote:

From: John Harrison <[email protected]>

There was a report of error captures occurring without any hung context being indicated despite the capture being initiated by a 'hung context notification' from GuC. The problem was not reproducible. However, it is possible to happen if the context in question has no active requests. For example, if the hang was in the context switch itself then the breadcrumb write would have occurred and the KMD would see an idle context.

In the interests of attempting to provide as much information as possible about a hang, it seems wise to include the engine info regardless of whether a request was found or not. As opposed to just prentending there was no hang at all.

So update the error capture code to always record engine information if a context is given. Which means updating record_context() to take a context instead of a request (which it only ever used to find the context anyway). And split the request agnostic parts of intel_engine_coredump_add_request() out into a seaprate function.

Quoted 5 lines

v2: Remove a duplicate 'if' statement (Umesh) and fix a put of a null pointer.
v3: Tidy up request locking code flow (Tvrtko)
v4: Pull in improved info message from next patch and fix up potential leak of GuC register state (Daniele)

In the very unlikely case that the capture fails, we're leaving the data inside the GuC buffer. This is not new with this patch and not a bug (that buffer is a ring and the stale data will be overwritten if it gets full), but maybe something that can be improved as a follow-up.

Daniele

Quoted 137 lines
---
  drivers/gpu/drm/i915/i915_gpu_error.c | 74 ++++++++++++++++++---------
  1 file changed, 50 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/i915_gpu_error.c +50 -24
index b20bd6365615b..225f1b11a6b93 100644
@@ -1370,14 +1370,14 @@ static void engine_record_execlists(struct intel_engine_coredump *ee)
  }
 
  static bool record_context(struct i915_gem_context_coredump *e,
-			   const struct i915_request *rq)
+			   struct intel_context *ce)
  {
  	struct i915_gem_context *ctx;
  	struct task_struct *task;
  	bool simulated;
 
  	rcu_read_lock();
-	ctx = rcu_dereference(rq->context->gem_context);
+	ctx = rcu_dereference(ce->gem_context);
  	if (ctx && !kref_get_unless_zero(&ctx->ref))
  		ctx = NULL;
  	rcu_read_unlock();
@@ -1396,8 +1396,8 @@ static bool record_context(struct i915_gem_context_coredump *e,
  	e->guilty = atomic_read(&ctx->guilty_count);
  	e->active = atomic_read(&ctx->active_count);
 
-	e->total_runtime = intel_context_get_total_runtime_ns(rq->context);
-	e->avg_runtime = intel_context_get_avg_runtime_ns(rq->context);
+	e->total_runtime = intel_context_get_total_runtime_ns(ce);
+	e->avg_runtime = intel_context_get_avg_runtime_ns(ce);
 
  	simulated = i915_gem_context_no_error_capture(ctx);
 
@@ -1532,15 +1532,37 @@ intel_engine_coredump_alloc(struct intel_engine_cs *engine, gfp_t gfp, u32 dump_
  	return ee;
  }
 
+static struct intel_engine_capture_vma *
+engine_coredump_add_context(struct intel_engine_coredump *ee,
+			    struct intel_context *ce,
+			    gfp_t gfp)
+{
+	struct intel_engine_capture_vma *vma = NULL;
+
+	ee->simulated |= record_context(&ee->context, ce);
+	if (ee->simulated)
+		return NULL;
+
+	/*
+	 * We need to copy these to an anonymous buffer
+	 * as the simplest method to avoid being overwritten
+	 * by userspace.
+	 */
+	vma = capture_vma(vma, ce->ring->vma, "ring", gfp);
+	vma = capture_vma(vma, ce->state, "HW context", gfp);
+
+	return vma;
+}
+
  struct intel_engine_capture_vma *
  intel_engine_coredump_add_request(struct intel_engine_coredump *ee,
  				  struct i915_request *rq,
  				  gfp_t gfp)
  {
-	struct intel_engine_capture_vma *vma = NULL;
+	struct intel_engine_capture_vma *vma;
 
-	ee->simulated |= record_context(&ee->context, rq);
-	if (ee->simulated)
+	vma = engine_coredump_add_context(ee, rq->context, gfp);
+	if (!vma)
  		return NULL;
 
  	/*
@@ -1550,8 +1572,6 @@ intel_engine_coredump_add_request(struct intel_engine_coredump *ee,
  	 */
  	vma = capture_vma_snapshot(vma, rq->batch_res, gfp, "batch");
  	vma = capture_user(vma, rq, gfp);
-	vma = capture_vma(vma, rq->ring->vma, "ring", gfp);
-	vma = capture_vma(vma, rq->context->state, "HW context", gfp);
 
  	ee->rq_head = rq->head;
  	ee->rq_post = rq->postfix;
@@ -1604,25 +1624,31 @@ capture_engine(struct intel_engine_cs *engine,
  		return NULL;
 
  	intel_engine_get_hung_entity(engine, &ce, &rq);
-	if (!rq || !i915_request_started(rq))
-		goto no_request_capture;
+	if (rq && !i915_request_started(rq)) {
+		drm_info(&engine->gt->i915->drm, "Got hung context on %s with active request %lld:%lld [0x%04X] not yet started\n",
+			 engine->name, rq->fence.context, rq->fence.seqno, ce->guc_id.id);
+		i915_request_put(rq);
+		rq = NULL;
+	}
 
-	capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);
-	if (!capture)
-		goto no_request_capture;
-	if (dump_flags & CORE_DUMP_FLAG_IS_GUC_CAPTURE)
-		intel_guc_capture_get_matching_node(engine->gt, ee, ce);
+	if (rq) {
+		capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);
+		i915_request_put(rq);
+	} else if (ce) {
+		capture = engine_coredump_add_context(ee, ce, ATOMIC_MAYFAIL);
+	}
 
-	intel_engine_coredump_add_vma(ee, capture, compress);
-	i915_request_put(rq);
+	if (capture) {
+		intel_engine_coredump_add_vma(ee, capture, compress);
 
-	return ee;
+		if (dump_flags & CORE_DUMP_FLAG_IS_GUC_CAPTURE)
+			intel_guc_capture_get_matching_node(engine->gt, ee, ce);
+	} else {
+		kfree(ee);
+		ee = NULL;
+	}
 
-no_request_capture:
-	if (rq)
-		i915_request_put(rq);
-	kfree(ee);
-	return NULL;
+	return ee;
  }
 
  static void
#14 lore raw

Re: [Intel-gfx] [PATCH v4 3/7] drm/i915: Allow error capture without a request

Quoted 22 lines · Daniele
Quoted 21 lines · On 1/20/2023 3:28 PM, [email protected] wrote:

From: John Harrison <[email protected]>

There was a report of error captures occurring without any hung context being indicated despite the capture being initiated by a 'hung context notification' from GuC. The problem was not reproducible. However, it is possible to happen if the context in question has no active requests. For example, if the hang was in the context switch itself then the breadcrumb write would have occurred and the KMD would see an idle context.

In the interests of attempting to provide as much information as possible about a hang, it seems wise to include the engine info regardless of whether a request was found or not. As opposed to just prentending there was no hang at all.

So update the error capture code to always record engine information if a context is given. Which means updating record_context() to take a context instead of a request (which it only ever used to find the context anyway). And split the request agnostic parts of intel_engine_coredump_add_request() out into a seaprate function.

Quoted 7 lines
Quoted 5 lines

v2: Remove a duplicate 'if' statement (Umesh) and fix a put of a null pointer.
v3: Tidy up request locking code flow (Tvrtko)
v4: Pull in improved info message from next patch and fix up potential leak of GuC register state (Daniele)

In the very unlikely case that the capture fails, we're leaving the data inside the GuC buffer. This is not new with this patch and not a bug (that buffer is a ring and the stale data will be overwritten if it gets full), but maybe something that can be improved as a follow-up.

Correct and correct.

John.

Quoted 134 lines

Daniele

Quoted 128 lines

---
  drivers/gpu/drm/i915/i915_gpu_error.c | 74 ++++++++++++++++++---------

  1 file changed, 50 insertions(+), 24 deletions(-)
drivers/gpu/drm/i915/i915_gpu_error.c +4 -3
index b20bd6365615b..225f1b11a6b93 100644
@@ -1370,14 +1370,14 @@ static void engine_record_execlists(struct 
 intel_engine_coredump *ee)
   }
     static bool record_context(struct i915_gem_context_coredump *e,
-               const struct i915_request *rq)
+               struct intel_context *ce)
   {
       struct i915_gem_context *ctx;
       struct task_struct *task;
       bool simulated;
         rcu_read_lock();
-    ctx = rcu_dereference(rq->context->gem_context);
+    ctx = rcu_dereference(ce->gem_context);
       if (ctx && !kref_get_unless_zero(&ctx->ref))
           ctx = NULL;
       rcu_read_unlock();
@@ -1396,8 +1396,8 @@ static bool record_context(struct 
 i915_gem_context_coredump *e,
       e->guilty = atomic_read(&ctx->guilty_count);
       e->active = atomic_read(&ctx->active_count);
   -    e->total_runtime = intel_context_get_total_runtime_ns(rq->context);
-    e->avg_runtime = intel_context_get_avg_runtime_ns(rq->context);
+    e->total_runtime = intel_context_get_total_runtime_ns(ce);
+    e->avg_runtime = intel_context_get_avg_runtime_ns(ce);
         simulated = i915_gem_context_no_error_capture(ctx);

  @@ -1532,15 +1532,37 @@ intel_engine_coredump_alloc(struct intel_engine_cs *engine, gfp_t gfp, u32 dump_ return ee;
  }
  +static struct intel_engine_capture_vma *

drivers/gpu/drm/i915/i915_gpu_error.c +21 -0
+engine_coredump_add_context(struct intel_engine_coredump *ee,
+                struct intel_context *ce,
+                gfp_t gfp)
+{
+    struct intel_engine_capture_vma *vma = NULL;
+
+    ee->simulated |= record_context(&ee->context, ce);
+    if (ee->simulated)
+        return NULL;
+
+    /*
+     * We need to copy these to an anonymous buffer
+     * as the simplest method to avoid being overwritten
+     * by userspace.
+     */
+    vma = capture_vma(vma, ce->ring->vma, "ring", gfp);
+    vma = capture_vma(vma, ce->state, "HW context", gfp);
+
+    return vma;
+}
+

  struct intel_engine_capture_vma * intel_engine_coredump_add_request(struct intel_engine_coredump *ee, struct i915_request *rq,
                    gfp_t gfp)
  {
-    struct intel_engine_capture_vma *vma = NULL;
+    struct intel_engine_capture_vma *vma;
  -    ee->simulated |= record_context(&ee->context, rq); -    if (ee->simulated)
+    vma = engine_coredump_add_context(ee, rq->context, gfp); +    if (!vma)
          return NULL;
        /*

drivers/gpu/drm/i915/i915_gpu_error.c +20 -9
@@ -1550,8 +1572,6 @@ intel_engine_coredump_add_request(struct 
 intel_engine_coredump *ee,
        */
       vma = capture_vma_snapshot(vma, rq->batch_res, gfp, "batch");
       vma = capture_user(vma, rq, gfp);
-    vma = capture_vma(vma, rq->ring->vma, "ring", gfp);
-    vma = capture_vma(vma, rq->context->state, "HW context", gfp);
         ee->rq_head = rq->head;
       ee->rq_post = rq->postfix;
@@ -1604,25 +1624,31 @@ capture_engine(struct intel_engine_cs *engine,
           return NULL;
         intel_engine_get_hung_entity(engine, &ce, &rq);
-    if (!rq || !i915_request_started(rq))
-        goto no_request_capture;
+    if (rq && !i915_request_started(rq)) {
+        drm_info(&engine->gt->i915->drm, "Got hung context on %s 
 with active request %lld:%lld [0x%04X] not yet started\n",
+             engine->name, rq->fence.context, rq->fence.seqno, 
 ce->guc_id.id);
+        i915_request_put(rq);
+        rq = NULL;
+    }
   -    capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);
-    if (!capture)
-        goto no_request_capture;
-    if (dump_flags & CORE_DUMP_FLAG_IS_GUC_CAPTURE)
-        intel_guc_capture_get_matching_node(engine->gt, ee, ce);
+    if (rq) {
+        capture = intel_engine_coredump_add_request(ee, rq, 
 ATOMIC_MAYFAIL);
+        i915_request_put(rq);
+    } else if (ce) {
+        capture = engine_coredump_add_context(ee, ce, ATOMIC_MAYFAIL);
+    }
   -    intel_engine_coredump_add_vma(ee, capture, compress);
-    i915_request_put(rq);
+    if (capture) {
+        intel_engine_coredump_add_vma(ee, capture, compress);
   -    return ee;
+        if (dump_flags & CORE_DUMP_FLAG_IS_GUC_CAPTURE)
+            intel_guc_capture_get_matching_node(engine->gt, ee, ce);
+    } else {
+        kfree(ee);
+        ee = NULL;
+    }

  -no_request_capture:
-    if (rq)
-        i915_request_put(rq);
-    kfree(ee);
-    return NULL;
+    return ee;
  }
    static void

#15 lore raw

PATCH v4 4/7 drm/i915: Allow error capture of a pending request

In reply to [email protected]

From: John Harrison <[email protected]>

A hang situation has been observed where the only requests on the context were either completed or not yet started according to the breaadcrumbs. However, the register state claimed a batch was (maybe) in progress. So, allow capture of the pending request on the grounds that this might be better than nothing.

v2: Reword 'not started' warning message (Tvrtko)

---
 drivers/gpu/drm/i915/i915_gpu_error.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_gpu_error.c +1 -4
index 225f1b11a6b93..904f21e1380cd 100644
@@ -1624,12 +1624,9 @@ capture_engine(struct intel_engine_cs *engine,
 		return NULL;
 
 	intel_engine_get_hung_entity(engine, &ce, &rq);
-	if (rq && !i915_request_started(rq)) {
+	if (rq && !i915_request_started(rq))
 		drm_info(&engine->gt->i915->drm, "Got hung context on %s with active request %lld:%lld [0x%04X] not yet started\n",
 			 engine->name, rq->fence.context, rq->fence.seqno, ce->guc_id.id);
-		i915_request_put(rq);
-		rq = NULL;
-	}
 
 	if (rq) {
 		capture = intel_engine_coredump_add_request(ee, rq, ATOMIC_MAYFAIL);
Signature · 1 line
2.39.0
#16 lore raw

PATCH v4 5/7 drm/i915/guc: Look for a guilty context when an engine reset fails

In reply to [email protected]

From: John Harrison <[email protected]>

Engine resets are supposed to never fail. But in the case when one does (due to unknown reasons that normally come down to a missing w/a), it is useful to get as much information out of the system as possible. Given that the GuC intentionally dies on such a situation, it is not possible to get a guilty context notification back. So do a manual search instead. Given that GuC is dead, this is safe because GuC won't be changing the engine state asynchronously.

v2: Change comment to be less alarming (Tvrtko)

---
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c   | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +15 -2
index ad4b2848b0f83..b6b4061e4b633 100644
@@ -4755,11 +4755,24 @@ static void reset_fail_worker_func(struct work_struct *w)
 	guc->submission_state.reset_fail_mask = 0;
 	spin_unlock_irqrestore(&guc->submission_state.lock, flags);
 
-	if (likely(reset_fail_mask))
+	if (likely(reset_fail_mask)) {
+		struct intel_engine_cs *engine;
+		enum intel_engine_id id;
+
+		/*
+		 * GuC is toast at this point - it dead loops after sending the failed
+		 * reset notification. So need to manually determine the guilty context.
+		 * Note that it should be reliable to do this here because the GuC is
+		 * toast and will not be scheduling behind the KMD's back.
+		 */
+		for_each_engine_masked(engine, gt, reset_fail_mask, id)
+			intel_guc_find_hung_context(engine);
+
 		intel_gt_handle_error(gt, reset_fail_mask,
 				      I915_ERROR_CAPTURE,
-				      "GuC failed to reset engine mask=0x%x\n",
+				      "GuC failed to reset engine mask=0x%x",
 				      reset_fail_mask);
+	}
 }
 
 int intel_guc_engine_failure_process_msg(struct intel_guc *guc,
Signature · 1 line
2.39.0
#17 lore raw

PATCH v4 6/7 drm/i915/guc: Add a debug print on GuC triggered reset

In reply to [email protected]

From: John Harrison <[email protected]>

For understanding bug reports, it can be useful to have an explicit dmesg print when a reset notification is received from GuC. As opposed to simply inferring that this happened from other messages.

---
 drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +4 -0
index b6b4061e4b633..b11d98092ffd1 100644
@@ -4666,6 +4666,10 @@ static void guc_handle_context_reset(struct intel_guc *guc,
 {
 	trace_intel_context_reset(ce);
 
+	drm_dbg(&guc_to_gt(guc)->i915->drm, "Got GuC reset of 0x%04X, exiting = %d, banned = %d\n",
+		ce->guc_id.id, test_bit(CONTEXT_EXITING, &ce->flags),
+		test_bit(CONTEXT_BANNED, &ce->flags));
+
 	if (likely(intel_context_is_schedulable(ce))) {
 		capture_error_state(guc, ce);
 		guc_context_replay(ce);
Signature · 1 line
2.39.0
#18 lore raw

PATCH v4 7/7 drm/i915/guc: Rename GuC register state capture node to be more obvious

In reply to [email protected]

From: John Harrison <[email protected]>

The GuC specific register state entry in the error capture object was just called 'capture'. Although the companion 'node' entry was called 'guc_capture_node'. Rename the base entry to be 'guc_capture' instead so that it is a) more consistent and b) more obvious what it is.

---
 drivers/gpu/drm/i915/gt/uc/intel_guc_capture.c | 8 ++++----
 drivers/gpu/drm/i915/i915_gpu_error.h          | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/gt/uc/intel_guc_capture.c +4 -4
index 1c1b85073b4bd..fc3b994626a4f 100644
@@ -1506,7 +1506,7 @@ int intel_guc_capture_print_engine_node(struct drm_i915_error_state_buf *ebuf,
 
 	if (!ebuf || !ee)
 		return -EINVAL;
-	cap = ee->capture;
+	cap = ee->guc_capture;
 	if (!cap || !ee->engine)
 		return -ENODEV;
 
@@ -1576,8 +1576,8 @@ void intel_guc_capture_free_node(struct intel_engine_coredump *ee)
 	if (!ee || !ee->guc_capture_node)
 		return;
 
-	guc_capture_add_node_to_cachelist(ee->capture, ee->guc_capture_node);
-	ee->capture = NULL;
+	guc_capture_add_node_to_cachelist(ee->guc_capture, ee->guc_capture_node);
+	ee->guc_capture = NULL;
 	ee->guc_capture_node = NULL;
 }
 
@@ -1611,7 +1611,7 @@ void intel_guc_capture_get_matching_node(struct intel_gt *gt,
 		    (ce->lrc.lrca & CTX_GTT_ADDRESS_MASK)) {
 			list_del(&n->link);
 			ee->guc_capture_node = n;
-			ee->capture = guc->capture;
+			ee->guc_capture = guc->capture;
 			return;
 		}
 	}
drivers/gpu/drm/i915/i915_gpu_error.h +1 -1
index efc75cc2ffdb9..56027ffbce51f 100644
@@ -94,7 +94,7 @@ struct intel_engine_coredump {
 	struct intel_instdone instdone;
 
 	/* GuC matched capture-lists info */
-	struct intel_guc_state_capture *capture;
+	struct intel_guc_state_capture *guc_capture;
 	struct __guc_capture_parsed_output *guc_capture_node;
 
 	struct i915_gem_context_coredump {
Signature · 1 line
2.39.0
Reviewed-by on v4 7/7
#19 lore raw

Re: [Intel-gfx] [PATCH v4 7/7] drm/i915/guc: Rename GuC register state capture node to be more obvious

Quoted 8 lines · On 1/20/2023 3:28 PM, [email protected] wrote:

From: John Harrison <[email protected]>

The GuC specific register state entry in the error capture object was just called 'capture'. Although the companion 'node' entry was called 'guc_capture_node'. Rename the base entry to be 'guc_capture' instead so that it is a) more consistent and b) more obvious what it is.

Daniele

Quoted 51 lines
---
  drivers/gpu/drm/i915/gt/uc/intel_guc_capture.c | 8 ++++----
  drivers/gpu/drm/i915/i915_gpu_error.h          | 2 +-
  2 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/gt/uc/intel_guc_capture.c +4 -4
index 1c1b85073b4bd..fc3b994626a4f 100644
@@ -1506,7 +1506,7 @@ int intel_guc_capture_print_engine_node(struct drm_i915_error_state_buf *ebuf,
 
  	if (!ebuf || !ee)
  		return -EINVAL;
-	cap = ee->capture;
+	cap = ee->guc_capture;
  	if (!cap || !ee->engine)
  		return -ENODEV;
 
@@ -1576,8 +1576,8 @@ void intel_guc_capture_free_node(struct intel_engine_coredump *ee)
  	if (!ee || !ee->guc_capture_node)
  		return;
 
-	guc_capture_add_node_to_cachelist(ee->capture, ee->guc_capture_node);
-	ee->capture = NULL;
+	guc_capture_add_node_to_cachelist(ee->guc_capture, ee->guc_capture_node);
+	ee->guc_capture = NULL;
  	ee->guc_capture_node = NULL;
  }
 
@@ -1611,7 +1611,7 @@ void intel_guc_capture_get_matching_node(struct intel_gt *gt,
  		    (ce->lrc.lrca & CTX_GTT_ADDRESS_MASK)) {
  			list_del(&n->link);
  			ee->guc_capture_node = n;
-			ee->capture = guc->capture;
+			ee->guc_capture = guc->capture;
  			return;
  		}
  	}
drivers/gpu/drm/i915/i915_gpu_error.h +1 -1
index efc75cc2ffdb9..56027ffbce51f 100644
@@ -94,7 +94,7 @@ struct intel_engine_coredump {
  	struct intel_instdone instdone;
 
  	/* GuC matched capture-lists info */
-	struct intel_guc_state_capture *capture;
+	struct intel_guc_state_capture *guc_capture;
  	struct __guc_capture_parsed_output *guc_capture_node;
 
  	struct i915_gem_context_coredump {
#20 lore raw

[Intel-gfx] ✓ Fi.CI.BAT: success for Allow error capture without a request & fix locking issues (rev2)

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

== Series Details ==

Series: Allow error capture without a request & fix locking issues (rev2)
URL : https://patchwork.freedesktop.org/series/113078/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_12619 -> Patchwork_113078v2
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/index.html

Participating hosts (37 -> 35)
------------------------------

Additional (1): fi-bsw-kefka
Missing (3): fi-kbl-soraka bat-rpls-2 fi-snb-2520m

Known issues
------------

Here are the changes found in Patchwork_113078v2 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_gttfill@basic:
- fi-pnv-d510: [PASS][1] -> [FAIL][2] ([i915#7229])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/fi-pnv-d510/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/fi-pnv-d510/igt@[email protected]

* igt@kms_chamelium_hpd@common-hpd-after-suspend:
- fi-rkl-guc: NOTRUN -> [SKIP][3] ([i915#7828])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/fi-rkl-guc/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor@atomic-transitions:
- fi-bsw-kefka: NOTRUN -> [FAIL][4] ([i915#6298])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/fi-bsw-kefka/igt@kms_cursor_legacy@[email protected]

* igt@prime_vgem@basic-fence-flip:
- fi-bsw-kefka: NOTRUN -> [SKIP][5] ([fdo#109271]) +26 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/fi-bsw-kefka/igt@[email protected]

#### Possible fixes ####

* igt@i915_pm_rpm@module-reload:
- {bat-adls-5}: [FAIL][6] -> [PASS][7]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/bat-adls-5/igt@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/bat-adls-5/igt@[email protected]

* igt@i915_selftest@live@migrate:
- {bat-dg2-11}: [DMESG-WARN][8] ([i915#7699]) -> [PASS][9]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/bat-dg2-11/igt@i915_selftest@[email protected]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/bat-dg2-11/igt@i915_selftest@[email protected]

* igt@i915_selftest@live@reset:
- {bat-rpls-1}: [DMESG-FAIL][10] ([i915#4983]) -> [PASS][11]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/bat-rpls-1/igt@i915_selftest@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/bat-rpls-1/igt@i915_selftest@[email protected]

* igt@i915_selftest@live@workarounds:
- fi-rkl-guc: [INCOMPLETE][12] ([i915#4983]) -> [PASS][13]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/fi-rkl-guc/igt@i915_selftest@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/fi-rkl-guc/igt@i915_selftest@[email protected]

* igt@kms_pipe_crc_basic@suspend-read-crc@pipe-a-hdmi-a-3:
- {bat-dg2-11}: [INCOMPLETE][14] -> [PASS][15]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/bat-dg2-11/igt@kms_pipe_crc_basic@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/bat-dg2-11/igt@kms_pipe_crc_basic@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983
[i915#6298]: https://gitlab.freedesktop.org/drm/intel/issues/6298
[i915#7229]: https://gitlab.freedesktop.org/drm/intel/issues/7229
[i915#7359]: https://gitlab.freedesktop.org/drm/intel/issues/7359
[i915#7625]: https://gitlab.freedesktop.org/drm/intel/issues/7625
[i915#7699]: https://gitlab.freedesktop.org/drm/intel/issues/7699
[i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828

Build changes
-------------

* Linux: CI_DRM_12619 -> Patchwork_113078v2

CI-20190529: 20190529
CI_DRM_12619: 7d3e7f64a42d66ba8da6e7b66a8d85457ef84570 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7129: 7816773163a1b0d248dd9dd34d14e632ad8903be @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_113078v2: 7d3e7f64a42d66ba8da6e7b66a8d85457ef84570 @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

f1bdcb5595b7 drm/i915/guc: Rename GuC register state capture node to be more obvious 10f107d2b706 drm/i915/guc: Add a debug print on GuC triggered reset 29179dee3ab7 drm/i915/guc: Look for a guilty context when an engine reset fails d72f9299e2bd drm/i915: Allow error capture of a pending request cb21c0bd7920 drm/i915: Allow error capture without a request f4b27660f9b6 drm/i915: Fix up locking around dumping requests lists 9d53138718e2 drm/i915: Fix request locking during error capture & debugfs dump

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/index.html

#21 lore raw

[Intel-gfx] ✓ Fi.CI.IGT: success for Allow error capture without a request & fix locking issues (rev2)

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

== Series Details ==

Series: Allow error capture without a request & fix locking issues (rev2)
URL : https://patchwork.freedesktop.org/series/113078/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_12619_full -> Patchwork_113078v2_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/index.html

Participating hosts (11 -> 10)
------------------------------

Additional (1): shard-rkl0
Missing (2): pig-skl-6260u pig-kbl-iris

Known issues
------------

Here are the changes found in Patchwork_113078v2_full that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_fair@basic-deadline:
- shard-glk: NOTRUN -> [FAIL][1] ([i915#2846])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-glk9/igt@[email protected]

* igt@gem_lmem_swapping@heavy-verify-random:
- shard-glk: NOTRUN -> [SKIP][2] ([fdo#109271] / [i915#4613])
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-glk9/igt@[email protected]

* igt@kms_ccs@pipe-b-bad-pixel-format-y_tiled_gen12_mc_ccs:
- shard-glk: NOTRUN -> [SKIP][3] ([fdo#109271] / [i915#3886]) +4 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-glk9/igt@kms_ccs@pipe-b-bad-pixel-format-y_tiled_gen12_mc_ccs.html

* igt@kms_ccs@pipe-d-ccs-on-another-bo-yf_tiled_ccs:
- shard-glk: NOTRUN -> [SKIP][4] ([fdo#109271]) +41 similar issues
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-glk9/igt@kms_ccs@pipe-d-ccs-on-another-bo-yf_tiled_ccs.html

* igt@kms_cursor_legacy@flip-vs-cursor@atomic-transitions-varying-size:
- shard-glk: [PASS][5] -> [FAIL][6] ([i915#2346])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/shard-glk1/igt@kms_cursor_legacy@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-glk2/igt@kms_cursor_legacy@[email protected]

* igt@kms_psr2_sf@overlay-plane-update-sf-dmg-area:
- shard-glk: NOTRUN -> [SKIP][7] ([fdo#109271] / [i915#658])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-glk9/igt@[email protected]

* igt@kms_writeback@writeback-fb-id:
- shard-glk: NOTRUN -> [SKIP][8] ([fdo#109271] / [i915#2437])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-glk9/igt@[email protected]

* igt@sysfs_clients@fair-0:
- shard-glk: NOTRUN -> [SKIP][9] ([fdo#109271] / [i915#2994])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-glk9/igt@[email protected]

#### Possible fixes ####

* igt@fbdev@nullptr:
- {shard-rkl}: [SKIP][10] ([i915#2582]) -> [PASS][11] +1 similar issue
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/shard-rkl-1/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-rkl-6/igt@[email protected]

* igt@gem_exec_reloc@basic-wc-read-noreloc:
- {shard-rkl}: [SKIP][12] ([i915#3281]) -> [PASS][13] +9 similar issues
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/shard-rkl-2/igt@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-rkl-5/igt@[email protected]

* igt@gem_partial_pwrite_pread@write:
- {shard-rkl}: [SKIP][14] ([i915#3282]) -> [PASS][15] +5 similar issues
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/shard-rkl-2/igt@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-rkl-5/igt@[email protected]

* igt@gen9_exec_parse@allowed-single:
- shard-glk: [DMESG-WARN][16] ([i915#5566] / [i915#716]) -> [PASS][17]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/shard-glk2/igt@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-glk9/igt@[email protected]

* igt@gen9_exec_parse@bb-start-far:
- {shard-rkl}: [SKIP][18] ([i915#2527]) -> [PASS][19] +1 similar issue
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/shard-rkl-2/igt@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-rkl-5/igt@[email protected]

* igt@i915_pm_dc@dc6-dpms:
- {shard-rkl}: [SKIP][20] ([i915#3361]) -> [PASS][21]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/shard-rkl-5/igt@[email protected]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-rkl-3/igt@[email protected]

* igt@i915_pm_rpm@i2c:
- {shard-rkl}: [SKIP][22] ([fdo#109308]) -> [PASS][23]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/shard-rkl-5/igt@[email protected]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-rkl-6/igt@[email protected]

* igt@kms_big_fb@linear-32bpp-rotate-180:
- {shard-rkl}: [SKIP][24] ([i915#1845] / [i915#4098]) -> [PASS][25] +23 similar issues
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/shard-rkl-5/igt@[email protected]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-rkl-6/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-badstride:
- {shard-rkl}: [SKIP][26] ([i915#1849] / [i915#4098]) -> [PASS][27] +18 similar issues
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/shard-rkl-5/igt@[email protected]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-rkl-6/igt@[email protected]

* igt@kms_plane@plane-panning-top-left@pipe-a-planes:
- {shard-rkl}: [SKIP][28] ([i915#1849]) -> [PASS][29] +4 similar issues
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/shard-rkl-3/igt@kms_plane@[email protected]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-rkl-6/igt@kms_plane@[email protected]

* igt@kms_psr@cursor_plane_onoff:
- {shard-rkl}: [SKIP][30] ([i915#1072]) -> [PASS][31] +2 similar issues
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/shard-rkl-3/igt@kms_psr@cursor_plane_onoff.html
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-rkl-6/igt@kms_psr@cursor_plane_onoff.html

* igt@perf@gen12-oa-tlb-invalidate:
- {shard-rkl}: [SKIP][32] ([fdo#109289]) -> [PASS][33]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/shard-rkl-5/igt@[email protected]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-rkl-6/igt@[email protected]

* igt@prime_vgem@basic-read:
- {shard-rkl}: [SKIP][34] ([fdo#109295] / [i915#3291] / [i915#3708]) -> [PASS][35]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/shard-rkl-2/igt@[email protected]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-rkl-5/igt@[email protected]

* igt@testdisplay:
- {shard-rkl}: [SKIP][36] ([i915#4098]) -> [PASS][37]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12619/shard-rkl-5/[email protected]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/shard-rkl-6/[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109274]: https://bugs.freedesktop.org/show_bug.cgi?id=109274
[fdo#109280]: https://bugs.freedesktop.org/show_bug.cgi?id=109280
[fdo#109283]: https://bugs.freedesktop.org/show_bug.cgi?id=109283
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109289]: https://bugs.freedesktop.org/show_bug.cgi?id=109289
[fdo#109291]: https://bugs.freedesktop.org/show_bug.cgi?id=109291
[fdo#109295]: https://bugs.freedesktop.org/show_bug.cgi?id=109295
[fdo#109302]: https://bugs.freedesktop.org/show_bug.cgi?id=109302
[fdo#109303]: https://bugs.freedesktop.org/show_bug.cgi?id=109303
[fdo#109307]: https://bugs.freedesktop.org/show_bug.cgi?id=109307
[fdo#109308]: https://bugs.freedesktop.org/show_bug.cgi?id=109308
[fdo#109309]: https://bugs.freedesktop.org/show_bug.cgi?id=109309
[fdo#109312]: https://bugs.freedesktop.org/show_bug.cgi?id=109312
[fdo#109313]: https://bugs.freedesktop.org/show_bug.cgi?id=109313
[fdo#109314]: https://bugs.freedesktop.org/show_bug.cgi?id=109314
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#109506]: https://bugs.freedesktop.org/show_bug.cgi?id=109506
[fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
[fdo#110189]: https://bugs.freedesktop.org/show_bug.cgi?id=110189
[fdo#110542]: https://bugs.freedesktop.org/show_bug.cgi?id=110542
[fdo#110723]: https://bugs.freedesktop.org/show_bug.cgi?id=110723
[fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
[fdo#111614]: https://bugs.freedesktop.org/show_bug.cgi?id=111614
[fdo#111615]: https://bugs.freedesktop.org/show_bug.cgi?id=111615
[fdo#111644]: https://bugs.freedesktop.org/show_bug.cgi?id=111644
[fdo#111656]: https://bugs.freedesktop.org/show_bug.cgi?id=111656
[fdo#111825]: https://bugs.freedesktop.org/show_bug.cgi?id=111825
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[fdo#112054]: https://bugs.freedesktop.org/show_bug.cgi?id=112054
[fdo#112283]: https://bugs.freedesktop.org/show_bug.cgi?id=112283
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1257]: https://gitlab.freedesktop.org/drm/intel/issues/1257
[i915#132]: https://gitlab.freedesktop.org/drm/intel/issues/132
[i915#1397]: https://gitlab.freedesktop.org/drm/intel/issues/1397
[i915#1722]: https://gitlab.freedesktop.org/drm/intel/issues/1722
[i915#1755]: https://gitlab.freedesktop.org/drm/intel/issues/1755
[i915#1769]: https://gitlab.freedesktop.org/drm/intel/issues/1769
[i915#1825]: https://gitlab.freedesktop.org/drm/intel/issues/1825
[i915#1839]: https://gitlab.freedesktop.org/drm/intel/issues/1839
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#1849]: https://gitlab.freedesktop.org/drm/intel/issues/1849
[i915#2346]: https://gitlab.freedesktop.org/drm/intel/issues/2346
[i915#2433]: https://gitlab.freedesktop.org/drm/intel/issues/2433
[i915#2434]: https://gitlab.freedesktop.org/drm/intel/issues/2434
[i915#2437]: https://gitlab.freedesktop.org/drm/intel/issues/2437
[i915#2527]: https://gitlab.freedesktop.org/drm/intel/issues/2527
[i915#2575]: https://gitlab.freedesktop.org/drm/intel/issues/2575
[i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
[i915#2587]: https://gitlab.freedesktop.org/drm/intel/issues/2587
[i915#2658]: https://gitlab.freedesktop.org/drm/intel/issues/2658
[i915#2672]: https://gitlab.freedesktop.org/drm/intel/issues/2672
[i915#2705]: https://gitlab.freedesktop.org/drm/intel/issues/2705
[i915#280]: https://gitlab.freedesktop.org/drm/intel/issues/280
[i915#2842]: https://gitlab.freedesktop.org/drm/intel/issues/2842
[i915#2846]: https://gitlab.freedesktop.org/drm/intel/issues/2846
[i915#2856]: https://gitlab.freedesktop.org/drm/intel/issues/2856
[i915#2920]: https://gitlab.freedesktop.org/drm/intel/issues/2920
[i915#2994]: https://gitlab.freedesktop.org/drm/intel/issues/2994
[i915#3116]: https://gitlab.freedesktop.org/drm/intel/issues/3116
[i915#3281]: https://gitlab.freedesktop.org/drm/intel/issues/3281
[i915#3282]: https://gitlab.freedesktop.org/drm/intel/issues/3282
[i915#3291]: https://gitlab.freedesktop.org/drm/intel/issues/3291
[i915#3297]: https://gitlab.freedesktop.org/drm/intel/issues/3297
[i915#3299]: https://gitlab.freedesktop.org/drm/intel/issues/3299
[i915#3323]: https://gitlab.freedesktop.org/drm/intel/issues/3323
[i915#3359]: https://gitlab.freedesktop.org/drm/intel/issues/3359
[i915#3361]: https://gitlab.freedesktop.org/drm/intel/issues/3361
[i915#3458]: https://gitlab.freedesktop.org/drm/intel/issues/3458
[i915#3469]: https://gitlab.freedesktop.org/drm/intel/issues/3469
[i915#3528]: https://gitlab.freedesktop.org/drm/intel/issues/3528
[i915#3539]: https://gitlab.freedesktop.org/drm/intel/issues/3539
[i915#3546]: https://gitlab.freedesktop.org/drm/intel/issues/3546
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3558]: https://gitlab.freedesktop.org/drm/intel/issues/3558
[i915#3637]: https://gitlab.freedesktop.org/drm/intel/issues/3637
[i915#3638]: https://gitlab.freedesktop.org/drm/intel/issues/3638
[i915#3689]: https://gitlab.freedesktop.org/drm/intel/issues/3689
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#3734]: https://gitlab.freedesktop.org/drm/intel/issues/3734
[i915#3742]: https://gitlab.freedesktop.org/drm/intel/issues/3742
[i915#3886]: https://gitlab.freedesktop.org/drm/intel/issues/3886
[i915#3955]: https://gitlab.freedesktop.org/drm/intel/issues/3955
[i915#3966]: https://gitlab.freedesktop.org/drm/intel/issues/3966
[i915#4070]: https://gitlab.freedesktop.org/drm/intel/issues/4070
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4098]: https://gitlab.freedesktop.org/drm/intel/issues/4098
[i915#4212]: https://gitlab.freedesktop.org/drm/intel/issues/4212
[i915#4215]: https://gitlab.freedesktop.org/drm/intel/issues/4215
[i915#426]: https://gitlab.freedesktop.org/drm/intel/issues/426
[i915#4270]: https://gitlab.freedesktop.org/drm/intel/issues/4270
[i915#4349]: https://gitlab.freedesktop.org/drm/intel/issues/4349
[i915#4538]: https://gitlab.freedesktop.org/drm/intel/issues/4538
[i915#4565]: https://gitlab.freedesktop.org/drm/intel/issues/4565
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4767]: https://gitlab.freedesktop.org/drm/intel/issues/4767
[i915#4771]: https://gitlab.freedesktop.org/drm/intel/issues/4771
[i915#4812]: https://gitlab.freedesktop.org/drm/intel/issues/4812
[i915#4833]: https://gitlab.freedesktop.org/drm/intel/issues/4833
[i915#4852]: https://gitlab.freedesktop.org/drm/intel/issues/4852
[i915#4860]: https://gitlab.freedesktop.org/drm/intel/issues/4860
[i915#4874]: https://gitlab.freedesktop.org/drm/intel/issues/4874
[i915#4877]: https://gitlab.freedesktop.org/drm/intel/issues/4877
[i915#4880]: https://gitlab.freedesktop.org/drm/intel/issues/4880
[i915#4881]: https://gitlab.freedesktop.org/drm/intel/issues/4881
[i915#4958]: https://gitlab.freedesktop.org/drm/intel/issues/4958
[i915#5030]: https://gitlab.freedesktop.org/drm/intel/issues/5030
[i915#5176]: https://gitlab.freedesktop.org/drm/intel/issues/5176
[i915#5235]: https://gitlab.freedesktop.org/drm/intel/issues/5235
[i915#5286]: https://gitlab.freedesktop.org/drm/intel/issues/5286
[i915#5288]: https://gitlab.freedesktop.org/drm/intel/issues/5288
[i915#5289]: https://gitlab.freedesktop.org/drm/intel/issues/5289
[i915#5325]: https://gitlab.freedesktop.org/drm/intel/issues/5325
[i915#5327]: https://gitlab.freedesktop.org/drm/intel/issues/5327
[i915#533]: https://gitlab.freedesktop.org/drm/intel/issues/533
[i915#5439]: https://gitlab.freedesktop.org/drm/intel/issues/5439
[i915#5461]: https://gitlab.freedesktop.org/drm/intel/issues/5461
[i915#5563]: https://gitlab.freedesktop.org/drm/intel/issues/5563
[i915#5566]: https://gitlab.freedesktop.org/drm/intel/issues/5566
[i915#5784]: https://gitlab.freedesktop.org/drm/intel/issues/5784
[i915#6095]: https://gitlab.freedesktop.org/drm/intel/issues/6095
[i915#6227]: https://gitlab.freedesktop.org/drm/intel/issues/6227
[i915#6230]: https://gitlab.freedesktop.org/drm/intel/issues/6230
[i915#6248]: https://gitlab.freedesktop.org/drm/intel/issues/6248
[i915#6252]: https://gitlab.freedesktop.org/drm/intel/issues/6252
[i915#6301]: https://gitlab.freedesktop.org/drm/intel/issues/6301
[i915#6344]: https://gitlab.freedesktop.org/drm/intel/issues/6344
[i915#6412]: https://gitlab.freedesktop.org/drm/intel/issues/6412
[i915#6433]: https://gitlab.freedesktop.org/drm/intel/issues/6433
[i915#6497]: https://gitlab.freedesktop.org/drm/intel/issues/6497
[i915#6524]: https://gitlab.freedesktop.org/drm/intel/issues/6524
[i915#658]: https://gitlab.freedesktop.org/drm/intel/issues/658
[i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
[i915#6768]: https://gitlab.freedesktop.org/drm/intel/issues/6768
[i915#6944]: https://gitlab.freedesktop.org/drm/intel/issues/6944
[i915#6946]: https://gitlab.freedesktop.org/drm/intel/issues/6946
[i915#7052]: https://gitlab.freedesktop.org/drm/intel/issues/7052
[i915#7116]: https://gitlab.freedesktop.org/drm/intel/issues/7116
[i915#7118]: https://gitlab.freedesktop.org/drm/intel/issues/7118
[i915#716]: https://gitlab.freedesktop.org/drm/intel/issues/716
[i915#7443]: https://gitlab.freedesktop.org/drm/intel/issues/7443
[i915#7456]: https://gitlab.freedesktop.org/drm/intel/issues/7456
[i915#7561]: https://gitlab.freedesktop.org/drm/intel/issues/7561
[i915#7651]: https://gitlab.freedesktop.org/drm/intel/issues/7651
[i915#7697]: https://gitlab.freedesktop.org/drm/intel/issues/7697
[i915#7701]: https://gitlab.freedesktop.org/drm/intel/issues/7701
[i915#7707]: https://gitlab.freedesktop.org/drm/intel/issues/7707
[i915#7711]: https://gitlab.freedesktop.org/drm/intel/issues/7711
[i915#7742]: https://gitlab.freedesktop.org/drm/intel/issues/7742
[i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828

Build changes
-------------

* Linux: CI_DRM_12619 -> Patchwork_113078v2
* Piglit: piglit_4509 -> None

CI-20190529: 20190529
CI_DRM_12619: 7d3e7f64a42d66ba8da6e7b66a8d85457ef84570 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7129: 7816773163a1b0d248dd9dd34d14e632ad8903be @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_113078v2: 7d3e7f64a42d66ba8da6e7b66a8d85457ef84570 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_113078v2/index.html