Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1592863 > unrolled thread

[PATCH] tpm/tpm_crb: enter the low power state upon device suspend

Started byTomas Winkler <tomas.winkler@intel.com>
First post2017-03-06 01:00 +0100
Last post2017-03-07 11:00 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] tpm/tpm_crb: enter the low power state upon device suspend Tomas Winkler <tomas.winkler@intel.com> - 2017-03-06 01:00 +0100
    Re: [PATCH] tpm/tpm_crb: enter the low power state upon device  suspend Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2017-03-06 15:50 +0100
      RE: [PATCH] tpm/tpm_crb: enter the low power state upon device  suspend "Winkler, Tomas" <tomas.winkler@intel.com> - 2017-03-06 19:30 +0100
        Re: [PATCH] tpm/tpm_crb: enter the low power state upon device  suspend Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2017-03-07 11:00 +0100

#1592863 — [PATCH] tpm/tpm_crb: enter the low power state upon device suspend

FromTomas Winkler <tomas.winkler@intel.com>
Date2017-03-06 01:00 +0100
Subject[PATCH] tpm/tpm_crb: enter the low power state upon device suspend
Message-ID<thOed-7Rd-9@gated-at.bofh.it>
This fix enables a platform to enter the idle state (suspend-to-idle)

The driver needs to request explicitly go_idle upon completion
from the pm suspend handler.
The runtime pm is disabled on suspend during prepare state by calling
pm_runtime_get_noresume, hence we cannot relay on runtime pm to leave
the device in low power state. Symmetrically cmdReady is called
upon resume.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/char/tpm/tpm_crb.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
index 86f355b6df1d..d8dfff0fdfce 100644
--- a/drivers/char/tpm/tpm_crb.c
+++ b/drivers/char/tpm/tpm_crb.c
@@ -479,10 +479,33 @@ static int crb_pm_runtime_resume(struct device *dev)
 
 	return crb_cmd_ready(dev, priv);
 }
+
+static int crb_pm_suspend(struct device *dev)
+{
+	int ret;
+
+	ret = tpm_pm_suspend(dev);
+	if (ret)
+		return ret;
+
+	return crb_pm_runtime_suspend(dev);
+}
+
+static int crb_pm_resume(struct device *dev)
+{
+	int ret;
+
+	ret = crb_pm_runtime_resume(dev);
+	if (ret)
+		return ret;
+
+	return tpm_pm_resume(dev);
+}
+
 #endif /* CONFIG_PM */
 
 static const struct dev_pm_ops crb_pm = {
-	SET_SYSTEM_SLEEP_PM_OPS(tpm_pm_suspend, tpm_pm_resume)
+	SET_SYSTEM_SLEEP_PM_OPS(crb_pm_suspend, crb_pm_resume)
 	SET_RUNTIME_PM_OPS(crb_pm_runtime_suspend, crb_pm_runtime_resume, NULL)
 };
 
-- 
2.7.4

[toc] | [next] | [standalone]


#1593453 — Re: [PATCH] tpm/tpm_crb: enter the low power state upon device suspend

FromJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Date2017-03-06 15:50 +0100
SubjectRe: [PATCH] tpm/tpm_crb: enter the low power state upon device suspend
Message-ID<ti27w-199-31@gated-at.bofh.it>
In reply to#1592863
On Mon, Mar 06, 2017 at 01:53:35AM +0200, Tomas Winkler wrote:
> This fix enables a platform to enter the idle state (suspend-to-idle)
> 
> The driver needs to request explicitly go_idle upon completion
> from the pm suspend handler.
> The runtime pm is disabled on suspend during prepare state by calling
> pm_runtime_get_noresume, hence we cannot relay on runtime pm to leave
> the device in low power state. Symmetrically cmdReady is called
> upon resume.
> 
> Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>

LGTM

Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

PS. What about Fixes? Does this need it?

/Jarkko

> ---
>  drivers/char/tpm/tpm_crb.c | 25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
> index 86f355b6df1d..d8dfff0fdfce 100644
> --- a/drivers/char/tpm/tpm_crb.c
> +++ b/drivers/char/tpm/tpm_crb.c
> @@ -479,10 +479,33 @@ static int crb_pm_runtime_resume(struct device *dev)
>  
>  	return crb_cmd_ready(dev, priv);
>  }
> +
> +static int crb_pm_suspend(struct device *dev)
> +{
> +	int ret;
> +
> +	ret = tpm_pm_suspend(dev);
> +	if (ret)
> +		return ret;
> +
> +	return crb_pm_runtime_suspend(dev);
> +}
> +
> +static int crb_pm_resume(struct device *dev)
> +{
> +	int ret;
> +
> +	ret = crb_pm_runtime_resume(dev);
> +	if (ret)
> +		return ret;
> +
> +	return tpm_pm_resume(dev);
> +}
> +
>  #endif /* CONFIG_PM */
>  
>  static const struct dev_pm_ops crb_pm = {
> -	SET_SYSTEM_SLEEP_PM_OPS(tpm_pm_suspend, tpm_pm_resume)
> +	SET_SYSTEM_SLEEP_PM_OPS(crb_pm_suspend, crb_pm_resume)
>  	SET_RUNTIME_PM_OPS(crb_pm_runtime_suspend, crb_pm_runtime_resume, NULL)
>  };
>  
> -- 
> 2.7.4
> 

[toc] | [prev] | [next] | [standalone]


#1593568 — RE: [PATCH] tpm/tpm_crb: enter the low power state upon device suspend

From"Winkler, Tomas" <tomas.winkler@intel.com>
Date2017-03-06 19:30 +0100
SubjectRE: [PATCH] tpm/tpm_crb: enter the low power state upon device suspend
Message-ID<ti5yp-3DN-7@gated-at.bofh.it>
In reply to#1593453
> 
> On Mon, Mar 06, 2017 at 01:53:35AM +0200, Tomas Winkler wrote:
> > This fix enables a platform to enter the idle state (suspend-to-idle)
> >
> > The driver needs to request explicitly go_idle upon completion from
> > the pm suspend handler.
> > The runtime pm is disabled on suspend during prepare state by calling
> > pm_runtime_get_noresume, hence we cannot relay on runtime pm to leave
> > the device in low power state. Symmetrically cmdReady is called upon
> > resume.
> >
> > Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> 
> LGTM
> 
> Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> 
> PS. What about Fixes? Does this need it?

No, I don't think this is a regression caused by any patch, rather the pm solution was not complete.
Thanks  
Tomas

 
> /Jarkko
> 
> > ---
> >  drivers/char/tpm/tpm_crb.c | 25 ++++++++++++++++++++++++-
> >  1 file changed, 24 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c
> > index 86f355b6df1d..d8dfff0fdfce 100644
> > --- a/drivers/char/tpm/tpm_crb.c
> > +++ b/drivers/char/tpm/tpm_crb.c
> > @@ -479,10 +479,33 @@ static int crb_pm_runtime_resume(struct device
> > *dev)
> >
> >  	return crb_cmd_ready(dev, priv);
> >  }
> > +
> > +static int crb_pm_suspend(struct device *dev) {
> > +	int ret;
> > +
> > +	ret = tpm_pm_suspend(dev);
> > +	if (ret)
> > +		return ret;
> > +
> > +	return crb_pm_runtime_suspend(dev);
> > +}
> > +
> > +static int crb_pm_resume(struct device *dev) {
> > +	int ret;
> > +
> > +	ret = crb_pm_runtime_resume(dev);
> > +	if (ret)
> > +		return ret;
> > +
> > +	return tpm_pm_resume(dev);
> > +}
> > +
> >  #endif /* CONFIG_PM */
> >
> >  static const struct dev_pm_ops crb_pm = {
> > -	SET_SYSTEM_SLEEP_PM_OPS(tpm_pm_suspend, tpm_pm_resume)
> > +	SET_SYSTEM_SLEEP_PM_OPS(crb_pm_suspend, crb_pm_resume)
> >  	SET_RUNTIME_PM_OPS(crb_pm_runtime_suspend,
> crb_pm_runtime_resume,
> > NULL)  };
> >
> > --
> > 2.7.4
> >

[toc] | [prev] | [next] | [standalone]


#1594061 — Re: [PATCH] tpm/tpm_crb: enter the low power state upon device suspend

FromJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Date2017-03-07 11:00 +0100
SubjectRe: [PATCH] tpm/tpm_crb: enter the low power state upon device suspend
Message-ID<tik4q-5CJ-29@gated-at.bofh.it>
In reply to#1593568
On Mon, Mar 06, 2017 at 06:19:59PM +0000, Winkler, Tomas wrote:
> 
> > 
> > On Mon, Mar 06, 2017 at 01:53:35AM +0200, Tomas Winkler wrote:
> > > This fix enables a platform to enter the idle state (suspend-to-idle)
> > >
> > > The driver needs to request explicitly go_idle upon completion from
> > > the pm suspend handler.
> > > The runtime pm is disabled on suspend during prepare state by calling
> > > pm_runtime_get_noresume, hence we cannot relay on runtime pm to leave
> > > the device in low power state. Symmetrically cmdReady is called upon
> > > resume.
> > >
> > > Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
> > 
> > LGTM
> > 
> > Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > 
> > PS. What about Fixes? Does this need it?
> 
> No, I don't think this is a regression caused by any patch, rather the pm solution was not complete.
> Thanks  
> Tomas

It's in my tree now (and should be in linux-next too soon).

/Jarkko

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web