-
Notifications
You must be signed in to change notification settings - Fork 319
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
component: move comp_copy from header file to source file #6344
Conversation
This problem statement and rationale are too short for me to make sense of them. Can you expand a bit and/or add URL(s)? |
src/audio/mixer/mixer.c
Outdated
static SHARED_DATA struct comp_driver_info comp_mixer_info = { | ||
.drv = &comp_mixer, | ||
}; | ||
#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.
not much prettier but maybe
#ifndef UNIT_TEST
static
#endif
SHARED_DATA struct comp_driver_info comp_mixer_info = {
.drv = &comp_mixer,
};
would be better
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.
done, less change always looks better, I also checked, it is working, :)
742e5cf
to
2f85de0
Compare
Yes, I added more comments, please check again, if still have problems, you can refer to below link: |
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.
@aiChaoSONG @btian1 looks like zephyrproject-rtos/zephyr#43786 is closed. Good to remove the comment ?
Hi, Liam Althrough it was closed, however, this issue is WA by ifndef zephyr due to urgent schedule, now this PR fixed it, after this patch merge, I will reconsolidate another PR #6322 to remove those code with other performance code and test it on IPC4 fw build. Thanks |
@@ -234,3 +234,33 @@ void audio_stream_copy_to_linear(const struct audio_stream __sparse_cache *sourc | |||
snk += bytes_copied; | |||
} | |||
} | |||
|
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.
@btian1 why will cmocka tests require comp_copy() On the contrary the comp_drv interface will eventually be deprecated for all modules.
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.
because each cmocka module unit test need comp_copy, once move it from component_ext.h to component.c, cmocka need component.c to make comp_copy real.
regarding remove comp_drv, that's another topic for me, let's keep current solution, I can't wait until comp_drv disappearred.
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.
As far as I understand zephyrproject-rtos/zephyr#43786 affects only static inline
, which I believe is why you're moving this to a .c file. Correct?
If correct then why are you keeping the #ifndef __ZEPHYR__
? Are you not testing Zephyr?
Very confused sorry.
Hi, This change is low risk, hope this can be review and merge soon, then I can continue submit another PR for performance build. Thanks |
"I will finish this commit in the next commit" is not good. Each commit must have one logical change and anyone must be able to At the very least you should fix the comment or the commit message. Right now you're keeping unchanged the zephyrproject-rtos/zephyr#43786 reference to a static inline problem in a commit that moves away from a static inline?! Very confusing. Or maybe the commit message should say "this is the first step but there's still another problem that will be fixed next" |
changed, confirmed the bug has been fully fixed, please check again, and if no other issues, please +1 Thanks |
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.
@btian1 can you say the inline was blocked by old xcc. Was the code not producing correct results or not running at all ? Need to be clear in the commit message as a change like this is hard to understand unless you can paste the old data n the commit vs the new data.
previously, comp_copy is located in header file, type is static inline. however, current xcc is based on gcc 4.x version, does not support static inline log print, this block measure component performance. move it to source file will benefit code size, and have very small impact on performance, since this is component level function and only have one parameter. @lgirdwood , I explained in commit message with above, inline just block add log and profiling each module, there is no functionality impact for comp_copy. |
Hello, Reviewers, could you check again and approve this? this patch is only for profiling purpose: to add profiling log to comp_copy with zephyr + ipc4 build, without this change, logs can't added into comp_copy, then can't profiling each component. Thanks |
#endif | ||
|
||
ret = dev->drv->ops.copy(dev); | ||
int comp_copy(struct comp_dev *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.
I think this should be in component.h
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 is no component_ext.c for source file, so component.c can cover component_ext.h and component.h both.
and if move to component.h will cause much more changes, a lot of component_ext.h include will change to component.h.
Agree?
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.
component_ext.h contains all inline functions, no function prototype in it. while component.c and component.h are .c/.h pair.
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.
void sys_comp_init(struct sof *sof);
it have, also defined in component.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.
It seems quite confusing indeed. Some prototypes like comp_get_copy_limits() are in component.h while others like comp_new() are in component_ext.h. Given other copy relate functions have prototypes in component.h, I'd put comp_copy() there as well. @ranj063 @juimonen do you happen to recollect the history?
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 searched #include <sof/audio/component_ext.h> under SOF directory, it have nearly 50 place to include, if move it to component.h, it will cause much more source file to change.
I don't know history about component.h and compont_ext.h, but currently, they have same component.c source file.
even check component.h, it is mixed with macro, inline, prototype.
If we really want to change, I would suggest discuss first, then raise an CR to merge(or re-arrange) two header files
currently, suggest to keep, since component_ext also have prototype declaration, Agree?
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.
it have nearly 50 place to include, if move it to component.h, it will cause much more source file to change.
This would not be pleasant but it's not the end of world either: it's only a one-line change in each file so this would not break git
much. If this is really the best choice then don't be afraid to do it.
Most projects have some messy #include
s that no one really cares about... until someone tries to move something exactly like as you're doing here; it's typical. Sometimes this can trigger some #include
cleanup and that's usually a good thing.
Note: I do NOT know whether it's the best choice! Discuss and make sure first. Considering how longer and longer this thread is getting, a call should help.
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.
@btian1 I think keeping the comp_copy() declaration is component_ext.h is fine. All the other ops' declaration or definition are in this file. So I see no objection here
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 don't know history about component.h and compont_ext.h
Github's browsing features are very user-friendly. Sometimes I drop tig
and switch to the web browser instead!
...
(top right corner) -> View File -> Blame -> line 1 ->
comp: api: advanced and internal functions separated
The current content of component.h is a mix of basic api, common
basic helpers for every component developers as well as advanced
functions and macros used by infrastructure and very specialized
components like host, dai, kpb etc.
This patch moves the advanced part to component_ext.h and keeps
only basic part in component.h to avoid overloading effects
component developers with declarations and code they do not use.
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 this should be in component.h
No, it should not. It is a little helper function that hides comp driver/device details, called by the infrastructure. While the component.h was intended to declare things relevant for component implementors, see the commit message @marc-hb mentioned in the comment above. component.h had been overloaded and unreadable before component_ext.h was created to separate internal non-api things. Not sure if merging back is a good idea.
I think below commit message is much clearer.
|
@@ -470,7 +470,10 @@ static const struct comp_driver comp_mixer = { | |||
}, | |||
}; | |||
|
|||
static SHARED_DATA struct comp_driver_info comp_mixer_info = { | |||
#ifndef UNIT_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.
Why only mixer component needs these additions? Is there something in other components or their unit tests that helps to avoid to do these.
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 is because mixer cmocka test need this API for test purpose.
I changed commit message today, and Thanks |
@btian1 in these cases its always best in include the output before and after your change in your commit message. i.e. paste 2 lines of trace messages without your change and then 2 lines of trace with your change. This makes it really easy to see why it's needed as its difficult to understand why its been working so far (whilst it's "not supported" by XCC) |
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.
Looks almost ready to merge. Please see a few notes @btian1 inline.
#endif | ||
|
||
ret = dev->drv->ops.copy(dev); | ||
int comp_copy(struct comp_dev *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.
It seems quite confusing indeed. Some prototypes like comp_get_copy_limits() are in component.h while others like comp_new() are in component_ext.h. Given other copy relate functions have prototypes in component.h, I'd put comp_copy() there as well. @ranj063 @juimonen do you happen to recollect the history?
84fc720
to
d48cfec
Compare
@kv2019i , I talked with Ranjani this afternoon, she have no concern put it to component_ext.h, you can double confirm with her later. |
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.
Thanks @btian1 , good now!
Ready to go but waiting for CI results. |
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.
LGTM
|
||
/* copy only if we are the owner of the component */ | ||
if (cpu_is_me(dev->ipc_config.core)) { | ||
#if CONFIG_PERFORMANCE_COUNTERS |
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 are empty definitions of perf_...()
provided in the header for a configuration with CONFIG_PERFORMANCE_COUNTERS undefined, so it not necessary to use #if-s inside the caller's code. Also the code would be easier to maintain when number of #if-s is limited.
Similar CI error as with other PRs, and does not seem to be related. A force repush may be needed. |
done, force pushed again for this PR |
On sof zephyr ipc4 build, component performance profiling logs can't be enabled due to current xcc compiler does not support inline logging in header file, logs as below: log_level undeclared (first use in this function) log_current_const_data undeclared (first use in this function) Move comp_copy to component.c can resolve this limitation. However, this brings another cmocka issue for mixer unit test, this patch also fixed cmocka mixer unit test issue. BugLink: zephyrproject-rtos/zephyr#43786 Signed-off-by: Baofeng Tian <[email protected]>
Now all good (except for known Intel IPC4 failure), going ahead with merge. |
On sof zephyr ipc4 build, component performance profiling logs can't
be enabled due to current xcc compiler does not support inline
logging in header file, logs as below:
log_level undeclared (first use in this function)
log_current_const_data undeclared (first use in this function)
Move comp_copy to component.c can resolve this limitation.
However, this brings another cmocka issue for mixer unit test,
this patch also fixed cmocka mixer unit test issue.
BugLink: zephyrproject-rtos/zephyr#43786
Signed-off-by: Baofeng Tian [email protected]