Uh oh!
There was an error while loading. Please reload this page.
forked from torvalds/linux
- Notifications
You must be signed in to change notification settings - Fork 150
ASoC: SOF: ipc4/Intel: Support for loading external libraries#3826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
plbossart
merged 19 commits into
thesofproject:topic/sof-dev
from
ujfalusi:peter/sof/pr/ipc4_external_lib_support_v1Sep 19, 2022
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0f23919
ASoC: SOF: loader: Set complete state before post_fw_run op
ranj063 127aa3c
ASoC: SOF: Introduce container struct for SOF firmware
ujfalusi 74324a7
ASoC: SOF: amd: Use the basefw firmware container directly
ujfalusi 3a7fd4b
ASoC: SOF: Intel: hda-loader: Use the basefw firmware container directly
ujfalusi a1e313a
ASoC: SOF: Intel: hda-loader-skl: Use the basefw firmware container d…
ujfalusi 7e69eec
ASoC: SOF: Drop the firmware and fw_offset from snd_sof_pdata
ujfalusi 178afa6
ASoC: SOF: ipc: ops: Add support for optional init and exit callbacks
ujfalusi dfa03d6
ASoC: SOF: ipc4-loader: Save the maximum number of libraries supported
ujfalusi 1946837
ASoC: SOF: ipc4: Convert the firmware handling (loader) to library co…
ujfalusi 323bbed
ASoC: SOF: IPC4: Add helper for looking up module by UUID
ujfalusi 8892d18
ASoC: SOF: Add path definition for external firmware libraries
ujfalusi ff9aedc
ASoC: SOF: Intel: Set the default firmware library path for IPC4
ujfalusi 571f447
ASoC: SOF: ipc4: Define platform dependent library loading callback
ujfalusi 3825848
ASoC: SOF: Intel: hda: Add flag to indicate that the firmware is IMR …
ujfalusi 37e2ab0
ASoC: SOF: Intel: Add ipc4 library loading implementation
ujfalusi b193fb2
ASoC: SOF: loader: Add support for IPC dependent post firmware boot ops
ujfalusi 4966d36
ASoC: SOF: ipc4: Stop using the query_fw_configuration fw_loader ops
ujfalusi 2a5ce69
ASoC: SOF: loader: Remove the query_fw_configuration ops
ujfalusi 210555c
ASoC: SOF: ipc4-loader: Support for loading external libraries
ujfalusi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -19,7 +19,9 @@ | ||
| #include <sound/hdaudio_ext.h> | ||
| #include <sound/hda_register.h> | ||
| #include <sound/sof.h> | ||
| #include <sound/sof/ipc4/header.h> | ||
| #include "ext_manifest.h" | ||
| #include "../ipc4-priv.h" | ||
| #include "../ops.h" | ||
| #include "../sof-priv.h" | ||
| #include "hda.h" | ||
| @@ -318,7 +320,6 @@ int hda_cl_copy_fw(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_stream | ||
| int hda_dsp_cl_boot_firmware_iccmax(struct snd_sof_dev *sdev) | ||
| { | ||
| struct snd_sof_pdata *plat_data = sdev->pdata; | ||
| struct hdac_ext_stream *iccmax_stream; | ||
| struct hdac_bus *bus = sof_to_bus(sdev); | ||
| struct firmware stripped_firmware; | ||
| @@ -329,12 +330,12 @@ int hda_dsp_cl_boot_firmware_iccmax(struct snd_sof_dev *sdev) | ||
| /* save the original LTRP guardband value */ | ||
| original_gb = snd_hdac_chip_readb(bus, VS_LTRP) & HDA_VS_INTEL_LTRP_GB_MASK; | ||
| if (plat_data->fw->size <= plat_data->fw_offset) { | ||
| if (sdev->basefw.fw->size <= sdev->basefw.payload_offset) { | ||
| dev_err(sdev->dev, "error: firmware size must be greater than firmware offset\n"); | ||
| return -EINVAL; | ||
| } | ||
| stripped_firmware.size = plat_data->fw->size - plat_data->fw_offset; | ||
| stripped_firmware.size = sdev->basefw.fw->size - sdev->basefw.payload_offset; | ||
| /* prepare capture stream for ICCMAX */ | ||
| iccmax_stream = hda_cl_stream_prepare(sdev, HDA_CL_STREAM_FORMAT, stripped_firmware.size, | ||
| @@ -397,21 +398,25 @@ int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev) | ||
| dev_dbg(sdev->dev, "IMR restore supported, booting from IMR directly\n"); | ||
| hda->boot_iteration = 0; | ||
| ret = hda_dsp_boot_imr(sdev); | ||
| if (!ret) | ||
| if (!ret) { | ||
| hda->booted_from_imr = true; | ||
| return 0; | ||
| } | ||
| dev_warn(sdev->dev, "IMR restore failed, trying to cold boot\n"); | ||
| } | ||
| hda->booted_from_imr = false; | ||
| chip_info = desc->chip_info; | ||
| if (plat_data->fw->size <= plat_data->fw_offset) { | ||
| if (sdev->basefw.fw->size <= sdev->basefw.payload_offset) { | ||
| dev_err(sdev->dev, "error: firmware size must be greater than firmware offset\n"); | ||
| return -EINVAL; | ||
| } | ||
| stripped_firmware.data = plat_data->fw->data + plat_data->fw_offset; | ||
| stripped_firmware.size = plat_data->fw->size - plat_data->fw_offset; | ||
| stripped_firmware.data = sdev->basefw.fw->data + sdev->basefw.payload_offset; | ||
| stripped_firmware.size = sdev->basefw.fw->size - sdev->basefw.payload_offset; | ||
| /* init for booting wait */ | ||
| init_waitqueue_head(&sdev->boot_wait); | ||
| @@ -515,6 +520,70 @@ int hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev) | ||
| return ret; | ||
| } | ||
| int hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev, | ||
| struct sof_ipc4_fw_library *fw_lib, bool reload) | ||
| { | ||
| struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; | ||
| struct hdac_ext_stream *hext_stream; | ||
| struct firmware stripped_firmware; | ||
| struct sof_ipc4_msg msg = {}; | ||
| struct snd_dma_buffer dmab; | ||
| int ret, ret1; | ||
| /* IMR booting will restore the libraries as well, skip the loading */ | ||
| if (reload && hda->booted_from_imr) | ||
RanderWang marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| return 0; | ||
| /* the fw_lib has been verified during loading, we can trust the validity here */ | ||
| stripped_firmware.data = fw_lib->sof_fw.fw->data + fw_lib->sof_fw.payload_offset; | ||
| stripped_firmware.size = fw_lib->sof_fw.fw->size - fw_lib->sof_fw.payload_offset; | ||
| /* prepare DMA for code loader stream */ | ||
| hext_stream = hda_cl_stream_prepare(sdev, HDA_CL_STREAM_FORMAT, | ||
| stripped_firmware.size, | ||
| &dmab, SNDRV_PCM_STREAM_PLAYBACK); | ||
| if (IS_ERR(hext_stream)) { | ||
| dev_err(sdev->dev, "%s: DMA prepare failed\n", __func__); | ||
| return PTR_ERR(hext_stream); | ||
| } | ||
| memcpy(dmab.area, stripped_firmware.data, stripped_firmware.size); | ||
| msg.primary = hext_stream->hstream.stream_tag - 1; | ||
| msg.primary |= SOF_IPC4_MSG_TYPE_SET(SOF_IPC4_GLB_LOAD_LIBRARY); | ||
| msg.primary |= SOF_IPC4_MSG_DIR(SOF_IPC4_MSG_REQUEST); | ||
| msg.primary |= SOF_IPC4_MSG_TARGET(SOF_IPC4_FW_GEN_MSG); | ||
| msg.primary |= SOF_IPC4_GLB_LOAD_LIBRARY_LIB_ID(fw_lib->id); | ||
| ret = cl_trigger(sdev, hext_stream, SNDRV_PCM_TRIGGER_START); | ||
| if (ret < 0) { | ||
| dev_err(sdev->dev, "%s: DMA trigger start failed\n", __func__); | ||
| goto cleanup; | ||
| } | ||
| ret = sof_ipc_tx_message(sdev->ipc, &msg, 0, NULL, 0); | ||
| ret1 = cl_trigger(sdev, hext_stream, SNDRV_PCM_TRIGGER_STOP); | ||
| if (ret1 < 0) { | ||
| dev_err(sdev->dev, "%s: DMA trigger stop failed\n", __func__); | ||
| if (!ret) | ||
| ret = ret1; | ||
| } | ||
| cleanup: | ||
| /* clean up even in case of error and return the first error */ | ||
| ret1 = hda_cl_cleanup(sdev, &dmab, hext_stream); | ||
| if (ret1 < 0) { | ||
| dev_err(sdev->dev, "%s: Code loader DSP cleanup failed\n", __func__); | ||
| /* set return value to indicate cleanup failure */ | ||
| if (!ret) | ||
| ret = ret1; | ||
| } | ||
| return ret; | ||
| } | ||
| /* pre fw run operations */ | ||
| int hda_dsp_pre_fw_run(struct snd_sof_dev *sdev) | ||
| { | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -481,6 +481,7 @@ enum sof_hda_D0_substate { | ||
| struct sof_intel_hda_dev { | ||
| bool imrboot_supported; | ||
| bool skip_imr_boot; | ||
| bool booted_from_imr; | ||
| int boot_iteration; | ||
| @@ -857,4 +858,7 @@ int hda_dsp_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg) | ||
| void hda_ipc4_dump(struct snd_sof_dev *sdev); | ||
| extern struct sdw_intel_ops sdw_callback; | ||
| struct sof_ipc4_fw_library; | ||
RanderWang marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| int hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev, | ||
| struct sof_ipc4_fw_library *fw_lib, bool reload); | ||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.