Message ID | 20221017235732.10145-1-LinoSanfilippo@gmx.de |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1697563wrs; Mon, 17 Oct 2022 17:02:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5dtgsEXfKfr9ICtQSznmYkLyOp6KBIXHVb91jQPJCZ5hTwLKwAnQp+/oWKFYUCY/vdTrOe X-Received: by 2002:a17:907:7626:b0:78d:e65b:e5ac with SMTP id jy6-20020a170907762600b0078de65be5acmr189195ejc.416.1666051374060; Mon, 17 Oct 2022 17:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666051374; cv=none; d=google.com; s=arc-20160816; b=QSghEDjjZLW3CkMkCarYBcJ5o36Opw5XkyZPlLx8yixcbm9/V5D/2muaft43nfLO0m zzG/m1SbMzm2PN5m6TdiMSGRjFlmzqVDMlNeWFkdImn6oqoDyexvc2X5eH64zwr4/cpK O0QSu+ovWg7lo8sGe6TPmNMmjm7/cAHa2+0+Rpb8YMmmzbLRAwgvG0s4J1H9qJm5O7IJ Kdiuz4EyKLwBpL2cw8OmUUDYqVOo741XE30oLAuxcd53dVNFhls+yG5Af5w51wK1jxuK uQCEGiyWrBjCEHkM8aNsqXkMmcUBHpVoPmTwF3oJmMGNUi/OmKP0Hazu/aumf2EZPJ3R TVCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=7oD2gJbQp1Cg+oLFOTx+aePoyBmlEYcvMuhJJrprPIc=; b=cgRq6r7OemUEnIhHM3SdKZ7JHAiWp4Hxod0MoJGF7d34IqoMXiY9N+NY91Vxy1By1/ 0cpQkOwHm33lFd6H9Ujcpn9u0JDFPzCA5N3f1XQs/I+J53FZxdmhWiy4X2gLKNfvoc66 lAcDiv3Fdz3OU/N9TU/lD/9My9An24kPIAaUV6F7kQ6toHoj8ezkdsr9CKw50M+o45s7 h1z463bWfigaiLubSihkx4HNV85ytj6cPIFV+OoCp/QuFQSZwAYMPJ+t+T8KpDGJitvW /QaTaXuxsl6xelxyfV+kmVIx6NITRoVKGFM+LDmknHUys1eplj9oGUfS1jkH7EuD5W/p GMEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=khWyHDKN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i6-20020a0564020f0600b00454474269dbsi9581976eda.154.2022.10.17.17.02.26; Mon, 17 Oct 2022 17:02:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=khWyHDKN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231304AbiJQX6h (ORCPT <rfc822;kernel.ruili@gmail.com> + 99 others); Mon, 17 Oct 2022 19:58:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230327AbiJQX6S (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Oct 2022 19:58:18 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CD8782617; Mon, 17 Oct 2022 16:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1666051070; bh=7oD2gJbQp1Cg+oLFOTx+aePoyBmlEYcvMuhJJrprPIc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=khWyHDKN65JI84+f6bjynqpyozr+CU4eO2p75KbTr6szb7PX90WsTAJmAmp1jlPWj H+VSwvxrLW5N4IaV6jrc1d6s7a1P+81SFha1aKQMDpotlCsH8VYIYCBLOyULW8NZuU h+CHMD1keS+3rx2e3+j2ABA2lS5Q4GiQsJKm/x0k= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.speedport.ip ([84.162.5.241]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MSbx3-1oZBxv0Vj7-00Swlr; Tue, 18 Oct 2022 01:57:50 +0200 From: Lino Sanfilippo <LinoSanfilippo@gmx.de> To: peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca Cc: stefanb@linux.vnet.ibm.com, linux@mniewoehner.de, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, jandryuk@gmail.com, pmenzel@molgen.mpg.de, l.sanfilippo@kunbus.com, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com Subject: [PATCH v8 00/11] TPM IRQ fixes Date: Tue, 18 Oct 2022 01:57:21 +0200 Message-Id: <20221017235732.10145-1-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: base64 X-Provags-ID: V03:K1:YSik3saGDZfzYMWiK3Wa4Ktgwk+JxreBdc2ZO9VkCW6FK/I1q2h XAYazegPHH8whNGrzO3/4839Fxu8+sQHMdMgFJvv95ZQzwu1UDIfoxjAaDybaMCUYj43wFb GaBdHR4iLY2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w4s9/OBG9qqN6dZ+6Jt09 p9/RCVvyctfmbeqEtkezya46Is29nauO6pstYKhTycSMwzmRm/QDZe966uQps11fWl12dh1GT tckDadSmaOeizy6kxS83nT9iNvUV5RiOL8gceGPPZ1PmqL6PnQdb5kr2zvQD66lsrgtrh/QU1 6qL/m2kMJxqjpUnINJMc5lVVVFyC3iAg/HM1Pvz/wtQ/kRgil4gQUZSl4uNkTqBVZGthq/u2f UXZko13ELE6ZFKY44LS4EFak7wMN35QgyhxwZcYd4q1PysTqgwiuEp3Xinll1e6jR+geF5JNH FwtZLQWBFnpTqIGOcBz+zFXvbUPsO5ztkJprfAJ5yJkW+pAvCSb01hpfPmSdCiXMoxrxvNw4q ocR5Es8hNsE0Pn+Hn1tcK1/sI+n7UJLkVtcV9jHO6Xey9iseSWQ1kxT1mKF8yKKJ6Y1DC6OKO yN/YwVIIEC01+HDtAb9e4ZkR3CKhLZIaVoMs99IwaiVIlG8qwMcwfR7ssAAAeF+4G8ZbEYbLX uyRdSZTEIYUvbPzvdCPCMI0TMyjQTo5L7X7ZRiBOUsUcJs00zRpXbOPbsgKyfdnVI37S1qGxq bddEaAsRZsre5DofqI75b0F4uB+uj8xr/yRhmAb8lUBtd X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746981485362853686?= X-GMAIL-MSGID: =?utf-8?q?1746981485362853686?= |
Series |
TPM IRQ fixes
|
|
Message
Lino Sanfilippo
Oct. 17, 2022, 11:57 p.m. UTC
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 enables the test for interrupts by setting the required flag
before the test is executed.
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 (11):
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: Enable interrupt test
drivers/char/tpm/tpm_tis.c | 2 +-
drivers/char/tpm/tpm_tis_core.c | 267 +++++++++++++++++++++-----------
drivers/char/tpm/tpm_tis_core.h | 5 +-
3 files changed, 181 insertions(+), 93 deletions(-)
base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780