diff mbox

ASoC: pcm: allow delayed suspending request by users

Message ID 1451994289-29256-1-git-send-email-vinod.koul@intel.com (mailing list archive)
State Accepted
Commit 3f80978397f447973d278198e8bbde82826cb9c1
Headers show

Commit Message

Vinod Koul Jan. 5, 2016, 11:44 a.m. UTC
From: Sanyog Kale <sanyog.r.kale@intel.com>

If a device would like to use delayed suspending then PM
recommendation is to set ‘power.use_autosuspend’ flag. To allow
users to do so we need to change runtime calls in core to use
autosuspend counterparts.

For user who do not wish to use delayed suspend not setting the
device's ‘power.use_autosuspend’ flag will result in non-delayed
suspend even with these APIs which incidentally is also the default
behaviour, so only users will be impacted who opt in for this.

Signed-off-by: Sanyog Kale <sanyog.r.kale@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
 sound/soc/soc-pcm.c | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

Comments

Takashi Iwai Jan. 6, 2016, 1:08 p.m. UTC | #1
On Tue, 05 Jan 2016 12:44:49 +0100,
Vinod Koul wrote:
> 
> From: Sanyog Kale <sanyog.r.kale@intel.com>
> 
> If a device would like to use delayed suspending then PM
> recommendation is to set ‘power.use_autosuspend’ flag. To allow
> users to do so we need to change runtime calls in core to use
> autosuspend counterparts.
> 
> For user who do not wish to use delayed suspend not setting the
> device's ‘power.use_autosuspend’ flag will result in non-delayed
> suspend even with these APIs which incidentally is also the default
> behaviour, so only users will be impacted who opt in for this.
> 
> Signed-off-by: Sanyog Kale <sanyog.r.kale@intel.com>
> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
> ---
>  sound/soc/soc-pcm.c | 28 ++++++++++++++++++++--------
>  1 file changed, 20 insertions(+), 8 deletions(-)
> 
> diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
> index c86dc96e8986..efad248efd4f 100644
> --- a/sound/soc/soc-pcm.c
> +++ b/sound/soc/soc-pcm.c
> @@ -599,10 +599,15 @@ platform_err:
>  out:
>  	mutex_unlock(&rtd->pcm_mutex);
>  
> -	pm_runtime_put(platform->dev);
> -	for (i = 0; i < rtd->num_codecs; i++)
> -		pm_runtime_put(rtd->codec_dais[i]->dev);
> -	pm_runtime_put(cpu_dai->dev);
> +	pm_runtime_mark_last_busy(platform->dev);
> +	pm_runtime_put_autosuspend(platform->dev);
> +	for (i = 0; i < rtd->num_codecs; i++) {
> +		pm_runtime_mark_last_busy(rtd->codec_dais[i]->dev);
> +		pm_runtime_put_autosuspend(rtd->codec_dais[i]->dev);
> +	}
> +
> +	pm_runtime_mark_last_busy(cpu_dai->dev);
> +	pm_runtime_put_autosuspend(cpu_dai->dev);
>  	for (i = 0; i < rtd->num_codecs; i++) {
>  		if (!rtd->codec_dais[i]->active)
>  			pinctrl_pm_select_sleep_state(rtd->codec_dais[i]->dev);
> @@ -706,10 +711,17 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
>  
>  	mutex_unlock(&rtd->pcm_mutex);
>  
> -	pm_runtime_put(platform->dev);
> -	for (i = 0; i < rtd->num_codecs; i++)
> -		pm_runtime_put(rtd->codec_dais[i]->dev);
> -	pm_runtime_put(cpu_dai->dev);
> +	pm_runtime_mark_last_busy(platform->dev);
> +	pm_runtime_put_autosuspend(platform->dev);
> +
> +	for (i = 0; i < rtd->num_codecs; i++) {
> +		pm_runtime_mark_last_busy(rtd->codec_dais[i]->dev);
> +		pm_runtime_put_autosuspend(rtd->codec_dais[i]->dev);
> +	}
> +
> +	pm_runtime_mark_last_busy(cpu_dai->dev);
> +	pm_runtime_put_autosuspend(cpu_dai->dev);
> +
>  	for (i = 0; i < rtd->num_codecs; i++) {
>  		if (!rtd->codec_dais[i]->active)
>  			pinctrl_pm_select_sleep_state(rtd->codec_dais[i]->dev);

Lots of duplicated codes there...  Worth to have a common helper?


Takashi
Vinod Koul Jan. 7, 2016, 8:25 a.m. UTC | #2
On Wed, Jan 06, 2016 at 02:08:57PM +0100, Takashi Iwai wrote:
> On Tue, 05 Jan 2016 12:44:49 +0100,
> Vinod Koul wrote:
> > -	pm_runtime_put(platform->dev);
> > -	for (i = 0; i < rtd->num_codecs; i++)
> > -		pm_runtime_put(rtd->codec_dais[i]->dev);
> > -	pm_runtime_put(cpu_dai->dev);
> > +	pm_runtime_mark_last_busy(platform->dev);
> > +	pm_runtime_put_autosuspend(platform->dev);
> > +
> > +	for (i = 0; i < rtd->num_codecs; i++) {
> > +		pm_runtime_mark_last_busy(rtd->codec_dais[i]->dev);
> > +		pm_runtime_put_autosuspend(rtd->codec_dais[i]->dev);
> > +	}
> > +
> > +	pm_runtime_mark_last_busy(cpu_dai->dev);
> > +	pm_runtime_put_autosuspend(cpu_dai->dev);
> > +
> >  	for (i = 0; i < rtd->num_codecs; i++) {
> >  		if (!rtd->codec_dais[i]->active)
> >  			pinctrl_pm_select_sleep_state(rtd->codec_dais[i]->dev);
> 
> Lots of duplicated codes there...  Worth to have a common helper?

I certainly think so :) will do this after merge window
diff mbox

Patch

diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index c86dc96e8986..efad248efd4f 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -599,10 +599,15 @@  platform_err:
 out:
 	mutex_unlock(&rtd->pcm_mutex);
 
-	pm_runtime_put(platform->dev);
-	for (i = 0; i < rtd->num_codecs; i++)
-		pm_runtime_put(rtd->codec_dais[i]->dev);
-	pm_runtime_put(cpu_dai->dev);
+	pm_runtime_mark_last_busy(platform->dev);
+	pm_runtime_put_autosuspend(platform->dev);
+	for (i = 0; i < rtd->num_codecs; i++) {
+		pm_runtime_mark_last_busy(rtd->codec_dais[i]->dev);
+		pm_runtime_put_autosuspend(rtd->codec_dais[i]->dev);
+	}
+
+	pm_runtime_mark_last_busy(cpu_dai->dev);
+	pm_runtime_put_autosuspend(cpu_dai->dev);
 	for (i = 0; i < rtd->num_codecs; i++) {
 		if (!rtd->codec_dais[i]->active)
 			pinctrl_pm_select_sleep_state(rtd->codec_dais[i]->dev);
@@ -706,10 +711,17 @@  static int soc_pcm_close(struct snd_pcm_substream *substream)
 
 	mutex_unlock(&rtd->pcm_mutex);
 
-	pm_runtime_put(platform->dev);
-	for (i = 0; i < rtd->num_codecs; i++)
-		pm_runtime_put(rtd->codec_dais[i]->dev);
-	pm_runtime_put(cpu_dai->dev);
+	pm_runtime_mark_last_busy(platform->dev);
+	pm_runtime_put_autosuspend(platform->dev);
+
+	for (i = 0; i < rtd->num_codecs; i++) {
+		pm_runtime_mark_last_busy(rtd->codec_dais[i]->dev);
+		pm_runtime_put_autosuspend(rtd->codec_dais[i]->dev);
+	}
+
+	pm_runtime_mark_last_busy(cpu_dai->dev);
+	pm_runtime_put_autosuspend(cpu_dai->dev);
+
 	for (i = 0; i < rtd->num_codecs; i++) {
 		if (!rtd->codec_dais[i]->active)
 			pinctrl_pm_select_sleep_state(rtd->codec_dais[i]->dev);