Commit e60d726f authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'tpmdd-next-v5.14-rc1' of...

Merge tag 'tpmdd-next-v5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd

Pull tpm driver updates from Jarkko Sakkinen:
 "Bug fixes for TPM"

[ This isn't actually the whole contents of the tag and thus doesn't
  contain Jarkko's signature - I dropped the two top commits that added
  support for signing modules using elliptic curve keys because there's
  a new series for that that fixes a few confising things   - Linus ]

* tag 'tpmdd-next-v5.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd:
  tpm: Replace WARN_ONCE() with dev_err_once() in tpm_tis_status()
  tpm_tis: Use DEFINE_RES_MEM() to simplify code
  tpm: fix some doc warnings in tpm1-cmd.c
  tpm_tis_spi: add missing SPI device ID entries
  tpm: add longer timeout for TPM2_CC_VERIFY_SIGNATURE
  char: tpm: move to use request_irq by IRQF_NO_AUTOEN flag
  tpm_tis_spi: set default probe function if device id not match
  tpm_crb: Use IOMEM_ERR_PTR when function returns iomem
parents 776ba3ad 0178f9d0
...@@ -312,7 +312,7 @@ unsigned long tpm1_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal) ...@@ -312,7 +312,7 @@ unsigned long tpm1_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal)
#define TPM_ST_CLEAR 1 #define TPM_ST_CLEAR 1
/** /**
* tpm_startup() - turn on the TPM * tpm1_startup() - turn on the TPM
* @chip: TPM chip to use * @chip: TPM chip to use
* *
* Normally the firmware should start the TPM. This function is provided as a * Normally the firmware should start the TPM. This function is provided as a
...@@ -611,7 +611,7 @@ int tpm1_pcr_read(struct tpm_chip *chip, u32 pcr_idx, u8 *res_buf) ...@@ -611,7 +611,7 @@ int tpm1_pcr_read(struct tpm_chip *chip, u32 pcr_idx, u8 *res_buf)
#define TPM_ORD_CONTINUE_SELFTEST 83 #define TPM_ORD_CONTINUE_SELFTEST 83
/** /**
* tpm_continue_selftest() - run TPM's selftest * tpm1_continue_selftest() - run TPM's selftest
* @chip: TPM chip to use * @chip: TPM chip to use
* *
* Returns 0 on success, < 0 in case of fatal error or a value > 0 representing * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing
......
...@@ -87,7 +87,7 @@ static u8 tpm2_ordinal_duration_index(u32 ordinal) ...@@ -87,7 +87,7 @@ static u8 tpm2_ordinal_duration_index(u32 ordinal)
return TPM_MEDIUM; return TPM_MEDIUM;
case TPM2_CC_VERIFY_SIGNATURE: /* 177 */ case TPM2_CC_VERIFY_SIGNATURE: /* 177 */
return TPM_LONG; return TPM_LONG_LONG;
case TPM2_CC_PCR_EXTEND: /* 182 */ case TPM2_CC_PCR_EXTEND: /* 182 */
return TPM_MEDIUM; return TPM_MEDIUM;
......
...@@ -464,7 +464,7 @@ static void __iomem *crb_map_res(struct device *dev, struct resource *iores, ...@@ -464,7 +464,7 @@ static void __iomem *crb_map_res(struct device *dev, struct resource *iores,
/* Detect a 64 bit address on a 32 bit system */ /* Detect a 64 bit address on a 32 bit system */
if (start != new_res.start) if (start != new_res.start)
return (void __iomem *) ERR_PTR(-EINVAL); return IOMEM_ERR_PTR(-EINVAL);
if (!iores) if (!iores)
return devm_ioremap_resource(dev, &new_res); return devm_ioremap_resource(dev, &new_res);
......
...@@ -363,11 +363,7 @@ static int tpm_tis_force_device(void) ...@@ -363,11 +363,7 @@ static int tpm_tis_force_device(void)
{ {
struct platform_device *pdev; struct platform_device *pdev;
static const struct resource x86_resources[] = { static const struct resource x86_resources[] = {
{ DEFINE_RES_MEM(0xFED40000, TIS_MEM_LEN)
.start = 0xFED40000,
.end = 0xFED40000 + TIS_MEM_LEN - 1,
.flags = IORESOURCE_MEM,
},
}; };
if (!force) if (!force)
......
...@@ -196,13 +196,24 @@ static u8 tpm_tis_status(struct tpm_chip *chip) ...@@ -196,13 +196,24 @@ static u8 tpm_tis_status(struct tpm_chip *chip)
return 0; return 0;
if (unlikely((status & TPM_STS_READ_ZERO) != 0)) { if (unlikely((status & TPM_STS_READ_ZERO) != 0)) {
/* if (!test_and_set_bit(TPM_TIS_INVALID_STATUS, &priv->flags)) {
* If this trips, the chances are the read is /*
* returning 0xff because the locality hasn't been * If this trips, the chances are the read is
* acquired. Usually because tpm_try_get_ops() hasn't * returning 0xff because the locality hasn't been
* been called before doing a TPM operation. * acquired. Usually because tpm_try_get_ops() hasn't
*/ * been called before doing a TPM operation.
WARN_ONCE(1, "TPM returned invalid status\n"); */
dev_err(&chip->dev, "invalid TPM_STS.x 0x%02x, dumping stack for forensics\n",
status);
/*
* Dump stack for forensics, as invalid TPM_STS.x could be
* potentially triggered by impaired tpm_try_get_ops() or
* tpm_find_get_ops().
*/
dump_stack();
}
return 0; return 0;
} }
......
...@@ -83,6 +83,7 @@ enum tis_defaults { ...@@ -83,6 +83,7 @@ enum tis_defaults {
enum tpm_tis_flags { enum tpm_tis_flags {
TPM_TIS_ITPM_WORKAROUND = BIT(0), TPM_TIS_ITPM_WORKAROUND = BIT(0),
TPM_TIS_INVALID_STATUS = BIT(1),
}; };
struct tpm_tis_data { struct tpm_tis_data {
...@@ -90,7 +91,7 @@ struct tpm_tis_data { ...@@ -90,7 +91,7 @@ struct tpm_tis_data {
int locality; int locality;
int irq; int irq;
bool irq_tested; bool irq_tested;
unsigned int flags; unsigned long flags;
void __iomem *ilb_base_addr; void __iomem *ilb_base_addr;
u16 clkrun_enabled; u16 clkrun_enabled;
wait_queue_head_t int_queue; wait_queue_head_t int_queue;
......
...@@ -706,14 +706,14 @@ static int tpm_cr50_i2c_probe(struct i2c_client *client, ...@@ -706,14 +706,14 @@ static int tpm_cr50_i2c_probe(struct i2c_client *client,
if (client->irq > 0) { if (client->irq > 0) {
rc = devm_request_irq(dev, client->irq, tpm_cr50_i2c_int_handler, rc = devm_request_irq(dev, client->irq, tpm_cr50_i2c_int_handler,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT, IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
IRQF_NO_AUTOEN,
dev->driver->name, chip); dev->driver->name, chip);
if (rc < 0) { if (rc < 0) {
dev_err(dev, "Failed to probe IRQ %d\n", client->irq); dev_err(dev, "Failed to probe IRQ %d\n", client->irq);
return rc; return rc;
} }
disable_irq(client->irq);
priv->irq = client->irq; priv->irq = client->irq;
} else { } else {
dev_warn(dev, "No IRQ, will use %ums delay for TPM ready\n", dev_warn(dev, "No IRQ, will use %ums delay for TPM ready\n",
......
...@@ -240,10 +240,14 @@ static int tpm_tis_spi_driver_probe(struct spi_device *spi) ...@@ -240,10 +240,14 @@ static int tpm_tis_spi_driver_probe(struct spi_device *spi)
tpm_tis_spi_probe_func probe_func; tpm_tis_spi_probe_func probe_func;
probe_func = of_device_get_match_data(&spi->dev); probe_func = of_device_get_match_data(&spi->dev);
if (!probe_func && spi_dev_id) if (!probe_func) {
probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data; if (spi_dev_id) {
if (!probe_func) probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data;
return -ENODEV; if (!probe_func)
return -ENODEV;
} else
probe_func = tpm_tis_spi_probe;
}
return probe_func(spi); return probe_func(spi);
} }
...@@ -260,6 +264,8 @@ static int tpm_tis_spi_remove(struct spi_device *dev) ...@@ -260,6 +264,8 @@ static int tpm_tis_spi_remove(struct spi_device *dev)
} }
static const struct spi_device_id tpm_tis_spi_id[] = { static const struct spi_device_id tpm_tis_spi_id[] = {
{ "st33htpm-spi", (unsigned long)tpm_tis_spi_probe },
{ "slb9670", (unsigned long)tpm_tis_spi_probe },
{ "tpm_tis_spi", (unsigned long)tpm_tis_spi_probe }, { "tpm_tis_spi", (unsigned long)tpm_tis_spi_probe },
{ "cr50", (unsigned long)cr50_spi_probe }, { "cr50", (unsigned long)cr50_spi_probe },
{} {}
......
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