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

modules: Remove unused code and variables #8897

Merged
merged 5 commits into from
Apr 3, 2024

Conversation

softwarecki
Copy link
Collaborator

Removed unnecessary functions from Processing Module Adapter. To ensure proper operation of native loadable modules it is necessary to bypass Processing Module Adapter used by FDK modules. This is currently done by overriding the pointer to module_interface used by the Module Adapter. Thanks to this, the Module Adapter directly calls functions provided by native module. As in this case the Processing Module Adapter functions are omitted, support for native libraries are removed from it as
it is no longer needed. This leads to remove is_native_sof variable and modules_process_raw, modules_process_audio_stream functions.

The code allocating/freeing in_buff and out_buff buffers, which were not used, was removed from the processing module adapter.

The value stored by the Processing Module Adapter in the module_adapter field of module_data structure has been moved to an unused private field. This change allowed the module_adapter field to be removed.

The unused sys_service field has been removed from the processing_module structure. It was never initialized anywhere, and its value was passed as a parameter to the native_system_agent_start function which did not use it.

The value assigned to the module_entry_point field in the module_data structure wasn't used anywhere. This field has been removed.

@softwarecki softwarecki force-pushed the modules_cleanup branch 2 times, most recently from 7413498 to 62fbba6 Compare March 5, 2024 09:05
@softwarecki softwarecki marked this pull request as ready for review March 5, 2024 09:05
@dbaluta
Copy link
Collaborator

dbaluta commented Mar 5, 2024

@softwarecki what is native loadable modules? Is the support from Zephyr for loading modules or the one from SOF?

@softwarecki
Copy link
Collaborator Author

softwarecki commented Mar 5, 2024

@dbaluta:

@softwarecki what is native loadable modules?

We currently have three types of loadable modules...

  1. IADK supported by Processing Module Aadapter,
  2. native supported by lib_manager
  3. llext supported by llext_manager and zephyr.

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.

Seems ok. I'd appreciate if @pjdobrowolski , @lyakh and others working with the loadable modules could review this before we go ahead and merge.

@@ -63,6 +63,7 @@ static int modules_init(struct processing_module *mod)
struct comp_dev *dev = mod->dev;
const struct ipc4_base_module_cfg *src_cfg = &md->cfg.base_cfg;
byte_array_t mod_cfg;
bool is_native_sof = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

@softwarecki I don't think we have really explained "FDK" in SOF context, so following the git commit messages is a bit challenging. Correct Adrian me if I'm wrong, but in this context "FDK modules" is same as IADK modules which we have explained and documented in https://thesofproject.github.io/latest/architectures/firmware/intel/ace/iadk_modules.html .

So essentially, when you have native SOF loadable modules that don't depend on Intel IADK, the IADK specific code is not needed and code for native modules can be simplified like done in this PR.

I do find the language around "adapter"'s confusing. We have had adapters both between old SOF component.h interface and the new module interface. But we also have adapters between specialized interfaces (like Intel's IADK) and the module interface. This is not incorrect, but makes harder to follow changes like this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@softwarecki please explain: currently modules_init() performs the mapping of the memory for the module and the copying. How do you get rid of that? Do you work from the IMR directly? Let me mark this for "changes" until this is clarified

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@kv2019i Yes, i mean IADK modules. FDK modules was rebranded to IADK.

@lyakh The modules_init() function is still used, called by Module Adapter. After detecting that it is not an IADK module, the pointer to module_interface is overwritten and points to the interface provided by a loaded module. In this way, all other functions of the Processing Module Adapter are omitted.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@softwarecki I think you're right, thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

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

@softwarecki but then - doesn't that mean, that lib_manager_free_module() is never called?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, I think it is a problem, that operations are completely overwritten and .free() isn't called any more. But it also looks like that was introduced earlier by a082752 . I'll block this PR for now, until we clarify or fix this.

Copy link
Collaborator Author

@softwarecki softwarecki Mar 8, 2024

Choose a reason for hiding this comment

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

@lyakh: As you noticed, this PR does not introduce this change, so I see no reason to block it and thus postpone the next PR that will solve the described issue. I have already prepared the necessary changes and we are waiting for the current PRs to be merged.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@softwarecki well, I don't see a fix among currently submitted PRs and I think the offending commit should be reverted as per #8923 instead of being further deepened. Let's revert that commit and then we can base further work on modifying the shim on top of a working state.

lyakh
lyakh previously requested changes Mar 6, 2024
@@ -63,6 +63,7 @@ static int modules_init(struct processing_module *mod)
struct comp_dev *dev = mod->dev;
const struct ipc4_base_module_cfg *src_cfg = &md->cfg.base_cfg;
byte_array_t mod_cfg;
bool is_native_sof = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

@softwarecki please explain: currently modules_init() performs the mapping of the memory for the module and the copying. How do you get rid of that? Do you work from the IMR directly? Let me mark this for "changes" until this is clarified

@lyakh lyakh dismissed their stale review March 6, 2024 15:04

resolved

lyakh
lyakh previously requested changes Mar 8, 2024
@@ -63,6 +63,7 @@ static int modules_init(struct processing_module *mod)
struct comp_dev *dev = mod->dev;
const struct ipc4_base_module_cfg *src_cfg = &md->cfg.base_cfg;
byte_array_t mod_cfg;
bool is_native_sof = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, I think it is a problem, that operations are completely overwritten and .free() isn't called any more. But it also looks like that was introduced earlier by a082752 . I'll block this PR for now, until we clarify or fix this.

@softwarecki softwarecki force-pushed the modules_cleanup branch 2 times, most recently from b3e5d75 to a207823 Compare March 11, 2024 15:20
@lyakh lyakh dismissed their stale review March 13, 2024 08:58

we understand the .free() problem rather well now and have a couple of potential solutions for it.

To ensure proper operation of native loadable modules it is necessary to
bypass Processing Module Adapter used by IADK modules. This is currently
done by overriding the pointer to module_interface used by the Module
Adapter. Thanks to this, the Module Adapter directly calls functions
provided by native module. As in this case the Processing Module Adapter
functions are omitted, support for native libraries are removed from it as
it is no longer needed. This leads to remove modules_process_raw and
modules_process_audio_stream functions.

Signed-off-by: Adrian Warecki <[email protected]>
The code allocating/freeing in_buff and out_buff buffers, which were not
used, was removed from the processing module adapter.

Signed-off-by: Adrian Warecki <[email protected]>
The value stored by the Processing Module Adapter in the module_adapter
field of module_data structure has been moved to an unused private field.
This change allowed the module_adapter field to be removed.

Signed-off-by: Adrian Warecki <[email protected]>
The unused sys_service field has been removed from the processing_module
structure. It was never initialized anywhere, and its value was passed as
a parameter to the native_system_agent_start function which did not use it.

Signed-off-by: Adrian Warecki <[email protected]>
The value assigned to the module_entry_point field in the module_data
structure wasn't used anywhere. This field has been removed.

Signed-off-by: Adrian Warecki <[email protected]>
@kv2019i kv2019i merged commit 1ce9e45 into thesofproject:main Apr 3, 2024
43 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.

6 participants