Skip to content

Commit 773e297

Browse files
committed
ASoC: SOF: ipc4/Intel: Add support for library restore firmware functionality
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>
1 parent 2b31f5e commit 773e297

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

include/sound/sof/ipc4/header.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,8 @@ struct sof_ipc4_intel_mic_privacy_cap {
502502
#define SOF_IPC4_LOG_CORE_GET(x) (((x) & SOF_IPC4_LOG_CORE_MASK) >> \
503503
SOF_IPC4_LOG_CORE_SHIFT)
504504

505+
#define SOF_IPC4_FW_READY_LIB_RESTORED BIT(15)
506+
505507
/* Value of notification type field - must fit into 8 bits */
506508
enum sof_ipc4_notification_type {
507509
/* Phrase detected (notification from WoV module) */

sound/soc/sof/intel/hda-loader.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,11 @@ int hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev,
579579
struct sof_ipc4_msg msg = {};
580580
int ret, ret1;
581581

582-
/* if IMR booting is enabled and fw context is saved for D3 state, skip the loading */
583-
if (reload && hda->booted_from_imr && ipc4_data->fw_context_save)
582+
/*
583+
* if IMR booting is enabled and libraries have been restored during fw
584+
* boot, skip the loading
585+
*/
586+
if (reload && hda->booted_from_imr && ipc4_data->libraries_restored)
584587
return 0;
585588

586589
/* the fw_lib has been verified during loading, we can trust the validity here */

sound/soc/sof/ipc4-priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ struct sof_ipc4_fw_library {
7373
* @max_libs_count: Maximum number of libraries support by the FW including the
7474
* base firmware
7575
* @fw_context_save: Firmware supports full context save and restore
76+
* @libraries_restored: The libraries have been retained during firmware boot
7677
*
7778
* @load_library: Callback function for platform dependent library loading
7879
* @pipeline_state_mutex: Mutex to protect pipeline triggers, ref counts, states and deletion
@@ -88,6 +89,7 @@ struct sof_ipc4_fw_data {
8889
int max_num_pipelines;
8990
u32 max_libs_count;
9091
bool fw_context_save;
92+
bool libraries_restored;
9193

9294
int (*load_library)(struct snd_sof_dev *sdev,
9395
struct sof_ipc4_fw_library *fw_lib, bool reload);

sound/soc/sof/ipc4.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,18 @@ EXPORT_SYMBOL(sof_ipc4_find_debug_slot_offset_by_type);
602602
static int ipc4_fw_ready(struct snd_sof_dev *sdev, struct sof_ipc4_msg *ipc4_msg)
603603
{
604604
/* no need to re-check version/ABI for subsequent boots */
605-
if (!sdev->first_boot)
605+
if (!sdev->first_boot) {
606+
struct sof_ipc4_fw_data *ipc4_data = sdev->private;
607+
608+
/*
609+
* The libraries have been restored if full context save is
610+
* enabled or the firmware reports this via the FW_READY
611+
*/
612+
ipc4_data->libraries_restored = ipc4_data->fw_context_save ||
613+
(ipc4_msg->primary & SOF_IPC4_FW_READY_LIB_RESTORED);
614+
606615
return 0;
616+
}
607617

608618
sof_ipc4_create_exception_debugfs_node(sdev);
609619

0 commit comments

Comments
 (0)