Skip to content

Conversation

@ranj063
Copy link
Collaborator

@ranj063 ranj063 commented Dec 19, 2022

No description provided.

@ranj063 ranj063 force-pushed the fix/mixin_convert branch 2 times, most recently from bf63c12 to 5e8cb39 Compare December 19, 2022 05:00
@ranj063 ranj063 changed the title Convert the mixin module to use the module adapter [DO NOT REVIEW]Convert the mixin module to use the module adapter Dec 19, 2022
@ranj063 ranj063 changed the title [DO NOT REVIEW]Convert the mixin module to use the module adapter Convert the mixin module to use the module adapter Dec 19, 2022
@ranj063 ranj063 marked this pull request as ready for review December 19, 2022 16:43
@ranj063 ranj063 force-pushed the fix/mixin_convert branch 7 times, most recently from d661254 to b3c89ef Compare December 20, 2022 16:23
@lgirdwood
Copy link
Member

@ranj063 #6833 now merged, this will need a rebase.

@ranj063 ranj063 force-pushed the fix/mixin_convert branch 2 times, most recently from f9929bb to 16133e9 Compare December 20, 2022 18:41
@lgirdwood
Copy link
Member

@ranj063 can you check internal CI thanks.

@ranj063 ranj063 force-pushed the fix/mixin_convert branch 3 times, most recently from ae5793d to 7b09c9e Compare December 21, 2022 19:04
@ranj063
Copy link
Collaborator Author

ranj063 commented Dec 21, 2022

@ranj063 can you check internal CI thanks.

@lgirdwood looking into it. Looks like the gain quality test is failing.

@ranj063
Copy link
Collaborator Author

ranj063 commented Dec 22, 2022

SOFCI TEST

@ranj063
Copy link
Collaborator Author

ranj063 commented Dec 22, 2022

SOFCI TEST

3 similar comments
@ranj063
Copy link
Collaborator Author

ranj063 commented Dec 23, 2022

SOFCI TEST

@ranj063
Copy link
Collaborator Author

ranj063 commented Dec 23, 2022

SOFCI TEST

@ranj063
Copy link
Collaborator Author

ranj063 commented Dec 23, 2022

SOFCI TEST

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.

Nothing major, some minor comments, please see inline.

size_t size = MAX(mod->deep_buff_bytes, mod->period_bytes);
uint32_t min_free_frames = UINT_MAX;
uint32_t num_input_buffers = 0;
uint32_t num_output_buffers = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not really specific to this PR, but the "copy()" starts to be very complex. I wonder if some of this logic could be moved to some less-often-run function. Could we even have a separate copy for the "simple_copy case"?

base_module_cfg_to_stream_params(&mod->priv.cfg.base_cfg, params);

/* Buffers between mixins and mixouts are not used (mixin writes data directly to mixout
* sink). But, anyway, let's setup these buffers properly just in case.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This feels quit out-of-place, but as this is existing comment (and code) moved as-is, not need to block because of this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

the comment could be a bit "kinder" though at least, stating some "better sounding" reason than "just in case," e.g. "for correctness," "for consistency" etc. But yes, it's just a verbatim copy of the current comment


dev->ipc_config.frame_fmt = frame_fmt;
mod->simple_copy = true;
mod->skip_src_buffer_invalidate = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor thing, but the commit leaves a bit open why the modules need the ability to do this. This does add two code branches to a very common code path (the module process). I wonder if it's more efficient to just remove the extra writebacks from modules, and if there a few cases where this can't be done, pay the cost only for these cases.

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 I think we need to clean this up for sure to not allow modules to do the WB/invalidates. But for now, I want to leave it as is to reduce the amount of changes.

Copy link
Member

Choose a reason for hiding this comment

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

The cache work needs to go in the module core, however, agree we should do teh module conversion first and then do the cache work (when hopefully the Zephyr cache API is ready).

@kv2019i
Copy link
Collaborator

kv2019i commented Dec 29, 2022

@wszypelt "System/merge/codecheck" error hit with this one as well..

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 don't like this. We're in .copy() i.e. in the pipeline task, actually performing streaming, right? These buffers can only be modified when modifying topology, i.e. either when connecting or when disconnecting pipelines. Those actions should also only be done in a pipeline task context. As long as we only allow connected pipelines on the same core, these tasks will run sequentially without preempting each other. So within one scheduling invocation these buffers remain consistent.
Only when we move to connecting different cores, then this will become a problem. But even then this will be a larger problem, requiring proper robust locking. And if we ever hit this condition, it means we were in an inconsistent state and it can bite us elsewhere. These checks seem only to reduce the probability of hitting a problem, making it more difficult to debug and fix. Really don't seem useful to me. Same below of course.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@lyakh I'm fully with you that this does not seem right in copy (we should have less frequent state change callbacks where module can react to changes in its configuration or the configuration of its immediate connections, and NOT do this check in each copy), but it's still a fact that currently this is hit in pause-resume tests (with sof-tests), so it's not like this is a corner case at this point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh i missed these 2. fixed now

Copy link
Collaborator

Choose a reason for hiding this comment

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

@lyakh I'm fully with you that this does not seem right in copy (we should have less frequent state change callbacks where module can react to changes in its configuration or the configuration of its immediate connections, and NOT do this check in each copy), but it's still a fact that currently this is hit in pause-resume tests (with sof-tests), so it's not like this is a corner case at this point.

@kv2019i if it's so easy to hit, then we really need to investigate and fix these properly. Maybe someone could add a task to our planning ;-)

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, this is cleaner than my #6909 .

The concern raised by Guennadi on whether copy()/process() has to have so much conditional code, remains on open, but not really specific to this PR. Given I can easily hit these conditions with sof-test, it would seem this requires a separate PR (if someone disagrees, please chime in).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup, this is cleaner,

Add a helper function to set up the input/output buffers for the 1:1 and
N:1 source:sink buffer configuration. Also, expand the
module_adapter_copy() function to support the simple_copy flag with the
single source and multiple sink buffer configuration.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Replace the comp_drv ops for the mixin component to use the
module_adapter interface. The trigger and get_attribute ops are replaced
with the module_adapter ops which do the exact same thing. The base_cfg
field from struct mixin_data is removed as it is replaced with the
base_cfg in struct module_config and all users have been updated.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
…back

Some modules like the mixin/mixout do the invalidate/writebacks for the
source/sink buffers themselves. So, add flags in struct
processing_module to skip doing the same again in the module adapter
code.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
In the simple_copy case, source/sink modules that aren't active are
skipped when passing the buffers to the process callback. So,
produce/consume from only the active buffers that were passed to the
process callback as well.

Reported-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
@ranj063 ranj063 force-pushed the fix/mixin_convert branch from 2d9da91 to 5414c49 Compare January 5, 2023 17:05
base_module_cfg_to_stream_params(&mod->priv.cfg.base_cfg, params);

/* Buffers between mixins and mixouts are not used (mixin writes data directly to mixout
* sink). But, anyway, let's setup these buffers properly just in case.
Copy link
Collaborator

Choose a reason for hiding this comment

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

the comment could be a bit "kinder" though at least, stating some "better sounding" reason than "just in case," e.g. "for correctness," "for consistency" etc. But yes, it's just a verbatim copy of the current comment

@lgirdwood lgirdwood merged commit f8bdef3 into thesofproject:main Jan 6, 2023
@lgirdwood
Copy link
Member

@ranj063 btw, what's module adapter plan for N:1 and M:N based processing optimisation ?

@ranj063
Copy link
Collaborator Author

ranj063 commented Jan 6, 2023

@ranj063 btw, what's module adapter plan for N:1 and M:N based processing optimisation ?

@lgirdwood N:1 is already supported by the module adapter. M:N is the only open. I dont have a line of sight for this one due to the lack of a module for this type. Maybe what we need to think of extending the passthrough module to support M:N confg instead of 1:1 so we can test this. WHat do you think?

@ranj063 ranj063 deleted the fix/mixin_convert branch January 6, 2023 17:29
@lgirdwood
Copy link
Member

@ranj063 lets leave M:N then for later.

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