Skip to content

Conversation

@libinyang
Copy link

@libinyang libinyang commented Jan 7, 2019

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

@mengdonglin
Copy link

This is to fix the open #421

Copy link
Collaborator

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.

Copy link
Member

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

Copy link
Author

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.

Copy link
Author

@libinyang libinyang Jan 8, 2019

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.

Copy link
Member

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?

Copy link
Author

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.

@libinyang libinyang force-pushed the non-atomic_comments branch from cf2913c to c998df2 Compare January 10, 2019 13:23
@libinyang
Copy link
Author

@plbossart
patch is updated for non-atomic comments.

Copy link
Collaborator

@ranj063 ranj063 Jan 11, 2019

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?

Copy link
Collaborator

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.

Copy link
Author

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.

@plbossart
Copy link
Member

plbossart commented Jan 11, 2019 via email

@libinyang
Copy link
Author

@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
Do we set nonatomic for BE? I'm afraid not. We only set FE as nonatomic. And please my updated patch, I have explained why set for FE is enough.

@ranj063
Copy link
Collaborator

ranj063 commented Jan 12, 2019

@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
Do we set nonatomic for BE? I'm afraid not. We only set FE as nonatomic. And please my updated patch, I have explained why set for FE is enough.

Yes, we do set it for BE's.
take a look at the line 2349 in topology.c in sof_link_load():
link->nonatomic = true;

@libinyang
Copy link
Author

Yes, we do set it for BE's.
take a look at the line 2349 in topology.c in sof_link_load():
link->nonatomic = true;

@ranj063
Yes, it is set here :). However, it is OK to set nonatomic. It doesn't matter.

@ranj063
Copy link
Collaborator

ranj063 commented Jan 12, 2019

@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.

@libinyang
Copy link
Author

@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?

@ranj063
Copy link
Collaborator

ranj063 commented Jan 14, 2019

@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.

@libinyang
Copy link
Author

@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
As Pierre mentioned, if you don't set nonatomic, it means nonatomic is default to 0, this means it nonatomic is false :)
We don't need to make SOF be the same as cAVS. Actually, I think our SOF is better than cAVS in the nonatomic setting ;-)

@ranj063
Copy link
Collaborator

ranj063 commented Jan 14, 2019

@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.

@libinyang
Copy link
Author

@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.

@ranj063
Copy link
Collaborator

ranj063 commented Jan 14, 2019

@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.

@libinyang
Copy link
Author

@ranj063
OK. I will update the patch later. Maybe today or tomorrow after my test on the new patch.

@libinyang libinyang force-pushed the non-atomic_comments branch from c998df2 to befc2f8 Compare January 15, 2019 06:22
@libinyang
Copy link
Author

@plbossart

I have refined the patch based on your requirement. Could you please help review if it is OK?

Copy link
Member

@plbossart plbossart left a 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.

Copy link
Member

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.?

Copy link
Author

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;

Copy link
Author

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.

Copy link
Collaborator

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

Copy link
Author

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...

Copy link
Member

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 ...

Copy link
Author

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.

@libinyang libinyang force-pushed the non-atomic_comments branch 3 times, most recently from 955e640 to d97dbd1 Compare January 17, 2019 07:05
Copy link
Member

@plbossart plbossart left a 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.

Copy link
Member

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.

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?

Copy link
Author

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>
@libinyang libinyang force-pushed the non-atomic_comments branch from d97dbd1 to f375e19 Compare January 22, 2019 05:43
@libinyang
Copy link
Author

@plbossart
Patch is updated. Thanks.

@plbossart
Copy link
Member

allow me to double-check the logic:
We set the FEs as non-atomic because they involve IPC
So we set the BEs as atomic because they don't involve IPCs.
Is the latter point correct?

@ranj063
Copy link
Collaborator

ranj063 commented Jan 22, 2019

allow me to double-check the logic:
We set the FEs as non-atomic because they involve IPC
So we set the BEs as atomic because they don't involve IPCs.
Is the latter point correct?

@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.

@libinyang
Copy link
Author

BE will do nothing for the pcm action.

Copy link
Member

@plbossart plbossart left a 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.

@plbossart plbossart merged commit 4b60986 into thesofproject:topic/sof-dev Jan 23, 2019
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.

Upstream: Patch 5/14: pcm: need comments on non-atomic trigger

5 participants