drm/xe/heci: expose the DG2 HECI1 interface to mei
Subsystems (6)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/5 drm/xe/heci: expose the DG2 HECI1 interface to mei
On DG2 the HuC is loaded and authenticated by the GSC, through the PXP client that lives on HECI1. Like i915 (intel_gsc.c), add HECI1 as the "mei-gsc" auxiliary device with 4 MiB of VRAM as the GSC extended operational memory, and route its interrupt (GSC_IRQ_INTF(0)).
HECI2 keeps its current setup; a HECI1 failure only leaves the HuC unauthenticated and does not fail the probe.
--- drivers/gpu/drm/xe/regs/xe_gsc_regs.h | 1 + drivers/gpu/drm/xe/xe_heci_gsc.c | 171 +++++++++++++++++++------- drivers/gpu/drm/xe/xe_heci_gsc.h | 27 +++- drivers/gpu/drm/xe/xe_irq.c | 2 + 4 files changed, 149 insertions(+), 52 deletions(-)
drivers/gpu/drm/xe/regs/xe_gsc_regs.h +1 -0
@@ -20,6 +20,7 @@#define DG1_GSC_HECI2_BASE 0x00259000#define PVC_GSC_HECI2_BASE 0x00285000 +#define DG2_GSC_HECI1_BASE 0x00373000#define DG2_GSC_HECI2_BASE 0x00374000#define HECI_H_CSR (base) XE_REG((base) + 0x4)
drivers/gpu/drm/xe/xe_heci_gsc.c +124 -47
270 lines not on this page · raw message
drivers/gpu/drm/xe/xe_heci_gsc.h +22 -5
@@ -7,6 +7,7 @@#include <linux/types.h> +struct xe_bo ;struct xe_device ;struct mei_aux_device ;
@@ -21,16 +22,32 @@ struct mei_aux_device;*/ #define CSC_IRQ_INTF (_x) BIT(9 + (_x)) +enum xe_heci_intf { +XE_HECI1 , +XE_HECI2 , +XE_HECI_COUNT , +}; +/** -* struct xe_heci_gsc - graphics security controller for xe, HECI interface -* -* @adev : pointer to mei auxiliary device structure -* @irq : irq number +* struct xe_heci_gsc_intf - one HECI interface of the GSC * +* @adev: mei auxiliary device of the interface +* @irq: irq number, -1 when polled +* @ext_op_mem: VRAM the GSC uses as extended operational memory, if any */ -struct xe_heci_gsc { +struct xe_heci_gsc_intf {struct mei_aux_device *adev;int irq; +struct xe_bo *ext_op_mem; +}; + +/** +* struct xe_heci_gsc - graphics security controller for xe, HECI interfaces +* +* @intf: HECI1 (DG2 PXP and HuC) and HECI2 (firmware interface) +*/ +struct xe_heci_gsc { +struct xe_heci_gsc_intf intf[XE_HECI_COUNT ]; };int xe_heci_gsc_init (struct xe_device *xe);
drivers/gpu/drm/xe/xe_irq.c +2 -0
@@ -247,6 +247,8 @@ void xe_irq_enable_hwe(struct xe_gt *gt)if (other_fuse_mask) { gsc_mask = common_mask |GSC_ER_COMPLETE ; heci_mask =GSC_IRQ_INTF (1 ); + }else if (xe->info.platform ==XE_DG2 ) { + gsc_mask =GSC_IRQ_INTF (0 ) |GSC_IRQ_INTF (1 ); }else if (xe->info.has_heci_gscfi) { gsc_mask =GSC_IRQ_INTF (1 ); }
Signature · 1 line
2.56.1
PATCH 2/5 mei: gsc: bind the xe HECI1 device
In reply to a message not in the archivexe now exposes the DG2 HECI1 interface as "xe.mei-gsc", the same interface i915 exposes as "i915.mei-gsc".
--- drivers/misc/mei/gsc-me.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/misc/mei/gsc-me.c +5 -0
@@ -276,6 +276,10 @@ static const struct auxiliary_device_id mei_gsc_id_table[] = { .name = "xe.mei-gscfi", .driver_data = MEI_ME_GSCFI_CFG, }, + { + .name = "xe.mei-gsc", + .driver_data = MEI_ME_GSC_CFG, + }, {/* sentinel */ }
@@ -297,5 +301,6 @@ MODULE_AUTHOR("Intel Corporation");MODULE_ALIAS ("auxiliary:i915.mei-gsc" );MODULE_ALIAS ("auxiliary:i915.mei-gscfi" );MODULE_ALIAS ("auxiliary:xe.mei-gscfi" ); +MODULE_ALIAS ("auxiliary:xe.mei-gsc" );MODULE_DESCRIPTION ("Intel(R) Graphics System Controller" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.56.1
PATCH 3/5 drm/xe/huc: load the DG2 HuC through the GSC via mei_pxp
In reply to a message not in the archiveOn DG2 the GSC both loads and authenticates the HuC. Register as the I915_COMPONENT_PXP component, as i915 does, so mei_pxp hands us its ops, and send PXP43 START_HUC_AUTH with the DPA of the firmware in VRAM through gsc_command(), whose request and reply live in a VRAM page. Leaving the GSC to mei keeps two drivers from driving the same hardware.
The load is asynchronous. It runs from a worker after every uC load (probe, GT reset, resume) and when mei binds; a stop before a reset, a suspend or an FLR waits for a running load and drops a pending one. Each load gets a fence that signals when it succeeded, failed or stopped waiting for mei. If mei_pxp does not bind within 10 s the HuC stays unloaded and later loads stop waiting for it until it binds, as i915's INTEL_HUC_DELAYED_LOAD_ERROR does.
As on i915, the GSC must be the one loading the HuC (GSC_LOADS_HUC), and a missing mei module or a failed setup only leaves the HuC unloaded.
A GSC command that never returns still holds up a stop, as on i915; a mei reset ends it. Video decode does not wait on it past the 10 s.
Nothing selects a DG2 HuC blob yet, so this changes nothing on its own.
--- drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/regs/xe_guc_regs.h | 3 + drivers/gpu/drm/xe/xe_huc.c | 16 +- drivers/gpu/drm/xe/xe_huc_mei.c | 569 ++++++++++++++++++++++++++ drivers/gpu/drm/xe/xe_huc_mei.h | 21 + drivers/gpu/drm/xe/xe_huc_types.h | 57 +++ drivers/gpu/drm/xe/xe_uc.c | 7 + 7 files changed, 673 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/xe/xe_huc_mei.c create mode 100644 drivers/gpu/drm/xe/xe_huc_mei.h
drivers/gpu/drm/xe/Makefile +1 -0
@@ -81,6 +81,7 @@ xe-y += xe_bb.o \ xe_guc_tlb_inval.o \ xe_heci_gsc.o \ xe_huc.o \ + xe_huc_mei.o \ xe_hw_engine.o \ xe_hw_engine_class_sysfs.o \ xe_hw_engine_group.o \
drivers/gpu/drm/xe/regs/xe_guc_regs.h +3 -0
@@ -60,6 +60,9 @@#define GUC_ENABLE_READ_CACHE_LOGIC REG_BIT(1)#define GUC_DISABLE_SRAM_INIT_TO_ZEROES REG_BIT(0) +#define GUC_SHIM_CONTROL2 XE_REG(0xc068) +#define GSC_LOADS_HUC REG_BIT(30) +#define SOFT_SCRATCH (n) XE_REG(0xc180 + (n) * 4)#define SOFT_SCRATCH_COUNT 16
drivers/gpu/drm/xe/xe_huc.c +15 -1
@@ -19,6 +19,7 @@#include "xe_gt.h" #include "xe_gt_printk.h" #include "xe_guc.h" +#include "xe_huc_mei.h" #include "xe_map.h" #include "xe_mmio.h" #include "xe_sriov.h"
@@ -91,7 +92,8 @@ int xe_huc_init(struct xe_huc *huc)if (IS_SRIOV_VF (xe))return 0 ; -if (huc->fw.has_gsc_headers) { +/* on DG2 the GSC loads the HuC through mei, not via GSCCS packets */ +if (huc->fw.has_gsc_headers && xe->info.platform !=XE_DG2 ) { ret =huc_alloc_gsc_pkt (huc);if (ret) goto out;
@@ -122,6 +124,8 @@ int xe_huc_init_post_hwconfig(struct xe_huc *huc)if (ret)return ret; +xe_huc_mei_init (huc); +return 0 ; }
@@ -129,6 +133,11 @@ int xe_huc_upload(struct xe_huc *huc) {if (!xe_uc_fw_is_loadable (&huc->fw))return 0 ; + +/* the GSC loads it from VRAM itself */ +if (xe_huc_mei_is_used (huc)) +return 0 ; +return xe_uc_fw_upload (&huc->fw,0 ,HUC_UKERNEL ); }
@@ -244,6 +253,11 @@ int xe_huc_auth(struct xe_huc *huc, enum xe_huc_auth_types type)if (!xe_uc_fw_is_loadable (&huc->fw))return 0 ; +if (xe_huc_mei_is_used (huc)) { +xe_huc_mei_start (huc); +return 0 ; + } +/* On newer platforms the HuC survives reset, so no need to re-auth */ if (xe_huc_is_authenticated (huc, type)) {xe_uc_fw_change_status (&huc->fw,XE_UC_FIRMWARE_RUNNING );
drivers/gpu/drm/xe/xe_huc_mei.c new file +569 -0
569 lines not on this page · raw message
drivers/gpu/drm/xe/xe_huc_mei.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright © 2026 Arisa Snowbell +*/ + +#ifndef _XE_HUC_MEI_H_ +#define _XE_HUC_MEI_H_ + +#include <linux/types.h> + +struct dma_fence ; +struct xe_huc ; + +bool xe_huc_mei_is_used (struct xe_huc *huc); +void xe_huc_mei_init (struct xe_huc *huc); +void xe_huc_mei_start (struct xe_huc *huc); +void xe_huc_mei_stop (struct xe_huc *huc); +struct dma_fence *xe_huc_mei_load_fence (struct xe_huc *huc); +int xe_huc_mei_wait (struct xe_huc *huc); + +#endif
drivers/gpu/drm/xe/xe_huc_types.h +57 -0
73 lines not on this page · raw message
drivers/gpu/drm/xe/xe_uc.c +7 -0
@@ -20,6 +20,7 @@#include "xe_guc_engine_activity.h" #include "xe_guc_submit.h" #include "xe_huc.h" +#include "xe_huc_mei.h" #include "xe_mmio.h" #include "xe_sriov.h" #include "xe_tile.h"
@@ -374,6 +375,7 @@ int xe_uc_reset_prepare(struct xe_uc *uc)void xe_uc_stop_prepare (struct xe_uc *uc) { +xe_huc_mei_stop (&uc->huc);xe_gsc_stop_prepare (&uc->gsc);xe_guc_stop_prepare (&uc->guc); }
@@ -444,6 +446,7 @@ void xe_uc_flr_prepare(struct xe_uc *uc)struct xe_uc_flr flr = { .uc = uc };struct xe_gt *gt =uc_to_gt (uc); +xe_huc_mei_stop (&uc->huc);xe_uc_reset_prepare (uc);/*
@@ -485,6 +488,7 @@ int xe_uc_reinit(struct xe_uc *uc)void xe_uc_suspend_prepare (struct xe_uc *uc) { +xe_huc_mei_stop (&uc->huc);xe_gsc_wait_for_worker_completion (&uc->gsc);xe_guc_stop_prepare (&uc->guc); }
@@ -495,6 +499,9 @@ int xe_uc_suspend(struct xe_uc *uc)if (!xe_device_uc_enabled (uc_to_xe (uc)))return 0 ; +/* runtime D3cold gets here without xe_uc_suspend_prepare() */ +xe_huc_mei_stop (&uc->huc); +uc_reset_wait (uc);xe_uc_stop (uc);
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH 3/5] drm/xe/huc: load the DG2 HuC through the GSC via mei_pxp
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]…
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.
Quoted 6 lines
drivers/gpu/drm/xe/xe_huc_mei.c new file +0
-0@@ -0,0 +1,569 @@
[ ... ]
Quoted 4 lines
drivers/gpu/drm/xe/xe_huc_mei.c new file +4
-0+/* 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);
drivers/gpu/drm/xe/xe_huc_mei.c line 114
Quoted 10 lines
drivers/gpu/drm/xe/xe_huc_mei.c new file +10
-0+ +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.
[ ... ]
Quoted 18 lines
drivers/gpu/drm/xe/xe_huc_mei.c new file +18
-0+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;
drivers/gpu/drm/xe/xe_huc_mei.c line 507
Quoted 10 lines
drivers/gpu/drm/xe/xe_huc_mei.c new file +10
-0+ 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 CPU1xe_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.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
PATCH 4/5 drm/xe: hold video decode work and HuC queries for a pending DG2 HuC load
In reply to a message not in the archiveOn DG2 the HuC load by the GSC completes asynchronously after probe, a GT reset or a resume. Media submitted before then would run without the HuC, and userspace querying the HuC version (as Mesa and the media driver do at init) would see a device without one.
Like i915 (i915_request_await_huc()), make video decode jobs depend on the fence of the pending load. The HuC version query waits for it too, interruptibly and bounded by the load's own 10 s deadline; document that.
--- drivers/gpu/drm/xe/xe_exec.c | 13 +++++++++++++ drivers/gpu/drm/xe/xe_query.c | 5 +++++ include/uapi/drm/xe_drm.h | 5 +++++ 3 files changed, 23 insertions(+)
drivers/gpu/drm/xe/xe_exec.c +13 -0
@@ -14,6 +14,8 @@#include "xe_device.h" #include "xe_exec_queue.h" +#include "xe_gt_types.h" +#include "xe_huc_mei.h" #include "xe_hw_engine_group.h" #include "xe_macros.h" #include "xe_pm.h"
@@ -317,6 +319,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)
drivers/gpu/drm/xe/xe_query.c +5 -0
@@ -22,6 +22,7 @@#include "xe_gt.h" #include "xe_gt_topology.h" #include "xe_guc_hwconfig.h" +#include "xe_huc_mei.h" #include "xe_macros.h" #include "xe_mmio.h" #include "xe_oa.h"
@@ -600,6 +601,7 @@ query_uc_fw_version(struct xe_device *xe, struct drm_xe_device_query *query)case XE_QUERY_UC_TYPE_HUC : {struct xe_gt *media_gt =NULL ;struct xe_huc *huc; +int ret;if (MEDIA_VER (xe) >=13 ) {struct xe_tile *tile;
@@ -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 ;
include/uapi/drm/xe_drm.h +5 -0
@@ -628,6 +628,11 @@ struct drm_xe_query_engine_cycles {* * Given a uc_type this will return the branch, major, minor and patch version * of the micro-controller firmware. +* +* On platforms where the GSC loads the HuC (DG2), the load runs asynchronously +* after probe, reset and resume. A query of %XE_QUERY_UC_TYPE_HUC then waits +* (interruptibly, for at most 10 seconds) until a pending load settled, so +* that it does not report a HuC that is about to run as missing. */ struct drm_xe_query_uc_fw_version {/** @uc_type: The micro-controller type to query firmware version */
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH 4/5] drm/xe: hold video decode work and HuC queries for a pending DG2 HuC load
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…
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 <[email protected]>
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.
Quoted 4 lines
drivers/gpu/drm/xe/xe_exec.c +0
-0
[ ... ]
Quoted 8 lines
drivers/gpu/drm/xe/xe_exec.c +4
-0@@ -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); +
drivers/gpu/drm/xe/xe_exec.c int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file) · line 352
Quoted 10 lines
drivers/gpu/drm/xe/xe_exec.c +7
-0+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) CPU1xe_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 finishesAt 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.
Quoted 4 lines
drivers/gpu/drm/xe/xe_query.c +0
-0
[ ... ]
drivers/gpu/drm/xe/xe_query.c query_uc_fw_version(struct xe_device *xe, struct drm_xe_device_query *query) · line 629
Quoted 10 lines
drivers/gpu/drm/xe/xe_query.c +3
-0@@ -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) CPU1xe_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.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
PATCH 5/5 drm/xe/uc_fw: select the DG2 HuC blob for a load by the GSC
In reply to a message not in the archiveThe GSC loads the whole DG2 HuC binary (dg2_huc_gsc.bin, the one i915 uses), so there is no legacy CSS image to find in it for a DMA load: parse the CPD header for the manifest version only.
This enables the HuC on DG2.
--- drivers/gpu/drm/xe/xe_uc_fw.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/gpu/drm/xe/xe_uc_fw.c +9 -5
@@ -137,6 +137,7 @@ struct fw_blobs_by_type { fw_def(BATTLEMAGE, GT_TYPE_ANY, no_ver(xe, huc, bmg)) \ fw_def(LUNARLAKE, GT_TYPE_ANY, no_ver(xe, huc, lnl)) \ fw_def(METEORLAKE, GT_TYPE_ANY, no_ver(i915, huc_gsc, mtl)) \ + fw_def(DG2, GT_TYPE_ANY, no_ver(i915, huc_gsc, dg2)) \ fw_def(DG1, GT_TYPE_ANY, no_ver(i915, huc, dg1)) \ fw_def(ALDERLAKE_N, GT_TYPE_ANY, no_ver(i915, huc, tgl)) \fw_def (ALDERLAKE_P ,GT_TYPE_ANY ,no_ver (i915, huc, tgl)) \
@@ -555,11 +556,7 @@ static int parse_cpd_header(struct xe_uc_fw *uc_fw, const void *data, size_t sizif (css_entry) {int ret; -/* -* This section does not contain a CSS entry on DG2. We -* don't support DG2 HuC right now, so no need to handle -* it, just add a reminder in case that changes. -*/ +/* The DG2 HuC has no CSS entry, its caller passes none */ xe_assert (xe, xe->info.platform !=XE_DG2 ); offset =entry_offset (header, css_entry);
@@ -661,6 +658,13 @@ static int parse_headers(struct xe_uc_fw *uc_fw, const struct firmware *fw)case XE_UC_FW_TYPE_GSC :return parse_gsc_layout (uc_fw, fw->data, fw->size);case XE_UC_FW_TYPE_HUC : +/* +* The GSC loads the whole DG2 binary itself, so there is no +* legacy CSS image to find for a DMA load. +*/ +if (uc_fw_to_xe (uc_fw)->info.platform ==XE_DG2 ) +return parse_cpd_header (uc_fw, fw->data, fw->size,"HUCP.man" ,NULL ); + ret =parse_cpd_header (uc_fw, fw->data, fw->size,"HUCP.man" ,"huc_fw" );if (!ret || ret != -ENOENT )return ret;
Signature · 1 line
2.56.1