linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tpm/tpm_i2c_infineon: ensure no ongoing commands on shutdown
@ 2017-01-14  0:09 Andrey Pronin
  2017-01-14  0:28 ` Jason Gunthorpe
  0 siblings, 1 reply; 17+ messages in thread
From: Andrey Pronin @ 2017-01-14  0:09 UTC (permalink / raw)
  To: Peter Huewe, Marcel Selhorst, Jarkko Sakkinen
  Cc: Andrey Pronin, Jason Gunthorpe, tpmdd-devel, linux-kernel,
	semenzato, groeck

Resetting TPM while processing a command may lead to issues
on the next boot. Ensure that we don't have any ongoing
commands, and that no further commands can be sent to the chip
by unregistering the device in the shutdown handler.
tpm_chip_unregister() waits for the completion of an ongoing
command, if any, and then clears out chip->ops and unregisters
sysfs entities.

Signed-off-by: Andrey Pronin <apronin@chromium.org>
---
 drivers/char/tpm/tpm_i2c_infineon.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm_i2c_infineon.c b/drivers/char/tpm/tpm_i2c_infineon.c
index 62ee44e57ddc..0c829fe26561 100644
--- a/drivers/char/tpm/tpm_i2c_infineon.c
+++ b/drivers/char/tpm/tpm_i2c_infineon.c
@@ -689,14 +689,18 @@ static int tpm_tis_i2c_probe(struct i2c_client *client,
 	return rc;
 }
 
-static int tpm_tis_i2c_remove(struct i2c_client *client)
+static void tpm_tis_i2c_shutdown(struct i2c_client *client)
 {
 	struct tpm_chip *chip = tpm_dev.chip;
 
 	tpm_chip_unregister(chip);
 	release_locality(chip, tpm_dev.locality, 1);
 	tpm_dev.client = NULL;
+}
 
+static int tpm_tis_i2c_remove(struct i2c_client *client)
+{
+	tpm_tis_i2c_shutdown(client);
 	return 0;
 }
 
@@ -704,6 +708,7 @@ static struct i2c_driver tpm_tis_i2c_driver = {
 	.id_table = tpm_tis_i2c_table,
 	.probe = tpm_tis_i2c_probe,
 	.remove = tpm_tis_i2c_remove,
+	.shutdown = tpm_tis_i2c_shutdown,
 	.driver = {
 		   .name = "tpm_i2c_infineon",
 		   .pm = &tpm_tis_i2c_ops,
-- 
2.11.0.483.g087da7b7c-goog

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

end of thread, other threads:[~2017-01-25 18:59 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-14  0:09 [PATCH] tpm/tpm_i2c_infineon: ensure no ongoing commands on shutdown Andrey Pronin
2017-01-14  0:28 ` Jason Gunthorpe
2017-01-14  0:42   ` Andrey Pronin
2017-01-16  9:33     ` Jarkko Sakkinen
2017-01-25 18:59       ` [tpmdd-devel] " Jarkko Sakkinen
2017-01-16 16:19     ` Jason Gunthorpe
2017-01-17 17:58       ` Andrey Pronin
2017-01-17 19:27         ` Jason Gunthorpe
2017-01-17 20:13           ` Andrey Pronin
2017-01-17 20:59             ` Jason Gunthorpe
2017-01-17 23:00               ` Andrey Pronin
2017-01-17 23:22                 ` Jason Gunthorpe
2017-01-23 20:02                   ` Andrey Pronin
2017-01-23 20:16                     ` [tpmdd-devel] " Andrey Pronin
2017-01-23 20:39                     ` Jason Gunthorpe
2017-01-23 22:19                       ` Andrey Pronin
2017-01-23 22:57                         ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).