Commit cba58263 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'tpmdd-v6.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd

Pull tpm fixes from Jarkko Sakkinen:
 "Three bug fixes for recently discovered issues"

* tag 'tpmdd-v6.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd:
  tpm/tpm_tis: Disable interrupts for more Lenovo devices
  tpm: Prevent hwrng from activating during resume
  tpm_tis: Use tpm_chip_{start,stop} decoration inside tpm_tis_resume
parents a18ef64f e7d3e5c4
...@@ -571,6 +571,10 @@ static int tpm_hwrng_read(struct hwrng *rng, void *data, size_t max, bool wait) ...@@ -571,6 +571,10 @@ static int tpm_hwrng_read(struct hwrng *rng, void *data, size_t max, bool wait)
{ {
struct tpm_chip *chip = container_of(rng, struct tpm_chip, hwrng); struct tpm_chip *chip = container_of(rng, struct tpm_chip, hwrng);
/* Give back zero bytes, as TPM chip has not yet fully resumed: */
if (chip->flags & TPM_CHIP_FLAG_SUSPENDED)
return 0;
return tpm_get_random(chip, data, max); return tpm_get_random(chip, data, max);
} }
......
...@@ -412,6 +412,8 @@ int tpm_pm_suspend(struct device *dev) ...@@ -412,6 +412,8 @@ int tpm_pm_suspend(struct device *dev)
} }
suspended: suspended:
chip->flags |= TPM_CHIP_FLAG_SUSPENDED;
if (rc) if (rc)
dev_err(dev, "Ignoring error %d while suspending\n", rc); dev_err(dev, "Ignoring error %d while suspending\n", rc);
return 0; return 0;
...@@ -429,6 +431,14 @@ int tpm_pm_resume(struct device *dev) ...@@ -429,6 +431,14 @@ int tpm_pm_resume(struct device *dev)
if (chip == NULL) if (chip == NULL)
return -ENODEV; return -ENODEV;
chip->flags &= ~TPM_CHIP_FLAG_SUSPENDED;
/*
* Guarantee that SUSPENDED is written last, so that hwrng does not
* activate before the chip has been fully resumed.
*/
wmb();
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(tpm_pm_resume); EXPORT_SYMBOL_GPL(tpm_pm_resume);
......
...@@ -122,6 +122,22 @@ static const struct dmi_system_id tpm_tis_dmi_table[] = { ...@@ -122,6 +122,22 @@ static const struct dmi_system_id tpm_tis_dmi_table[] = {
DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T490s"), DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T490s"),
}, },
}, },
{
.callback = tpm_tis_disable_irq,
.ident = "ThinkStation P360 Tiny",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkStation P360 Tiny"),
},
},
{
.callback = tpm_tis_disable_irq,
.ident = "ThinkPad L490",
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L490"),
},
},
{} {}
}; };
......
...@@ -1209,25 +1209,20 @@ static void tpm_tis_reenable_interrupts(struct tpm_chip *chip) ...@@ -1209,25 +1209,20 @@ static void tpm_tis_reenable_interrupts(struct tpm_chip *chip)
u32 intmask; u32 intmask;
int rc; int rc;
if (chip->ops->clk_enable != NULL) /*
chip->ops->clk_enable(chip, true); * Re-enable interrupts that device may have lost or BIOS/firmware may
* have disabled.
/* reenable interrupts that device may have lost or
* BIOS/firmware may have disabled
*/ */
rc = tpm_tis_write8(priv, TPM_INT_VECTOR(priv->locality), priv->irq); rc = tpm_tis_write8(priv, TPM_INT_VECTOR(priv->locality), priv->irq);
if (rc < 0) if (rc < 0) {
goto out; dev_err(&chip->dev, "Setting IRQ failed.\n");
return;
}
intmask = priv->int_mask | TPM_GLOBAL_INT_ENABLE; intmask = priv->int_mask | TPM_GLOBAL_INT_ENABLE;
rc = tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask);
tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); if (rc < 0)
dev_err(&chip->dev, "Enabling interrupts failed.\n");
out:
if (chip->ops->clk_enable != NULL)
chip->ops->clk_enable(chip, false);
return;
} }
int tpm_tis_resume(struct device *dev) int tpm_tis_resume(struct device *dev)
...@@ -1235,27 +1230,27 @@ int tpm_tis_resume(struct device *dev) ...@@ -1235,27 +1230,27 @@ int tpm_tis_resume(struct device *dev)
struct tpm_chip *chip = dev_get_drvdata(dev); struct tpm_chip *chip = dev_get_drvdata(dev);
int ret; int ret;
ret = tpm_tis_request_locality(chip, 0); ret = tpm_chip_start(chip);
if (ret < 0) if (ret)
return ret; return ret;
if (chip->flags & TPM_CHIP_FLAG_IRQ) if (chip->flags & TPM_CHIP_FLAG_IRQ)
tpm_tis_reenable_interrupts(chip); tpm_tis_reenable_interrupts(chip);
ret = tpm_pm_resume(dev);
if (ret)
goto out;
/* /*
* TPM 1.2 requires self-test on resume. This function actually returns * TPM 1.2 requires self-test on resume. This function actually returns
* an error code but for unknown reason it isn't handled. * an error code but for unknown reason it isn't handled.
*/ */
if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) if (!(chip->flags & TPM_CHIP_FLAG_TPM2))
tpm1_do_selftest(chip); tpm1_do_selftest(chip);
out:
tpm_tis_relinquish_locality(chip, 0);
return ret; tpm_chip_stop(chip);
ret = tpm_pm_resume(dev);
if (ret)
return ret;
return 0;
} }
EXPORT_SYMBOL_GPL(tpm_tis_resume); EXPORT_SYMBOL_GPL(tpm_tis_resume);
#endif #endif
......
...@@ -282,6 +282,7 @@ enum tpm_chip_flags { ...@@ -282,6 +282,7 @@ enum tpm_chip_flags {
TPM_CHIP_FLAG_ALWAYS_POWERED = BIT(5), TPM_CHIP_FLAG_ALWAYS_POWERED = BIT(5),
TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED = BIT(6), TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED = BIT(6),
TPM_CHIP_FLAG_FIRMWARE_UPGRADE = BIT(7), TPM_CHIP_FLAG_FIRMWARE_UPGRADE = BIT(7),
TPM_CHIP_FLAG_SUSPENDED = BIT(8),
}; };
#define to_tpm_chip(d) container_of(d, struct tpm_chip, dev) #define to_tpm_chip(d) container_of(d, struct tpm_chip, dev)
......
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