Skip to content

put audio to D3 if no d0i3 compatible stream opened. - #1418

Merged
plbossart merged 4 commits into
thesofproject:topic/sof-devfrom
keyonjie:d0ix_dapm
Nov 11, 2019
Merged

plbossart merged 4 commits into
thesofproject:topic/sof-devfrom
keyonjie:d0ix_dapm

Conversation

@keyonjie

Copy link
Copy Markdown
When there is d0i3_compatible stream opened, mark the d0i3_suspend flag
which will help to put audio to D0I3 state in the coming PM suspend
callback, and clear the flag once the stream are triggered resumed.

@ranj063

ranj063 commented Oct 31, 2019

Copy link
Copy Markdown
Collaborator

@keyonjie one more flag to add to the list of flags we already for D0i3 support?
How about you iterate through the spcm list and see if any of them have their suspend_ignored flag set and then make the decision to enter S0i3 or D3 accordingly?

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

@keyonjie I don't know how many times I have explained that you can be in D0i3 in both S0 and S0ix states. Please don't take shortcuts again and lump S0ix and D0ix together.

Comment thread sound/soc/sof/sof-priv.h Outdated
/* power states related */
enum sof_d0_substate d0_substate;
/* flag to track if the intended power target of suspend is S0ix */
/* flag to track if the intended power target of the system is S0ix */

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.

intended S state is S0ix.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

OK.

Comment thread sound/soc/sof/sof-priv.h Resolved
Comment thread sound/soc/sof/pm.c Resolved
@keyonjie

keyonjie commented Nov 1, 2019

Copy link
Copy Markdown
Author

@keyonjie I don't know how many times I have explained that you can be in D0i3 in both S0 and S0ix states. Please don't take shortcuts again and lump S0ix and D0ix together.

Yes, as explained in the replying to your detail comment, this was in my to-do list, if the conclusion is that we still need support D0ix in S0, then please help shed lights on:

  1. what kind of solution do you prefer? I have thought about:
    a. using our existed runtime PM ops for the S0 D0ix enter/exit when the runtime suspend/resume are invoked. This will require changes in soc-pcm.c, I did investigate in the very beginning of the D0ix task and managed it work, but the changing in ASoC core may not be liked by the community.
    b. creating another platform device for this specific task which I posted it PR#1234, that will simplify the logic handling, but someone might not like the idea that creating an extra platform device just for this d0<->d0i3 dynamic transition task.
    c. using ref_count and delayed work to handle this D0<->D0I3 transition, which I posted early in PR [RFC DO NOT MERGE]SOF D0ix support #1154, it can also work, except the concerned about the handling to the cancellation and updating to the delayed work, it could be error-prone there.

  2. after multiple ssp and icelake support #1 is chosen, we need clear state machines for both D0(including D0I3) <->D3 and D0<->D0I3, I drew them in the comments inside my commits in the PR#1154 {which actually took quite long time to do that in text only), we need to align on these state machines before doing the real coding.

  3. the customization and reconfigurability. It could be customer flavor choice for these kinds of transition, e.g. some customers don't want the D0I3 in S0, some customers want to enter to D0I3 for either S0 suspend or S0Ix suspend to provide a fast audio response (we can get a fast audio resume from a suspending). So, we need to make them configurable, what's your suggestion here?

@ranj063

ranj063 commented Nov 1, 2019 •

Copy link
Copy Markdown
Collaborator

@plbossart @keyonjie there are 2 different asks here:

  1. Putting the DSP in D3 when the system is entering into S0ix and there are no active pipelines
  2. Putting the DSP in D0i3 when the system is in S0

"1" is a minor change in our current flow and easy to implement.

"2" is a bigger ask and of course a mandatory one. I think we already discussed this and we want to go with the delayed work solution that the skylake driver has implemented.

But I don't think we need to tie these two together at all.

@ranj063

ranj063 commented Nov 1, 2019

Copy link
Copy Markdown
Collaborator

@keyonjie I don't know how many times I have explained that you can be in D0i3 in both S0 and S0ix states. Please don't take shortcuts again and lump S0ix and D0ix together.

Yes, as explained in the replying to your detail comment, this was in my to-do list, if the conclusion is that we still need support D0ix in S0, then please help shed lights on:

  1. what kind of solution do you prefer? I have thought about:
    a. using our existed runtime PM ops for the S0 D0ix enter/exit when the runtime suspend/resume are invoked. This will require changes in soc-pcm.c, I did investigate in the very beginning of the D0ix task and managed it work, but the changing in ASoC core may not be liked by the community.
    b. creating another platform device for this specific task which I posted it PR#1234, that will simplify the logic handling, but someone might not like the idea that creating an extra platform device just for this d0<->d0i3 dynamic transition task.
    c. using ref_count and delayed work to handle this D0<->D0I3 transition, which I posted early in PR [RFC DO NOT MERGE]SOF D0ix support #1154, it can also work, except the concerned about the handling to the cancellation and updating to the delayed work, it could be error-prone there.
  2. after multiple ssp and icelake support #1 is chosen, we need clear state machines for both D0(including D0I3) <->D3 and D0<->D0I3, I drew them in the comments inside my commits in the PR#1154 {which actually took quite long time to do that in text only), we need to align on these state machines before doing the real coding.
  3. the customization and reconfigurability. It could be customer flavor choice for these kinds of transition, e.g. some customers don't want the D0I3 in S0, some customers want to enter to D0I3 for either S0 suspend or S0Ix suspend to provide a fast audio response (we can get a fast audio resume from a suspending). So, we need to make them configurable, what's your suggestion here?

@keyonjie I dont think the latency of resuming from D0i3 will be noticeable enough to disable D0i3 in S0. Its as good or probably lesser than resuming from D3 in the case of runtime PM. I wouldnt worry about making this configurable if you ask me. If the DSP supports D0i3, it will be the only option.

@keyonjie

keyonjie commented Nov 1, 2019

Copy link
Copy Markdown
Author

@plbossart @keyonjie there are 2 different asks here:

  1. Putting the DSP in D3 when the system is entering into S0ix and there are no active pipelines
  2. Putting the DSP in D0i3 when the system is in S0

"1" is a minor change in our current flow and easy to implement.

"2" is a bigger ask and of course a mandatory one. I think we already discussed this and we want to go with the delayed work solution that the skylake driver has implemented.

But I don't think we need to tie these two together at all.

Thanks for summarizing @ranj063 Yes, @plbossart this PR only aims to fix "1".

@plbossart

Copy link
Copy Markdown
Member

@keyonjie what I am asking is an infrastructure in place to deal with all possible transitions. It's ok if we don't implement all transitions, e.g. we could do the idle detection last, but I don't want to keep changing the code and adding new flags all the time. We have to show in our upstream contributions we understand what we are doing and the development follows a logical progression. This specific PR is an ad-hoc fix and it doesn't scale to the future cases, so let's do things right please.

@keyonjie

keyonjie commented Nov 1, 2019 •

Copy link
Copy Markdown
Author

@keyonjie what I am asking is an infrastructure in place to deal with all possible transitions. It's ok if we don't implement all transitions, e.g. we could do the idle detection last, but I don't want to keep changing the code and adding new flags all the time. We have to show in our upstream contributions we understand what we are doing and the development follows a logical progression. This specific PR is an ad-hoc fix and it doesn't scale to the future cases, so let's do things right please.

Got your point and understood your concern about adding flags now and removing them later, back and forth, let me try to make this PR more clear and scalable for adding runtime D0I3 support.

@keyonjie

keyonjie commented Nov 1, 2019 •

Copy link
Copy Markdown
Author

@keyonjie one more flag to add to the list of flags we already for D0i3 support?
How about you iterate through the spcm list and see if any of them have their suspend_ignored flag set and then make the decision to enter S0i3 or D3 accordingly?

@ranj063 that should work also, my point here is that using the flag d0i3_suspend is more straight-forward and efficient, so, with this new added one, we have 3 flags in total:

d0_substate: to indicate if we are in D0 or D0I3 when the system is in S0, this will be useful for the coming D0I3 in S0 support.
s0_suspend: to indicate if the system is entering s2idle or s3, it is needed for us to make decision of stopping d0i3_compatible pipelines or not during the audio suspending.
d0i3_suspend: to indicate if we are going to put audio to d0i3 or d3 during suspending.

Using a separated d0i3_suspend flag will help for the configurable suspend/resume logic in the future, e.g. we could force to put audio DSP to d0i3 (if the platform support d0i3) for suspending always if it is required, then the logic might not be the suspend_ignored flag set there.

@ranj063

ranj063 commented Nov 1, 2019

Copy link
Copy Markdown
Collaborator

d0_substate: to indicate if we are in D0 or D0I3 when the system is in S0, this will be useful for the coming D0I3 in S0 support.
s0_suspend: to indicate if the system is entering s2idle or s3, it is needed for us to make decision of stopping d0i3_compatible pipelines or not during the audio suspending.
d0i3_suspend: to indicate if we are going to put audio to d0i3 or d3 during suspending.

@keyonjie you forgot "d0i3_compatible".

For you and I, these all make perfect sense. For someone new to the implementation, it can be quite confusing to understand. In my opinion: only 2 flags are mandatory:

  1. S0_suspend: to indicate whether the system is entering S0ix or S3
  2. d0i3_compatible: to indicate whether the pipeline can be active in D0i3 or not.

Everything else should be handled with appropriate logic.

@plbossart

Copy link
Copy Markdown
Member
  1. S0_suspend: to indicate whether the system is entering S0ix or S3

I think we are missing information on whether the platform supports S0ix or not. This is BIOS dependent and the kernel should know about it.

@ranj063

ranj063 commented Nov 1, 2019

Copy link
Copy Markdown
Collaborator

I think we are missing information on whether the platform supports S0ix or not. This is BIOS dependent and the kernel should know about it.

@plbossart if the platform doesnt support S0ix, then S0_suspend would always be false isnt it?
Are your saying that the kernel should be aware of this beforehand and ignore everything to do with the S0ix entry logic?

@plbossart

plbossart commented Nov 1, 2019 •

Copy link
Copy Markdown
Member

I think we are missing information on whether the platform supports S0ix or not. This is BIOS dependent and the kernel should know about it.

@plbossart if the platform doesnt support S0ix, then S0_suspend would always be false isnt it?
Are your saying that the kernel should be aware of this beforehand and ignore everything to do with the S0ix entry logic?

If the platform does not support S0ix, then we should remain in S0 if there is a D0ix_compatible stream. That means not changing the PCI state and stuff.

@ranj063

ranj063 commented Nov 1, 2019

Copy link
Copy Markdown
Collaborator

If the platform does not support S0ix, then we should remain in S0 if there is a D0ix_compatible stream. That means not changing the PCI state and stuff.

Ahh I see. If S0ix is not supported, the audio power domain will not be power gated with the DSP in D0i3. This will prevent the S3 entry automatically right?

@plbossart

Copy link
Copy Markdown
Member

If the platform does not support S0ix, then we should remain in S0 if there is a D0ix_compatible stream. That means not changing the PCI state and stuff.

Ahh I see. If S0ix is not supported, the audio power domain will not be power gated with the DSP in D0i3. This will prevent the S3 entry automatically right?

not many double negatives for me...

S0: D0, D0ix, D3
S0ix: D0ix, D3
S3: D3

if S0ix is not supported, we still need to support S0 and S3.

What's misleading is that 'suspend to S0' means different things depending if S0ix is supported or not. We don't have a 'suspend to S0ix', we have to infer it based on platform information when we get the 'suspend to S0' request.

@keyonjie

keyonjie commented Nov 1, 2019

Copy link
Copy Markdown
Author

d0_substate: to indicate if we are in D0 or D0I3 when the system is in S0, this will be useful for the coming D0I3 in S0 support.
s0_suspend: to indicate if the system is entering s2idle or s3, it is needed for us to make decision of stopping d0i3_compatible pipelines or not during the audio suspending.
d0i3_suspend: to indicate if we are going to put audio to d0i3 or d3 during suspending.

@keyonjie you forgot "d0i3_compatible".

That is for stream, not sdev. for snd_sof_pcm_stream, we have one more actually :-), suspend_ignored.

For you and I, these all make perfect sense. For someone new to the implementation, it can be quite confusing to understand. In my opinion: only 2 flags are mandatory:

  1. S0_suspend: to indicate whether the system is entering S0ix or S3
  2. d0i3_compatible: to indicate whether the pipeline can be active in D0i3 or not.

If we don't have d0i3, how can people understand d0i3_compatible?

Everything else should be handled with appropriate logic.

@keyonjie

keyonjie commented Nov 1, 2019

Copy link
Copy Markdown
Author

If the platform does not support S0ix, then we should remain in S0 if there is a D0ix_compatible stream. That means not changing the PCI state and stuff.

Ahh I see. If S0ix is not supported, the audio power domain will not be power gated with the DSP in D0i3. This will prevent the S3 entry automatically right?

not many double negatives for me...

S0: D0, D0ix, D3
S0ix: D0ix, D3
S3: D3

if S0ix is not supported, we still need to support S0 and S3.

These make sense to me.

What's misleading is that 'suspend to S0' means different things depending if S0ix is supported or not. We don't have a 'suspend to S0ix', we have to infer it based on platform information when we get the 'suspend to S0' request.

Sorry, @ranj063 don't catch your means by 'if the platform doesnt support S0ix' and 'don't have a suspend to S0ix', do you mean the case our .suspend() will not be called in some cases on some platforms? or we can't set 'freeze' to /sys/power/state, or can't set 's2idle' to /sys/power/mem_sleep ?

@ranj063

ranj063 commented Nov 1, 2019

Copy link
Copy Markdown
Collaborator

Sorry, @ranj063 don't catch your means by 'if the platform doesnt support S0ix' and 'don't have a suspend to S0ix', do you mean the case our .suspend() will not be called in some cases on some platforms? or we can't set 'freeze' to /sys/power/state, or can't set 's2idle' to /sys/power/mem_sleep ?

@keyonjie that was Pierre's comment. But basically there can be platforms that only support S0 and S3. In such cases, if there are any D0i3 compatible streams running, we should suspend them and enter S3 when it is requested.

@keyonjie

keyonjie commented Nov 1, 2019

Copy link
Copy Markdown
Author

Sorry, @ranj063 don't catch your means by 'if the platform doesnt support S0ix' and 'don't have a suspend to S0ix', do you mean the case our .suspend() will not be called in some cases on some platforms? or we can't set 'freeze' to /sys/power/state, or can't set 's2idle' to /sys/power/mem_sleep ?

@keyonjie that was Pierre's comment. But basically there can be platforms that only support S0 and S3. In such cases, if there are any D0i3 compatible streams running, we should suspend them and enter S3 when it is requested.

In this case, the s0_suspend will be false, we will enter D3 with today's code.

@ranj063

ranj063 commented Nov 2, 2019

Copy link
Copy Markdown
Collaborator

Sorry, @ranj063 don't catch your means by 'if the platform doesnt support S0ix' and 'don't have a suspend to S0ix', do you mean the case our .suspend() will not be called in some cases on some platforms? or we can't set 'freeze' to /sys/power/state, or can't set 's2idle' to /sys/power/mem_sleep ?

@keyonjie that was Pierre's comment. But basically there can be platforms that only support S0 and S3. In such cases, if there are any D0i3 compatible streams running, we should suspend them and enter S3 when it is requested.

In this case, the s0_suspend will be false, we will enter D3 with today's code.

@keyonjie perfect thats what the question was about.

@ranj063

ranj063 commented Nov 2, 2019

Copy link
Copy Markdown
Collaborator

@keyonjie in your next update for S0ix/D0i3, lets try to draw the state machine to show the transitions that are permitted to make it clearer

Comment thread sound/soc/sof/pm.c
* d0i3_suspend = s0_suspend && D0I3 stream opened,
* D3 suspend = !d0i3_suspend,
*/

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.

@keyonjie in my interpretation there are only 3 states for the DSP (D0, D0i3 and D3) So it is a bit confusing when your say D3 runtime-suspended and D3 suspended. Its not quite clear what it really means.

I made a simpler diagram. Let me know if you cant understand my handwriting. I may have missed something but I think this shows the transitions between the DSP states better.
IMG_20191104_161010

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.

The above diagram only applies if the platform supports D0i3. The other thing is this diagram is intel specific. So needs to be moved there

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@keyonjie in my interpretation there are only 3 states for the DSP (D0, D0i3 and D3) So it is a bit confusing when your say D3 runtime-suspended and D3 suspended. Its not quite clear what it really means.

I made a simpler diagram. Let me know if you cant understand my handwriting. I may have missed something but I think this shows the transitions between the DSP states better.
IMG_20191104_161010

Thanks, basically, I think your diagram is good to describe to DSP state transitions, except that it doesn't include:

  1. the runtime PM ops handling (the left-upper part in my diagram), we can treat the DSP state in runtime-suspended as a sub-state of D0 in your diagram, and don't care about its internal transition?
  2. the difference of S0 D0i3 and S0Ix D0i3. In your diagram, you try to include both in D0<-->D0i3, but it doesn't describe how should we handle when the S0Ix suspend arrive if we are already in S0 D0i3, which is we need to do here in pm.c:snd_sof_suspend/resume(). Yes, again, we can treat both S0-D0i3 and S0Ix-D0i3 as sub-states of D0i3 and ignore its internal transition here.

Then should we draw another diagram to describe the internal transition for '2' and '1'?

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 knew I missed something and yes the runtime PM case is important. Let me add it and send you a new diagram in a bit

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.

agree with Ranjani, there is no difference between runtime_suspended D3 and system_suspended D3. it's D3.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

um, it depends on how do you define the DSP state, e.g. we may put DSP to lower power state D0i3 when the system is in S0ix suspended, comparing with the S0 D0i3, so the flags in PM_GATE IPC will be different for them.

I am fine to use the simpler diagram here to make it easier for understanding, but we need to keep in mind that we still have difference scenarios(or called sub-state) inside both the D3 and D0i3 state, when we are in coding of the detail logic handling there.

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.

um, it depends on how do you define the DSP state, e.g. we may put DSP to lower power state D0i3 when the system is in S0ix suspended, comparing with the S0 D0i3, so the flags in PM_GATE IPC will be different for them.

@keyonjie Why would it be different in S0? Why cant you put the DSP in the same lower power D0i3 in S0?

@keyonjie keyonjie Nov 5, 2019 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

um, it depends on how do you define the DSP state, e.g. we may put DSP to lower power state D0i3 when the system is in S0ix suspended, comparing with the S0 D0i3, so the flags in PM_GATE IPC will be different for them.

@keyonjie Why would it be different in S0? Why cant you put the DSP in the same lower power D0i3 in S0?

For example, per my observation, in S0 D0i3, access to memory windows is possible, and we are planning to keep DMA trace active in this state for debug purpose, but when the system is entering S0ix, everything is changed, I don't have enough knowledge to explain how PMC will handling to the audio domain on S0ix entering, but I am quite sure the behavior of the Audio DSP in this S0ix D0i3 has difference with the one in S0 D0i3.

And, from the system point of view, we might need more normal interaction between FW & host in S0 D0i3 without putting the DSP back to D0, which is impossible in S0ix D0i3. When we are in S0ix D0i3, the only interaction between DSP and host is that the FW will send an IPC to wake the host up.

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.

Then you have different definitions of D0i3....
You should have one well defined behavior. If you have multiple behaviors, then you are not validating the same things.
I think the memory windows and DMA should only be allowed in D0i3_streaming. @mmaka1 and @lbetlej mentioned this state when we started this, and maybe it's time to formally recognize the difference between usages.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Then you have different definitions of D0i3....
You should have one well defined behavior. If you have multiple behaviors, then you are not validating the same things.
I think the memory windows and DMA should only be allowed in D0i3_streaming. @mmaka1 and @lbetlej mentioned this state when we started this, and maybe it's time to formally recognize the difference between usages.

Oh yes, that is a major scenario of S0 D0i3, I think.

@keyonjie

keyonjie commented Nov 5, 2019 •

Copy link
Copy Markdown
Author

Hi @ranj063 , how about this diagram?

/*
 * Audio DSP states may transform as below:-
 *
 *					   D0I3+compatible stream
 *     Runtime	  +---------------------+   opened only, timeout
 *     suspend	  |			+--------------------+
 *   +------------+	  D0(active)	|		     |
 *   |		  |			<---------------+    |
 *   |	 +-------->			| The last D0i3 |    |
 *   |	 |Runtime +--^--+---------^--+--+ stream closed |    |
 *   |	 |resume     |	|	  |  |			|    |
 *   |	 |	     |	|	  |  |			|    |
 *   |	 |     resume|	|	  |  |			|    |
 *   |	 |	from |	| D3	  |  | d0i3		|    |
 *   |	 |	 D3  |	|suspend  |  | suspend	 +------+----v----+
 *   |	 |	     |	|	  |  |		 |		  +--------+
 *   |	 |	     |	|	  |  |		 | D0I3 run-time  |	   |
 *   |	 |	     |	|	  |  |		 |		  +------+ |
 * +-v---+------+----+--v-------+ |  |		 +----------------+	 | |
 * |		|		| |  +----------->		  | D0I3 | |
 * | D3 run-time| D3 suspended	| |		 | D0I3 suspended <------+ |
 * | suspended	|		| +--------------+		  |suspend |
 * |		|		|  resume from	 |		  |	   |
 * +------------+------^--------+  d0i3 suspend  +----------------+	   |
 *		       |						   |
 *		       |		       D3 suspend		   |
 *		       +---------------------------------------------------+
 *
 * d0i3 suspend = s0_suspend && D0I3 stream opened,
 * D3 suspend = !(d0i3 suspend).
 */

@ranj063

ranj063 commented Nov 5, 2019

Copy link
Copy Markdown
Collaborator

Hi @ranj063 , how about this diagram?

/*
 * Audio DSP states may transform as below:-
 *
 *					   D0I3+compatible stream
 *     Runtime	  +---------------------+   opened only, timeout
 *     suspend	  |			+--------------------+
 *   +------------+	  D0(active)	|		     |
 *   |		  |			<---------------+    |
 *   |	 +-------->			| The last D0i3 |    |
 *   |	 |Runtime +--^--+---------^--+--+ stream closed |    |
 *   |	 |resume     |	|	  |  |			|    |
 *   |	 |	     |	|	  |  |			|    |
 *   |	 |     resume|	|	  |  |			|    |
 *   |	 |	from |	| D3	  |  | d0i3		|    |
 *   |	 |	 D3  |	|suspend  |  | suspend	 +------+----v----+
 *   |	 |	     |	|	  |  |		 |		  +--------+
 *   |	 |	     |	|	  |  |		 | D0I3 run-time  |	   |
 *   |	 |	     |	|	  |  |		 |		  +------+ |
 * +-v---+------+----+--v-------+ |  |		 +----------------+	 | |
 * |		|		| |  +----------->		  | D0I3 | |
 * | D3 run-time| D3 suspended	| |		 | D0I3 suspended <------+ |
 * | suspended	|		| +--------------+		  |suspend |
 * |		|		|  resume from	 |		  |	   |
 * +------------+------^--------+  d0i3 suspend  +----------------+	   |
 *		       |						   |
 *		       |		       D3 suspend		   |
 *		       +---------------------------------------------------+
 *
 * d0i3 suspend = s0_suspend && D0I3 stream opened,
 * D3 suspend = !(d0i3 suspend).
 */

@keyonjie I would not separate D3 and D0i3 (based on runtime PM or system suspend) at all. That gives an impression of them being 2 separate states when in fact there is no difference.

@plbossart

Copy link
Copy Markdown
Member

@keyonjie I would not separate D3 and D0i3 (based on runtime PM or system suspend) at all. That gives an impression of them being 2 separate states when in fact there is no difference.

Not to mention that D0i3 runtime does not exist - the transitions are not handled by pm_runtime but by an idle detection at the device level (orthogonal to pm_runtime).

@plbossart

Copy link
Copy Markdown
Member

@keyonjie can you try and prioritize this, we have a number of QA tests failing because of the S0ix issues and s2idle being broken

@keyonjie

keyonjie commented Nov 7, 2019

Copy link
Copy Markdown
Author

@keyonjie can you try and prioritize this, we have a number of QA tests failing because of the S0ix issues and s2idle being broken

Sure, let me do this now.

@keyonjie

keyonjie commented Nov 7, 2019

Copy link
Copy Markdown
Author

@plbossart @ranj063 updated.

@keyonjie
keyonjie requested a review from ranj063 November 7, 2019 22:36
@ranj063

ranj063 commented Nov 7, 2019 •

Copy link
Copy Markdown
Collaborator

@keyonjie even though sequence you have seems OK, I am a bit uncomfortable with setting the sdev->d0i3_suspend flag every time a D0i3-compatible pipeline executing its TRIGGER suspend callback.

If I were you, I would just check if we're entering S0ix and a D0i3-compatible pipeline is running in the suspend callback and make the decision

@keyonjie

keyonjie commented Nov 8, 2019

Copy link
Copy Markdown
Author

@ranj063 makes sense, adding a helper to iterate the list, to remove usage of this extra flag now.

Comment thread sound/soc/sof/core.c Outdated
return NULL;
}

bool snd_sof_pcm_d0i3_suspend(struct snd_sof_dev *sdev)

@ranj063 ranj063 Nov 8, 2019 •

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.

@keyonjie fix commit message:
"Add helper to check if the DSP should be put in D0i3. This function returns true if a stream has ignored
the SUSPEND trigger to keep the pipeline running in the DSP"

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 why call it pcm_D0i3_suspend? I think snd_sof_dsp_D0i3_suspend() makes better sense no?

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.

@ranj063 @keyonjie is there a goto document to understand PM states. I must admit I have little experience with this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

and why call it pcm_D0i3_suspend? I think snd_sof_dsp_D0i3_suspend() makes better sense no?

The intention was to emphasize that it is from the view of the stream/pcm point as what we were doing inside is iterating the stream list only.

@keyonjie keyonjie Nov 8, 2019 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@ranj063 @keyonjie is there a goto document to understand PM states. I must admit I have little experience with this.

Oh yes @dbaluta it is in my last commit, we draw a state machine diagram there, see?

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.

The intention was to emphasize that it is from the view of the stream/pcm point as what we were doing inside is iterating the stream list only.

Right but what you're setting is the state for the DSP and not the pcm. So I dont think pcm in the name is relevant

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

OK, let me change it.

Comment thread sound/soc/sof/pm.c Outdated
int ret;

if (sdev->s0_suspend) {
if (snd_sof_pcm_d0i3_suspend(sdev)) {

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.

@keyonjie forgot to change the name here? and below?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

oops, my bad, shouldn't ignore compiling test for each change.

ranj063
ranj063 previously approved these changes Nov 8, 2019

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

looks good now, thanks!

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

@keyonjie minor change on the naming needed, see below.
Can you take care of this ASAP, I'd like to merge this so that all suspend/resume tests can be checked with SoundWire overnight.
Thanks!

Comment thread sound/soc/sof/pm.c Outdated
int ret;

if (sdev->s0_suspend) {
if (snd_sof_dsp_d0i3_suspend(sdev)) {

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.

the changes look odd.

in the resume() you call a suspend() operation, which means the naming isn't quite right.

snd_sof_dsp_d0i3_used() would make more sense to me.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

How about snd_sof_is_d0i3_suspend(), @plbossart ?

@plbossart plbossart Nov 11, 2019 •

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.

it's also confusing to use snd_sof_is_d0i3_suspend() in a resume() routine.

maybe snd_sof_dsp_d0i3_on_suspend() ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

it's also confusing to use snd_sof_is_d0i3_suspend() in a suspend() routine.

maybe snd_sof_dsp_d0i3_on_suspend() ?

Sounds good, changing it now.

Add check before seeting d0_substate and return success if Audio DSP is
already in the target substate.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Add helper to check if the DSP should be put in D0i3. This function
returns true if a stream has ignored the SUSPEND trigger to keep the
pipelines running in the DSP.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
We should suspend audio to D3 by default, for the sake of power saving,
change the condition of D0I3 suspending here to that when there is
stream with suspend_ignored specified.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Add Audio DSP state machine with comments, be noticed that the
'D0<-->runtime D0I3' part is not implemented yet.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>

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

thanks @keyonjie

@keyonjie
keyonjie requested a review from ranj063 November 11, 2019 22:07
@plbossart
plbossart merged commit f55db62 into thesofproject:topic/sof-dev Nov 11, 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.

4 participants