All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arisa Snowbell" <arisa.snowbell@gmail.com>,
	intel-xe@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH 3/5] drm/xe/huc: load the DG2 HuC through the GSC via mei_pxp
Date: Thu, 26 Nov 2026 21:23:01 +0000	[thread overview]
Message-ID: <sashiko-outbox-236230@kernel.org> (raw)
In-Reply-To: <20261126205758.49845-4-arisa.snowbell@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/xe/huc: missing flags argument to dma_fence_init() in
  huc_mei_fence_create()
- [Medium] drm/xe/huc: race on mei->state_lock in xe_huc_mei_start()
--

commit d092793f788c438939dcaa8d822c0755ed1b7fc7
Author: Arisa Snowbell <arisa.snowbell@gmail.com>

drm/xe/huc: load the DG2 HuC through the GSC via mei_pxp

This commit adds support for loading and authenticating the DG2 HuC
firmware asynchronously through the GSC via the mei_pxp component.

> diff --git a/drivers/gpu/drm/xe/xe_huc_mei.c b/drivers/gpu/drm/xe/xe_huc_mei.c
> new file mode 100644
> index 0000000000000..595405c4abfde
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_huc_mei.c
> @@ -0,0 +1,569 @@

[ ... ]

> +/* start() runs in the reset and resume paths, which must not wait on reclaim */
> +static struct dma_fence *huc_mei_fence_create(struct xe_huc_mei *mei)
> +{
> +	struct huc_mei_fence *fence = kzalloc_obj(*fence, GFP_NOWAIT | __GFP_NOWARN);
> +
> +	if (!fence)
> +		return NULL;
> +
> +	spin_lock_init(&fence->lock);
> +	dma_fence_init(&fence->base, &huc_mei_fence_ops, &fence->lock,
> +		       mei->fence_context, atomic64_inc_return(&mei->seqno));
> +
> +	return &fence->base;
> +}

[Severity: High]
Is dma_fence_init() missing its sixth argument (unsigned long flags) here?
This fails to compile when CONFIG_DRM_XE is enabled.

[ ... ]

> +void xe_huc_mei_start(struct xe_huc *huc)
> +{
> +	struct xe_huc_mei *mei = &huc->mei;
> +	struct dma_fence *load, *old;
> +	bool wait;
> +
> +	if (!xe_huc_mei_is_used(huc) || !xe_uc_fw_is_loadable(&huc->fw))
> +		return;
> +
> +	scoped_guard(spinlock_irqsave, &mei->state_lock)
> +		wait = !mei->absent;
> +
> +	/* without a fence submissions just don't wait */
> +	load = wait ? huc_mei_fence_create(mei) : NULL;
> +
> +	scoped_guard(spinlock_irqsave, &mei->state_lock) {
> +		huc_mei_settle_locked(mei);
> +		old = mei->load;
> +		mei->state = wait ? XE_HUC_MEI_LOADING : XE_HUC_MEI_SETTLED;
> +		mei->load = load;
> +	}
> +	dma_fence_put(old);
> +
> +	if (wait)
> +		mod_delayed_work(system_dfl_wq, &mei->deadline,
> +				 msecs_to_jiffies(HUC_MEI_COMPONENT_TIMEOUT_MS));
> +	huc_mei_queue(mei);
> +}

[Severity: Medium]
Can dropping mei->state_lock before mod_delayed_work() leave mei->deadline
queued after the load has already settled?

CPU0                                  CPU1
xe_huc_mei_start()
  lock(&mei->state_lock)
  mei->state = XE_HUC_MEI_LOADING
  unlock(&mei->state_lock)
                                      huc_mei_auth_work()
                                        huc_mei_load_and_auth()
                                        lock(&mei->state_lock)
                                        huc_mei_settle_locked()
                                          mei->state = XE_HUC_MEI_SETTLED
                                          cancel_delayed_work(&mei->deadline)
                                        unlock(&mei->state_lock)
  mod_delayed_work(..., &mei->deadline, ...)  <-- re-arms cancelled work

Also, if mei->absent was true and huc_mei_component_bind() runs between
the two mei->state_lock sections, huc_mei_component_bind() clears
mei->absent = false while mei->state is still XE_HUC_MEI_DOWN.  Because
 the second critical section does not re-check mei->absent, it uses the
stale wait == false and sets mei->state = XE_HUC_MEI_SETTLED with
mei->load = NULL, so submissions and HuC queries will not wait for the
pending load.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126205758.49845-2-arisa.snowbell@gmail.com?part=3

  reply	other threads:[~2026-11-26 21:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 20:57 [PATCH 0/5] drm/xe: load the DG2 HuC through the GSC via mei_pxp Arisa Snowbell
2026-11-26 20:57 ` [PATCH 1/5] drm/xe/heci: expose the DG2 HECI1 interface to mei Arisa Snowbell
2026-11-26 20:57 ` [PATCH 2/5] mei: gsc: bind the xe HECI1 device Arisa Snowbell
2026-11-26 20:57 ` [PATCH 3/5] drm/xe/huc: load the DG2 HuC through the GSC via mei_pxp Arisa Snowbell
2026-11-26 21:23   ` sashiko-bot [this message]
2026-12-02  1:38   ` Ceraolo Spurio, Daniele
2026-11-26 20:57 ` [PATCH 4/5] drm/xe: hold video decode work and HuC queries for a pending DG2 HuC load Arisa Snowbell
2026-11-26 21:12   ` sashiko-bot
2026-11-26 20:57 ` [PATCH 5/5] drm/xe/uc_fw: select the DG2 HuC blob for a load by the GSC Arisa Snowbell
2026-11-30 15:51 ` ✗ LGCI.VerificationFailed: failure for drm/xe: load the DG2 HuC through the GSC via mei_pxp 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=sashiko-outbox-236230@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=arisa.snowbell@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=media-ci@linuxtv.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.