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

developer-guide: add LLEXT module documentation #493

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

lyakh
Copy link
Contributor

@lyakh lyakh commented Apr 11, 2024

Describe LLEXT loadable module support in SOF.

Installation
************

As described in :ref:`intel_debug_introduction` the |SOF| Linux kernel driver
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unless I missed something that page does not really "describe" anything; it merely gives a /lib/firmware location.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marc-hb wording updated

************

As described in :ref:`intel_debug_introduction` the |SOF| Linux kernel driver
loads SOF modules, using their UUIDs. For SOF internal modules the process
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does "using their UUIDs" mean? How does the kernel know which modules to load and which not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marc-hb Topology specifies UUIDs, the kernel driver also parses the base firmware manifest to see which UUIDs are built-in. For any, that are specified in topology but aren't available in the base firmware, an attempt will be made to load them dynamically. But this is generic SOF architecture information, not LLEXT specific

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, I think I found it at _apps-component-overview, please add a link to that.

Earlier you mentioned that a single LLEXT file can have multiple modules, in that case which UUID is used for its filename?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Earlier you mentioned that a single LLEXT file can have multiple modules, in that case which UUID is used for its filename?

@marc-hb none. Filenames are created from a common name: "eq_iir," "mixin_mixout," etc. UUIDs are soft links to those files

Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you mean "all of them"? As in:

  UUID1.bin -> module1and2combined.llext
  UUID2.bin -> module1and2combined.llext

developer_guides/firmware/llext_modules.rst Outdated Show resolved Hide resolved
developer_guides/firmware/llext_modules.rst Outdated Show resolved Hide resolved
lgirdwood
lgirdwood previously approved these changes Apr 30, 2024
A TOML configuration file is needed for building of LLEXT modules too. It is
generated by the C preprocessor at build time from the same components, as would
be used for a monolithic build. A small additional file to bring components
together is needed too, similar to
Copy link
Collaborator

Choose a reason for hiding this comment

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

"A small additional file to bring components together" is not decriptive; very vague. Having an example is great but it's not a substitute for a description.

developer_guides/firmware/llext_modules.rst Outdated Show resolved Hide resolved
With that in place, it is also possible to switch between monolithic and modular
builds by specifying the module as "tristate" in its Kconfig and selecting "m"
for modular builds, however, for modules, exclusively built as LLEXT objects,
this might not be necessary. Thus it is possible to implement third party Module
Copy link
Collaborator

Choose a reason for hiding this comment

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

By "not necessary" you mean "not possible"? As in "exclusively". I think I'm guessing what you mean but this is confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marc-hb no, I didn't mean that. I don't know if anybody would want to write modules that they never need to build into the actual SOF image.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm still confused sorry. I guess I don't understand what is a "module exclusively built as LLEXT object". Sounds like you select "monolithic" but that is ignored by some modules? Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marc-hb no, that isn't what I meant. I just meant, that if you're sure to only build your code as a loadable LLEXT module, it doesn't matter what you do in your Kconfig, you can just hard fix it to always build as a 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 still have no idea how you "hard fix" the build-as-module and how the Kconfig gets ignored in that case (which is confusing?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marc-hb this is what I currently use to switch to building a loadable module: https://github.com/thesofproject/sof/blob/fdb67ee782808f6d5488a53441cdecd75f458677/zephyr/CMakeLists.txt#L874 If you only ever build your code as such, you don't need that if, you use that code unconditionally.

Copy link
Collaborator

Choose a reason for hiding this comment

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

https://github.com/thesofproject/sof/blob/fdb67ee782808f6d5488a53441cdecd75f458677/zephyr/CMakeLists.txt#L874 seems to build a totally distinct .c file depending on whether the user selects "module" or "built-in". This looks... wrong: unexpected and very confusing. Is this what this section tries to allude to?

If something can only be built as a module, IMHO then the build should fail when the user selects "built-in". It should not silently switch to a different .c file :-(

Adapter drivers, that would be built exclusively as loadable modules.

Note, that a single LLEXT object file can also contain multiple Module Adapter
modules. In that case an array of ``struct sof_module_api_build_info`` objects
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is EXPORT_SYMBOL() required between these? Or is that not supported yet?

This "multiple modules inside one module" does not look like a "note", more like a key design aspect. It should be moved near the top of this section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is EXPORT_SYMBOL() required between these? Or is that not supported yet?

no, that isn't needed. It's a single ELF image.

************

As described in :ref:`intel_debug_introduction` the |SOF| Linux kernel driver
loads SOF modules, using their UUIDs. For SOF internal modules the process
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks, I think I found it at _apps-component-overview, please add a link to that.

Earlier you mentioned that a single LLEXT file can have multiple modules, in that case which UUID is used for its filename?

developer_guides/firmware/llext_modules.rst Outdated Show resolved Hide resolved
lgirdwood
lgirdwood previously approved these changes May 14, 2024
@deb-intel
Copy link
Collaborator

@marc-hb Are you satisfied with the updates?

@lgirdwood
Copy link
Member

@marc-hb ping

With that in place, it is also possible to switch between monolithic and modular
builds by specifying the module as "tristate" in its Kconfig and selecting "m"
for modular builds, however, for modules, exclusively built as LLEXT objects,
this might not be necessary. Thus it is possible to implement third party Module
Copy link
Collaborator

Choose a reason for hiding this comment

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

https://github.com/thesofproject/sof/blob/fdb67ee782808f6d5488a53441cdecd75f458677/zephyr/CMakeLists.txt#L874 seems to build a totally distinct .c file depending on whether the user selects "module" or "built-in". This looks... wrong: unexpected and very confusing. Is this what this section tries to allude to?

If something can only be built as a module, IMHO then the build should fail when the user selects "built-in". It should not silently switch to a different .c file :-(


As specified in
:ref:`Firmware look-up paths per Intel platform <intel_firmware_paths>`
the |SOF| Linux kernel driver loads SOF modules, using their UUIDs. For SOF
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
the |SOF| Linux kernel driver loads SOF modules, using their UUIDs. For SOF
the |SOF| Linux kernel driver loads SOF modules with UUIDs specified in the topology. For SOF

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please mention briefly that UUIDs.bin are symbolic links and that several of them can point to the same LLEXT file. Again, a link to _apps-component-overview would probably be good.

As specified in
:ref:`Firmware look-up paths per Intel platform <intel_firmware_paths>`
the |SOF| Linux kernel driver loads SOF modules, using their UUIDs. For SOF
internal modules the process of creation
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does "internal" mean? Available in https://github.com/thesofproject/sof I'm guessing?

In the context of SOF, "internal" usually means "not open-source".

Suggest: "for modules in the main SOF repo"

As explained above, LLEXT modules in general look very similar to native SOF
code, with the only restriction of having no access to not-exported symbols. If
any such symbols are needed to LLEXT modules, additionally exporting them can be
considered.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand this last sentence sorry, what does "additionally" mean?

I can't decide whether this sentence is merely repeating that modules can only access exported symbols (in which case it should be dropped), or too briefly alluding to some other, more complex development question.

developer_guides/firmware/llext_modules.rst Show resolved Hide resolved

A TOML configuration file is needed for building of LLEXT modules too. It is
generated by the C preprocessor at build time from the same components, as would
be used for a monolithic build. For this preprocessor run a small header file,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not a "English comma expert" but I really struggled to parse this sentence (also because run is both a noun and a verb). I think this is what it means:

Suggested change
be used for a monolithic build. For this preprocessor run a small header file,
be used for a monolithic build. For this preprocessor run, a small header file that ...

Describe LLEXT loadable module support in SOF.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
@lgirdwood lgirdwood merged commit 8c2a968 into thesofproject:master Sep 13, 2024
4 checks passed
@lyakh lyakh deleted the llext branch September 16, 2024 06:31
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.

4 participants