From: "Vivekanandan, Balasubramani" <balasubramani.vivekanandan@intel.com>
To: Sujaritha Sundaresan <sujaritha.sundaresan@intel.com>,
<intel-xe@lists.freedesktop.org>
Cc: Tangudu Tilak Tirumalesh <tilak.tirumalesh.tangudu@intel.com>,
"Matthew Brost" <matthew.brost@intel.com>,
Stuart Summers <stuart.summers@intel.com>
Subject: Re: [PATCH] drm/xe/guc: Reset GuC before unmapping its post-hwconfig buffers
Date: Mon, 26 Oct 2026 19:37:33 +0530 [thread overview]
Message-ID: <at9epeRtNe-eKEdY@bvivekan-mobl1> (raw)
In-Reply-To: <20261019100448.759503-1-sujaritha.sundaresan@intel.com>
On 19.10.2026 15:34, Sujaritha Sundaresan wrote:
> guc_fini_hw() resets the GuC on teardown, but it is registered before
> xe_guc_init_post_hwconfig() (re)allocates most of the GuC buffers. As
> devm actions run in reverse order, these buffers get unmapped from the
> GGTT while the GuC is still running and may still access them. When
> unmapped GGTT entries are left invalid, this results in a GuC page
> fault on unbind or probe failure.
>
> Re-register guc_fini_hw() after all the GuC buffer allocations, so the
> GuC is reset before any of them is unmapped. Keep GuC submit and RC
> teardown running before the reset, as they still need to stop or talk
> to the GuC.
>
> Assisted-by: LLM
> Signed-off-by: Sujaritha Sundaresan <sujaritha.sundaresan@intel.com>
> ---
> drivers/gpu/drm/xe/xe_guc.c | 30 ++++++++++++++++++++++--------
> 1 file changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
> index 6c35474ab843..14ae73844d76 100644
> --- a/drivers/gpu/drm/xe/xe_guc.c
> +++ b/drivers/gpu/drm/xe/xe_guc.c
> @@ -882,9 +882,10 @@ static u32 guc_additional_cache_size(struct xe_device *xe)
> */
> int xe_guc_init_post_hwconfig(struct xe_guc *guc)
> {
> + struct xe_device *xe = guc_to_xe(guc);
> int ret;
>
> - if (IS_SRIOV_VF(guc_to_xe(guc)))
> + if (IS_SRIOV_VF(xe))
> return vf_guc_init_post_hwconfig(guc);
>
> ret = xe_guc_realloc_post_hwconfig(guc);
> @@ -897,28 +898,41 @@ int xe_guc_init_post_hwconfig(struct xe_guc *guc)
>
> guc_init_params_post_hwconfig(guc);
>
> - ret = xe_guc_submit_init(guc);
The teardown function guc_submit_fini, registered by xe_guc_submit_init,
is invoked before releasing the buffers shared with GuC.
guc_submit_fini stops guc submission and also does a soft reset using
XE_GUC_ACTION_CLIENT_SOFT_RESET.
The GuC specification says, on XE_GUC_ACTION_CLIENT_SOFT_RESET, the GuC
revokes the log and CTB buffers.
So I believe, after that GuC shouldn't be accessing any buffers shared
by XeKMD. It must be safe to release the buffers after sending
XE_GUC_ACTION_CLIENT_SOFT_RESET.
Did we understand why are seeing this issue now but not earlier?
Is it a regresssion from a patch, either in KMD or GuC?
Regards,
Bala
> + ret = xe_guc_pc_init(&guc->pc);
> if (ret)
> return ret;
>
> - ret = xe_guc_db_mgr_init(&guc->dbm, ~0);
> + ret = xe_guc_engine_activity_init(guc);
> if (ret)
> return ret;
>
> - ret = xe_guc_pc_init(&guc->pc);
> + ret = xe_guc_buf_cache_init_with_size(&guc->buf,
> + guc_additional_cache_size(xe));
> if (ret)
> return ret;
>
> - ret = xe_guc_rc_init(guc);
> + /*
> + * The GuC keeps accessing its GGTT-mapped buffers until it is reset,
> + * so move guc_fini_hw() after all GuC allocations above to have the
> + * reset done before any of them is unpinned and its GGTT PTEs cleared.
> + * Teardown actions that must run before the reset, either because they
> + * still talk to the GuC (like GuC RC) or because they stop the CT and
> + * submission (like GuC submit), must be registered after this point.
> + */
> + devm_remove_action(xe->drm.dev, guc_fini_hw, guc);
> + ret = devm_add_action_or_reset(xe->drm.dev, guc_fini_hw, guc);
> if (ret)
> return ret;
>
> - ret = xe_guc_engine_activity_init(guc);
> + ret = xe_guc_submit_init(guc);
> if (ret)
> return ret;
>
> - ret = xe_guc_buf_cache_init_with_size(&guc->buf,
> - guc_additional_cache_size(guc_to_xe(guc)));
> + ret = xe_guc_db_mgr_init(&guc->dbm, ~0);
> + if (ret)
> + return ret;
> +
> + ret = xe_guc_rc_init(guc);
> if (ret)
> return ret;
>
>
> base-commit: 5bc00022b24f8a7bc6630609e9fd93dd977a87d3
> --
> 2.34.1
>
next prev parent reply other threads:[~2026-10-26 14:09 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 10:04 [PATCH] drm/xe/guc: Reset GuC before unmapping its post-hwconfig buffers Sujaritha Sundaresan
2026-10-19 9:26 ` ✓ CI.KUnit: success for " Patchwork
2026-10-19 10:17 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-19 12:08 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-11-17 23:14 ` Summers, Stuart
2026-10-26 14:07 ` Vivekanandan, Balasubramani [this message]
2026-11-04 7:37 ` [PATCH] " Sundaresan, Sujaritha
2026-11-13 19:51 ` Ceraolo Spurio, Daniele
2026-11-18 14:28 ` Vivekanandan, Balasubramani
2026-11-18 9:47 ` ✗ CI.checkpatch: warning for drm/xe/guc: Reset GuC before unmapping its post-hwconfig buffers (rev2) Patchwork
2026-11-18 9:49 ` ✓ CI.KUnit: success " Patchwork
2026-11-18 10:28 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-18 22:48 ` ✓ Xe.CI.FULL: " 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=at9epeRtNe-eKEdY@bvivekan-mobl1 \
--to=balasubramani.vivekanandan@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=stuart.summers@intel.com \
--cc=sujaritha.sundaresan@intel.com \
--cc=tilak.tirumalesh.tangudu@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.