-
Notifications
You must be signed in to change notification settings - Fork 349
llext: fix save-restore with no initialized modules #10360
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
Conversation
LLEXT save-restore to DRAM had a bug: if the DSP is powered off with loaded LLEXT modules, none of which was used, context restoration was performed incorrectly, leading to inability to use LLEXT after the next boot. This patch fixes that bug. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the LLEXT (Loadable Extensions) manager's DRAM storage and restoration functionality by adding tracking for the total number of modules (n_mod) in addition to the existing tracking of instantiated LLEXT instances (n_llext). This allows the system to properly handle scenarios where modules exist without LLEXT instances.
Key changes:
- Added
n_modfield to track total number of modules stored in DRAM - Modified the restore function's initial check to use
n_modinstead ofn_llextfor determining if modules are saved - Refactored memory allocation for LLEXT restoration to be conditional on
n_llext > 0
Comments suppressed due to low confidence (2)
src/library_manager/llext_manager_dram.c:310
- Missing cleanup of
lib_manager_dram.n_modfield. This field should also be reset to 0 after successful restoration to maintain consistency with the new tracking mechanism and prevent stale data on subsequent operations. Addlib_manager_dram.n_mod = 0;after line 310.
lib_manager_dram.n_llext = 0;
src/library_manager/llext_manager_dram.c:308
- Memory leak when
lib_manager_dram.n_llext == 0. Therfree(ldr)call at line 308 attempts to freeldr, but whenn_llextis 0,ldris set toNULL(line 191), making this a no-op. However, if the code takes thegoto nomempath before the conditional check at line 275,ldrmight be undefined. Additionally, the comment and logic suggestptr_arrayshould be freed, notldrspecifically. Consider freeing using a temporary variable that holdsptr_arrayor adjusting the logic to ensure proper cleanup.
rfree(ldr);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Where are the CI test results? I do not see them in in failed, successful or pendig list. The function where the fix is is too long an hairy for me to truly understand in one or two hours, but for what I understand it looks ok. I also run some manual tests to verify that the code now indeed works.
|
weird, the build step isn't completing https://sof-ci.01.org/sofpr/PR10360/build17230/build |
|
SOFCI TEST |
|
@lrudyX hi, could you check "Internal CI" results please? All TGL and MTL tests failed and they shouldn't be affected at all, because this PR only touches LLEXT, and neither of them uses it |
lgirdwood
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lyakh 2.14 ?
@lgirdwood if we want to disable full context saving for LNL in 2.14, then yes, it's needed. Otherwise - not urgent. |
|
SOFCI TEST |
|
rerun CI, looks like it was stuck. |
|
@lyakh Can you check the warning from doxygen, it's blockng merge. Otherwise this would be ready to go. |
LLEXT save-restore to DRAM had a bug: if the DSP is powered off with loaded LLEXT modules, none of which was used, context restoration was performed incorrectly, leading to inability to use LLEXT after the next boot. This patch fixes that bug.