Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Matthew Brost <matthew.brost@intel.com>
Cc: Raag Jadav <raag.jadav@intel.com>,
	<intel-xe@lists.freedesktop.org>, <riana.tauro@intel.com>,
	<michal.wajdeczko@intel.com>, <lukasz.laguna@intel.com>,
	<matthew.d.roper@intel.com>, <mallesh.koujalagi@intel.com>
Subject: Re: [PATCH v8 1/7] drm/xe/gt: Use GT ordered workqueue for wedging
Date: Thu, 15 Oct 2026 09:42:47 -0400	[thread overview]
Message-ID: <atDYV_pMUFxgj_Me@intel.com> (raw)
In-Reply-To: <atDVeL467De0qK0Q@gsse-cloud1.jf.intel.com>

On Thu, Oct 15, 2026 at 06:30:32AM -0700, Matthew Brost wrote:
> On Thu, Oct 15, 2026 at 01:05:13PM +0200, Raag Jadav wrote:
> > On Thu, Oct 15, 2026 at 01:40:15PM +0530, Raag Jadav wrote:
> > > Currently, xe_gt_declare_wedged() stops GuC CT and initiates exec queue
> > > teardown synchronously. This can result in tdr timeout in cases where
> > > the device is declared wedged while jobs are still in-flight.
> > > 
> > > Introduce a worker for GT specific wedge handling and queue the teardown
> > > on GT ordered workqueue, so we don't disrupt the scheduler while jobs
> > > are still in-flight.
> > > 
> > > While at it, introduce for_each_initialized_gt() macro and use it for
> > > wedging GT. This helps avoid races in case the device is declared wedged
> > > in probe sequence before GT is initialized.
> > > 
> > > Fixes: c9474b726b93 ("drm/xe: Wedge the entire device")
> > > Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> > > Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> > > ---
> > > v2: Split fixes into separate patches (Rodrigo, Michal)
> > > v4: Introduce for_each_initialized_gt() (Michal)
> > > v5: Flush GT wedge worker to avoid races (Sashiko)
> > > v6: Move wedge worker initialization to xe_gt_init_early() (Rodrigo)
> > >     Don't flush GT wedge worker to avoid deadlock (Sashiko)
> > > v7: Guard GT wedge worker with runtime PM (Rodrigo)
> > > ---
> > >  drivers/gpu/drm/xe/xe_device.c   |  2 +-
> > >  drivers/gpu/drm/xe/xe_device.h   |  4 ++++
> > >  drivers/gpu/drm/xe/xe_gt.c       | 17 +++++++++++++++--
> > >  drivers/gpu/drm/xe/xe_gt_types.h |  9 +++++++++
> > >  4 files changed, 29 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> > > index db0b883322ef..c7d8aea56f58 100644
> > > --- a/drivers/gpu/drm/xe/xe_device.c
> > > +++ b/drivers/gpu/drm/xe/xe_device.c
> > > @@ -1436,7 +1436,7 @@ void xe_device_declare_wedged(struct xe_device *xe)
> > >  			    WEDGED_URL, XE_BUG_URL);
> > >  	}
> > >  
> > > -	for_each_gt(gt, xe, id)
> > > +	for_each_initialized_gt(gt, xe, id)
> > >  		xe_gt_declare_wedged(gt);
> > >  
> > >  	if (xe_device_wedged(xe)) {
> > > diff --git a/drivers/gpu/drm/xe/xe_device.h b/drivers/gpu/drm/xe/xe_device.h
> > > index 83d6dafab53c..80bda9b548d5 100644
> > > --- a/drivers/gpu/drm/xe/xe_device.h
> > > +++ b/drivers/gpu/drm/xe/xe_device.h
> > > @@ -139,6 +139,10 @@ static inline bool xe_device_uc_enabled(struct xe_device *xe)
> > >  	for_each_gt((gt__), (tile__)->xe, (id__)) \
> > >  		for_each_if((gt__)->tile == (tile__))
> > >  
> > > +#define for_each_initialized_gt(gt__, xe__, id__) \
> > > +	for_each_gt((gt__), (xe__), (id__)) \
> > > +		for_each_if(READ_ONCE((gt__)->initialized))
> > > +
> > >  static inline struct xe_force_wake *gt_to_fw(struct xe_gt *gt)
> > >  {
> > >  	return &gt->pm.fw;
> > > diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
> > > index bc9bf6f0b5a7..d85406ba6f06 100644
> > > --- a/drivers/gpu/drm/xe/xe_gt.c
> > > +++ b/drivers/gpu/drm/xe/xe_gt.c
> > > @@ -175,6 +175,7 @@ static void xe_gt_enable_comp_1wcoh(struct xe_gt *gt)
> > >  }
> > >  
> > >  static void gt_reset_worker(struct work_struct *w);
> > > +static void gt_wedge_worker(struct work_struct *w);
> > >  
> > >  static int emit_job_sync(struct xe_exec_queue *q, struct xe_bb *bb,
> > >  			 long timeout_jiffies, bool force_reset)
> > > @@ -546,6 +547,7 @@ int xe_gt_init_early(struct xe_gt *gt)
> > >  	xe_gt_mcr_init_early(gt);
> > >  	xe_pat_init(gt);
> > >  
> > > +	INIT_WORK(&gt->wedge.worker, gt_wedge_worker);
> > >  	return 0;
> > >  }
> > >  
> > > @@ -724,6 +726,7 @@ static void xe_gt_fini(void *arg)
> > >  	struct xe_gt *gt = arg;
> > >  	int i;
> > >  
> > > +	disable_work_sync(&gt->wedge.worker);
> > >  	gt_reset_worker_disable(gt);
> > >  
> > >  	for (i = 0; i < XE_ENGINE_CLASS_MAX; ++i)
> > > @@ -784,6 +787,8 @@ int xe_gt_init(struct xe_gt *gt)
> > >  			return err;
> > >  	}
> > >  
> > > +	/* Must be last */
> > > +	WRITE_ONCE(gt->initialized, true);
> > >  	return 0;
> > >  }
> > >  
> > > @@ -1204,6 +1209,15 @@ struct xe_hw_engine *xe_gt_any_hw_engine(struct xe_gt *gt)
> > >  	return NULL;
> > >  }
> > >  
> > > +static void gt_wedge_worker(struct work_struct *w)
> > > +{
> > > +	struct xe_gt *gt = container_of(w, typeof(*gt), wedge.worker);
> > > +
> > > +	guard(xe_pm_runtime)(gt_to_xe(gt));
> > 
> > As this runs on GT ordered WQ, I'm a bit unsure about this. I'll rely on
> > Matt's input on this.
> > 
> 
> You can't take a waking PM reference on the GT ordered workqueue, as the
> entire workqueue is in the reclaim path. Lockdep will complain once we
> eventually annotate the workqueue as reclaim-capable [1]. I agree that
> this work item should probably hold a PM reference, but we should follow
> the same pattern we use for GT reset [2].
> 
> Matt
> 
> [1] https://patchwork.freedesktop.org/patch/711929/?series=163245&rev=1
> [2] https://patchwork.freedesktop.org/patch/682622/?series=156292&rev=1

I had forgotten about that, I'm sorry.

Yes, this solution is what we need.

> 
> > Raag
> > 
> > > +	xe_uc_declare_wedged(&gt->uc);
> > > +	xe_tlb_inval_reset(&gt->tlb_inval);
> > > +}
> > > +
> > >  /**
> > >   * xe_gt_declare_wedged() - Declare GT wedged
> > >   * @gt: the GT object
> > > @@ -1215,6 +1229,5 @@ void xe_gt_declare_wedged(struct xe_gt *gt)
> > >  {
> > >  	xe_gt_assert(gt, gt_to_xe(gt)->wedged.mode);
> > >  
> > > -	xe_uc_declare_wedged(&gt->uc);
> > > -	xe_tlb_inval_reset(&gt->tlb_inval);
> > > +	queue_work(gt->ordered_wq, &gt->wedge.worker);
> > >  }
> > > diff --git a/drivers/gpu/drm/xe/xe_gt_types.h b/drivers/gpu/drm/xe/xe_gt_types.h
> > > index 628911346455..c00a7c171f80 100644
> > > --- a/drivers/gpu/drm/xe/xe_gt_types.h
> > > +++ b/drivers/gpu/drm/xe/xe_gt_types.h
> > > @@ -233,6 +233,12 @@ struct xe_gt {
> > >  		struct work_struct worker;
> > >  	} reset;
> > >  
> > > +	/** @wedge: state for GT wedge */
> > > +	struct {
> > > +		/** @wedge.worker: worker for GT wedge to be done async */
> > > +		struct work_struct worker;
> > > +	} wedge;
> > > +
> > >  	/** @tlb_inval: TLB invalidation state */
> > >  	struct xe_tlb_inval tlb_inval;
> > >  
> > > @@ -419,6 +425,9 @@ struct xe_gt {
> > >  
> > >  	/** @eu_stall: EU stall counters subsystem per gt info */
> > >  	struct xe_eu_stall_gt *eu_stall;
> > > +
> > > +	/** @initialized: GT is initialized */
> > > +	bool initialized;
> > >  };
> > >  
> > >  #endif
> > > -- 
> > > 2.43.0
> > > 

  reply	other threads:[~2026-10-15 13:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15  8:10 [PATCH v8 0/7] Introduce xe_wedge Raag Jadav
2026-10-15  8:10 ` [PATCH v8 1/7] drm/xe/gt: Use GT ordered workqueue for wedging Raag Jadav
2026-10-15 11:05   ` Raag Jadav
2026-10-15 13:30     ` Matthew Brost
2026-10-15 13:42       ` Rodrigo Vivi [this message]
2026-10-15  8:10 ` [PATCH v8 2/7] drm/xe: Drop xe_device_set_wedged_method() Raag Jadav
2026-10-15  8:10 ` [PATCH v8 3/7] drm/xe: Move xe_device_wedged_fini() registration to xe_device_probe_early() Raag Jadav
2026-10-15  8:10 ` [PATCH v8 4/7] drm/xe: Make xe_device_declare_wedged() IRQ safe Raag Jadav
2026-10-15  8:10 ` [PATCH v8 5/7] drm/xe/pci_error: Flush GT wedge worker before bus reset Raag Jadav
2026-10-15  8:10 ` [PATCH v8 6/7] drm/xe: Introduce xe_wedge Raag Jadav
2026-10-15  8:10 ` [PATCH v8 7/7] drm/xe/ras: Move xe_ras_process_errors() to xe_ras Raag Jadav
2026-10-15  8:18 ` ✗ CI.checkpatch: warning for Introduce xe_wedge (rev7) Patchwork
2026-10-15  8:20 ` ✓ CI.KUnit: success " Patchwork
2026-10-15 15:33 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-15 22:10 ` ✗ Xe.CI.FULL: failure " Patchwork

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=atDYV_pMUFxgj_Me@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lukasz.laguna@intel.com \
    --cc=mallesh.koujalagi@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=matthew.d.roper@intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=raag.jadav@intel.com \
    --cc=riana.tauro@intel.com \
    /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