Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Dong, Zhanjun" <zhanjun.dong@intel.com>
To: Matthew Brost <matthew.brost@intel.com>,
	Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH v4 3/5] drm/xe: Trigger queue cleanup if not in wedged mode 2
Date: Wed, 28 Jan 2026 16:55:14 -0500	[thread overview]
Message-ID: <55663496-af72-4a9f-8d4e-75ff88016f9e@intel.com> (raw)
In-Reply-To: <aXmE19aGZIjWjDaF@lstrano-desk.jf.intel.com>



On 2026-01-27 10:39 p.m., Matthew Brost wrote:
> On Tue, Jan 27, 2026 at 11:02:42PM +0100, Michal Wajdeczko wrote:
>>
>>
>> On 1/27/2026 6:04 PM, Zhanjun Dong wrote:
>>> From: Matthew Brost <matthew.brost@intel.com>
>>>
>>> The intent of wedging a device is to allow queues to continue running
>>> only in wedged mode 2. In other modes, queues should initiate cleanup
>>> and signal all remaining fences. Fix xe_guc_submit_wedge to correctly
>>> clean up queues when wedge mode != 2.
>>>
>>> Fixes: 7dbe8af13c18 ("drm/xe: Wedge the entire device")
>>> Cc: stable@vger.kernel.org
>>> Signed-off-by: Matthew Brost <matthew.brost@intel.com>
>>> Signed-off-by: Zhanjun Dong <zhanjun.dong@intel.com>
>>> ---
>>>   drivers/gpu/drm/xe/xe_guc_submit.c | 34 ++++++++++++++++++------------
>>>   1 file changed, 21 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
>>> index 92ea32423838..f29ed62d2b12 100644
>>> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
>>> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
>>> @@ -1326,6 +1326,7 @@ static void disable_scheduling_deregister(struct xe_guc *guc,
>>>    */
>>>   void xe_guc_submit_wedge(struct xe_guc *guc)
>>>   {
>>> +	struct xe_device *xe = guc_to_xe(guc);
>>>   	struct xe_gt *gt = guc_to_gt(guc);
>>>   	struct xe_exec_queue *q;
>>>   	unsigned long index;
>>> @@ -1340,20 +1341,27 @@ void xe_guc_submit_wedge(struct xe_guc *guc)
>>>   	if (!guc->submission_state.initialized)
>>>   		return;
>>>   
>>> -	err = devm_add_action_or_reset(guc_to_xe(guc)->drm.dev,
>>> -				       guc_submit_wedged_fini, guc);
>>> -	if (err) {
>>> -		xe_gt_err(gt, "Failed to register clean-up in wedged.mode=%s; "
>>> -			  "Although device is wedged.\n",
>>> -			  xe_wedged_mode_to_string(XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET));
>>> -		return;
>>> -	}
>>> +	if (xe->wedged.mode == 2) {
>>
>> wedged.mode is now an enum
>> you should use XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET instead of plain 2
>>
> 
> Yes it should be. This is a fixes patch though and with
> XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET, this patch will not cleanly apply
> to stable kernels. A later patch in the series could add in the enum I
> guess but maybe not an issue as xe_guc_submit_pause_abort isn't present
> in a lot kernels either.
> 
>>> +		err = devm_add_action_or_reset(guc_to_xe(guc)->drm.dev,
>>> +					       guc_submit_wedged_fini, guc);
>>> +		if (err) {
>>> +			xe_gt_err(gt, "Failed to register clean-up on wedged.mode=2; "
>>> +				  "Although device is wedged.\n");
>>> +			return;
>>
>> if we want to continue, shouldn't we call just devm_add_action() here?
>> some default cleanup will be done later anyway, no?
>>
> 
> Ah, no. If guc_submit_wedged_fini doesn't run at the end the driver will
> not unload cleanly. This could be refactored but it is correct as is.
> 
>>> +		}
>>>   
>>> -	mutex_lock(&guc->submission_state.lock);
>>> -	xa_for_each(&guc->submission_state.exec_queue_lookup, index, q)
>>> -		if (xe_exec_queue_get_unless_zero(q))
>>> -			set_exec_queue_wedged(q);
>>> -	mutex_unlock(&guc->submission_state.lock);
>>> +		mutex_lock(&guc->submission_state.lock);
>>> +		xa_for_each(&guc->submission_state.exec_queue_lookup, index, q)
>>> +			if (xe_exec_queue_get_unless_zero(q))
>>> +				set_exec_queue_wedged(q);
>>> +		mutex_unlock(&guc->submission_state.lock);
>>> +	} else {
>>> +		/* Forcefully kill any remaining exec queues, signal fences */
>>> +		xe_guc_ct_stop(&guc->ct);
>>
>> this was already called by xe_guc_declare_wedged() before calling us here
>>
>>> +		__xe_guc_submit_reset_prepare(guc);
> 
> We actually can skip __xe_guc_submit_reset_prepare too I believe as that
> is also called by an upper layer.
Will remove above 2 calls in next rev.

Regards,
Zhanjun Dong
> 
> Matt
> 
>>> +		xe_guc_submit_stop(guc);
>>> +		xe_guc_submit_pause_abort(guc);
>>> +	}
>>>   }
>>>   
>>>   static bool guc_submit_hint_wedged(struct xe_guc *guc)
>>


  reply	other threads:[~2026-01-28 21:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27 17:04 [PATCH v4 0/5] Attempt to fixup reset, wedge, unload corner cases Zhanjun Dong
2026-01-27 17:04 ` [PATCH v4 1/5] drm/xe: Always kill exec queues in xe_guc_submit_pause_abort Zhanjun Dong
2026-01-27 17:04 ` [PATCH v4 2/5] drm/xe: Forcefully tear down exec queues in GuC submit fini Zhanjun Dong
2026-01-27 17:04 ` [PATCH v4 3/5] drm/xe: Trigger queue cleanup if not in wedged mode 2 Zhanjun Dong
2026-01-27 22:02   ` Michal Wajdeczko
2026-01-28  3:39     ` Matthew Brost
2026-01-28 21:55       ` Dong, Zhanjun [this message]
2026-01-27 17:04 ` [PATCH v4 4/5] drm/xe/guc: Ensure CT state transitions via STOP before DISABLED Zhanjun Dong
2026-01-27 17:04 ` [PATCH v4 5/5] drm/xe/uc: Drop xe_guc_sanitize in favor of managed cleanup Zhanjun Dong
2026-01-27 17:12 ` ✓ CI.KUnit: success for Attempt to fixup reset, wedge, unload corner cases Patchwork
2026-01-27 18:08 ` ✓ Xe.CI.BAT: " Patchwork
2026-01-27 22:26 ` ✗ Xe.CI.Full: failure " Patchwork
2026-01-28  3:24   ` Matthew Brost

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=55663496-af72-4a9f-8d4e-75ff88016f9e@intel.com \
    --to=zhanjun.dong@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

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

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