* Re: [PATCH 4/5] drm/xe: hold video decode work and HuC queries for a pending DG2 HuC load
[not found] ` <20261126205758.49845-5-arisa.snowbell@gmail.com>
@ 2026-11-26 21:12 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-26 21:12 UTC (permalink / raw)
To: Arisa Snowbell, intel-xe; +Cc: dri-devel, media-ci
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/xe: race in query_uc_fw_version() during GT reset returns
-ENODEV
- [Medium] drm/xe: video decode jobs miss post-reset HuC load fence in
xe_exec_ioctl()
--
commit 5dc281ce1c152eb029eef3dac3ecc0b42e37b1fb
Author: Arisa Snowbell <arisa.snowbell@gmail.com>
drm/xe: hold video decode work and HuC queries for a pending DG2 HuC load
This commit adds a dependency on the pending DG2 HuC MEI load fence for
video decode jobs in xe_exec_ioctl() and waits for that fence in
query_uc_fw_version() before reporting the HuC firmware version.
> diff --git a/drivers/gpu/drm/xe/xe_exec.c b/drivers/gpu/drm/xe/xe_exec.c
> index 0e6a197a8e85e..020dc78948910 100644
> --- a/drivers/gpu/drm/xe/xe_exec.c
> +++ b/drivers/gpu/drm/xe/xe_exec.c
[ ... ]
> @@ -334,6 +336,17 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
> if (err)
> goto err_put_job;
>
> + /* as on i915, video decode must not run before a pending HuC load */
> + if (q->class == XE_ENGINE_CLASS_VIDEO_DECODE) {
> + struct dma_fence *huc_load = xe_huc_mei_load_fence(&q->gt->uc.huc);
> +
> + if (huc_load) {
> + err = drm_sched_job_add_dependency(&job->drm, huc_load);
> + if (err)
> + goto err_put_job;
> + }
> + }
> +
> if (!xe_vm_in_lr_mode(vm)) {
> err = xe_svm_notifier_lock_interruptible(vm);
> if (err)
[Severity: Medium]
Can video decode jobs still run before the post-reset HuC load finishes if
a GT reset occurs?
CPU0 (gt_reset_worker) CPU1
xe_uc_stop_prepare()
xe_huc_mei_stop()
huc_mei_go_down()
huc_mei_settle_locked()
mei->state = XE_HUC_MEI_DOWN
mei->load = NULL
xe_uc_stop()
do_gt_reset()
do_gt_restart()
xe_exec_ioctl()
xe_huc_mei_load_fence() -> NULL
xe_sched_job_push(job)
xe_uc_load_hw()
xe_huc_auth()
xe_huc_mei_start()
mei->state = XE_HUC_MEI_LOADING
queue_work(..., &mei->auth)
xe_uc_start()
...
guc_exec_queue_start() <-- job runs before mei->auth finishes
At the start of a GT reset, huc_mei_go_down() signals any pre-reset
mei->load fence and sets mei->state to XE_HUC_MEI_DOWN until
xe_huc_mei_start() runs at the end of xe_uc_load_hw(). During that window
xe_huc_mei_load_fence() returns NULL, so jobs submitted in xe_exec_ioctl()
acquire no fence dependency, and jobs already queued in q->entity or
replayed from sched->pending_list had their pre-reset fence signaled.
When xe_uc_start() restarts the queue schedulers immediately after
xe_huc_mei_start(), those video decode jobs are submitted to the GuC
before the asynchronous HuC load completes.
> diff --git a/drivers/gpu/drm/xe/xe_query.c b/drivers/gpu/drm/xe/xe_query.c
> index 9cc35fc83954f..696bae5eea3b3 100644
> --- a/drivers/gpu/drm/xe/xe_query.c
> +++ b/drivers/gpu/drm/xe/xe_query.c
[ ... ]
> @@ -619,6 +621,9 @@ query_uc_fw_version(struct xe_device *xe, struct drm_xe_device_query *query)
> break;
>
> huc = &media_gt->uc.huc;
> + ret = xe_huc_mei_wait(huc);
> + if (ret)
> + return ret;
> if (huc->fw.status == XE_UC_FIRMWARE_RUNNING)
> version = &huc->fw.versions.found[XE_UC_FW_VER_RELEASE];
> break;
[Severity: Medium]
Can query_uc_fw_version() still return -ENODEV during a GT reset instead
of waiting for the post-reset HuC load?
CPU0 (gt_reset_worker) CPU1
xe_uc_stop_prepare()
xe_huc_mei_stop()
huc_mei_go_down()
huc_mei_settle_locked()
mei->state = XE_HUC_MEI_DOWN
mei->load = NULL
...
do_gt_restart()
xe_uc_sanitize_reset()
...
huc->fw.status = XE_UC_FIRMWARE_LOADABLE
query_uc_fw_version()
xe_huc_mei_wait()
xe_huc_mei_load_fence() -> NULL
huc->fw.status != XE_UC_FIRMWARE_RUNNING
return -ENODEV
xe_uc_load_hw()
xe_huc_auth()
xe_huc_mei_start()
Between xe_huc_mei_stop() and xe_huc_mei_start(), mei->state is
XE_HUC_MEI_DOWN and xe_huc_mei_load_fence() returns NULL:
drivers/gpu/drm/xe/xe_huc_mei.c:xe_huc_mei_load_fence() {
guard(spinlock_irqsave)(&mei->state_lock);
if (mei->state != XE_HUC_MEI_LOADING || !mei->load)
return NULL;
return dma_fence_get(mei->load);
}
Meanwhile xe_uc_sanitize_reset() resets huc->fw.status to
XE_UC_FIRMWARE_LOADABLE before xe_uc_load_hw() uploads GuC firmware and
calls xe_huc_mei_start(). A query running in that window (or woken early
when huc_mei_go_down() signals a pre-reset load fence) returns 0 from
xe_huc_mei_wait(), sees huc->fw.status != XE_UC_FIRMWARE_RUNNING, and
returns -ENODEV to userspace.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126205758.49845-2-arisa.snowbell@gmail.com?part=4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 3/5] drm/xe/huc: load the DG2 HuC through the GSC via mei_pxp
[not found] ` <20261126205758.49845-4-arisa.snowbell@gmail.com>
@ 2026-11-26 21:23 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-26 21:23 UTC (permalink / raw)
To: Arisa Snowbell, intel-xe; +Cc: dri-devel, media-ci
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-26 21:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261126205758.49845-1-arisa.snowbell@gmail.com>
[not found] ` <20261126205758.49845-5-arisa.snowbell@gmail.com>
2026-11-26 21:12 ` [PATCH 4/5] drm/xe: hold video decode work and HuC queries for a pending DG2 HuC load sashiko-bot
[not found] ` <20261126205758.49845-4-arisa.snowbell@gmail.com>
2026-11-26 21:23 ` [PATCH 3/5] drm/xe/huc: load the DG2 HuC through the GSC via mei_pxp sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox