All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tpm/tpm_crb: enter the low power state upon device suspend
@ 2017-03-05 23:53 Tomas Winkler
  2017-03-06 14:44   ` Jarkko Sakkinen
  0 siblings, 1 reply; 7+ messages in thread
From: Tomas Winkler @ 2017-03-05 23:53 UTC (permalink / raw)
  To: tpmdd-devel, Jarkko Sakkinen, Jason Gunthorpe
  Cc: linux-security-module, linux-kernel, Tomas Winkler

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] tpm/tpm_crb: enter the low power state upon device suspend
@ 2017-03-06 14:44   ` Jarkko Sakkinen
  0 siblings, 0 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2017-03-06 14:44 UTC (permalink / raw)
  To: Tomas Winkler
  Cc: tpmdd-devel, Jason Gunthorpe, linux-security-module, linux-kernel

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
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tpm/tpm_crb: enter the low power state upon device suspend
@ 2017-03-06 14:44   ` Jarkko Sakkinen
  0 siblings, 0 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2017-03-06 14:44 UTC (permalink / raw)
  To: Tomas Winkler
  Cc: linux-security-module-u79uwXL29TY76Z2rM5mHXA,
	tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

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-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

LGTM

Tested-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

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
> 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH] tpm/tpm_crb: enter the low power state upon device suspend
@ 2017-03-06 18:19     ` Winkler, Tomas
  0 siblings, 0 replies; 7+ messages in thread
From: Winkler, Tomas @ 2017-03-06 18:19 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: tpmdd-devel, Jason Gunthorpe, linux-security-module, linux-kernel


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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tpm/tpm_crb: enter the low power state upon device suspend
@ 2017-03-06 18:19     ` Winkler, Tomas
  0 siblings, 0 replies; 7+ messages in thread
From: Winkler, Tomas @ 2017-03-06 18:19 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: linux-security-module-u79uwXL29TY76Z2rM5mHXA,
	tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA


> 
> 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-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> 
> LGTM
> 
> Tested-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> 
> 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
> >

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tpm/tpm_crb: enter the low power state upon device suspend
@ 2017-03-07  8:30       ` Jarkko Sakkinen
  0 siblings, 0 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2017-03-07  8:30 UTC (permalink / raw)
  To: Winkler, Tomas
  Cc: tpmdd-devel, Jason Gunthorpe, linux-security-module, linux-kernel

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] tpm/tpm_crb: enter the low power state upon device suspend
@ 2017-03-07  8:30       ` Jarkko Sakkinen
  0 siblings, 0 replies; 7+ messages in thread
From: Jarkko Sakkinen @ 2017-03-07  8:30 UTC (permalink / raw)
  To: Winkler, Tomas
  Cc: linux-security-module-u79uwXL29TY76Z2rM5mHXA,
	tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

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-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> > 
> > LGTM
> > 
> > Tested-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> > Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> > 
> > 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

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-03-07  9:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-05 23:53 [PATCH] tpm/tpm_crb: enter the low power state upon device suspend Tomas Winkler
2017-03-06 14:44 ` Jarkko Sakkinen
2017-03-06 14:44   ` Jarkko Sakkinen
2017-03-06 18:19   ` Winkler, Tomas
2017-03-06 18:19     ` Winkler, Tomas
2017-03-07  8:30     ` Jarkko Sakkinen
2017-03-07  8:30       ` Jarkko Sakkinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.