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: Implemented ipc4 libraries info get #9031

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

gbernatxintel
Copy link
Contributor

Added support for ipc4 query no 16.
This makes it possible to get information about the current basefw library.

lyakh
lyakh previously requested changes Apr 12, 2024
src/audio/base_fw.c Show resolved Hide resolved
src/audio/base_fw.c Outdated Show resolved Hide resolved
src/audio/base_fw.c Outdated Show resolved Hide resolved
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.

Will need to additionally pack our ABI

uint16_t build_version;
/* Number of modules packed into the library. */
uint32_t num_module_entries;
} __aligned(4);
Copy link
Member

Choose a reason for hiding this comment

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

will need packed too

@gbernatxintel gbernatxintel force-pushed the gb_branch_1 branch 5 times, most recently from b0a49ff to 3f28d85 Compare April 15, 2024 12:07
@gbernatxintel
Copy link
Contributor Author

SOFCI TEST

libs_info->library_count = 0;

for (int lib_id = 0; lib_id < LIB_MANAGER_MAX_LIBS; ++lib_id) {
#ifdef ZEPHYR_SOC_INTEL_ADSP_MEMORY_H_
Copy link
Collaborator

Choose a reason for hiding this comment

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

This condition is surprising. What is it supposed to check, apart from a header file is included?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is exactly what he is supposed to check. Generally it is that in uses the definition which is platform specific. The idea is to check if there is this definition which is in the code. Do you think it's better to replace it with 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.

@kv2019i and I were discussing a src/ipc/ipc4/intel.c where we could put a lot of the vendor specific code and wrap it with Kconfigs, have it read values from Zephyr DT later too.

It would seem we could use that here too and rather than using the #ifdef ZEPHYR_SOC_INTEL_ADSP_MEMORY_H_ we use a Kconfig CONFIG_SOME_INTEL_MEMORY_OPTION, so lets use Kconfig now and next step move into an intel specific file.

Copy link
Collaborator

@softwarecki softwarecki Apr 17, 2024

Choose a reason for hiding this comment

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

My question arises from the fact that in another place in the code where the IMR_BOOT_LDR_MANIFEST_BASE definition is used, the condition looks different. It would be good to check it the same way in both places.

sof/src/ipc/ipc4/helper.c

Lines 959 to 961 in 14c4e86

#ifdef RIMAGE_MANIFEST
desc = (const struct sof_man_fw_desc *)IMR_BOOT_LDR_MANIFEST_BASE;
#else

Copy link
Collaborator

Choose a reason for hiding this comment

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

I was looking at the same @softwarecki but later realized RIMAGE_MANIFEST is locally defined in helper.c. However, #9012 was now merged, so we now have a place to put Intel/vendor specific bits of code and don't need to ifdefs like RIMAGE_MANIFEST anymore.

E.g. I'd propose to make getting the base_fw manifest a platform specific call. Something like:

``` `
if (lib_id == 0)
desc = platform_base_fw_get_manifest()
else
desc = lib_manager_get_library_manifest()


And add platform_base_fw_get_manifest() to the newly added base_fw_platform.h and add implementation for Intel ACE and a dummy one for posix.

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.

Lets use Kconfig

libs_info->library_count = 0;

for (int lib_id = 0; lib_id < LIB_MANAGER_MAX_LIBS; ++lib_id) {
#ifdef ZEPHYR_SOC_INTEL_ADSP_MEMORY_H_
Copy link
Member

Choose a reason for hiding this comment

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

@kv2019i and I were discussing a src/ipc/ipc4/intel.c where we could put a lot of the vendor specific code and wrap it with Kconfigs, have it read values from Zephyr DT later too.

It would seem we could use that here too and rather than using the #ifdef ZEPHYR_SOC_INTEL_ADSP_MEMORY_H_ we use a Kconfig CONFIG_SOME_INTEL_MEMORY_OPTION, so lets use Kconfig now and next step move into an intel specific file.

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.

Proposal how to handle the ifdef added inline

libs_info->library_count = 0;

for (int lib_id = 0; lib_id < LIB_MANAGER_MAX_LIBS; ++lib_id) {
#ifdef ZEPHYR_SOC_INTEL_ADSP_MEMORY_H_
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was looking at the same @softwarecki but later realized RIMAGE_MANIFEST is locally defined in helper.c. However, #9012 was now merged, so we now have a place to put Intel/vendor specific bits of code and don't need to ifdefs like RIMAGE_MANIFEST anymore.

E.g. I'd propose to make getting the base_fw manifest a platform specific call. Something like:

``` `
if (lib_id == 0)
desc = platform_base_fw_get_manifest()
else
desc = lib_manager_get_library_manifest()


And add platform_base_fw_get_manifest() to the newly added base_fw_platform.h and add implementation for Intel ACE and a dummy one for posix.

@gbernatxintel gbernatxintel force-pushed the gb_branch_1 branch 3 times, most recently from d4ecab6 to 48241b5 Compare April 19, 2024 07:41
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.

Thanks @gbernatxintel , looks good now!

Copy link
Collaborator

@softwarecki softwarecki left a comment

Choose a reason for hiding this comment

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

In my opinion, there is a missing check (eg. static assert) to make sure that sizeof(struct ipc4_libraries_info) + LIB_MANAGER_MAX_LIBS * sizeof(struct ipc4_library_props) not exceed the SOF_IPC_MSG_MAX_SIZE. Under unfavorable circumstances, this may result in a response buffer overflow.

libs_info->library_count++;
}

*data_offset = sizeof(libs_info->library_count) +
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would like change the libraries filed declaration to struct ipc4_library_props libraries[0]; and then simplify this calculation to *data_offset = sizeof(libs_info) + libs_info->library_count * sizeof(libs_info->libraries[0]);

src/audio/base_fw.c Show resolved Hide resolved
@gbernatxintel gbernatxintel force-pushed the gb_branch_1 branch 3 times, most recently from eb69c56 to 7baafb8 Compare April 19, 2024 12:43
@kv2019i kv2019i dismissed lyakh’s stale review April 23, 2024 09:00

Comments addressed

@kv2019i
Copy link
Collaborator

kv2019i commented Apr 23, 2024

@softwarecki Ok for you?

@@ -425,6 +427,56 @@ static int basefw_power_state_info_get(uint32_t *data_offset, char *data)
return 0;
}

static int basefw_libraries_info_get(uint32_t *data_offset, char *data)
{
if (sizeof(uint32_t) + LIB_MANAGER_MAX_LIBS * sizeof(struct ipc4_library_props) >
Copy link
Collaborator

Choose a reason for hiding this comment

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

sizeof(uint32_t) -> sizeof(struct ipc4_libraries_info)

Added support for ipc4 query no 16. This makes it possible to get
information about the current basefw library.

Signed-off-by: Grzegorz Bernat <[email protected]>
@kv2019i kv2019i merged commit 7b0c202 into thesofproject:main Apr 23, 2024
44 of 45 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.

5 participants