[PATCH v3 0/4] Fixes for TPM interrupt handling

From: Lino Sanfilippo
Date: Sat May 01 2021 - 10:01:55 EST


This series enables interrupts for TPM. For this some obstacles had to be
removed first, like the interrupt handler running in interrupt context and
thus not allowing to access registers over SPI. Also the locality handling
has been simplified to make a complicated synchronization between threads
and irq handler unnecessary. As a side effect of this simplification a bug
is fixed in which a TMP command is issued without a claimed locality in
case of TPM 2.
Another fix concerns the interrupt test which currently is broken.
Finally the results of the capability query at startup is used to only set
the interrupts which are actually supported by the hardware.

These patches are based on commit 9f67672a817e ("Merge tag 'ext4_for_linus'
of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4") and tested on
on a SLB 9670 which is connected via SPI.

Of course any further testing is highly appreciated.

PATCH 1: The SPI implementation of the functions to read/write to/from
registers uses mutexes and thus require a sleepable context. For this
reason request a threaded interrupt handler.

PATCH 2: Simplify locality handling by taking the driver locality (0) at
driver startup and releasing it at driver shutdown. This also fixes a bug
in case of TMP 2.

PATCH 3: Fix and simplify the test for interrupts.

PATCH 4: Only set the interrupts which are reported as being available.

Changes in v3:
- fixed compiler error reported by kernel test robot
- rephrased commit message as suggested by Jarko Sakkinen
- added Reviewed-by tag

Changes in v2:
- rebase against 5.12
- free irq on error path


Lino Sanfilippo (4):
tpm: Use a threaded interrupt handler
tpm: Simplify locality handling
tpm: Fix test for interrupts
tpm: Only enable supported irqs

drivers/char/tpm/tpm-chip.c | 40 --------
drivers/char/tpm/tpm_tis_core.c | 170 +++++++++++++-------------------
drivers/char/tpm/tpm_tis_core.h | 2 +-
include/linux/tpm.h | 5 +-
4 files changed, 72 insertions(+), 145 deletions(-)


base-commit: 9f67672a817ec046f7554a885f0fe0d60e1bf99f
--
2.31.1