-
Notifications
You must be signed in to change notification settings - Fork 139
ASoC: sof: add comments for non-atomic pcm trigger #506
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
ASoC: sof: add comments for non-atomic pcm trigger #506
Conversation
|
This is to fix the open #421 |
sound/soc/sof/pcm.c
Outdated
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.
@libinyang the comment here looks very ambiguous. A better place would be just a few lines above where we return 0 for BE:
/* nothing todo for BE */
We could call out that the trigger is purely for FE's and that the non-atomic field for FE's is explicitly set to true.
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.
@libinyang The ask was to clarify when we use non-atomic and if there are any differences with the other drivers. The current behavior for other drivers is non-atomic for FEs only
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.
@ranj063
Actually, it is not related to FE/BE trigger. Both FE/BE trigger will be in non-atomic environment in our case.
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.
@plbossart
Do you mean I should add the comment about why FE is non-atomic will cause the trigger non-atomic? I think this is a alsa/asoc level general question. I'm afraid that the maintainers may be not interested in this? For the comments, I believe we just need to explain why our code is OK. We don't need to explain what other drivers flow. What do you think?
From Takashi's comments, my understanding is Takashi just want to make sure trigger is in non-atomic environment, and when it is set. Maybe I misunderstand Takashi's meaning. If you think we need to explain why setting non-atomic in FE can make sure the trigger is in non-atomic environment, I will add the details.
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 just want to clarify what assumptions are made for FE and BE and check that this is aligned with the previous solutions. not sure what's so complicated?
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.
@plbossart
I think I got you now. Do you want the clarify in the comments of the code or the description header of the patch?
Today, I will work on hdmi audio patch firstly. Maybe the comments are ready tomorrow.
cf2913c to
c998df2
Compare
|
@plbossart |
sound/soc/sof/pcm.c
Outdated
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.
@libinyang this is too confusing to read. I think it is already quite clear that the trigger is in non-atomic context. The information we need to clarify is:
The SOF driver sets nonatomic to true for both BE and FE dai links.
But the legacy driver only sets nonatomic for FE dai links and not for BE dai links. Why is this different?
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.
@libinyang I think it is meaningless to set BE dai link to nonatomic, which is what we do now. I think we should change that and then clarify here that FE dai links are set to non-atomic because the trigger is always in non-atomic context.
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.
@libinyang I think it is meaningless to set BE dai link to nonatomic, which is what we do now. I think we should change that and then clarify here that FE dai links are set to non-atomic because the trigger is always in non-atomic context.
@ranj063
Yes, you got it :)
Do we set nonatomic for BE? I didn't find we define nonatomic for BE. Anyway, it is OK for us to define nonatomic for BE because it will be ignored whatever it is set.
|
@libinyang <https://github.com/libinyang> this is too confusing to
read. I think it is already quite clear that the trigger is in the
non-atomic context. The information we need to clarify is:
The SOF driver sets nonatomic to true for both BE and FE dai links.
But the legacy driver only sets nonatomic for FE dai links and not for
BE dai links. Why is this different?
Agree with Ranjani, her write-up is what I asked for initially.
And in addition to comments we'd want actual fixes since we seem to do
the opposite of what everyone else does.
|
@plbossart |
Yes, we do set it for BE's. |
@ranj063 |
|
@libinyang maybe it doesnt matter but it cant be explained. So better to remove it and then mention that FE trigger is always in non-atomic context. |
@ranj063 If we remove it, it means we will set BE as atomic. Is there any benifit to set BE as atomic? I'm OK to set BE as atomic, but maybe it is not necessary to do it. What do you think? |
|
@libinyang if we remove it, it doesnt mean we are setting it to atomic, we're just not setting it to non-atomic. Anyway, if you look at the FW dai link definitions in the legacy drivers, we explicitly set nonatomic to true only for FE's and not BE dai links. At least this way we'll be consistent with them. |
@ranj063 |
|
@libinyang I think the expectation for this PR was that we explain whatever we are doing properly. If you want to set BE dai link to non-atomic, thats fine. Just please make sure you can back it up with a proper explanation. |
@ranj063 I understand. If both you and Pierre are OK, I will remove the nonatomic setting for BE. I just think it is not necessary to do that. |
|
@libinyang if I did this PR, i'd set the non-atomic only for FE's dai links and then in the trigger callback, i'd make it clear that the trigger is always in non-atomic context. This way, a reviewer will know to connect them both. |
|
@ranj063 |
c998df2 to
befc2f8
Compare
|
I have refined the patch based on your requirement. Could you please help review if it is OK? |
plbossart
left a 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.
Sorry, more work needed on the wording. English isn't the most straightforward language so it helps to keep the explanations logical and simple.
sound/soc/sof/topology.c
Outdated
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.
FE trigger is not executed in an atomic environment.?
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.
BE->no_pcm is true and FE->no_pcm is false. So in our case (!link->no_pcm), FE will be true and will be set nonatomic = 1;
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.
And in FE trigger, it is not executed in an atomic environment because sof_ipc_tx_message() needs to be in non-atomic environment.
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.
@libinyang Pierre's only asking to re-word your comment to
" FE trigger is not executed in atomic context". not asking for an explanation
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.
@libinyang Pierre's only asking to re-word your comment to
" FE trigger is not executed in atomic context". not asking for an explanation
@ranj063 @plbossart
I understand your means...
Sorry for my poor understanding...
sound/soc/sof/pcm.c
Outdated
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 @libinyang, I find your answers convoluted. I was expecting something like
The FE can be triggered in a non-atomic environment because ..... The non-atomic property is set in the DAI link and copied into the PCM fields.
The BE link does not set the non-atomic property because ...
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.
Got it. I will change the comments.
955e640 to
d97dbd1
Compare
plbossart
left a 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.
The comments are not quite what I was expecting. I'd like code reviewers to have a clear explanation as to why the FE trigger will happen in a non-atomic context and the BE trigger will happen in a atomic one.
In other words, I am not asking for how the .non-atomic information is propagated from dailink to PCM but WHY it's set in the first place.
sound/soc/sof/pcm.c
Outdated
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 @libinyang, you are describing the actions when the .non-atomic field is set in the dailink but not the rationale behind setting this .non-atomic field.
Again we need to explain WHY the FE needs this .non-atomic field set and the BE does not.
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.
How about explaining "WHY FE PCM is set .non-atomic" in topology.c, and just mention here that PCMs are .non-atomic so sending IPC here is safe?
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.
@plbossart
Really thanks for your patient on my patch. I will sync with Ranjani and Keyon firstly and update the patch later. Hope this can save your time and speed up this patch merging process. Thanks.
Add the comments to why explain non-atomic is set in topology parsing. So it is safe to call sof_ipc_tx_message() in the trigger callback. Only FE need nonatomic = 1 Signed-off-by: Libin Yang <libin.yang@intel.com> Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
d97dbd1 to
f375e19
Compare
|
@plbossart |
|
allow me to double-check the logic: |
@plbossart yes, that correct. We return after doing nothing in the trigger routine for BE dai links. So it is safe for it to be atomic. |
|
BE will do nothing for the pcm action. |
plbossart
left a 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.
ok let's merge.
This fixes #421
Add the comments in pcm trigger to explain non-atomic is
set in topology parsing. So it is safe to call
sof_ipc_tx_message() in the trigger callback.
Signed-off-by: Libin Yang libin.yang@intel.com