Skip to content
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

Check fw boot flags to load library #4643

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/sound/sof/info.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define SOF_IPC_INFO_LOCKSV BIT(2)
#define SOF_IPC_INFO_GDB BIT(3)
#define SOF_IPC_INFO_D3_PERSISTENT BIT(4)
#define SOF_IPC_INFO_CONTEXT_SAVE BIT(5)

/* extended data types that can be appended onto end of sof_ipc_fw_ready */
enum sof_ipc_ext_data {
Expand Down
4 changes: 2 additions & 2 deletions sound/soc/sof/intel/hda-loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,8 @@ int hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev,
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)
/* if IMR booting and D3 context save are supported, skip the loading */
if (reload && hda->booted_from_imr && sdev->fw_ready.flags & SOF_IPC_INFO_CONTEXT_SAVE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is going to fail with reference firmware. FW_READY in IPC4 does not contain payload, thus the "fw_ready" is going to be all 0, the flag is 0 but the reference fw does have context save and the library re-load will fail since we are trying to load already loaded library.

Or do I miss something?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so what 's your advice ? I don't want to add more config in get_fw config which is also not compatible with reference fw.

return 0;

/* the fw_lib has been verified during loading, we can trust the validity here */
Expand Down
9 changes: 9 additions & 0 deletions sound/soc/sof/ipc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,8 @@ 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)
{
int inbox_offset, inbox_size, outbox_offset, outbox_size;
struct sof_ipc_fw_ready *fw_ready = &sdev->fw_ready;
int ret;

/* no need to re-check version/ABI for subsequent boots */
if (!sdev->first_boot)
Expand All @@ -599,6 +601,13 @@ static int ipc4_fw_ready(struct snd_sof_dev *sdev, struct sof_ipc4_msg *ipc4_msg
sdev->debug_box.offset = snd_sof_dsp_get_window_offset(sdev,
SOF_IPC4_DEBUG_WINDOW_IDX);

ret = snd_sof_dsp_block_read(sdev, SOF_FW_BLK_TYPE_SRAM, inbox_offset, fw_ready,
sizeof(*fw_ready));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

struct sof_ipc_fw_ready is the IPC3 fw_ready message. IPC4 does not define payload for FW_READY notification.
Reference fw definitely not giving any payload. The way to get the configuration and parameters is via GET_LARGE_CONFIG:FW_CONFIG, but that does not have a tuple defined for context save support as it is always supported in the reference fw along with IMR boot.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ujfalusi why do we need to worry about the reference firmware in the context of library loading? Is this something we will ever test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only lose compatibility with a reference when all possible alternatives have been exhausted...

if (ret) {
dev_err(sdev->dev, "Unable to read fw_ready, read from TYPE_SRAM failed\n");
return ret;
}

sof_ipc4_create_exception_debugfs_node(sdev);

dev_dbg(sdev->dev, "mailbox upstream 0x%x - size 0x%x\n",
Expand Down