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

Audio: basefw: Implement ipc4 modules info get #9032

Merged
merged 2 commits into from
May 2, 2024

Conversation

gbernatxintel
Copy link
Contributor

@gbernatxintel gbernatxintel commented Apr 11, 2024

Add support to handle IPC4_MODULES_INFO_GET message.
This make it possible to get information about the current loaded modules.

@@ -497,6 +520,7 @@ static int basefw_get_large_config(struct comp_dev *dev,
case IPC4_DSP_RESOURCE_STATE:
case IPC4_NOTIFICATION_MASK:
case IPC4_MODULES_INFO_GET:
return basefw_modules_info_get(data_offset, data);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this handler will also handle IPC4_DSP_RESOURCE_STATE and IPC4_NOTIFICATION_MASK?

struct sof_man_module *module_entry =
(struct sof_man_module *)((char *)desc + SOF_MAN_MODULE_OFFSET(idx));
memcpy(&(module_info->modules[idx]), module_entry, sizeof(struct sof_man_module));
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

indentation


module_info->modules_count = desc->header.num_module_entries;

for(int idx = 0; idx < module_info->modules_count; ++idx){
Copy link
Collaborator

Choose a reason for hiding this comment

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

space before {

for(int idx = 0; idx < module_info->modules_count; ++idx){
struct sof_man_module *module_entry =
(struct sof_man_module *)((char *)desc + SOF_MAN_MODULE_OFFSET(idx));
memcpy(&(module_info->modules[idx]), module_entry, sizeof(struct sof_man_module));
Copy link
Collaborator

Choose a reason for hiding this comment

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

sizeof(module_info->modules[idx]) as the last parameter

memcpy(&(module_info->modules[idx]), module_entry, sizeof(struct sof_man_module));
}

*data_offset = sizeof(uint32_t) + module_info->modules_count * sizeof(struct sof_man_module);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd do sizeof(module_info->modules_count) + module_info->modules_count * sizeof(module_info->modules[0]) - makes it clearer what is calculated IMHO

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Some review comments inline.

{
struct ipc4_modules_info *const module_info = (struct ipc4_modules_info *)data;

struct sof_man_fw_desc *desc = (struct sof_man_fw_desc *)IMR_BOOT_LDR_MANIFEST_BASE;
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 a bit platform specific. The work to add a platform layer for IPC4 basefw is still in progress, but at a minimum, I think you need to ifdef this with "#ifdef RIMAGE_MANIFEST" like done in ipc4/helper.c.

@@ -329,7 +329,7 @@ struct ipc_cmd_hdr;
#define SOF_IPC_MESSAGE_ID(x) ((x) & 0xffff)

/** Maximum message size for mailbox Tx/Rx */
#define SOF_IPC_MSG_MAX_SIZE 384
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this needs a separate commit and rationale for the increase. This affects all IPC3 implementations as well and increases memory use as this is directly used to allocate memory (which so far has been 384 bytes).

Or is this something only for IPC4. Then tihs could be changed only if built for IPC4.

Copy link
Member

Choose a reason for hiding this comment

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

@gbernatxintel We can play safe here. e.g.

#if IPC4
#define SIZE 0x1000
#else
#define SIZE 384
#endif

Copy link
Member

Choose a reason for hiding this comment

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

IPC fuzz failed only for IPC3 so please try this @gbernatxintel

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ujfalusi @plbossart This SOF_IPC_MSG_MAX_SIZE is only used in IPC3 code, so if this change is ifdeffed like this, I don't think we need to bump the ABI ver

Copy link
Contributor

Choose a reason for hiding this comment

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

@kv2019i, the kernel uses different defines for the message size (in mailbox):
include/sound/sof/header.h:#define SOF_IPC_MSG_MAX_SIZE 384
include/sound/sof/ipc4/header.h:#define SOF_IPC4_MSG_MAX_SIZE 4096

sound/soc/sof/ipc3.c: sdev->ipc->max_payload_size = SOF_IPC_MSG_MAX_SIZE;
sound/soc/sof/ipc4.c: sdev->ipc->max_payload_size = SOF_IPC4_MSG_MAX_SIZE;

@gbernatxintel gbernatxintel marked this pull request as draft April 16, 2024 08:04
@gbernatxintel gbernatxintel force-pushed the gb_modules_info_get branch 7 times, most recently from 4744f21 to 7f3f141 Compare April 17, 2024 10:38
@gbernatxintel gbernatxintel marked this pull request as ready for review April 18, 2024 07:44
@gbernatxintel gbernatxintel requested a review from a team as a code owner April 18, 2024 07:44
@@ -329,8 +329,11 @@ struct ipc_cmd_hdr;
#define SOF_IPC_MESSAGE_ID(x) ((x) & 0xffff)

/** Maximum message size for mailbox Tx/Rx */
#if IPC4
Copy link
Member

Choose a reason for hiding this comment

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

Can you check the Kconfig symbol for IPC4, it should be something like CONFIG_IPC4

Copy link
Contributor

Choose a reason for hiding this comment

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

@gbernatxintel use #ifdef CONFIG_IPC_MAJOR_4

@@ -17,6 +17,10 @@
#ifndef __SOF_IPC4_BASE_FW_H__
#define __SOF_IPC4_BASE_FW_H__

#ifdef CONFIG_INTEL
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this a new Kconfig as manifest data is useful and generic that could be used by anyone. e.g. KCONFIG_IPC4_MANIFEST_MODULES we can have other ipc4 manifest kconfisg too as I would imagine a lot of vendors would like to export data.

@gbernatxintel gbernatxintel marked this pull request as draft April 18, 2024 09:34
@gbernatxintel gbernatxintel force-pushed the gb_modules_info_get branch 6 times, most recently from 1111c34 to a710f66 Compare April 24, 2024 09:19
@gbernatxintel
Copy link
Contributor Author

Update
Moved module_info_get functions to platform specs file, as there were problems with ipc fuzz testing. In general, the problem was that I use a structure that is defined in rimage/manifest.h. This file occurs on the intel platform, so to avoid the use of ifdef the whole thing was moved to the platform file.

@marc-hb Could you take a look at CI, is there a compilation problem?

@gbernatxintel gbernatxintel marked this pull request as ready for review April 24, 2024 09:26
Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

#9060 was merged, so you'll need to rebase this.

@@ -329,7 +329,7 @@ struct ipc_cmd_hdr;
#define SOF_IPC_MESSAGE_ID(x) ((x) & 0xffff)

/** Maximum message size for mailbox Tx/Rx */
#define SOF_IPC_MSG_MAX_SIZE 384
Copy link
Collaborator

Choose a reason for hiding this comment

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

@ujfalusi @plbossart This SOF_IPC_MSG_MAX_SIZE is only used in IPC3 code, so if this change is ifdeffed like this, I don't think we need to bump the ABI ver

@@ -29,7 +29,7 @@

/** \brief SOF ABI version major, minor and patch numbers */
#define SOF_ABI_MAJOR 3
#define SOF_ABI_MINOR 29
#define SOF_ABI_MINOR 30
Copy link
Collaborator

Choose a reason for hiding this comment

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

So this is not needed as this ABI versioning applies to IPC3 builds.

We still don't have infra to describe IPC4 infra. As this has been pending for long, let me file a ticket -> #9080

@marc-hb
Copy link
Collaborator

marc-hb commented Apr 24, 2024

@marc-hb Could you take a look at CI, is there a compilation problem?

Next time please share the link and error message, more specifically:

https://github.com/thesofproject/sof/actions/runs/8814185894/job/24193491363?pr=9032

E: Failed to fetch https://packages.microsoft.com/ubuntu/22.04/prod/dists/jammy/InRelease Clearsigned file isn't valid, got 'NOSPLIT' (does the network require authentication?)

It's either very hard or impossible (depending on which check) to find results again after a force-push.

Back to the actual issue: yes this looks like a Github glitch. Since you need to resolve git conflicts anyway, it will hopefully be fixed next time.

BTW: https://www.githubstatus.com/

@@ -461,7 +466,9 @@ static int basefw_get_large_config(struct comp_dev *dev,
/* TODO: add more support */
case IPC4_DSP_RESOURCE_STATE:
case IPC4_NOTIFICATION_MASK:
break;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this not even printing a warning?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You seem to be splitting the "TODO", unimplemented section in the middle. This means the second part is losing its "TODO" comment and silently doing nothing with zero comment and zero warning. So now it looks even less intentional and even more like a bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

move out the IPC4_MODULES_INFO_GET case from the TODO list.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, currently all implemented cases are before the TODO comment

@@ -329,7 +329,7 @@ struct ipc_cmd_hdr;
#define SOF_IPC_MESSAGE_ID(x) ((x) & 0xffff)

/** Maximum message size for mailbox Tx/Rx */
#define SOF_IPC_MSG_MAX_SIZE 384
Copy link
Contributor

Choose a reason for hiding this comment

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

@kv2019i, the kernel uses different defines for the message size (in mailbox):
include/sound/sof/header.h:#define SOF_IPC_MSG_MAX_SIZE 384
include/sound/sof/ipc4/header.h:#define SOF_IPC4_MSG_MAX_SIZE 4096

sound/soc/sof/ipc3.c: sdev->ipc->max_payload_size = SOF_IPC_MSG_MAX_SIZE;
sound/soc/sof/ipc4.c: sdev->ipc->max_payload_size = SOF_IPC4_MSG_MAX_SIZE;

@@ -461,7 +466,9 @@ static int basefw_get_large_config(struct comp_dev *dev,
/* TODO: add more support */
case IPC4_DSP_RESOURCE_STATE:
case IPC4_NOTIFICATION_MASK:
break;
Copy link
Contributor

Choose a reason for hiding this comment

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

move out the IPC4_MODULES_INFO_GET case from the TODO list.

@@ -461,7 +466,9 @@ static int basefw_get_large_config(struct comp_dev *dev,
/* TODO: add more support */
case IPC4_DSP_RESOURCE_STATE:
case IPC4_NOTIFICATION_MASK:
break;
case IPC4_MODULES_INFO_GET:
Copy link
Contributor

Choose a reason for hiding this comment

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

The commit message can use some update.
"Added support for ipc4 query no 9."
->
"Add support to handle IPC4_MODULES_INFO_GET message."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -334,6 +334,11 @@ static int basefw_libraries_info_get(uint32_t *data_offset, char *data)
return 0;
}

static int basefw_modules_info_get(uint32_t *data_offset, char *data)
{
return platform_basefw_modules_info_get(data_offset, data);
Copy link
Contributor

Choose a reason for hiding this comment

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

why it is offloaded to platform function?
What is the difference between the module info and library info (basefw_libraries_info_get()) to demand this handling?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have generally separated the function platform_basefw_modules_info_get(...) instead of implementing everything in base_fw.c because I use the ipc4_modules_info structure which uses sof_man_module.
sof_man_module is defined in rimage/manifest.h

I had a problem with the tests because on non-Intel platforms there is no manifest.h file and the tests did not pass. Besides, this modular approach follows the convention that we create code in base_fw_platform.c

With regard to the differences between basefw_modules_info_get and basefw_libraries_info_get

This basefw_libraries_info_get returns the currently loaded library and other structure.
basefw_modules_info_get returns which modules are loaded and which are not, along with information about them.

In short, both commands return a different data type, different structure. In preparing this PR I looked at previous code and tests that need specific information.

@gbernatxintel gbernatxintel marked this pull request as ready for review April 29, 2024 09:11
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

@kv2019i @lyakh good for you now ?

Copy link
Collaborator

@lyakh lyakh left a comment

Choose a reason for hiding this comment

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

one error to correct

module_entry, sizeof(struct sof_man_module));
}

*data_offset = sizeof(module_info) +
Copy link
Collaborator

Choose a reason for hiding this comment

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

you meant sizeof(*module_info)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, fixed

Maximym ipc4 message size changed to 4kB.
This is the size of a page.

Signed-off-by: Grzegorz Bernat <grzegorzx.bernat@intel.com>
Add support to handle IPC4_MODULES_INFO_GET message.
This make it possible to get information about the current loaded modules.

Signed-off-by: Grzegorz Bernat <grzegorzx.bernat@intel.com>
@lgirdwood
Copy link
Member

@lyakh good now ?

@kv2019i kv2019i merged commit 25423f5 into thesofproject:main May 2, 2024
42 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants