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 <[email protected]> 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/[email protected]?part=3
