Commit 7ab4032f authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Jarkko Sakkinen

tpm_tis: Get rid of the duplicate IRQ probing code

The new code that works directly in tpm_tis_send is able to handle
IRQ probing duties as well, so just use it for everything.
Signed-off-by: default avatarJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Reviewed-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: default avatarMartin Wilck <Martin.Wilck@ts.fujitsu.com>
Tested-by: default avatarScot Doyle <lkml14@scotdoyle.com>
Signed-off--by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Acked-by: default avatarPeter Huewe <peterhuewe@gmx.de>
parent 25112048
...@@ -138,7 +138,6 @@ struct tpm_vendor_specific { ...@@ -138,7 +138,6 @@ struct tpm_vendor_specific {
unsigned long base; /* TPM base address */ unsigned long base; /* TPM base address */
int irq; int irq;
int probed_irq;
int region_size; int region_size;
int have_region; int have_region;
......
...@@ -99,6 +99,7 @@ static struct tpm_info tis_default_info = { ...@@ -99,6 +99,7 @@ static struct tpm_info tis_default_info = {
#define TPM_RID(l) (0x0F04 | ((l) << 12)) #define TPM_RID(l) (0x0F04 | ((l) << 12))
struct priv_data { struct priv_data {
bool irq_probing;
bool irq_tested; bool irq_tested;
}; };
...@@ -463,8 +464,9 @@ static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len) ...@@ -463,8 +464,9 @@ static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len)
msleep(1); msleep(1);
if (!priv->irq_tested) { if (!priv->irq_tested) {
disable_interrupts(chip); disable_interrupts(chip);
dev_err(chip->pdev, if (!priv->irq_probing)
FW_BUG "TPM interrupt not working, polling instead\n"); dev_err(chip->pdev, FW_BUG
"TPM interrupt not working, polling instead\n");
} }
priv->irq_tested = true; priv->irq_tested = true;
return rc; return rc;
...@@ -570,26 +572,6 @@ static const struct tpm_class_ops tpm_tis = { ...@@ -570,26 +572,6 @@ static const struct tpm_class_ops tpm_tis = {
.req_canceled = tpm_tis_req_canceled, .req_canceled = tpm_tis_req_canceled,
}; };
static irqreturn_t tis_int_probe(int irq, void *dev_id)
{
struct tpm_chip *chip = dev_id;
u32 interrupt;
interrupt = ioread32(chip->vendor.iobase +
TPM_INT_STATUS(chip->vendor.locality));
if (interrupt == 0)
return IRQ_NONE;
chip->vendor.probed_irq = irq;
/* Clear interrupts handled with TPM_EOI */
iowrite32(interrupt,
chip->vendor.iobase +
TPM_INT_STATUS(chip->vendor.locality));
return IRQ_HANDLED;
}
static irqreturn_t tis_int_handler(int dummy, void *dev_id) static irqreturn_t tis_int_handler(int dummy, void *dev_id)
{ {
struct tpm_chip *chip = dev_id; struct tpm_chip *chip = dev_id;
...@@ -772,13 +754,14 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, ...@@ -772,13 +754,14 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
iowrite8(i, chip->vendor.iobase + iowrite8(i, chip->vendor.iobase +
TPM_INT_VECTOR(chip->vendor.locality)); TPM_INT_VECTOR(chip->vendor.locality));
if (devm_request_irq if (devm_request_irq
(dev, i, tis_int_probe, IRQF_SHARED, (dev, i, tis_int_handler, IRQF_SHARED,
chip->devname, chip) != 0) { chip->devname, chip) != 0) {
dev_info(chip->pdev, dev_info(chip->pdev,
"Unable to request irq: %d for probe\n", "Unable to request irq: %d for probe\n",
i); i);
continue; continue;
} }
chip->vendor.irq = i;
/* Clear all existing */ /* Clear all existing */
iowrite32(ioread32 iowrite32(ioread32
...@@ -792,7 +775,8 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, ...@@ -792,7 +775,8 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
chip->vendor.iobase + chip->vendor.iobase +
TPM_INT_ENABLE(chip->vendor.locality)); TPM_INT_ENABLE(chip->vendor.locality));
chip->vendor.probed_irq = 0; priv->irq_tested = false;
priv->irq_probing = true;
/* Generate Interrupts */ /* Generate Interrupts */
if (chip->flags & TPM_CHIP_FLAG_TPM2) if (chip->flags & TPM_CHIP_FLAG_TPM2)
...@@ -800,26 +784,20 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, ...@@ -800,26 +784,20 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
else else
tpm_gen_interrupt(chip); tpm_gen_interrupt(chip);
chip->vendor.irq = chip->vendor.probed_irq; priv->irq_probing = false;
/* free_irq will call into tis_int_probe;
clear all irqs we haven't seen while doing
tpm_gen_interrupt */
iowrite32(ioread32
(chip->vendor.iobase +
TPM_INT_STATUS(chip->vendor.locality)),
chip->vendor.iobase +
TPM_INT_STATUS(chip->vendor.locality));
/* Turn off */
iowrite32(intmask,
chip->vendor.iobase +
TPM_INT_ENABLE(chip->vendor.locality));
devm_free_irq(dev, i, chip); /* tpm_tis_send will either confirm the interrupt is
* working or it will call disable_irq which undoes
* all of the above.
*/
if (chip->vendor.irq)
break;
} }
if (!chip->vendor.irq)
iowrite8(irq_r, chip->vendor.iobase +
TPM_INT_VECTOR(chip->vendor.locality));
} }
if (chip->vendor.irq) { if (chip->vendor.irq && !priv->irq_tested) {
iowrite8(chip->vendor.irq, iowrite8(chip->vendor.irq,
chip->vendor.iobase + chip->vendor.iobase +
TPM_INT_VECTOR(chip->vendor.locality)); TPM_INT_VECTOR(chip->vendor.locality));
...@@ -843,9 +821,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info, ...@@ -843,9 +821,7 @@ static int tpm_tis_init(struct device *dev, struct tpm_info *tpm_info,
chip->vendor.iobase + chip->vendor.iobase +
TPM_INT_ENABLE(chip->vendor.locality)); TPM_INT_ENABLE(chip->vendor.locality));
} }
} else if (irq_r != -1) }
iowrite8(irq_r, chip->vendor.iobase +
TPM_INT_VECTOR(chip->vendor.locality));
if (tpm_get_timeouts(chip)) { if (tpm_get_timeouts(chip)) {
dev_err(dev, "Could not get TPM timeouts and durations\n"); dev_err(dev, "Could not get TPM timeouts and durations\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment