Skip to content

Commit e60d726

Browse files
committed
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
2 parents 776ba3a + 0178f9d commit e60d726

File tree

8 files changed

+37
-23
lines changed

8 files changed

+37
-23
lines changed

drivers/char/tpm/tpm1-cmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ unsigned long tpm1_calc_ordinal_duration(struct tpm_chip *chip, u32 ordinal)
312312
#define TPM_ST_CLEAR 1
313313

314314
/**
315-
* tpm_startup() - turn on the TPM
315+
* tpm1_startup() - turn on the TPM
316316
* @chip: TPM chip to use
317317
*
318318
* 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)
611611

612612
#define TPM_ORD_CONTINUE_SELFTEST 83
613613
/**
614-
* tpm_continue_selftest() - run TPM's selftest
614+
* tpm1_continue_selftest() - run TPM's selftest
615615
* @chip: TPM chip to use
616616
*
617617
* Returns 0 on success, < 0 in case of fatal error or a value > 0 representing

drivers/char/tpm/tpm2-cmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static u8 tpm2_ordinal_duration_index(u32 ordinal)
8787
return TPM_MEDIUM;
8888

8989
case TPM2_CC_VERIFY_SIGNATURE: /* 177 */
90-
return TPM_LONG;
90+
return TPM_LONG_LONG;
9191

9292
case TPM2_CC_PCR_EXTEND: /* 182 */
9393
return TPM_MEDIUM;

drivers/char/tpm/tpm_crb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ static void __iomem *crb_map_res(struct device *dev, struct resource *iores,
464464

465465
/* Detect a 64 bit address on a 32 bit system */
466466
if (start != new_res.start)
467-
return (void __iomem *) ERR_PTR(-EINVAL);
467+
return IOMEM_ERR_PTR(-EINVAL);
468468

469469
if (!iores)
470470
return devm_ioremap_resource(dev, &new_res);

drivers/char/tpm/tpm_tis.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,11 +363,7 @@ static int tpm_tis_force_device(void)
363363
{
364364
struct platform_device *pdev;
365365
static const struct resource x86_resources[] = {
366-
{
367-
.start = 0xFED40000,
368-
.end = 0xFED40000 + TIS_MEM_LEN - 1,
369-
.flags = IORESOURCE_MEM,
370-
},
366+
DEFINE_RES_MEM(0xFED40000, TIS_MEM_LEN)
371367
};
372368

373369
if (!force)

drivers/char/tpm/tpm_tis_core.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,24 @@ static u8 tpm_tis_status(struct tpm_chip *chip)
196196
return 0;
197197

198198
if (unlikely((status & TPM_STS_READ_ZERO) != 0)) {
199-
/*
200-
* If this trips, the chances are the read is
201-
* returning 0xff because the locality hasn't been
202-
* acquired. Usually because tpm_try_get_ops() hasn't
203-
* been called before doing a TPM operation.
204-
*/
205-
WARN_ONCE(1, "TPM returned invalid status\n");
199+
if (!test_and_set_bit(TPM_TIS_INVALID_STATUS, &priv->flags)) {
200+
/*
201+
* If this trips, the chances are the read is
202+
* returning 0xff because the locality hasn't been
203+
* acquired. Usually because tpm_try_get_ops() hasn't
204+
* been called before doing a TPM operation.
205+
*/
206+
dev_err(&chip->dev, "invalid TPM_STS.x 0x%02x, dumping stack for forensics\n",
207+
status);
208+
209+
/*
210+
* Dump stack for forensics, as invalid TPM_STS.x could be
211+
* potentially triggered by impaired tpm_try_get_ops() or
212+
* tpm_find_get_ops().
213+
*/
214+
dump_stack();
215+
}
216+
206217
return 0;
207218
}
208219

drivers/char/tpm/tpm_tis_core.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,15 @@ enum tis_defaults {
8383

8484
enum tpm_tis_flags {
8585
TPM_TIS_ITPM_WORKAROUND = BIT(0),
86+
TPM_TIS_INVALID_STATUS = BIT(1),
8687
};
8788

8889
struct tpm_tis_data {
8990
u16 manufacturer_id;
9091
int locality;
9192
int irq;
9293
bool irq_tested;
93-
unsigned int flags;
94+
unsigned long flags;
9495
void __iomem *ilb_base_addr;
9596
u16 clkrun_enabled;
9697
wait_queue_head_t int_queue;

drivers/char/tpm/tpm_tis_i2c_cr50.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,14 +706,14 @@ static int tpm_cr50_i2c_probe(struct i2c_client *client,
706706

707707
if (client->irq > 0) {
708708
rc = devm_request_irq(dev, client->irq, tpm_cr50_i2c_int_handler,
709-
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
709+
IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
710+
IRQF_NO_AUTOEN,
710711
dev->driver->name, chip);
711712
if (rc < 0) {
712713
dev_err(dev, "Failed to probe IRQ %d\n", client->irq);
713714
return rc;
714715
}
715716

716-
disable_irq(client->irq);
717717
priv->irq = client->irq;
718718
} else {
719719
dev_warn(dev, "No IRQ, will use %ums delay for TPM ready\n",

drivers/char/tpm/tpm_tis_spi_main.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,14 @@ static int tpm_tis_spi_driver_probe(struct spi_device *spi)
240240
tpm_tis_spi_probe_func probe_func;
241241

242242
probe_func = of_device_get_match_data(&spi->dev);
243-
if (!probe_func && spi_dev_id)
244-
probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data;
245-
if (!probe_func)
246-
return -ENODEV;
243+
if (!probe_func) {
244+
if (spi_dev_id) {
245+
probe_func = (tpm_tis_spi_probe_func)spi_dev_id->driver_data;
246+
if (!probe_func)
247+
return -ENODEV;
248+
} else
249+
probe_func = tpm_tis_spi_probe;
250+
}
247251

248252
return probe_func(spi);
249253
}
@@ -260,6 +264,8 @@ static int tpm_tis_spi_remove(struct spi_device *dev)
260264
}
261265

262266
static const struct spi_device_id tpm_tis_spi_id[] = {
267+
{ "st33htpm-spi", (unsigned long)tpm_tis_spi_probe },
268+
{ "slb9670", (unsigned long)tpm_tis_spi_probe },
263269
{ "tpm_tis_spi", (unsigned long)tpm_tis_spi_probe },
264270
{ "cr50", (unsigned long)cr50_spi_probe },
265271
{}

0 commit comments

Comments
 (0)