-
Notifications
You must be signed in to change notification settings - Fork 322
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
Add dummy Loadable smart amp support #8580
Add dummy Loadable smart amp support #8580
Conversation
a60b216
to
19b0ed0
Compare
int ret; | ||
|
||
base_cfg = mod_data->cfg.init_data; | ||
sad = &smart_amp_priv; |
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.
can and shall we add a check that this function isn't called when 1 instance of the module is already running?
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.
Only one smart amp in topology and the pcm can't be used two times at the same time, so no need to check it.
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.
Only one smart amp in topology and the pcm can't be used two times at the same time, so no need to check it.
If we so far don't have any topology with more than one smart amp, it doesn't mean, that we don't need to be able to correctly handle such topologies. SOF must be able to handle any valid topologies.
@@ -1107,6 +1114,8 @@ static int module_adapter_sink_source_copy(struct comp_dev *dev) | |||
|
|||
comp_dbg(dev, "module_adapter_sink_source_copy(): start"); | |||
|
|||
module_adapter_sink_src_update(dev, mod); |
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.
Why you want to get new set of sink/src pointers before each copy?
What is "dynamic multi-source issue"?
EDIT: it may affect overall performance as it will be executed every cycle for every single component
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.
This commit does fix the CI issue reported for #8537 PR. Verified on draft PR #8576 with 1855581 commit included.
Here is an example use case that requires this commit: consider two pipelines, one with mixin and the other with mixout, mixin is connected to mixout. After pipelines started, .prepare() is called for mixin and mixout. So now mixout has num_of_sources set to 1. After some time driver creates third pipeline containing mixin, binds that mixin to mixout and starts this new pipeline. .prepare() will be called for this new mixin, however, .prepare() will not be called for mixout!!! And mixout's num_of_sources is still 1, which is now wrong. This is because mixout pipeline was already running. To call .prepare() for mixout, its pipeline should be paused, then reset and then started again. However, driver does not do this.
So this commit fixes the problem. However, you are right, it is excessive to update sinks/sources at every copy call for each module. It would be better to move the module_adapter_sink_src_update() to bind() and unbind() handlers.
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.
sure, I agree to move it to bind & unbind. Actually I did it in bind & unbind at first. Let's change it.
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.
for smart amp, the reference buffer from capture will attach to playback stream, so the source count will be changed. This is the issue
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.
Some of this PR is fixes and can merged now with commit messages, but we need reuse and a single dummy smart amp code base.
We should only have 1 code base for each module regardless of how it's used (built-in or module)
lmdk/cmake/build.cmake
Outdated
@@ -25,6 +25,7 @@ foreach(MODULE ${MODULES_LIST}) | |||
"${LMDK_BASE}/include" | |||
"${RIMAGE_INCLUDE_DIR}" | |||
"${SOF_BASE}/src/include/module" | |||
"${SOF_BASE}/src/include" |
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.
Is this fix to be squashed ? (its missing a commit message)
@@ -0,0 +1,317 @@ | |||
// SPDX-License-Identifier: BSD-3-Clause |
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.
This needs to be in modules directory and we need to reuse code, we cant have 2 implementations of dummy smart amp. i.e. I would use Kconfig to select which functions to build in library mode and which to build in as I imagine most of the code will be the same.
@@ -0,0 +1,122 @@ | |||
/* SPDX-License-Identifier: BSD-3-Clause |
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.
This file needs to be in the common modules directory alongside the dummy smart amp implementation.
19b0ed0
to
823e545
Compare
823e545
to
e6dda3a
Compare
1cc00c4
to
9eb1c3b
Compare
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.
don't remap source pointers from const *, accidental modification of source buffers may result in hard to track issues (even to cache incoherency if dpQueue is used)
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.
need to keep all logging otherwise we will have difficulty with debug
5572498
to
be878db
Compare
SOFCI TEST |
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.
@marcinszkudlinski good for you ?
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.
We plan to enable two ways to build the smart amp test as a module: as in this PR, using the system services / LMDK approach, and as in #8180 . It should be possible to select in Kconfig which way the module is built. Some aspects of this work are common, like enabling tristate Kconfig options, and I find that some of them are better resolved in #8180. I propose to first merge at least those common commits and then merge these PRs in any order. Of course, the one, that gets merged as second, will have to be adjusted a bit
.process = modules_process, | ||
#else | ||
.process_raw_data = modules_raw_process, | ||
#endif |
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.
wouldn't 2873535 be a better solution?
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.
please check this #8554 (review). And I think the process will be the best one, so I didn't add more interface
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.
@RanderWang ok, we can use that work-around, but then you shouldn't need to touch modules.c ops at all - they're replaced by smart-amp's ops, aren't they?
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 this modules.c is used by loadable module which use "struct module_interface interface" as ops and in this ops to invoke loadable module's ops, right ?
Build-in smart amp doesn't use this ops.
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.
if you use the work-around, proposed by @softwarecki in softwarecki@26f4b47 then these ops won't be used by the smart-amp test when built as a loadable module
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 Actually I first used this patch and we have a discussion #8580 (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.
So we have 2 months until v2.9, lets refine this further as module support is still moving quickly. i.e. we can see how things work in practice with service API modules and Zephyr modules and see what solution for above supports both best.
|
||
ret = smart_amp_params(mod); |
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.
do you mean, that after #8612 is merged, the configuration will be handled at the module-adapter level? Then this PR should be marked as dependent on that one, and maybe removing (then redundant) configuration setting here should be a separate commit
int ret; | ||
const struct ipc4_base_module_extended_cfg *base_cfg = mod_data->cfg.init_data; | ||
|
||
comp_dbg(dev, "smart_amp_init()"); | ||
LOG_DBG("smart_amp_init()"); |
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.
cannot you just declare domp_dbg()
and friends as dummies themselves for modular builds?
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.
No. The problem is that dev is not available for loadable module build. please check "struct processing_module". I spent much effort to make compiling pass.
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.
@RanderWang sorry, don't understand. You replace comp_dbg()
with LOG_DBG()
and then redefine it to a NOP for loadable modules. So, why don't you just redefine the original comp_dbg()
to a NOP? If you do, you won't care about dev
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 I understand your idea. if I use comp_dbg(), it will be more ifdef in the code. So I don't prefer it
#ifdef MODULE
stuct comp_dev dev = mode->dev;
#endif
.....
comp_dbg(dev, ".....");
````c
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.
then define comp_dbg()
to something, that keeps dev
"used" and prevents compiler unused variable warnings?
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.
this return to the first question dev is not available for loadable module
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.
This should be resolved by using native Zephyr logging, but this is WIP.
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.
this return to the first question dev is not available for loadable module
I mean something like
#define dev_dbg(dev, ...) do { (void)dev; } while (0)
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.
The previous one wouldn't work probably because dev
isn't available at all as a variable. So I think a simple
#define comp_dbg(...) do {} while (0)
should do. If for some reason that doesn't work, maybe
#define comp_dbg(dev, ...) do { int dev; (void)dev; } while (0)
would.
if (!sad->model_handler) { | ||
ret = -ENOMEM; | ||
goto sad_fail; | ||
} |
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.
I think it was decided that the smart amp test doesn't really need and isn't using the data blob API, right? Can we make removing it a separate commit?
@@ -358,8 +349,32 @@ static const struct module_interface smart_amp_test_interface = { | |||
.free = smart_amp_free | |||
}; | |||
|
|||
#ifndef __MODULE_BUILD__ |
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.
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.
OK, we need to avoid common names to avoid collision with Zephyr, can we rename to __SOF_MODULE_SERVICE_BUILD__
and this would indicate a SOF macro for modules using the services API. Not a blocker for this PR, can be incrementally updated.
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.
sure, this is for a demo. We still need a lot of work to include loadable module building system
Alsabat test issue in CI test. debugging |
3153147
to
3dbd49a
Compare
SOFCI TEST |
This PR depends on #8594 |
Loadable modules are linked, using a linked script, built by a cmake script. That linker script includes multiple existing linker script fragments. Each of those fragments defines 1 or more sections and respective PHDRs. However, some of those scripts, e.g. common_rodata_linker_script.txt and data_linker_script.txt add sections to the same rodata_phdr PHDR. This makes the linker allocate sections in that PHDR twice in the resulting output file: one copy is real and the other one is filled with zeros. Removing one of the PHDR definitions solves the problem and removes about 60KiB of empty space from the output file. Signed-off-by: Guennadi Liakhovetski <[email protected]>
Set correct source & sink parameters for module prepare function Signed-off-by: Guennadi Liakhovetski <[email protected]>
3dbd49a
to
0e2194d
Compare
Test this PR with #8594 |
0e2194d
to
e8be072
Compare
#8594 was merged , ready for test |
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.
Any blocking issues @lyakh @softwarecki ?
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.
I think we are good to go, as the landing for the initial service API module user. This will no doubt be improved and refined as we head towards v2.9, but this now get some example code that can be tested.
.process = modules_process, | ||
#else | ||
.process_raw_data = modules_raw_process, | ||
#endif |
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.
So we have 2 months until v2.9, lets refine this further as module support is still moving quickly. i.e. we can see how things work in practice with service API modules and Zephyr modules and see what solution for above supports both best.
int ret; | ||
const struct ipc4_base_module_extended_cfg *base_cfg = mod_data->cfg.init_data; | ||
|
||
comp_dbg(dev, "smart_amp_init()"); | ||
LOG_DBG("smart_amp_init()"); |
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.
This should be resolved by using native Zephyr logging, but this is WIP.
7637b37
to
1d05739
Compare
The module-adapter API has 3 processing modes: raw, stream and source-sink, and until now only one of them can be implemented by any module. However, the "modules" module, that loads loadable modules, has to implement all of them to be prepared to handle any loadable modules. This adds support for such modules. Signed-off-by: Guennadi Liakhovetski <[email protected]> Signed-off-by: Rander Wang <[email protected]>
Use process instead of process_audio_stream for pipeline 2.0 Signed-off-by: Rander Wang <[email protected]>
It will be built will __SOF_MODULE_SERVICE_BUILD__ enabled Signed-off-by: Rander Wang <[email protected]>
1d05739
to
694aa9e
Compare
updated. The failure was caused by FDK library tests which uses different process function compared to sof loadable module. I have to reuse patch: 22c398c. I checked the QT internal state , all the tests passed, but why it still show error ? |
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.
Sorry, commit number 4 in this series now looks like too intrusive to me. As it stands it seems to modify the current smart-amp testing module a lot and I don't quite understand why. As far as I understand we don't want to change this module's functionality, we just want to make it usable as a loadable module. I understand that with system services that means eliminating most calls to the base firmware. But I'd think, that this should be done by disabling that code using #ifdef
s for this build, not by removing it, as requested e.g. in #8580 (comment) . Also comparing to 3163edf#diff-37cb5e9335e5fb23ba003096bb4c98cd7cbd91d550e280bbb06a188175974e6f which only adds a hook for loading and doesn't modify any code, this really looks very intrusive.
Clarified: the large diff in commit 4 is because that commit actually converts to the source-sink API. Such a conversion would be worthy a separate PR, but that isn't critical. And the removal of comp_dbg()
in commit 5 is because dev
isn't present in struct processing_module
when built for modules...
@lgirdwood We have tests for dummy smart amp but only for built-in module. after re-test all tests on green |
@marcinszkudlinski @mwasko good to cherry-pick |
@lgirdwood TGLU_RVP_NOCODEC failed in the CI tests https://sof-ci.01.org/sofpr/PR8580/build1172/devicetest/index.html?model=TGLU_RVP_NOCODEC-ipc4&testcase=check-suspend-resume-with-capture Not sure why it's marked as TIMEOUT and in the issue #8641 as a DSP panic? @keqiaozhang are you sure about the bisect to this PR? |
@plbossart I confirmed it again this morning, issue #8641 cannot be reproduced after reverting these 2 commits: 68c6357 and 7331745. |
No description provided.