Message ID | 20221110152533.24243-1-LinoSanfilippo@gmx.de |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp212943wru; Thu, 10 Nov 2022 07:30:36 -0800 (PST) X-Google-Smtp-Source: AMsMyM4GLjHKTRbLLwDLkR1rhYXbWmBdQDvv21fWltnBJhDRyjpqoZQi8uyYED3ZPUHm2BBAP0hm X-Received: by 2002:a17:90b:4a4d:b0:200:43c8:175a with SMTP id lb13-20020a17090b4a4d00b0020043c8175amr1333535pjb.88.1668094232984; Thu, 10 Nov 2022 07:30:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668094232; cv=none; d=google.com; s=arc-20160816; b=D9uNwYiltswmfh7TpP/pe1YCl53Y+dtlaqPuMVWBn5xb3zNwFGQeI7phpa5FpY2W+5 LSw8gJbnFFkegyShqemLajixhFQPkHSHwus5bqN9y4Bf93O1Ovo/vT8DyBXvCtXvO2Bz mv+tusHdXVKYi8yjbEOrOWMzxMpVs5wN03g9c6qlZJg/0d9ZYfYVE+hNGwtkndUZPznW Mve0+huv54lvbqU94HDBXF9G+bipvUCuunfQDJ/yPM3TvsKZXzzb49SEaTK87oLiPi8W qGIJbSqlr+IifVkrqKqRYj4ULp+RZ4TQ+pz7xjJN3TTStGFmNizP4fMYY6gfZizsyYen kctw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=xnA9uZjSroQUdAP0TmAbEAYIGefOjLYl/tIHe+qUBiA=; b=KWxVMZx1YQkvy03qar34vxRkOwmQaT4HJLMea2bHMsn8pYYLT3GZK2wblElavXunJg Hbd7eii/kfkDmePOLWlElunr4Iw+9BUrGO5wlv/tDTMXqdTVlJOqmev+fKE/3SeSDpgo 3d9MSvXhcyF/AVhSPwK56BDwFyW14YhUMd2Fffle7dOX/v+HydC4WvXimrp9IhxoLHr5 subYwRSV3ts2ky7NhxoNoeJCle8tlTcFCcld63O0BiWKXHutBR38HB9p7POT3kl8JD+I /u9EqPffLtvKwaupVI4X9us7VcH/3TAh2uWqZ2PhJIyRRRo11vdrP1LhlhShUgpJHjFd sYNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=jgVsWQon; 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=pass (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 a5-20020a170902900500b00186b1bb14a0si18747742plp.559.2022.11.10.07.30.16; Thu, 10 Nov 2022 07:30:32 -0800 (PST) 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.de header.s=s31663417 header.b=jgVsWQon; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231548AbiKJP0i (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Thu, 10 Nov 2022 10:26:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231552AbiKJP0U (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 10 Nov 2022 10:26:20 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F7ED2CCB2; Thu, 10 Nov 2022 07:26:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1668093942; bh=xnA9uZjSroQUdAP0TmAbEAYIGefOjLYl/tIHe+qUBiA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=jgVsWQonULu+0YCjdcMM+N+LvCWeqXd4sxYN6qXrM+9r4r0YSdWwIpKhbYeaIE6hG +jIFwf8qd+yQgkH4LTwDFs9G8lkipxeJaIMWlH++gZAgc3RHgdy4cNsoUbPTltCAcQ h94+BiCaeo9B6IMWre3dyotNuxzzeegUK2E9mg4ZPyv3TTL7qOWMZipbWPN3zkEuW/ lo0eLg/wOpaTXqgrA52RHy3dCJzT2VCo8C6HVYXxikfPpFjPHYG0p73/XQ01F14I4z 6e6m++x/AdecmMtxyk238jAkz8oWYKG4iaGcYyJn8ZcY63FJP80cPeb42mHXCxC4M6 qoQo0/b6q0RwA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from Venus.speedport.ip ([84.162.7.17]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M59GG-1os2yI388C-001EYr; Thu, 10 Nov 2022 16:25:42 +0100 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 v9 00/12] TPM IRQ fixes Date: Thu, 10 Nov 2022 16:25:21 +0100 Message-Id: <20221110152533.24243-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-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Fhpvmx9ih0pYjsgZA78QkSIUJPo2jBfYiMgF8DIEJ5cS JJJm2gVjoDMiUczIXSvHTN3J81WOpBovNVa+MopgQQQxXGZjvJRVx9DUAK7J5I50q9VtlnmSs ljCftf7WN1Z2yb27R0Q/e9sCZmPisxpMvWZKAOM0I09OPeuGIzSnQd/9vtURFUS19wFgy99Bl /Q+2Cg2jLpyub6IhS6kLyGaESAI= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1749123578538524779?= X-GMAIL-MSGID: =?utf-8?q?1749123578538524779?= |
Series |
TPM IRQ fixes
|
|
Message
Lino Sanfilippo
Nov. 10, 2022, 3:25 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 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