]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: SOF: ipc4/Intel: Add support for library restore firmware functionality
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Thu, 19 Jun 2025 10:56:23 +0000 (13:56 +0300)
committerMark Brown <broonie@kernel.org>
Thu, 19 Jun 2025 12:19:35 +0000 (13:19 +0100)
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.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Liam Girdwood <liam.r.girdwood@intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Link: https://patch.msgid.link/20250619105623.4546-3-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/sof/ipc4/header.h
sound/soc/sof/intel/hda-loader.c
sound/soc/sof/ipc4-loader.c
sound/soc/sof/ipc4-priv.h
sound/soc/sof/ipc4.c

index f71d04736d176c2530ada8e7a17e49b709712218..e85c7afd85a4d3eb1389f4de434b508b8c3d4ec3 100644 (file)
@@ -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) */
index 49085ca7b46bf01b66bc74b837d0e2a3d305d146..2cc11d8b0f70800cae261973d5dbd64075c8f0f4 100644 (file)
@@ -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 */
index d2f534d65edf166f2317e561dc217bab3f52bbde..ee61394e73d7c3ff9b6b936d0c3a8b12383ce42a 100644 (file)
@@ -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;
index 76dc54a2f07d9fc71dd873bea77c674201571c3c..45e9b78432f7817a63dd26fafa02f3a069472950 100644 (file)
@@ -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);
index 37e837b22ac88c1da6fd6260a3ad78fa77b5ba17..0ba0e8e615ae74d21669bff10f6592c3a64756be 100644 (file)
@@ -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);