Skip to content

Copier: preparation work for convert copier to module interface - #7740

Merged
lgirdwood merged 9 commits into
thesofproject:mainfrom
btian1:copier_modulerinterface
Jul 7, 2023
Merged

lgirdwood merged 9 commits into
thesofproject:mainfrom
btian1:copier_modulerinterface

Conversation

@btian1

@btian1 btian1 commented Jun 5, 2023

Copy link
Copy Markdown
Contributor

No description provided.

@btian1 btian1 changed the title Copier modulerinterface Copier: convert copier to module interface Jun 5, 2023
@btian1
btian1 force-pushed the copier_modulerinterface branch from 91196fc to 222ca47 Compare June 5, 2023 13:00
Comment thread src/audio/copier/copier.c Outdated
@btian1
btian1 force-pushed the copier_modulerinterface branch 8 times, most recently from 87556ea to d5ead7c Compare June 14, 2023 03:39
Comment thread src/audio/copier/copier.c Outdated
Comment thread src/audio/copier/copier.c Outdated
Comment thread src/audio/copier/copier.c Outdated
Comment thread src/audio/copier/copier.c Outdated
Comment thread src/audio/copier/copier.c Outdated
Comment thread src/audio/copier/copier.c Outdated
Comment thread src/audio/copier/copier.c Outdated

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.

will it all fit in one line?

Comment thread src/audio/copier/copier.c Outdated

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.

can we move this inside case SOF_COMP_DAI: for the multiendpoint case?

@btian1 btian1 Jun 15, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will move once all CI passed.

Comment thread src/audio/copier/copier.c Outdated

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.

for the module copier, will cd->endpoint_num ever be > 0?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it should be 0, also the type is NONE, neither host nor dai.

Comment thread src/audio/copier/copier.c Outdated

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.

endpoint_num will always be 0 for module copier

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.

and instead of checking for bsource_buffer, I'd check the cd->direction

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok, let's remove this part of code, since only endpoint copy need add this data.

Comment thread src/audio/copier/copier.c Outdated

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.

this will likely run into compilation issues because this function is unused. Either you need to call this from copier_copy() or you need convert to module_interface in this patch

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, right way is add all left code into this patch.

@btian1
btian1 force-pushed the copier_modulerinterface branch 3 times, most recently from dfd81d5 to abf7ed6 Compare June 15, 2023 06:58
Comment thread src/audio/copier/copier.c Outdated

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'm wondering why some .set_configuration() methods invalidate cache and others don't? If it's needed, maybe it should be done centrally in module_set_large_config()? @ranj063

Comment thread src/audio/copier/copier.c Outdated
Comment thread src/audio/copier/copier.c Outdated
@btian1
btian1 force-pushed the copier_modulerinterface branch 3 times, most recently from 0daed68 to 61bdee1 Compare June 30, 2023 02:24
@btian1 btian1 changed the title Copier: convert copier to module interface Copier: preparation work for convert copier to module interface Jun 30, 2023
@btian1
btian1 marked this pull request as ready for review June 30, 2023 02:30
@btian1
btian1 force-pushed the copier_modulerinterface branch 2 times, most recently from 0d06602 to 6a049b3 Compare July 3, 2023 13:23

@lgirdwood lgirdwood left a comment

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.

@btian1 can you check CI thanks.

Comment thread src/audio/copier/copier.c Outdated
Comment thread src/audio/copier/copier.c Outdated

@ranj063 ranj063 Jul 3, 2023 •

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.

@btian1 if you're going to do this, I think we can go further and remove do_enpoint_copy() altogether isnt it? Maybe we can do this ina follow up PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I use last patch to remove all do_endpoint_copy, please have a check.

@lyakh lyakh left a comment

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.

mostly looks good to me, just one doubt about a potential change in behaviour and a couple of minor comments

Comment thread src/audio/copier/copier.c Outdated

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.

this is an unusual name for a "configuration" variable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

followed module_adapter_new, we can change use another patch to unify those usages.

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.

ack, dst is usually used as a destination pointer. We use source or sink, so I would rename to sink_config if this is configuration data for a destination module. If its our local configuration then call it config.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ok, line 68 already have config named, for avoid confusing, I removed this variable.

Comment thread src/audio/copier/copier.c Outdated

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.

how about just md->cfg.init_data = spec and remove dst. Or even mod->priv.cfg.init_data = spec and remove both md and dst

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In assembly level, there is no difference at all for both implementation.

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.

Yes, dst is confusing name for me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@lyakh @lgirdwood , use md->cfg.init_data = spec to remove dst usage, mod->priv.cfg.init_data = spec this is a little long, I prefer use md->cfg.init_data = spec.

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.

In assembly level, there is no difference at all for both implementation.

Sure, but we aren't programming in assembly. There are many ways to write code in C to generate the same assembly output. You can name your variables a1, a2 etc. but that's not how we're programming

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fully agree, please review the changes, and let me know if you still have further comments.

Comment thread src/audio/copier/copier.c Outdated

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.

what was wrong with the original line 637?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

you are right, nothing changed, let me change back, don't remember why have this change.

Comment thread src/audio/copier/copier.c Outdated
@btian1
btian1 requested review from lgirdwood and lyakh July 4, 2023 08:41
@btian1
btian1 force-pushed the copier_modulerinterface branch from 577de5c to 86019ec Compare July 4, 2023 08:47
Comment thread src/audio/copier/copier.c Outdated

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.

ack, dst is usually used as a destination pointer. We use source or sink, so I would rename to sink_config if this is configuration data for a destination module. If its our local configuration then call it config.

Comment thread src/audio/copier/copier.c Outdated

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.

Yes, dst is confusing name for me.

Comment thread src/audio/copier/copier.c Outdated
btian1 added 5 commits July 5, 2023 09:38
Set dev private as module interface, create new copier_init
to meet module interface requirement, and change all copier_data
related code.

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
Add new function to implement free and reset module interface.

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
Use module parameter instead of device parameters.

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
Use standard module set and get config interface in copier.

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
Convert copier unbind to module interface.

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
@btian1
btian1 force-pushed the copier_modulerinterface branch from 86019ec to e0f6e19 Compare July 5, 2023 01:43
@btian1
btian1 requested a review from lgirdwood July 5, 2023 01:43
@btian1
btian1 force-pushed the copier_modulerinterface branch from e0f6e19 to 5a1331a Compare July 6, 2023 06:12
ranj063 and others added 4 commits July 6, 2023 14:24
This will be used to separate multi-endpoint DAI copy from the module
copier copy.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
In preparation for converting the copier to use the module interface,
split up the multi-endpoint DAI copy and the module copier copy cases.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
It is only used in the multi-endpoint case, so use the
multi_endpoint_buffer directly.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
This is 1ms function calling, remove one more layer to get
better performance.

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>

@lyakh lyakh left a comment

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.

we can address the comments in a follow-up, and the problem with the .init_data is larger than just the copier

Comment thread src/audio/copier/copier.c
*/
if (memcpy_s(&cd->config, sizeof(cd->config), copier, sizeof(*copier)) < 0)
goto error_cd;
if (memcpy_s(&cd->config, sizeof(cd->config), copier, sizeof(*copier)) < 0) {

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.

actually it would be better to propagate the error:

ret = memcpy_s(&cd->config, sizeof(cd->config), copier, sizeof(*copier));
if (ret < 0)
	goto error;

Can be done in a follow up, unless you anyway submit an update to this PR

Comment thread src/audio/copier/copier.c
comp_cl_err(&comp_copier, "pipeline %d is not existed", config->pipeline_id);
goto error_cd;
comp_err(dev, "pipeline %d is not existed", config->pipeline_id);
ret = -EPIPE;

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 EPIPE means "broken pipeline." Here it's more like ENODEV / ENOENT?

Comment thread src/audio/copier/copier.c
comp_set_drvdata(dev, mod);
md = &mod->priv;
mod->dev = dev;
md->cfg.init_data = spec;

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.

we should remove all these. spec points to the mailbox, data there will change, so storing a pointer to it isn't a good idea. The module adapter does that too and has to be fixed as well.

Comment thread src/audio/copier/copier.c
break;
case SOF_COMP_DAI:
if (cd->endpoint_num == 1)
return dai_common_copy(cd->dd[0], dev, cd->converter);

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.

this case is already handled somewhere, right?

@lgirdwood lgirdwood left a comment

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.

@ranj063 good for you ?

@ranj063

ranj063 commented Jul 7, 2023

Copy link
Copy Markdown
Collaborator

@ranj063 good for you ?

@lgirdwood yes already approved

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