diff mbox

[tpmdd-devel,3/6] tpm_tis: restore IRQ vector in IO memory after failed probing

Message ID 1446740353-15235-4-git-send-email-martin.wilck@ts.fujitsu.com
State New
Headers show

Commit Message

Martin Wilck Nov. 5, 2015, 4:19 p.m. UTC
From: Martin Wilck <Martin.Wilck@ts.fujitsu.com>

If no working IRQ is found during probing, restore the original
value found in IO memory before the probing procedure.

Signed-off-by: Martin Wilck <Martin.Wilck@ts.fujitsu.com>
---
 drivers/char/tpm/tpm_tis.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Jarkko Sakkinen Nov. 5, 2015, 10:07 p.m. UTC | #1
On Thu, Nov 05, 2015 at 05:19:10PM +0100, martin.wilck@ts.fujitsu.com wrote:
> From: Martin Wilck <Martin.Wilck@ts.fujitsu.com>
> 
> If no working IRQ is found during probing, restore the original
> value found in IO memory before the probing procedure.

Is this causing regressions?

> Signed-off-by: Martin Wilck <Martin.Wilck@ts.fujitsu.com>

/Jarkko

------------------------------------------------------------------------------
Martin Wilck Nov. 9, 2015, 10:33 a.m. UTC | #2
> > If no working IRQ is found during probing, restore the original
> > value found in IO memory before the probing procedure.
> 
> Is this causing regressions?

If the probing finishes without success, it will leave the value 15 in
the TPM_IRQ_VECTOR register. If the driver is unloaded and reloaded, it
will "think" that the hardware had been programmed with IRQ 15, and will
not probe again. That was causing me some trouble while testing.

Otherwise, it's just a matter of tidying up.

Martin

------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a 
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
Jarkko Sakkinen Nov. 9, 2015, 2:32 p.m. UTC | #3
On Mon, Nov 09, 2015 at 11:33:07AM +0100, Wilck, Martin wrote:
> > > If no working IRQ is found during probing, restore the original
> > > value found in IO memory before the probing procedure.
> > 
> > Is this causing regressions?
> 
> If the probing finishes without success, it will leave the value 15 in
> the TPM_IRQ_VECTOR register. If the driver is unloaded and reloaded, it
> will "think" that the hardware had been programmed with IRQ 15, and will
> not probe again. That was causing me some trouble while testing.
> 
> Otherwise, it's just a matter of tidying up.

This makes perfect sense and is a real regression. I'll include this to
my next pull request. Thanks for catching this!

> Martin

/Jarkko

------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a 
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
diff mbox

Patch

diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 474f752..7619035 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -645,6 +645,7 @@  static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
 {
 	u32 vendor, intfcaps, intmask;
 	int rc, i, irq_s, irq_e, probe;
+	int irq_r = -1;
 	struct tpm_chip *chip;
 	struct priv_data *priv;
 
@@ -770,6 +771,7 @@  static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
 		irq_s =
 		    ioread8(chip->vendor.iobase +
 			    TPM_INT_VECTOR(chip->vendor.locality));
+		irq_r = irq_s;
 		if (irq_s) {
 			irq_e = irq_s;
 		} else {
@@ -859,7 +861,9 @@  static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
 				  chip->vendor.iobase +
 				  TPM_INT_ENABLE(chip->vendor.locality));
 		}
-	}
+	} else if (irq_r != -1)
+		iowrite8(irq_r, chip->vendor.iobase +
+			 TPM_INT_VECTOR(chip->vendor.locality));
 
 	if (chip->flags & TPM_CHIP_FLAG_TPM2) {
 		rc = tpm2_do_selftest(chip);