From: Matthew Brost <matthew.brost@intel.com>
To: Matthew Auld <matthew.auld@intel.com>
Cc: intel-xe@lists.freedesktop.org,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"William Tseng" <william.tseng@intel.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v2] drm/xe/sched: stop re-submitting signalled jobs
Date: Tue, 27 May 2025 11:20:50 -0700 [thread overview]
Message-ID: <aDYCglGbDzqPNofk@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20250527101959.192437-2-matthew.auld@intel.com>
On Tue, May 27, 2025 at 11:20:00AM +0100, Matthew Auld wrote:
> Customer is reporting a really subtle issue where we get random DMAR
> faults, hangs and other nasties for kernel migration jobs when stressing
> stuff like s2idle/s3/s4. The explosions seems to happen somewhere
> after resuming the system with splats looking something like:
>
> PM: suspend exit
> rfkill: input handler disabled
> xe 0000:00:02.0: [drm] GT0: Engine reset: engine_class=bcs, logical_mask: 0x2, guc_id=0
> xe 0000:00:02.0: [drm] GT0: Timedout job: seqno=24496, lrc_seqno=24496, guc_id=0, flags=0x13 in no process [-1]
> xe 0000:00:02.0: [drm] GT0: Kernel-submitted job timed out
>
> The likely cause appears to be a race between suspend cancelling the
> worker that processes the free_job()'s, such that we still have pending
> jobs to be freed after the cancel. Following from this, on resume the
> pending_list will now contain at least one already complete job, but it
> looks like we call drm_sched_resubmit_jobs(), which will then call
> run_job() on everything still on the pending_list. But if the job was
> already complete, then all the resources tied to the job, like the bb
> itself, any memory that is being accessed, the iommu mappings etc. might
> be long gone since those are usually tied to the fence signalling.
>
> This scenario can be seen in ftrace when running a slightly modified
> xe_pm (kernel was only modified to inject artificial latency into
> free_job to make the race easier to hit):
>
> xe_sched_job_run: dev=0000:00:02.0, fence=0xffff888276cc8540, seqno=0, lrc_seqno=0, gt=0, guc_id=0, batch_addr=0x000000146910 ...
> xe_exec_queue_stop: dev=0000:00:02.0, 3:0x2, gt=0, width=1, guc_id=0, guc_state=0x0, flags=0x13
> xe_exec_queue_stop: dev=0000:00:02.0, 3:0x2, gt=0, width=1, guc_id=1, guc_state=0x0, flags=0x4
> xe_exec_queue_stop: dev=0000:00:02.0, 4:0x1, gt=1, width=1, guc_id=0, guc_state=0x0, flags=0x3
> xe_exec_queue_stop: dev=0000:00:02.0, 1:0x1, gt=1, width=1, guc_id=1, guc_state=0x0, flags=0x3
> xe_exec_queue_stop: dev=0000:00:02.0, 4:0x1, gt=1, width=1, guc_id=2, guc_state=0x0, flags=0x3
> xe_exec_queue_resubmit: dev=0000:00:02.0, 3:0x2, gt=0, width=1, guc_id=0, guc_state=0x0, flags=0x13
> xe_sched_job_run: dev=0000:00:02.0, fence=0xffff888276cc8540, seqno=0, lrc_seqno=0, gt=0, guc_id=0, batch_addr=0x000000146910 ...
> .....
> xe_exec_queue_memory_cat_error: dev=0000:00:02.0, 3:0x2, gt=0, width=1, guc_id=0, guc_state=0x3, flags=0x13
>
> So the job_run() is clearly triggered twice for the same job, even
> though the first must have already signalled to completion during
> suspend. We can also see a CAT error after the re-submit.
>
> To prevent this try to call xe_sched_stop() to forcefully remove
> anything on the pending_list that has already signalled, before we
> re-submit.
>
> v2:
> - Make sure to re-arm the fence callbacks with sched_start().
>
> Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/4856
> Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: William Tseng <william.tseng@intel.com>
> Cc: <stable@vger.kernel.org> # v6.8+
> ---
> drivers/gpu/drm/xe/xe_gpu_scheduler.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_gpu_scheduler.h b/drivers/gpu/drm/xe/xe_gpu_scheduler.h
> index c250ea773491..0c8fe0461df9 100644
> --- a/drivers/gpu/drm/xe/xe_gpu_scheduler.h
> +++ b/drivers/gpu/drm/xe/xe_gpu_scheduler.h
> @@ -51,7 +51,9 @@ static inline void xe_sched_tdr_queue_imm(struct xe_gpu_scheduler *sched)
>
> static inline void xe_sched_resubmit_jobs(struct xe_gpu_scheduler *sched)
> {
> + drm_sched_stop(&sched->base, NULL); /* remove completed jobs */
> drm_sched_resubmit_jobs(&sched->base);
drm_sched_resubmit_jobs is deprecated. IIRC it was suggested we should
replace drm_sched_resubmit_jobs with a loop which calls run_job on the
driver side. Can we do that and avoid calling run_job on jobs with
their fence signaled? I think that would preferred here.
Matt
> + drm_sched_start(&sched->base, 0); /* re-add fence callback for pending jobs */
> }
>
> static inline bool
> --
> 2.49.0
>
next prev parent reply other threads:[~2025-05-27 18:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-27 10:20 [PATCH v2] drm/xe/sched: stop re-submitting signalled jobs Matthew Auld
2025-05-27 17:02 ` ✓ CI.Patch_applied: success for drm/xe/sched: stop re-submitting signalled jobs (rev2) Patchwork
2025-05-27 17:02 ` ✗ CI.checkpatch: warning " Patchwork
2025-05-27 17:03 ` ✓ CI.KUnit: success " Patchwork
2025-05-27 17:14 ` ✓ CI.Build: " Patchwork
2025-05-27 17:16 ` ✓ CI.Hooks: " Patchwork
2025-05-27 17:17 ` ✓ CI.checksparse: " Patchwork
2025-05-27 17:58 ` ✓ Xe.CI.BAT: " Patchwork
2025-05-27 18:20 ` Matthew Brost [this message]
2025-05-27 19:51 ` ✗ 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=aDYCglGbDzqPNofk@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--cc=stable@vger.kernel.org \
--cc=thomas.hellstrom@linux.intel.com \
--cc=william.tseng@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.