Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
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, Raag Jadav <raag.jadav@intel.com>
Subject: [PATCH v1 1/6] drm/xe/uc_fw: Allow reloading firmware
Date: Tue, 24 Feb 2026 15:55:14 +0530	[thread overview]
Message-ID: <20260224102618.3105171-2-raag.jadav@intel.com> (raw)
In-Reply-To: <20260224102618.3105171-1-raag.jadav@intel.com>

In preparation of usecases which require loading firmware without
reloading the driver, introduce xe_uc_fw_copy() so that it can be
reused.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
---
 drivers/gpu/drm/xe/xe_uc_fw.c | 33 +++++++++++++++++----------------
 drivers/gpu/drm/xe/xe_uc_fw.h |  1 +
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_uc_fw.c b/drivers/gpu/drm/xe/xe_uc_fw.c
index d35bc4989144..a97cd885a052 100644
--- a/drivers/gpu/drm/xe/xe_uc_fw.c
+++ b/drivers/gpu/drm/xe/xe_uc_fw.c
@@ -320,7 +320,7 @@ size_t xe_uc_fw_copy_rsa(struct xe_uc_fw *uc_fw, void *dst, u32 max_len)
 	return size;
 }
 
-static void uc_fw_fini(struct drm_device *drm, void *arg)
+static void xe_uc_fw_fini(struct drm_device *drm, void *arg)
 {
 	struct xe_uc_fw *uc_fw = arg;
 
@@ -704,14 +704,6 @@ static int uc_fw_request(struct xe_uc_fw *uc_fw, const struct firmware **firmwar
 	const struct firmware *fw = NULL;
 	int err;
 
-	/*
-	 * we use FIRMWARE_UNINITIALIZED to detect checks against uc_fw->status
-	 * before we're looked at the HW caps to see if we have uc support
-	 */
-	BUILD_BUG_ON(XE_UC_FIRMWARE_UNINITIALIZED);
-	xe_gt_assert(gt, !uc_fw->status);
-	xe_gt_assert(gt, !uc_fw->path);
-
 	uc_fw_auto_select(xe, uc_fw);
 
 	if (IS_SRIOV_VF(xe)) {
@@ -804,15 +796,13 @@ static int uc_fw_copy(struct xe_uc_fw *uc_fw, const void *data, size_t size, u32
 		goto fail;
 	}
 
+	if (uc_fw->bo)
+		xe_managed_bo_unpin_map_no_vm(uc_fw->bo);
+
 	uc_fw->bo = obj;
 	uc_fw->size = size;
 
 	xe_uc_fw_change_status(uc_fw, XE_UC_FIRMWARE_AVAILABLE);
-
-	err = drmm_add_action_or_reset(&xe->drm, uc_fw_fini, uc_fw);
-	if (err)
-		goto fail;
-
 	return 0;
 
 fail:
@@ -823,7 +813,7 @@ static int uc_fw_copy(struct xe_uc_fw *uc_fw, const void *data, size_t size, u32
 	return err;
 }
 
-int xe_uc_fw_init(struct xe_uc_fw *uc_fw)
+int xe_uc_fw_copy(struct xe_uc_fw *uc_fw)
 {
 	const struct firmware *fw = NULL;
 	int err;
@@ -841,9 +831,20 @@ int xe_uc_fw_init(struct xe_uc_fw *uc_fw)
 			 XE_BO_FLAG_GGTT_INVALIDATE);
 
 	uc_fw_release(fw);
-
 	return err;
 }
+
+int xe_uc_fw_init(struct xe_uc_fw *uc_fw)
+{
+	struct xe_device *xe = uc_fw_to_xe(uc_fw);
+	int err;
+
+	err = xe_uc_fw_copy(uc_fw);
+	if (err)
+		return err;
+
+	return drmm_add_action_or_reset(&xe->drm, xe_uc_fw_fini, uc_fw);
+}
 ALLOW_ERROR_INJECTION(xe_uc_fw_init, ERRNO); /* See xe_pci_probe() */
 
 static u32 uc_fw_ggtt_offset(struct xe_uc_fw *uc_fw)
diff --git a/drivers/gpu/drm/xe/xe_uc_fw.h b/drivers/gpu/drm/xe/xe_uc_fw.h
index 6195e353f269..cbe8ea397efc 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_copy(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


  reply	other threads:[~2026-02-24 10:30 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24 10:25 [PATCH v1 0/6] Introduce Xe PCIe FLR Raag Jadav
2026-02-24 10:25 ` Raag Jadav [this message]
2026-02-24 10:25 ` [PATCH v1 2/6] drm/xe/uc: Introduce FLR helpers Raag Jadav
2026-02-24 10:25 ` [PATCH v1 3/6] drm/xe/irq: Introduce FLR helper Raag Jadav
2026-02-24 10:25 ` [PATCH v1 4/6] drm/xe: Introduce xe_device_assert_lmem_ready() Raag Jadav
2026-02-24 10:25 ` [PATCH v1 5/6] drm/xe/bo_evict: Introduce xe_bo_restore_map() Raag Jadav
2026-02-24 22:11   ` Matthew Brost
2026-02-26 12:13     ` Raag Jadav
2026-02-24 10:25 ` [PATCH v1 6/6] drm/xe/pci: Introduce PCIe FLR Raag Jadav
2026-02-26 16:42   ` Maarten Lankhorst
2026-02-26 16:46     ` Raag Jadav
2026-02-26 16:55       ` Raag Jadav
2026-02-24 10:36 ` ✗ CI.checkpatch: warning for Introduce Xe " Patchwork
2026-02-24 10:38 ` ✓ CI.KUnit: success " Patchwork
2026-02-26 10:28 ` [PATCH v1 0/6] " Jani Nikula
2026-02-26 12:31   ` Raag Jadav
2026-02-26 16:08 ` Matthew Auld
2026-02-26 16:37   ` Raag Jadav
2026-02-26 22:12 ` Matt Roper
2026-02-27  4:18   ` Raag Jadav

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=20260224102618.3105171-2-raag.jadav@intel.com \
    --to=raag.jadav@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --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 \
    /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