Skip to contentSkip to conversation

Use tpm_transmit_cmd() consistently across kernel call sites

PATCH Superseded Jarkko Sakkinen 2 participants 13 messages Jul 19, 2016 TPM device driver

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Use tpm_transmit_cmd() consistently across kernel call sites

These commits update the subsystem consistently to use tpm_transmit_cmd() throughout the subsystem the exception being tpm_write() where it makes sense to use the raw interface because higher level command handling is delegated to user space. The point is to make semantics and error handling across the kernel call sites.

v3: Removed patch that renames tpm_pcr_read_dev() to tpm1_pcr_read() because it is not mandatory for this patch set.

v2: Added commit that drops externs from all function declarations in tpm.h as suggested by Jason Gunthorpe.

Jarkko Sakkinen (5):
tpm: remove unnecessary externs from tpm.h
tpm: unify tpm_gen_interrupt()
tpm: return error code from tpm_gen_interrupt()
tpm: use tpm_transmit_cmd() in tpm2_probe()
tpm: use tpm_pcr_read_dev() in tpm_do_selftest()

 drivers/char/tpm/tpm-interface.c | 32 +++++++++++++++++---------------
 drivers/char/tpm/tpm.h           | 35 +++++++++++++++++------------------
 drivers/char/tpm/tpm2-cmd.c      | 21 +--------------------
 drivers/char/tpm/tpm_tis_core.c  |  7 +++----
 4 files changed, 38 insertions(+), 57 deletions(-)
Signature · 9 lines
2.7.4


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
#1 lore raw

PATCH v3 1/5 tpm: remove unnecessary externs from tpm.h

Removed unnecessary externs from tpm.h.

---
 drivers/char/tpm/tpm.h | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/char/tpm/tpm.h +18 -18
index 3e32d5b..8b864dd 100644
@@ -482,26 +482,26 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
 		     size_t bufsiz);
 ssize_t tpm_transmit_cmd(struct tpm_chip *chip, void *cmd, int len,
 			 const char *desc);
-extern int tpm_get_timeouts(struct tpm_chip *);
-extern void tpm_gen_interrupt(struct tpm_chip *);
+int tpm_get_timeouts(struct tpm_chip *chip);
+void tpm_gen_interrupt(struct tpm_chip *chip);
 int tpm1_auto_startup(struct tpm_chip *chip);
-extern int tpm_do_selftest(struct tpm_chip *);
-extern unsigned long tpm_calc_ordinal_duration(struct tpm_chip *, u32);
-extern int tpm_pm_suspend(struct device *);
-extern int tpm_pm_resume(struct device *);
-extern int wait_for_tpm_stat(struct tpm_chip *, u8, unsigned long,
-			     wait_queue_head_t *, bool);
+int tpm_do_selftest(struct tpm_chip *chip);
+unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
+int tpm_pm_suspend(struct device *dev);
+int tpm_pm_resume(struct device *dev);
+int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
+		      wait_queue_head_t *queue, bool check_cancel);
 
 struct tpm_chip *tpm_chip_find_get(int chip_num);
 __must_check int tpm_try_get_ops(struct tpm_chip *chip);
 void tpm_put_ops(struct tpm_chip *chip);
 
-extern struct tpm_chip *tpm_chip_alloc(struct device *dev,
-				       const struct tpm_class_ops *ops);
-extern struct tpm_chip *tpmm_chip_alloc(struct device *pdev,
-				       const struct tpm_class_ops *ops);
-extern int tpm_chip_register(struct tpm_chip *chip);
-extern void tpm_chip_unregister(struct tpm_chip *chip);
+struct tpm_chip *tpm_chip_alloc(struct device *dev,
+				const struct tpm_class_ops *ops);
+struct tpm_chip *tpmm_chip_alloc(struct device *pdev,
+				 const struct tpm_class_ops *ops);
+int tpm_chip_register(struct tpm_chip *chip);
+void tpm_chip_unregister(struct tpm_chip *chip);
 
 void tpm_sysfs_add_device(struct tpm_chip *chip);
 
@@ -528,8 +528,8 @@ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id,
 			u32 *value, const char *desc);
 
 int tpm2_auto_startup(struct tpm_chip *chip);
-extern void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
-extern unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *, u32);
-extern int tpm2_gen_interrupt(struct tpm_chip *chip);
-extern int tpm2_probe(struct tpm_chip *chip);
+void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
+unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
+int tpm2_gen_interrupt(struct tpm_chip *chip);
+int tpm2_probe(struct tpm_chip *chip);
 #endif
Signature · 1 line
2.7.4
#2 lore raw

PATCH v3 2/5 tpm: unify tpm_gen_interrupt()

In reply to Jarkko Sakkinen

Migrated into single tpm_gen_interrupt() function and cleaned up the whole construction in general because it was starting to turn into a train wreck.

---
 drivers/char/tpm/tpm-interface.c | 23 ++++++++++++++---------
 drivers/char/tpm/tpm.h           |  1 -
 drivers/char/tpm/tpm2-cmd.c      | 17 -----------------
 drivers/char/tpm/tpm_tis_core.c  |  5 +----
 4 files changed, 15 insertions(+), 31 deletions(-)
drivers/char/tpm/tpm-interface.c +14 -9
index 1abe2d7..88dafcd 100644
@@ -459,18 +459,23 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
 	return rc;
 }
 
+/**
+ * tpm_gen_interrupt -- generate an interrupt by issuing an idempotent command
+ * @chip: TPM chip to use
+ *
+ * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing
+ * a TPM error code.
+ */
 void tpm_gen_interrupt(struct tpm_chip *chip)
 {
-	struct	tpm_cmd_t tpm_cmd;
-	ssize_t rc;
+	const char *desc = "attempting to generate an interrupt";
+	u32 cap2;
+	cap_t cap;
 
-	tpm_cmd.header.in = tpm_getcap_header;
-	tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
-	tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
-	tpm_cmd.params.getcap_in.subcap = TPM_CAP_PROP_TIS_TIMEOUT;
-
-	rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE,
-			      "attempting to determine the timeouts");
+	if (chip->flags & TPM_CHIP_FLAG_TPM2)
+		tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
+	else
+		tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc);
 }
 EXPORT_SYMBOL_GPL(tpm_gen_interrupt);
 
drivers/char/tpm/tpm.h +0 -1
index 8b864dd..ec1f877 100644
@@ -530,6 +530,5 @@ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id,
 int tpm2_auto_startup(struct tpm_chip *chip);
 void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type);
 unsigned long tpm2_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
-int tpm2_gen_interrupt(struct tpm_chip *chip);
 int tpm2_probe(struct tpm_chip *chip);
 #endif
drivers/char/tpm/tpm2-cmd.c +0 -17
index 08c7e23..1c393ba 100644
@@ -895,23 +895,6 @@ static int tpm2_do_selftest(struct tpm_chip *chip)
 }
 
 /**
- * tpm2_gen_interrupt() - generate an interrupt
- * @chip: TPM chip to use
- *
- * 0 is returned when the operation is successful. If a negative number is
- * returned it remarks a POSIX error code. If a positive number is returned
- * it remarks a TPM error.
- */
-int tpm2_gen_interrupt(struct tpm_chip *chip)
-{
-	u32 dummy;
-
-	return tpm2_get_tpm_pt(chip, 0x100, &dummy,
-			       "attempting to generate an interrupt");
-}
-EXPORT_SYMBOL_GPL(tpm2_gen_interrupt);
-
-/**
  * tpm2_probe() - probe TPM 2.0
  * @chip: TPM chip to use
  *
drivers/char/tpm/tpm_tis_core.c +1 -4
index d66f51b..b67d225 100644
@@ -575,10 +575,7 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
 	/* Generate an interrupt by having the core call through to
 	 * tpm_tis_send
 	 */
-	if (chip->flags & TPM_CHIP_FLAG_TPM2)
-		tpm2_gen_interrupt(chip);
-	else
-		tpm_gen_interrupt(chip);
+	tpm_gen_interrupt(chip);
 
 	/* tpm_tis_send will either confirm the interrupt is working or it
 	 * will call disable_irq which undoes all of the above.
Signature · 9 lines
2.7.4


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
#3 lore raw

PATCH v3 3/5 tpm: return error code from tpm_gen_interrupt()

In reply to Jarkko Sakkinen

Return error code from tpm_gen_interrupt() and fail tpm_tis family of drivers on a system error. It doesn't make sense to continue if we cannot even reach the TPM.

---
 drivers/char/tpm/tpm-interface.c | 6 +++---
 drivers/char/tpm/tpm.h           | 2 +-
 drivers/char/tpm/tpm_tis_core.c  | 4 +++-
 3 files changed, 7 insertions(+), 5 deletions(-)
drivers/char/tpm/tpm-interface.c +3 -3
index 88dafcd..35b2722 100644
@@ -466,16 +466,16 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
  * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing
  * a TPM error code.
  */
-void tpm_gen_interrupt(struct tpm_chip *chip)
+int tpm_gen_interrupt(struct tpm_chip *chip)
 {
 	const char *desc = "attempting to generate an interrupt";
 	u32 cap2;
 	cap_t cap;
 
 	if (chip->flags & TPM_CHIP_FLAG_TPM2)
-		tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
+		return tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
 	else
-		tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc);
+		return tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc);
 }
 EXPORT_SYMBOL_GPL(tpm_gen_interrupt);
 
drivers/char/tpm/tpm.h +1 -1
index ec1f877..0cbb598 100644
@@ -483,7 +483,7 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
 ssize_t tpm_transmit_cmd(struct tpm_chip *chip, void *cmd, int len,
 			 const char *desc);
 int tpm_get_timeouts(struct tpm_chip *chip);
-void tpm_gen_interrupt(struct tpm_chip *chip);
+int tpm_gen_interrupt(struct tpm_chip *chip);
 int tpm1_auto_startup(struct tpm_chip *chip);
 int tpm_do_selftest(struct tpm_chip *chip);
 unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal);
drivers/char/tpm/tpm_tis_core.c +3 -1
index b67d225..45159e1 100644
@@ -575,7 +575,9 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,
 	/* Generate an interrupt by having the core call through to
 	 * tpm_tis_send
 	 */
-	tpm_gen_interrupt(chip);
+	rc = tpm_gen_interrupt(chip);
+	if (rc < 0)
+		return rc;
 
 	/* tpm_tis_send will either confirm the interrupt is working or it
 	 * will call disable_irq which undoes all of the above.
Signature · 9 lines
2.7.4


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
#4 lore raw

Re: [PATCH v3 3/5] tpm: return error code from tpm_gen_interrupt()

Quoted 14 lines · Jarkko Sakkinen

Return error code from tpm_gen_interrupt() and fail tpm_tis family of drivers on a system error. It doesn't make sense to continue if we cannot even reach the TPM.

 drivers/char/tpm/tpm-interface.c | 6 +++---
 drivers/char/tpm/tpm.h           | 2 +-
 drivers/char/tpm/tpm_tis_core.c  | 4 +++-
 3 files changed, 7 insertions(+), 5 deletions(-)
drivers/char/tpm/tpm-interface.c +1 -0
index 88dafcd..35b2722 100644
+++ b/drivers/char/tpm/tpm-interface.c

drivers/char/tpm/tpm-interface.c ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap, · line 469

Quoted 5 lines
drivers/char/tpm/tpm-interface.c +1 -1
@@ -466,16 +466,16 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
  * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing
  * a TPM error code.
  */
-void tpm_gen_interrupt(struct tpm_chip *chip)
+int tpm_gen_interrupt(struct tpm_chip *chip)

drivers/char/tpm/st33zp24/st33zp24.c needs to be updated too.

I looked at st33zp24.c and it looks broken, I don't see any logic that de-asserts TPM_CHIP_FLAG_IRQ if the irq test triggered by tpm_gen_interrupt, so presumably it should not be calling it at all.

IMHO, DT binding devices should never auto-probe IRQS anyhow, we only do it on PC because PC is insane...

If we fix st33 then I suggest just moving tpm_gen_interrupt into tpm_tis - nothing else should really be using it..

Jason

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports.http://sdm.link/zohodev2dev

#5 lore raw

Re: [PATCH v3 3/5] tpm: return error code from tpm_gen_interrupt()

Quoted 27 lines · Jason Gunthorpe
Quoted 14 lines · Jarkko Sakkinen

Return error code from tpm_gen_interrupt() and fail tpm_tis family of drivers on a system error. It doesn't make sense to continue if we cannot even reach the TPM.

 drivers/char/tpm/tpm-interface.c | 6 +++---
 drivers/char/tpm/tpm.h           | 2 +-
 drivers/char/tpm/tpm_tis_core.c  | 4 +++-
 3 files changed, 7 insertions(+), 5 deletions(-)
drivers/char/tpm/tpm-interface.c +1 -0
index 88dafcd..35b2722 100644
+++ b/drivers/char/tpm/tpm-interface.c

drivers/char/tpm/tpm-interface.c ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap, · line 469

Quoted 5 lines
drivers/char/tpm/tpm-interface.c +1 -1
@@ -466,16 +466,16 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
  * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing
  * a TPM error code.
  */
-void tpm_gen_interrupt(struct tpm_chip *chip)
+int tpm_gen_interrupt(struct tpm_chip *chip)

drivers/char/tpm/st33zp24/st33zp24.c needs to be updated too.

I looked at st33zp24.c and it looks broken, I don't see any logic that de-asserts TPM_CHIP_FLAG_IRQ if the irq test triggered by tpm_gen_interrupt, so presumably it should not be calling it at all.

Quoted 5 lines

IMHO, DT binding devices should never auto-probe IRQS anyhow, we only do it on PC because PC is insane...

If we fix st33 then I suggest just moving tpm_gen_interrupt into tpm_tis - nothing else should really be using it..

I'm happy to take fix for st33 but not the move because it does not matter for the release.

/Jarkko

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports.http://sdm.link/zohodev2dev

#6 lore raw

Re: [PATCH v3 3/5] tpm: return error code from tpm_gen_interrupt()

Quoted 28 lines · Jarkko Sakkinen
Quoted 27 lines · Jason Gunthorpe
Quoted 14 lines · Jarkko Sakkinen

Return error code from tpm_gen_interrupt() and fail tpm_tis family of drivers on a system error. It doesn't make sense to continue if we cannot even reach the TPM.

 drivers/char/tpm/tpm-interface.c | 6 +++---
 drivers/char/tpm/tpm.h           | 2 +-
 drivers/char/tpm/tpm_tis_core.c  | 4 +++-
 3 files changed, 7 insertions(+), 5 deletions(-)
drivers/char/tpm/tpm-interface.c +1 -0
index 88dafcd..35b2722 100644
+++ b/drivers/char/tpm/tpm-interface.c

drivers/char/tpm/tpm-interface.c ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap, · line 469

Quoted 5 lines
drivers/char/tpm/tpm-interface.c +1 -1
@@ -466,16 +466,16 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
  * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing
  * a TPM error code.
  */
-void tpm_gen_interrupt(struct tpm_chip *chip)
+int tpm_gen_interrupt(struct tpm_chip *chip)

drivers/char/tpm/st33zp24/st33zp24.c needs to be updated too.

I looked at st33zp24.c and it looks broken, I don't see any logic that de-asserts TPM_CHIP_FLAG_IRQ if the irq test triggered by tpm_gen_interrupt, so presumably it should not be calling it at all.

Quoted 8 lines
Quoted 5 lines

IMHO, DT binding devices should never auto-probe IRQS anyhow, we only do it on PC because PC is insane...

If we fix st33 then I suggest just moving tpm_gen_interrupt into tpm_tis - nothing else should really be using it..

I'm happy to take fix for st33 but not the move because it does not matter for the release.

Ignore this comment, this series is not anyway going to 4.8 release.

If Christophe could submit a fix for st33, I could include it to this series and make one more revision. Thank you for reviewing this!

/Jarkko

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports.http://sdm.link/zohodev2dev

#7 lore raw

Re: [tpmdd-devel] [PATCH v3 3/5] tpm: return error code from tpm_gen_interrupt()

Quoted 35 lines · Jarkko Sakkinen
Quoted 34 lines · Jarkko Sakkinen
Quoted 32 lines · Jason Gunthorpe
Quoted 14 lines · Jarkko Sakkinen

Return error code from tpm_gen_interrupt() and fail tpm_tis family of drivers on a system error. It doesn't make sense to continue if we cannot even reach the TPM.

 drivers/char/tpm/tpm-interface.c | 6 +++---
 drivers/char/tpm/tpm.h           | 2 +-
 drivers/char/tpm/tpm_tis_core.c  | 4 +++-
 3 files changed, 7 insertions(+), 5 deletions(-)
drivers/char/tpm/tpm-interface.c +1 -0
index 88dafcd..35b2722 100644
+++ b/drivers/char/tpm/tpm-interface.c

drivers/char/tpm/tpm-interface.c ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap, · line 469

Quoted 5 lines
drivers/char/tpm/tpm-interface.c +1 -1
@@ -466,16 +466,16 @@ ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
  * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing
  * a TPM error code.
  */
-void tpm_gen_interrupt(struct tpm_chip *chip)
+int tpm_gen_interrupt(struct tpm_chip *chip)

drivers/char/tpm/st33zp24/st33zp24.c needs to be updated too.

I looked at st33zp24.c and it looks broken, I don't see any logic that de-asserts TPM_CHIP_FLAG_IRQ if the irq test triggered by tpm_gen_interrupt, so presumably it should not be calling it at all.

IMHO, DT binding devices should never auto-probe IRQS anyhow, we only do it on PC because PC is insane...

If we fix st33 then I suggest just moving tpm_gen_interrupt into tpm_tis - nothing else should really be using it..

Quoted 7 lines
Quoted 2 lines

I'm happy to take fix for st33 but not the move because it does not matter for the release.

Ignore this comment, this series is not anyway going to 4.8 release.

If Christophe could submit a fix for st33, I could include it to this series and make one more revision. Thank you for reviewing this!

Or alternatively if you can provide the fix, Christophe could test it.

/Jarkko

#8 lore raw

Re: [PATCH v3 3/5] tpm: return error code from tpm_gen_interrupt()

In reply to Jarkko Sakkinen
Quoted 2 lines · Jarkko Sakkinen

If Christophe could submit a fix for st33, I could include it to this series and make one more revision. Thank you for reviewing this!

Here is a commit:

Quoted 1 line

From 5e178858dcdc2bff9ac31f9851db52370cc282cb Mon Sep 17 00:00:00 2001

From: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Date: Tue, 19 Jul 2016 14:38:55 -0600
Subject: [PATCH] tpm/st33zp24: Remove useless tpm_gen_interrupt

This function should only be called as part of an IRQ probing protocol and st33 does not have any code to detect that the IRQ it tries to generate was not generated and disable the IRQ.

Since st33 is primarily a DT binding driver it should not be doing IRQ probing anyhow, so let us just delete this useless call.

---
 drivers/char/tpm/st33zp24/st33zp24.c | 2 --
 1 file changed, 2 deletions(-)
drivers/char/tpm/st33zp24/st33zp24.c +0 -2
index c2ee30451e41..6f060c76217b 100644
@@ -589,8 +589,6 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops,
 		chip->flags |= TPM_CHIP_FLAG_IRQ;
 
 		disable_irq_nosync(tpm_dev->irq);
-
-		tpm_gen_interrupt(chip);
 	}
 
 	return tpm_chip_register(chip);
Signature · 9 lines
2.1.4


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
#9 lore raw

Re: [PATCH v3 3/5] tpm: return error code from tpm_gen_interrupt()

Quoted 5 lines · Jason Gunthorpe
Quoted 2 lines · Jarkko Sakkinen

If Christophe could submit a fix for st33, I could include it to this series and make one more revision. Thank you for reviewing this!

Here is a commit:

Right I see. I just read through that file and now I understand the context.

I revamp one more revision of the series with tpm_gen_interrupt() moved as internal function for tis.

/Jarkko

Quoted 37 lines

From 5e178858dcdc2bff9ac31f9851db52370cc282cb Mon Sep 17 00:00:00 2001
From: Jason Gunthorpe <[email protected]>
Date: Tue, 19 Jul 2016 14:38:55 -0600
Subject: [PATCH] tpm/st33zp24: Remove useless tpm_gen_interrupt

This function should only be called as part of an IRQ probing protocol and st33 does not have any code to detect that the IRQ it tries to generate was not generated and disable the IRQ.

Since st33 is primarily a DT binding driver it should not be doing IRQ probing anyhow, so let us just delete this useless call.

---
 drivers/char/tpm/st33zp24/st33zp24.c | 2 --
 1 file changed, 2 deletions(-)
drivers/char/tpm/st33zp24/st33zp24.c +0 -2
index c2ee30451e41..6f060c76217b 100644
@@ -589,8 +589,6 @@ int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops,
 		chip->flags |= TPM_CHIP_FLAG_IRQ;
 
 		disable_irq_nosync(tpm_dev->irq);
-
-		tpm_gen_interrupt(chip);
 	}
 
 	return tpm_chip_register(chip);
Signature · 6 lines
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#10 lore raw

PATCH v3 4/5 tpm: use tpm_transmit_cmd() in tpm2_probe()

In reply to Jarkko Sakkinen

It is better to tpm_transmit_cmd() in tpm2_probe() in order to get consistent command handling throughout the subsystem.

---
 drivers/char/tpm/tpm2-cmd.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/char/tpm/tpm2-cmd.c +1 -3
index 1c393ba..e1db404 100644
@@ -911,11 +911,9 @@ int tpm2_probe(struct tpm_chip *chip)
 	cmd.params.get_tpm_pt_in.property_id = cpu_to_be32(0x100);
 	cmd.params.get_tpm_pt_in.property_cnt = cpu_to_be32(1);
 
-	rc = tpm_transmit(chip, (const char *) &cmd, sizeof(cmd));
+	rc = tpm_transmit_cmd(chip, &cmd, sizeof(cmd), NULL);
 	if (rc <  0)
 		return rc;
-	else if (rc < TPM_HEADER_SIZE)
-		return -EFAULT;
 
 	if (be16_to_cpu(cmd.header.out.tag) == TPM2_ST_NO_SESSIONS)
 		chip->flags |= TPM_CHIP_FLAG_TPM2;
Signature · 9 lines
2.7.4


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
#11 lore raw

PATCH v3 5/5 tpm: use tpm_pcr_read_dev() in tpm_do_selftest()

In reply to Jarkko Sakkinen

Remove ad-hoc protocol message construction and call instead tpm_pcr_read_dev().

---
 drivers/char/tpm/tpm-interface.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/char/tpm/tpm-interface.c +2 -5
index 35b2722..2db1610e 100644
@@ -797,7 +797,7 @@ int tpm_do_selftest(struct tpm_chip *chip)
 	unsigned int loops;
 	unsigned int delay_msec = 100;
 	unsigned long duration;
-	struct tpm_cmd_t cmd;
+	u8 dummy[TPM_DIGEST_SIZE];
 
 	duration = tpm_calc_ordinal_duration(chip, TPM_ORD_CONTINUE_SELFTEST);
 
@@ -812,9 +812,7 @@ int tpm_do_selftest(struct tpm_chip *chip)
 
 	do {
 		/* Attempt to read a PCR value */
-		cmd.header.in = pcrread_header;
-		cmd.params.pcrread_in.pcr_idx = cpu_to_be32(0);
-		rc = tpm_transmit(chip, (u8 *) &cmd, READ_PCR_RESULT_SIZE);
+		rc = tpm_pcr_read_dev(chip, 0, dummy);
 		/* Some buggy TPMs will not respond to tpm_tis_ready() for
 		 * around 300ms while the self test is ongoing, keep trying
 		 * until the self test duration expires. */
@@ -829,7 +827,6 @@ int tpm_do_selftest(struct tpm_chip *chip)
 		if (rc < TPM_HEADER_SIZE)
 			return -EFAULT;
 
-		rc = be32_to_cpu(cmd.header.out.return_code);
 		if (rc == TPM_ERR_DISABLED || rc == TPM_ERR_DEACTIVATED) {
 			dev_info(&chip->dev,
 				 "TPM is disabled/deactivated (0x%X)\n", rc);
Signature · 1 line
2.7.4
Reviewed-by on the v3 series
#12 lore raw
In reply to Jarkko Sakkinen
Quoted 11 lines · Jarkko Sakkinen

These commits update the subsystem consistently to use tpm_transmit_cmd() throughout the subsystem the exception being tpm_write() where it makes sense to use the raw interface because higher level command handling is delegated to user space. The point is to make semantics and error handling across the kernel call sites.

v3: Removed patch that renames tpm_pcr_read_dev() to tpm1_pcr_read() because it is not mandatory for this patch set.

v2: Added commit that drops externs from all function declarations in tpm.h as suggested by Jason Gunthorpe.

Other than my comment:

Jason

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic patterns at an interface-level. Reveals which users, apps, and protocols are consuming the most bandwidth. Provides multi-vendor support for NetFlow, J-Flow, sFlow and other flows. Make informed decisions using capacity planning reports.http://sdm.link/zohodev2dev