intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Vivekanandan, Balasubramani" <balasubramani.vivekanandan@intel.com>
To: "Ceraolo Spurio, Daniele" <daniele.ceraolospurio@intel.com>,
	"Sundaresan,  Sujaritha" <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: Wed, 18 Nov 2026 19:58:03 +0530	[thread overview]
Message-ID: <av2184pRAeesmIai@bvivekan-mobl1> (raw)
In-Reply-To: <f4facd87-04f7-47b8-8cfb-dfa42fae965d@intel.com>

On 13.11.2026 11:51, Ceraolo Spurio, Daniele wrote:
> 
> 
> On 11/3/2026 11:37 PM, Sundaresan, Sujaritha wrote:
> > 
> > 
> > On 10/26/2026 7:37 PM, Vivekanandan, Balasubramani wrote:
> > > 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>
> 
> Do we need a fixes tag for this?
> 
> > > > ---
> > > >   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
> > 
> > Hi Bala,
> > 
> > 
> > Thanks for the review. I did some more digging here.
> > 
> > 
> > The soft reset in guc_submit_fini() goes through fine. Right after that
> > we unmap the GuC log buffer
> > 
> > (0x1e6a000-0x286b000), and the GuC faults reading 0x1e72138, which is
> > inside it.
> > 
> > So from what I see  the GuC is still touching the log buffer after
> > XE_GUC_ACTION_CLIENT_SOFT_RESET.
> > 
> 
> The CLIENT_SOFT_RESET was initially introduced for use by VFs, to allow a VF
> to reset its own state. Although a PF can also use this command, the type of
> state being reset doesn't change, so global allocations (GuC log, ADS) are
> not cleared by this command. I believe that the "log" in the specs refers to
> extra log buffers that can be registered with the GuC to get extra info
> (like the engine utilization buffers), but I'll ask the GuC team to clarify
> the specs.
> 
> I agree with the approach in this patch, we should definitely reset the GuC
> before we start unmapping its buffers. I have not reviewed the code changes
> yet, so no comment on those.
> 
> Daniele

That explains why we are seeing this issue now. Patch looks good to me.
Please add the Fixes tag as pointed by Daniele.

Reviewed-by: Balasubramani Vivekanandan <balasubramani.vivekanandan@intel.com>

Regards,
Bala

> 
> > 
> > ee460b8855d4 ("drm/xe/ggtt: fault on unmapped GGTT for multi-queue
> > platforms") dropped the scratch
> > 
> > page on multi-queue platforms. Before that, this late read just landed
> > on scratch; now it faults.
> > 
> > Thanks,
> > 
> > Suja
> > 
> > 
> > > > +	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
> > > > 

  reply	other threads:[~2026-11-18 14:28 UTC|newest]

Thread overview: 12+ 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 ` [PATCH] " Vivekanandan, Balasubramani
2026-11-04  7:37   ` Sundaresan, Sujaritha
2026-11-13 19:51     ` Ceraolo Spurio, Daniele
2026-11-18 14:28       ` Vivekanandan, Balasubramani [this message]
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

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=av2184pRAeesmIai@bvivekan-mobl1 \
    --to=balasubramani.vivekanandan@intel.com \
    --cc=daniele.ceraolospurio@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).