tpmdd-devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2 0/2] fixes for v4.4
@ 2018-05-30 20:44 Jarkko Sakkinen
  2018-05-30 20:44 ` [PATCH v2 1/2] tpm: do not suspend/resume if power stays on Jarkko Sakkinen
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jarkko Sakkinen @ 2018-05-30 20:44 UTC (permalink / raw)
  To: stable
  Cc: Jarkko Sakkinen, Jason Gunthorpe, open list,
	moderated list:TPM DEVICE DRIVER

Decided to add Enric's commit because it is also a bug fix instead
of modifying Chris commit.

Chris Chiu (1):
  tpm: self test failure should not cause suspend to fail

Enric Balletbo i Serra (1):
  tpm: do not suspend/resume if power stays on

 drivers/char/tpm/tpm-chip.c      | 12 ++++++++++++
 drivers/char/tpm/tpm-interface.c |  7 +++++++
 drivers/char/tpm/tpm.h           |  1 +
 3 files changed, 20 insertions(+)

-- 
v2: moved the check from tpm_of.c to tpm-chip.c as in v4.4 chip is
unreachable otherwise. I did compilation test now with BuildRoot
for power arch.
2.17.0

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

* [PATCH v2 1/2] tpm: do not suspend/resume if power stays on
  2018-05-30 20:44 [PATCH v2 0/2] fixes for v4.4 Jarkko Sakkinen
@ 2018-05-30 20:44 ` Jarkko Sakkinen
  2018-05-30 23:56   ` Jarkko Sakkinen
  2018-05-30 20:44 ` [PATCH v2 2/2] tpm: self test failure should not cause suspend to fail Jarkko Sakkinen
  2018-06-02 13:18 ` [PATCH v2 0/2] fixes for v4.4 Greg KH
  2 siblings, 1 reply; 6+ messages in thread
From: Jarkko Sakkinen @ 2018-05-30 20:44 UTC (permalink / raw)
  To: stable
  Cc: Enric Balletbo i Serra, Sonny Rao, Jarkko Sakkinen, James Morris,
	Peter Huewe, Marcel Selhorst, Jason Gunthorpe,
	moderated list:TPM DEVICE DRIVER, open list

From: Enric Balletbo i Serra <enric.balletbo@collabora.com>

commit b5d0ebc99bf5d0801a5ecbe958caa3d68b8eaee8 upstream

The suspend/resume behavior of the TPM can be controlled by setting
"powered-while-suspended" in the DTS. This is useful for the cases
when hardware does not power-off the TPM.

Signed-off-by: Sonny Rao <sonnyrao@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
---
 drivers/char/tpm/tpm-chip.c      | 12 ++++++++++++
 drivers/char/tpm/tpm-interface.c |  3 +++
 drivers/char/tpm/tpm.h           |  1 +
 3 files changed, 16 insertions(+)

diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
index a0d9ac6b6cc9..a8d7220f613c 100644
--- a/drivers/char/tpm/tpm-chip.c
+++ b/drivers/char/tpm/tpm-chip.c
@@ -324,8 +324,20 @@ static void tpm1_chip_unregister(struct tpm_chip *chip)
  */
 int tpm_chip_register(struct tpm_chip *chip)
 {
+#ifdef CONFIG_TCG_IBMVTPM
+	struct device_node *np;
+#endif
 	int rc;
 
+#ifdef CONFIG_TCG_IBMVTPM
+	np = of_find_node_by_name(NULL, "vtpm");
+	if (!np)
+		return -ENODEV;
+	if (of_property_read_bool(np, "powered-while-suspended"))
+		chip->flags |= TPM_CHIP_FLAG_ALWAYS_POWERED;
+	of_node_put(np);
+#endif
+
 	rc = tpm1_chip_register(chip);
 	if (rc)
 		return rc;
diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index aaa5fa95dede..247dd2b6504a 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -931,6 +931,9 @@ int tpm_pm_suspend(struct device *dev)
 	if (chip == NULL)
 		return -ENODEV;
 
+	if (chip->flags & TPM_CHIP_FLAG_ALWAYS_POWERED)
+		return 0;
+
 	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
 		tpm2_shutdown(chip, TPM2_SU_STATE);
 		return 0;
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 772d99b3a8e4..36e1abda00f9 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -168,6 +168,7 @@ struct tpm_vendor_specific {
 enum tpm_chip_flags {
 	TPM_CHIP_FLAG_REGISTERED	= BIT(0),
 	TPM_CHIP_FLAG_TPM2		= BIT(1),
+	TPM_CHIP_FLAG_ALWAYS_POWERED	= BIT(5),
 };
 
 struct tpm_chip {
-- 
2.17.0

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

* [PATCH v2 2/2] tpm: self test failure should not cause suspend to fail
  2018-05-30 20:44 [PATCH v2 0/2] fixes for v4.4 Jarkko Sakkinen
  2018-05-30 20:44 ` [PATCH v2 1/2] tpm: do not suspend/resume if power stays on Jarkko Sakkinen
@ 2018-05-30 20:44 ` Jarkko Sakkinen
  2018-06-02 13:18 ` [PATCH v2 0/2] fixes for v4.4 Greg KH
  2 siblings, 0 replies; 6+ messages in thread
From: Jarkko Sakkinen @ 2018-05-30 20:44 UTC (permalink / raw)
  To: stable
  Cc: Chris Chiu, Daniel Drake, Jarkko Sakkinen, Peter Huewe,
	Marcel Selhorst, Jason Gunthorpe,
	moderated list:TPM DEVICE DRIVER, open list

From: Chris Chiu <chiu@endlessm.com>

commit 0803d7befa15cab5717d667a97a66214d2a4c083 upstream

The Acer Acer Veriton X4110G has a TPM device detected as:
  tpm_tis 00:0b: 1.2 TPM (device-id 0xFE, rev-id 71)

After the first S3 suspend, the following error appears during resume:
  tpm tpm0: A TPM error(38) occurred continue selftest

Any following S3 suspend attempts will now fail with this error:
  tpm tpm0: Error (38) sending savestate before suspend
  PM: Device 00:0b failed to suspend: error 38

Error 38 is TPM_ERR_INVALID_POSTINIT which means the TPM is
not in the correct state. This indicates that the platform BIOS
is not sending the usual TPM_Startup command during S3 resume.
>From this point onwards, all TPM commands will fail.

The same issue was previously reported on Foxconn 6150BK8MC and
Sony Vaio TX3.

The platform behaviour seems broken here, but we should not break
suspend/resume because of this.

When the unexpected TPM state is encountered, set a flag to skip the
affected TPM_SaveState command on later suspends.

Cc: stable@vger.kernel.org
Signed-off-by: Chris Chiu <chiu@endlessm.com>
Signed-off-by: Daniel Drake <drake@endlessm.com>
Link: http://lkml.kernel.org/r/CAB4CAwfSCvj1cudi+MWaB5g2Z67d9DwY1o475YOZD64ma23UiQ@mail.gmail.com
Link: https://lkml.org/lkml/2011/3/28/192
Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=591031
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
 drivers/char/tpm/tpm-interface.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index 247dd2b6504a..be0547115d34 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -787,6 +787,10 @@ int tpm_do_selftest(struct tpm_chip *chip)
 	loops = jiffies_to_msecs(duration) / delay_msec;
 
 	rc = tpm_continue_selftest(chip);
+	if (rc == TPM_ERR_INVALID_POSTINIT) {
+		chip->flags |= TPM_CHIP_FLAG_ALWAYS_POWERED;
+		dev_info(&chip->dev, "TPM not ready (%d)\n", rc);
+	}
 	/* This may fail if there was no TPM driver during a suspend/resume
 	 * cycle; some may return 10 (BAD_ORDINAL), others 28 (FAILEDSELFTEST)
 	 */
-- 
2.17.0

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

* Re: [PATCH v2 1/2] tpm: do not suspend/resume if power stays on
  2018-05-30 20:44 ` [PATCH v2 1/2] tpm: do not suspend/resume if power stays on Jarkko Sakkinen
@ 2018-05-30 23:56   ` Jarkko Sakkinen
  0 siblings, 0 replies; 6+ messages in thread
From: Jarkko Sakkinen @ 2018-05-30 23:56 UTC (permalink / raw)
  To: stable
  Cc: Enric Balletbo i Serra, Sonny Rao, James Morris, Peter Huewe,
	Marcel Selhorst, Jason Gunthorpe,
	moderated list:TPM DEVICE DRIVER, open list

On Wed, May 30, 2018 at 11:44:39PM +0300, Jarkko Sakkinen wrote:
> From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
> 
> commit b5d0ebc99bf5d0801a5ecbe958caa3d68b8eaee8 upstream
> 
> The suspend/resume behavior of the TPM can be controlled by setting
> "powered-while-suspended" in the DTS. This is useful for the cases
> when hardware does not power-off the TPM.
> 
> Signed-off-by: Sonny Rao <sonnyrao@chromium.org>
> Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
> Reviewed-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> Signed-off-by: James Morris <james.l.morris@oracle.com>
> ---
>  drivers/char/tpm/tpm-chip.c      | 12 ++++++++++++
>  drivers/char/tpm/tpm-interface.c |  3 +++
>  drivers/char/tpm/tpm.h           |  1 +
>  3 files changed, 16 insertions(+)
> 
> diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
> index a0d9ac6b6cc9..a8d7220f613c 100644
> --- a/drivers/char/tpm/tpm-chip.c
> +++ b/drivers/char/tpm/tpm-chip.c
> @@ -324,8 +324,20 @@ static void tpm1_chip_unregister(struct tpm_chip *chip)
>   */
>  int tpm_chip_register(struct tpm_chip *chip)
>  {
> +#ifdef CONFIG_TCG_IBMVTPM
> +	struct device_node *np;
> +#endif
>  	int rc;
>  
> +#ifdef CONFIG_TCG_IBMVTPM
> +	np = of_find_node_by_name(NULL, "vtpm");
> +	if (!np)
> +		return -ENODEV;
> +	if (of_property_read_bool(np, "powered-while-suspended"))
> +		chip->flags |= TPM_CHIP_FLAG_ALWAYS_POWERED;
> +	of_node_put(np);
> +#endif

I'll have to revise this as more config flag should be CONFIG_OF
and property should be conditionally read if the node is found.
Then it can be relocated without interference.

/Jarkko

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

* Re: [PATCH v2 0/2] fixes for v4.4
  2018-05-30 20:44 [PATCH v2 0/2] fixes for v4.4 Jarkko Sakkinen
  2018-05-30 20:44 ` [PATCH v2 1/2] tpm: do not suspend/resume if power stays on Jarkko Sakkinen
  2018-05-30 20:44 ` [PATCH v2 2/2] tpm: self test failure should not cause suspend to fail Jarkko Sakkinen
@ 2018-06-02 13:18 ` Greg KH
  2018-06-04 20:00   ` Jarkko Sakkinen
  2 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2018-06-02 13:18 UTC (permalink / raw)
  To: Jarkko Sakkinen
  Cc: stable, Jason Gunthorpe, open list, moderated list:TPM DEVICE DRIVER

On Wed, May 30, 2018 at 11:44:38PM +0300, Jarkko Sakkinen wrote:
> Decided to add Enric's commit because it is also a bug fix instead
> of modifying Chris commit.

Why just 4.4 and not also 4.9?  I don't want to take patches that would
cause a regression for people moving from 4.4 to 4.9, so can you also
provide 4.9 backports of this?  If so, I will be glad to queue up both
sets of patches.

thanks,

greg k-h

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

* Re: [PATCH v2 0/2] fixes for v4.4
  2018-06-02 13:18 ` [PATCH v2 0/2] fixes for v4.4 Greg KH
@ 2018-06-04 20:00   ` Jarkko Sakkinen
  0 siblings, 0 replies; 6+ messages in thread
From: Jarkko Sakkinen @ 2018-06-04 20:00 UTC (permalink / raw)
  To: Greg KH
  Cc: stable, Jason Gunthorpe, open list, moderated list:TPM DEVICE DRIVER

On Sat, Jun 02, 2018 at 03:18:58PM +0200, Greg KH wrote:
> On Wed, May 30, 2018 at 11:44:38PM +0300, Jarkko Sakkinen wrote:
> > Decided to add Enric's commit because it is also a bug fix instead
> > of modifying Chris commit.
> 
> Why just 4.4 and not also 4.9?  I don't want to take patches that would
> cause a regression for people moving from 4.4 to 4.9, so can you also
> provide 4.9 backports of this?  If so, I will be glad to queue up both
> sets of patches.

Yes, I can do this. I'll check the v4.4 change with the original author
as I have to put the check in the original patch into different place
before sending anything (I do not have any POWER systes available to
test it myself).

/Jarkko

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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-30 20:44 [PATCH v2 0/2] fixes for v4.4 Jarkko Sakkinen
2018-05-30 20:44 ` [PATCH v2 1/2] tpm: do not suspend/resume if power stays on Jarkko Sakkinen
2018-05-30 23:56   ` Jarkko Sakkinen
2018-05-30 20:44 ` [PATCH v2 2/2] tpm: self test failure should not cause suspend to fail Jarkko Sakkinen
2018-06-02 13:18 ` [PATCH v2 0/2] fixes for v4.4 Greg KH
2018-06-04 20:00   ` Jarkko Sakkinen

tpmdd-devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/tpmdd-devel/0 tpmdd-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tpmdd-devel tpmdd-devel/ https://lore.kernel.org/tpmdd-devel \
		tpmdd-devel@lists.sourceforge.net tpmdd-devel@archiver.kernel.org
	public-inbox-index tpmdd-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/net.sourceforge.lists.tpmdd-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox