From: Raag Jadav <raag.jadav@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: matthew.brost@intel.com, rodrigo.vivi@intel.com,
thomas.hellstrom@linux.intel.com, riana.tauro@intel.com,
michal.wajdeczko@intel.com, matthew.d.roper@intel.com,
michal.winiarski@intel.com, matthew.auld@intel.com,
dev@lankhorst.se, jani.nikula@intel.com, lukasz.laguna@intel.com,
zhanjun.dong@intel.com, lukas@wunner.de,
daniele.ceraolospurio@intel.com, badal.nilawar@intel.com,
Raag Jadav <raag.jadav@intel.com>
Subject: [PATCH v9 01/10] drm/xe/uc_fw: Allow re-initializing firmware
Date: Wed, 1 Jul 2026 13:59:25 +0530 [thread overview]
Message-ID: <20260701083051.450259-2-raag.jadav@intel.com> (raw)
In-Reply-To: <20260701083051.450259-1-raag.jadav@intel.com>
In preparation of usecases which require re-initializing firmware without
reloading the driver, introduce xe_uc_fw_reinit(). The uC firmware bo
already exists but since it's contents are on VRAM, they are lost on PCIe
FLR. Copy the firmware back to it's bo and mark it as loadable as part of
re-initialization.
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Tested-by: Lukasz Laguna <lukasz.laguna@intel.com>
Reviewed-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
v2: Add kernel doc (Matthew Brost)
v6: Skip uC firmware selection during re-initialization (Daniele)
v8: Set fw state to XE_UC_FIRMWARE_INIT_FAIL on failure (Daniele)
---
drivers/gpu/drm/xe/xe_uc_fw.c | 67 +++++++++++++++++++++++++++++++++++
drivers/gpu/drm/xe/xe_uc_fw.h | 1 +
2 files changed, 68 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_uc_fw.c b/drivers/gpu/drm/xe/xe_uc_fw.c
index 3f08a3b54062..158ac15dde55 100644
--- a/drivers/gpu/drm/xe/xe_uc_fw.c
+++ b/drivers/gpu/drm/xe/xe_uc_fw.c
@@ -833,6 +833,14 @@ static int uc_fw_copy(struct xe_uc_fw *uc_fw, const void *data, size_t size, u32
return err;
}
+static void uc_fw_reinit(struct xe_uc_fw *uc_fw, const void *data)
+{
+ struct xe_device *xe = uc_fw_to_xe(uc_fw);
+
+ xe_map_memcpy_to(xe, &uc_fw->bo->vmap, 0, data, uc_fw->size);
+ xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_LOADABLE);
+}
+
int xe_uc_fw_init(struct xe_uc_fw *uc_fw)
{
const struct firmware *fw = NULL;
@@ -856,6 +864,65 @@ int xe_uc_fw_init(struct xe_uc_fw *uc_fw)
}
ALLOW_ERROR_INJECTION(xe_uc_fw_init, ERRNO); /* See xe_pci_probe() */
+/**
+ * xe_uc_fw_reinit() - Re-initialize uC firmware into its bo
+ * @uc_fw: uC firmware
+ *
+ * Returns: 0 on success, negative error code otherwise.
+ */
+int xe_uc_fw_reinit(struct xe_uc_fw *uc_fw)
+{
+ struct xe_device *xe = uc_fw_to_xe(uc_fw);
+ struct xe_uc_fw_version old_fw, new_fw;
+ const struct firmware *fw = NULL;
+ int err;
+
+ /* Make sure the status was cleared the last time we reset the uc */
+ xe_assert(xe, !xe_uc_fw_is_loaded(uc_fw));
+
+ /* We shouldn't be here for the firmware which wasn't available */
+ if (!xe_uc_fw_is_available(uc_fw))
+ return -ENOEXEC;
+
+ old_fw = uc_fw->versions.found[XE_UC_FW_VER_RELEASE];
+
+ err = firmware_request_nowarn(&fw, uc_fw->path, xe->drm.dev);
+ if (err)
+ goto init_fail;
+
+ err = parse_headers(uc_fw, fw);
+ if (err)
+ goto restore_old;
+
+ new_fw = uc_fw->versions.found[XE_UC_FW_VER_RELEASE];
+ if (memcmp(&old_fw, &new_fw, sizeof(old_fw)) || uc_fw->size != fw->size) {
+ drm_err(&xe->drm, "%s firmware mismatch on %s",
+ xe_uc_fw_type_repr(uc_fw->type), uc_fw->path);
+
+ err = -ENOEXEC;
+ goto restore_old;
+ }
+
+ uc_fw_reinit(uc_fw, fw->data);
+ uc_fw_release(fw);
+ return 0;
+
+restore_old:
+ /*
+ * parse_headers() updates version details, so restore original version
+ * before bailing.
+ *
+ * TODO: Create a struct of all the fields touched by parse_headers()
+ * and restore them all.
+ */
+ uc_fw->versions.found[XE_UC_FW_VER_RELEASE] = old_fw;
+init_fail:
+ xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_INIT_FAIL);
+ /* OK even if fw is NULL */
+ uc_fw_release(fw);
+ return err;
+}
+
static u32 uc_fw_ggtt_offset(struct xe_uc_fw *uc_fw)
{
return xe_bo_ggtt_addr(uc_fw->bo);
diff --git a/drivers/gpu/drm/xe/xe_uc_fw.h b/drivers/gpu/drm/xe/xe_uc_fw.h
index f2d3a3e7208b..6debdb924310 100644
--- a/drivers/gpu/drm/xe/xe_uc_fw.h
+++ b/drivers/gpu/drm/xe/xe_uc_fw.h
@@ -15,6 +15,7 @@
struct drm_printer;
int xe_uc_fw_init(struct xe_uc_fw *uc_fw);
+int xe_uc_fw_reinit(struct xe_uc_fw *uc_fw);
size_t xe_uc_fw_copy_rsa(struct xe_uc_fw *uc_fw, void *dst, u32 max_len);
int xe_uc_fw_upload(struct xe_uc_fw *uc_fw, u32 offset, u32 dma_flags);
int xe_uc_fw_check_version_requirements(struct xe_uc_fw *uc_fw);
--
2.43.0
next prev parent reply other threads:[~2026-07-01 8:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-01 8:29 [PATCH v9 00/10] Introduce Xe PCIe FLR Raag Jadav
2026-07-01 8:29 ` Raag Jadav [this message]
2026-07-01 8:29 ` [PATCH v9 02/10] drm/xe/guc_submit: Introduce guc_exec_queue_reinit_kernel() Raag Jadav
2026-07-01 8:29 ` [PATCH v9 03/10] drm/xe/gt: Introduce FLR helpers Raag Jadav
2026-07-01 8:29 ` [PATCH v9 04/10] drm/xe/bo_evict: Introduce xe_bo_restore_map() Raag Jadav
2026-07-01 8:29 ` [PATCH v9 05/10] drm/xe/exec_queue: Introduce xe_exec_queue_reinit() Raag Jadav
2026-07-01 8:29 ` [PATCH v9 06/10] drm/xe/migrate: Introduce xe_migrate_reinit() Raag Jadav
2026-07-01 8:29 ` [PATCH v9 07/10] drm/xe/pm: Introduce xe_device_suspend/resume() Raag Jadav
2026-07-01 8:29 ` [PATCH v9 08/10] drm/xe: Improve wedged state management Raag Jadav
2026-07-09 21:27 ` Matthew Brost
2026-07-10 5:01 ` Raag Jadav
2026-07-01 8:29 ` [PATCH v9 09/10] drm/xe/pci: Introduce PCIe FLR Raag Jadav
2026-07-01 8:29 ` [PATCH v9 10/10] drm/xe/doc: Wire up PCI Error Handling Raag Jadav
2026-07-01 8:42 ` ✗ CI.checkpatch: warning for Introduce Xe PCIe FLR (rev9) Patchwork
2026-07-01 8:43 ` ✓ CI.KUnit: success " Patchwork
2026-07-01 9:41 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-01 23:59 ` ✓ Xe.CI.FULL: " 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=20260701083051.450259-2-raag.jadav@intel.com \
--to=raag.jadav@intel.com \
--cc=badal.nilawar@intel.com \
--cc=daniele.ceraolospurio@intel.com \
--cc=dev@lankhorst.se \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=lukas@wunner.de \
--cc=lukasz.laguna@intel.com \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=matthew.d.roper@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=michal.winiarski@intel.com \
--cc=riana.tauro@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=thomas.hellstrom@linux.intel.com \
--cc=zhanjun.dong@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