All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
To: Raag Jadav <raag.jadav@intel.com>, <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>, <badal.nilawar@intel.com>
Subject: Re: [PATCH v8 01/10] drm/xe/uc_fw: Allow re-initializing firmware
Date: Thu, 25 Jun 2026 16:40:21 -0700	[thread overview]
Message-ID: <c24f22fd-86a6-4217-8ad5-cf5223589e08@intel.com> (raw)
In-Reply-To: <20260603101814.916948-2-raag.jadav@intel.com>



On 6/3/2026 3:17 AM, Raag Jadav wrote:
> 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);


  reply	other threads:[~2026-06-25 23:40 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03 10:17 [PATCH v8 00/10] Introduce Xe PCIe FLR Raag Jadav
2026-06-03 10:17 ` [PATCH v8 01/10] drm/xe/uc_fw: Allow re-initializing firmware Raag Jadav
2026-06-25 23:40   ` Daniele Ceraolo Spurio [this message]
2026-06-03 10:17 ` [PATCH v8 02/10] drm/xe/guc_submit: Introduce guc_exec_queue_reinit_kernel() Raag Jadav
2026-06-25 23:46   ` Daniele Ceraolo Spurio
2026-06-03 10:17 ` [PATCH v8 03/10] drm/xe/gt: Introduce FLR helpers Raag Jadav
2026-06-03 10:17 ` [PATCH v8 04/10] drm/xe/bo_evict: Introduce xe_bo_restore_map() Raag Jadav
2026-07-01  5:21   ` Gupta, Varun
2026-06-03 10:17 ` [PATCH v8 05/10] drm/xe/exec_queue: Introduce xe_exec_queue_reinit() Raag Jadav
2026-06-26  0:06   ` Daniele Ceraolo Spurio
2026-06-29 12:23     ` Raag Jadav
2026-06-03 10:17 ` [PATCH v8 06/10] drm/xe/migrate: Introduce xe_migrate_reinit() Raag Jadav
2026-06-03 10:17 ` [PATCH v8 07/10] drm/xe/pm: Introduce xe_device_suspend/resume() Raag Jadav
2026-06-03 10:58   ` Rodrigo Vivi
2026-06-03 10:17 ` [PATCH v8 08/10] drm/xe: Improve wedged state management Raag Jadav
2026-06-03 10:56   ` Rodrigo Vivi
2026-06-04  6:52     ` Tauro, Riana
2026-06-04  8:39       ` Raag Jadav
2026-06-17  5:58         ` Tauro, Riana
2026-06-17  6:11           ` Matthew Brost
2026-06-03 10:17 ` [PATCH v8 09/10] drm/xe/pci: Introduce PCIe FLR Raag Jadav
2026-06-03 10:40   ` Rodrigo Vivi
2026-06-03 10:17 ` [PATCH v8 10/10] drm/xe/doc: Wire up PCI Error Handling Raag Jadav
2026-06-03 10:28 ` ✗ CI.checkpatch: warning for Introduce Xe PCIe FLR (rev8) Patchwork
2026-06-03 10:29 ` ✓ CI.KUnit: success " Patchwork
2026-06-03 11:11 ` ✓ Xe.CI.BAT: " Patchwork
2026-06-03 22:55 ` ✓ 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=c24f22fd-86a6-4217-8ad5-cf5223589e08@intel.com \
    --to=daniele.ceraolospurio@intel.com \
    --cc=badal.nilawar@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=raag.jadav@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.