All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v9 00/12] TPM IRQ fixes
@ 2022-11-10 15:25 Lino Sanfilippo
  2022-11-10 15:25 ` [PATCH v9 01/12] tpm, tpm_tis: Avoid cache incoherency in test for interrupts Lino Sanfilippo
                   ` (11 more replies)
  0 siblings, 12 replies; 14+ messages in thread
From: Lino Sanfilippo @ 2022-11-10 15:25 UTC (permalink / raw)
  To: peterhuewe, jarkko, jgg
  Cc: stefanb, linux, linux-integrity, linux-kernel, jandryuk, pmenzel,
	l.sanfilippo, LinoSanfilippo, lukas, p.rosenberger

From: Lino Sanfilippo <l.sanfilippo@kunbus.com>

This series enables IRQ support for the TPM TIS core. For this reason a
number of bugfixes around the interrupt handling are required (patches 1 to
4).

Patch 5 takes into account that according to the TPM Interface
Specification stsValid and commandRead interrupts might not be supported
by the hardware. For this reason the supported interrupts are first queried
and stored. Then wait_for_tpm_stat() is adjusted to not wait for status
changes that are not reported by interrupts.

Patch 6 moves the interrupt flag checks into an own function as suggested
by Jarkko.

Patch 7 Removes the possibility that tpm_tis_data->locality can be changed
at driver runtime so this variable can be read without the need to protect
it against concurrent modification. 

Patch 8 addresses the issue with concurrent locality handling:
Since the interrupt handler writes the interrupt status registers it needs
to hold the locality. However it runs concurrently to the thread which
triggered the interrupt (e.g. by reading or writing data to the TPM). So
it must take care when claiming and releasing the locality itself,
because it may race with the concurrent running thread which also claims
and releases the locality.
To avoid that both interrupt and concurrent running thread interfere with
each other a locality counter is used which guarantees that at any time
the locality is held as long as it is required by one of both execution
paths.

Patch 9 implements the request of a threaded interrupt handler. This is
needed since SPI uses a mutex for data transmission and since we access the
interrupt status register via SPI in the irq handler we need a sleepable
context.

Patch 10 makes sure that writes to the interrupt register are effective if
done in the interrupt handler.

Patch 11 makes sure that writes to the interrupt and INTERRUPT_VECTOR
and INTERRUPT_ENABLE registers are effective by holding the locality.

Patch 12 enables the test for interrupts by setting the required flag
before the test is executed.

Changes in v9:
- add a fix for an issue when interrupts are reenabled on resume (PATCH 11)
- improve the commit message for patch 8 as requested by Jarkko
- improved functions naming
- changed patch 12 (tpm, tpm_tis: Request threaded interrupt handler) to
  not delete the TPM_CHIP_FLAG_IRQ flag any more when tpm2_get_tpm_pt()
  fails. Due to this change the 'Tested-by' tag from Michael and the
  'Reviewed-by:' tag from Jarko has been removed

Changes in v8:
- tpm_tis_data->locality is not changed at runtime any more so that it can
be read without any protection against concurrent modification.
- add missing brackets as pointed out by Jason Andryuk

Changes in v7:
- moved interrupt flag checks into an own function as suggested by Jarkko
- added "Tested-by" tags for Tests from Michael Niewöhner
- fixed one comment

Changes in v6:
- set TPM_TIS_IRQ_TESTED in flag member of the tpm_tis_data struct instead
in an own bitfield 
- improve commit messages
- use int_mask instead of irqs_in_use as variable name
- use sts_mask instead of active_irqs as variable name
- squash patch 5 and 6
- prefix functions with tpm_tis_
- remove "fixes" tag

Changes in v5:
- improve commit message of patch 1 as requested by Jarko
- drop patch that makes locality handling simpler by only claiming it at
  driver startup and releasing it at driver shutdown (requested by Jarko)
- drop patch that moves the interrupt test from tpm_tis_send()
  to tmp_tis_probe_irq_single() as requested by Jarko
- add patch to make locality handling threadsafe so that it can also be
  done by the irq handler
- separate logical changes into own patches
- always request threaded interrupt handler

Changes in v4:
- only request threaded irq in case of SPI as requested by Jarko.
- reimplement patch 2 to limit locality handling changes to the TIS core.
- separate fixes from cleanups as requested by Jarko.
- rephrase commit messages 

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 (12):
  tpm, tpm_tis: Avoid cache incoherency in test for interrupts
  tpm, tpm_tis: Claim locality before writing TPM_INT_ENABLE register
  tpm, tpm_tis: Disable interrupts if tpm_tis_probe_irq() failed
  tpm, tmp_tis: Claim locality before writing interrupt registers
  tpm, tpm_tis: Only handle supported interrupts
  tpm, tpm_tis: Move interrupt mask checks into own function
  tpm, tpm_tis: do not check for the active locality in interrupt
    handler
  tpm, tpm: Implement usage counter for locality
  tpm, tpm_tis: Request threaded interrupt handler
  tpm, tpm_tis: Claim locality in interrupt handler
  tpm, tpm_tis: Claim locality when interrupts are reenabled on resume
  tpm, tpm_tis: Enable interrupt test

 drivers/char/tpm/tpm_tis.c      |   2 +-
 drivers/char/tpm/tpm_tis_core.c | 279 ++++++++++++++++++++------------
 drivers/char/tpm/tpm_tis_core.h |   5 +-
 3 files changed, 185 insertions(+), 101 deletions(-)


base-commit: 30a0b95b1335e12efef89dd78518ed3e4a71a763
-- 
2.36.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-11-14 13:36 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-10 15:25 [PATCH v9 00/12] TPM IRQ fixes Lino Sanfilippo
2022-11-10 15:25 ` [PATCH v9 01/12] tpm, tpm_tis: Avoid cache incoherency in test for interrupts Lino Sanfilippo
2022-11-10 15:25 ` [PATCH v9 02/12] tpm, tpm_tis: Claim locality before writing TPM_INT_ENABLE register Lino Sanfilippo
2022-11-10 15:25 ` [PATCH v9 03/12] tpm, tpm_tis: Disable interrupts if tpm_tis_probe_irq() failed Lino Sanfilippo
2022-11-10 15:25 ` [PATCH v9 04/12] tpm, tmp_tis: Claim locality before writing interrupt registers Lino Sanfilippo
2022-11-10 15:25 ` [PATCH v9 05/12] tpm, tpm_tis: Only handle supported interrupts Lino Sanfilippo
2022-11-10 15:25 ` [PATCH v9 06/12] tpm, tpm_tis: Move interrupt mask checks into own function Lino Sanfilippo
2022-11-10 15:25 ` [PATCH v9 07/12] tpm, tpm_tis: do not check for the active locality in interrupt handler Lino Sanfilippo
2022-11-10 15:25 ` [PATCH v9 08/12] tpm, tpm: Implement usage counter for locality Lino Sanfilippo
2022-11-10 15:25 ` [PATCH v9 09/12] tpm, tpm_tis: Request threaded interrupt handler Lino Sanfilippo
2022-11-10 15:25 ` [PATCH v9 10/12] tpm, tpm_tis: Claim locality in " Lino Sanfilippo
2022-11-10 15:25 ` [PATCH v9 11/12] tpm, tpm_tis: Claim locality when interrupts are reenabled on resume Lino Sanfilippo
2022-11-10 15:25 ` [PATCH v9 12/12] tpm, tpm_tis: Enable interrupt test Lino Sanfilippo
2022-11-14 13:35   ` Lino Sanfilippo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.