Skip to content

module_adapter: refactor the copy function - #6929

Merged
lgirdwood merged 1 commit into
thesofproject:mainfrom
ranj063:fix/6864
Jan 24, 2023
Merged

module_adapter: refactor the copy function#6929
lgirdwood merged 1 commit into
thesofproject:mainfrom
ranj063:fix/6864

Conversation

@ranj063

@ranj063 ranj063 commented Jan 10, 2023

Copy link
Copy Markdown
Collaborator

Refactor the module_adapter_copy() function to split the simple_copy case into a separate helper function.

Signed-off-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com

Refactor the module_adapter_copy() function to split the simple_copy
case into a separate helper function

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

/* release all source buffers */
i = 0;
list_for_item(blist, &dev->bsource_list) {

@lgirdwood lgirdwood Jan 11, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This list iteration is confusing as we are using a list iterator (but not using the list item, we are just using it to get the array size).
Should we not use a for/while loop here based on number of source/sinks (or is source/sink != NULL) ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@lgirdwood I think it is better to keep the list iterator here because this balances the buffer_acquires done using the list iterator on lne 706.

ret = module_process(mod, mod->input_buffers, num_input_buffers,
mod->output_buffers, num_output_buffers);
ret = module_process(mod, mod->input_buffers, mod->num_input_buffers,
mod->output_buffers, mod->num_output_buffers);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think there's a change in behaviour here: before this patch if the loop always took the continue path because all components were in wrong states, then num_input_buffers and num_output_buffers were 0 here, now that's different. Is that intended?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@lyakh but that was only for the simple_copy case right?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

no, I mean old line 760 - I put a comment there

/* check if the source dev is in the same state as the dev */
if (!src_c->source || src_c->source->state != dev->state) {
buffer_release(src_c);
continue;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I mean this branch

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@lyakh if you look at the deep-buffer case in today code,

num_input_buffers = mod->num_input_buffers;
, num_input_buffers/num_output_buffers will never be 0. right?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

hmm, I have no idea what or how I was reading, you're right, no change here.

ret = module_process(mod, mod->input_buffers, num_input_buffers,
mod->output_buffers, num_output_buffers);
ret = module_process(mod, mod->input_buffers, mod->num_input_buffers,
mod->output_buffers, mod->num_output_buffers);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

no, I mean old line 760 - I put a comment there

@kv2019i
kv2019i requested a review from lgirdwood January 24, 2023 17:53
@kv2019i

kv2019i commented Jan 24, 2023

Copy link
Copy Markdown
Collaborator

@lgirdwood ok with this, you had comments earlier? this is ready to go, reviews ok and CI passes

@lgirdwood
lgirdwood merged commit 231622f into thesofproject:main Jan 24, 2023
@ranj063
ranj063 deleted the fix/6864 branch January 24, 2023 21:23
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