Skip to contentSkip to conversation

ASoC: SOF: ipc4/Intel: Support for partial context restore

PATCH In review Peter Ujfalusi 2 participants 4 messages Jun 19, 2025 – Jun 20, 2025

Subsystems (3)
lore
Share & tools
lore

Peter Ujfalusi

author maintainer
#0 lore raw

cover ASoC: SOF: ipc4/Intel: Support for partial context restore

Hi,

The firmware will be able to only save and restore the context related to library management.
This means that even without a full context save, the libraries do not need to be re-loaded to the firmware after second or consecutive boots.

This is reported via the FW_READY notification, where BIT(15) indicates:
0 - the library restore is not done
1 - library restore is done

This bit is only valid if full context save is not enabled, full context save is by definition saves and restores the library related book-keeping as well.

Add a new flag to tell the platform code if the libraries have been restored, no need to reload them after boot.

Regards,
Peter
---
Peter Ujfalusi (2):
ASoC: SOF: ipc4-priv: Add kernel doc for fw_context_save of
sof_ipc4_fw_data
ASoC: SOF: ipc4/Intel: Add support for library restore firmware
functionality

 include/sound/sof/ipc4/header.h  |  2 ++
 sound/soc/sof/intel/hda-loader.c |  7 +++++--
 sound/soc/sof/ipc4-loader.c      |  6 ++++++
 sound/soc/sof/ipc4-priv.h        |  3 +++
 sound/soc/sof/ipc4.c             | 14 ++++++++++++--
 5 files changed, 28 insertions(+), 4 deletions(-)
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH 1/2 ASoC: SOF: ipc4-priv: Add kernel doc for fw_context_save of sof_ipc4_fw_data

The kernel documentation is missing entry for the fw_context_save.

---
 sound/soc/sof/ipc4-priv.h | 1 +
 1 file changed, 1 insertion(+)
sound/soc/sof/ipc4-priv.h +1 -0
index 58b032820683..76dc54a2f07d 100644
@@ -72,6 +72,7 @@ struct sof_ipc4_fw_library {
  * @max_num_pipelines: max number of pipelines
  * @max_libs_count: Maximum number of libraries support by the FW including the
  *		    base firmware
+ * @fw_context_save: Firmware supports full context save and restore
  *
  * @load_library: Callback function for platform dependent library loading
  * @pipeline_state_mutex: Mutex to protect pipeline triggers, ref counts, states and deletion
Signature · 1 line
2.49.0
author maintainer
#2 lore raw

PATCH 2/2 ASoC: SOF: ipc4/Intel: Add support for library restore firmware functionality

In reply to Peter Ujfalusi

The firmware will be able to only save and restore the context related to library management.
This means that even without a full context save, the libraries do not need to be re-loaded to the firmware after second or consecutive boots.

This is reported via the FW_READY notification, where BIT(15) indicates:
0 - the library restore is not done
1 - library restore is done

This bit is only valid if full context save is not enabled, full context save is by definition saves and restores the library related book-keeping as well.

Add a new flag to tell the platform code if the libraries have been restored, no need to reload them after boot.

---
 include/sound/sof/ipc4/header.h  |  2 ++
 sound/soc/sof/intel/hda-loader.c |  7 +++++--
 sound/soc/sof/ipc4-loader.c      |  6 ++++++
 sound/soc/sof/ipc4-priv.h        |  2 ++
 sound/soc/sof/ipc4.c             | 14 ++++++++++++--
 5 files changed, 27 insertions(+), 4 deletions(-)
include/sound/sof/ipc4/header.h +2 -0
index f71d04736d17..e85c7afd85a4 100644
@@ -498,6 +498,8 @@ struct sof_ipc4_intel_mic_privacy_cap {
 #define SOF_IPC4_LOG_CORE_GET(x)		(((x) & SOF_IPC4_LOG_CORE_MASK) >> \
 						 SOF_IPC4_LOG_CORE_SHIFT)
 
+#define SOF_IPC4_FW_READY_LIB_RESTORED		BIT(15)
+
 /* Value of notification type field - must fit into 8 bits */
 enum sof_ipc4_notification_type {
 	/* Phrase detected (notification from WoV module) */
sound/soc/sof/intel/hda-loader.c +5 -2
index 49085ca7b46b..2cc11d8b0f70 100644
@@ -579,8 +579,11 @@ int hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev,
 	struct sof_ipc4_msg msg = {};
 	int ret, ret1;
 
-	/* if IMR booting is enabled and fw context is saved for D3 state, skip the loading */
-	if (reload && hda->booted_from_imr && ipc4_data->fw_context_save)
+	/*
+	 * if IMR booting is enabled and libraries have been restored during fw
+	 * boot, skip the loading
+	 */
+	if (reload && hda->booted_from_imr && ipc4_data->libraries_restored)
 		return 0;
 
 	/* the fw_lib has been verified during loading, we can trust the validity here */
sound/soc/sof/ipc4-loader.c +6 -0
index d2f534d65edf..ee61394e73d7 100644
@@ -494,6 +494,12 @@ int sof_ipc4_query_fw_configuration(struct snd_sof_dev *sdev)
 			break;
 		case SOF_IPC4_FW_CONTEXT_SAVE:
 			ipc4_data->fw_context_save = *tuple->value;
+			/*
+			 * Set the default libraries_restored value - if full
+			 * context save is supported then it means that
+			 * libraries are restored
+			 */
+			ipc4_data->libraries_restored = ipc4_data->fw_context_save;
 			break;
 		default:
 			break;
sound/soc/sof/ipc4-priv.h +2 -0
index 76dc54a2f07d..45e9b78432f7 100644
@@ -73,6 +73,7 @@ struct sof_ipc4_fw_library {
  * @max_libs_count: Maximum number of libraries support by the FW including the
  *		    base firmware
  * @fw_context_save: Firmware supports full context save and restore
+ * @libraries_restored: The libraries have been retained during firmware boot
  *
  * @load_library: Callback function for platform dependent library loading
  * @pipeline_state_mutex: Mutex to protect pipeline triggers, ref counts, states and deletion
@@ -88,6 +89,7 @@ struct sof_ipc4_fw_data {
 	int max_num_pipelines;
 	u32 max_libs_count;
 	bool fw_context_save;
+	bool libraries_restored;
 
 	int (*load_library)(struct snd_sof_dev *sdev,
 			    struct sof_ipc4_fw_library *fw_lib, bool reload);
sound/soc/sof/ipc4.c +12 -2
index 37e837b22ac8..0ba0e8e615ae 100644
@@ -576,9 +576,19 @@ EXPORT_SYMBOL(sof_ipc4_find_debug_slot_offset_by_type);
 
 static int ipc4_fw_ready(struct snd_sof_dev *sdev, struct sof_ipc4_msg *ipc4_msg)
 {
-	/* no need to re-check version/ABI for subsequent boots */
-	if (!sdev->first_boot)
+	if (!sdev->first_boot) {
+		struct sof_ipc4_fw_data *ipc4_data = sdev->private;
+
+		/*
+		 * After the initial boot only check if the libraries have been
+		 * restored when full context save is not enabled
+		 */
+		if (!ipc4_data->fw_context_save)
+			ipc4_data->libraries_restored = !!(ipc4_msg->primary &
+							   SOF_IPC4_FW_READY_LIB_RESTORED);
+
 		return 0;
+	}
 
 	sof_ipc4_create_exception_debugfs_node(sdev);
 
Signature · 1 line
2.49.0
maintainer
#3 lore raw
In reply to Peter Ujfalusi
Quoted 10 lines · Peter Ujfalusi

The firmware will be able to only save and restore the context related to library management.
This means that even without a full context save, the libraries do not need to be re-loaded to the firmware after second or consecutive boots.

This is reported via the FW_READY notification, where BIT(15) indicates:
0 - the library restore is not done
1 - library restore is done

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/2] ASoC: SOF: ipc4-priv: Add kernel doc for fw_context_save of sof_ipc4_fw_data

      commit: cec49fa47bccadb288fd984ef2a5c45e8a2e2099
[2/2] ASoC: SOF: ipc4/Intel: Add support for library restore firmware functionality
      commit: ace9b3daf2b4778358573d3698e34cb1c0fa7e14

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark