Skip to content

Commit fc391aa

Browse files
committed
ASoC: SOF: Add a new fw loader op to reload_module libraries
Add a new op to struct sof_ipc_fw_loader_ops, reload_libraries, to support reloading the libraries. For HDA platforms, this is called during the post_fw_run op after the base FW is cold booted with the exception of the first boot. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent b0aae2b commit fc391aa

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,6 @@ int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev)
538538
ret = hda_cl_copy_fw(sdev, hext_stream);
539539
if (!ret) {
540540
dev_dbg(sdev->dev, "Firmware download successful, booting...\n");
541-
hda->skip_imr_boot = false;
542541
} else {
543542
snd_sof_dsp_dbg_dump(sdev, "Firmware download failed",
544543
SOF_DBG_DUMP_PCI | SOF_DBG_DUMP_MBOX);
@@ -584,6 +583,7 @@ int hda_dsp_pre_fw_run(struct snd_sof_dev *sdev)
584583
/* post fw run operations */
585584
int hda_dsp_post_fw_run(struct snd_sof_dev *sdev)
586585
{
586+
struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata;
587587
int ret;
588588

589589
if (sdev->first_boot) {
@@ -601,8 +601,17 @@ int hda_dsp_post_fw_run(struct snd_sof_dev *sdev)
601601
(sdev->fw_ready.flags & SOF_IPC_INFO_D3_PERSISTENT ||
602602
sdev->pdata->ipc_type == SOF_INTEL_IPC4))
603603
hdev->imrboot_supported = true;
604+
} else {
605+
/* reload all 3rd party module libraries during cold boot */
606+
if (!hda->imrboot_supported || hda->skip_imr_boot) {
607+
ret = sdev->ipc->ops->fw_loader->reload_libraries(sdev);
608+
if (ret < 0)
609+
return ret;
610+
}
604611
}
605612

613+
hda->skip_imr_boot = false;
614+
606615
hda_sdw_int_enable(sdev, true);
607616

608617
/* re-enable clock gating and power gating */

sound/soc/sof/ipc4-loader.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,39 @@ static int sof_ipc4_load_library(struct snd_sof_dev *sdev, struct snd_sof_widget
352352
return ret;
353353
}
354354

355+
static int sof_ipc4_reload_libraries(struct snd_sof_dev *sdev)
356+
{
357+
struct sof_ipc4_fw_data *ipc4_data = sdev->private;
358+
int i, ret;
359+
360+
if (sof_ops(sdev)->load_library) {
361+
dev_err(sdev->dev, "Loading module libraries not supported\n");
362+
return -EINVAL;
363+
}
364+
365+
/* Index 0 is reserved for base firmware */
366+
for (i = 1; i < ipc4_data->max_fw_libs; i++) {
367+
if (!ipc4_data->module_lib_info[i].id)
368+
break;
369+
370+
ret = sof_ops(sdev)->load_library(sdev, &ipc4_data->module_lib_info[i]);
371+
if (ret < 0) {
372+
dev_err(sdev->dev, "Failed loading module FW library: %s\n",
373+
ipc4_data->module_lib_info[i].name);
374+
return ret;
375+
}
376+
377+
dev_dbg(sdev->dev, "Loaded FW library for module: %s\n",
378+
ipc4_data->module_lib_info[i].name);
379+
}
380+
381+
return 0;
382+
}
383+
355384
const struct sof_ipc_fw_loader_ops ipc4_loader_ops = {
356385
.validate = sof_ipc4_validate_firmware,
357386
.parse_ext_manifest = sof_ipc4_fw_parse_ext_man,
358387
.query_fw_configuration = sof_ipc4_query_fw_configuration,
359388
.load_library = sof_ipc4_load_library,
389+
.reload_libraries = sof_ipc4_reload_libraries,
360390
};

sound/soc/sof/sof-priv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ struct snd_sof_widget;
427427
* configuration from the booted firmware.
428428
* Executed after the first successful firmware boot.
429429
* @load_library: Optional function pointer to load a 3rd party module library
430+
* @reload_libraries: Optional function pointer to reload all needed 3rd party module libraries
430431
*/
431432
struct sof_ipc_fw_loader_ops {
432433
int (*validate)(struct snd_sof_dev *sdev);
@@ -435,6 +436,7 @@ struct sof_ipc_fw_loader_ops {
435436
int (*load_fw_to_dsp)(struct snd_sof_dev *sdev);
436437
int (*query_fw_configuration)(struct snd_sof_dev *sdev);
437438
int (*load_library)(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
439+
int (*reload_libraries)(struct snd_sof_dev *sdev);
438440
};
439441

440442
struct sof_ipc_tplg_ops;

0 commit comments

Comments
 (0)