Message ID | 20221120133134.28926-1-LinoSanfilippo@gmx.de |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1116277wrr; Sun, 20 Nov 2022 05:33:08 -0800 (PST) X-Google-Smtp-Source: AA0mqf6YrVBvXs9AuI0ZQPkaEA4ivEXYOnonYgbMRa61viF0dszH7zjd3p+wy4K5pyrNr37DjEvq X-Received: by 2002:a63:f047:0:b0:476:9591:5fad with SMTP id s7-20020a63f047000000b0047695915fadmr13867334pgj.342.1668951188547; Sun, 20 Nov 2022 05:33:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668951188; cv=none; d=google.com; s=arc-20160816; b=pVZgNJL6AnkN7Vy1dcU63JTbp4CtV24LUpwp5dZyjOJk6sehaGc6z2rC11XVqmApi1 w7zLiTz/ChkwgecVpICbkU8z2+P249TdiQWGL0Vx7S9/QuyVMgjR8InMZaYJNjHxFrGJ GXHatLmPDnMeBL8uGJm+Poix/SmyZz6RjdFCbLTuLfcFy5wNGfZb7Y2Kb/d/rVqTZweB iVmzi2JTH0hHroor9Rocvh1afUpDJ235fXwBBtu8YTCN9qtHB2CZ1VfieB4NBTDNWS0+ 4B4R9fXgzEDEin1+wfgjA5x3wJox23QZKU/AYIpVa8b1qmBYCOvllA1uY3YWC5WkV+Zp jNWw== 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=wCs303FkFRV9OH+Tz92ZPzedjuCgM7ELiXIAJXEA4S0=; b=G8lnychW7ifFrrZuYw2XUYCru+ckGqHwMwzqiJ5mRfH/+Ry/45pkq+6dLzWsOsvbmq Kn9Tmc+jERrwX2T5Jj3BBojBlj8so4abn1cYcx+7wPyxxeUe4dm0LTGgBZhcqG45Zgmj tPlY0yllJHcdKOMEkGYvlMShek44eqz5eqVcpr1DVueTHMPlFSdR3tog+ElcOLxv+vBa Yk/cazA/rMm7likCUuxBOB66zIhJSt8pRia34Om1ZxFp1FL4Do6E9obCSLLAZRmXzu9n 5jluiPS7Ehv1FTxTdPEukoZ7Qg5K7tWNYPIp9nfNHR93kazBaf9uyFEHtAwg0X8eHkUi Ba3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=bpAn3s0B; 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 h9-20020a170902704900b00188fead22f3si5960418plt.104.2022.11.20.05.32.55; Sun, 20 Nov 2022 05:33:08 -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=bpAn3s0B; 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 S229633AbiKTNc1 (ORCPT <rfc822;yuanzuo1009@gmail.com> + 99 others); Sun, 20 Nov 2022 08:32:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbiKTNcX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 20 Nov 2022 08:32:23 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BD1F2A943; Sun, 20 Nov 2022 05:32:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1668951124; bh=wCs303FkFRV9OH+Tz92ZPzedjuCgM7ELiXIAJXEA4S0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=bpAn3s0BAy0DwXgrtxsrtVWdhzJPq1VnTGbIi5eEwSiWAWQ3f3IFURMWENwptWyPU IoegB711+NUje/GLQNeplQRkesAYvZzrKuUG/xhYuLIhPe37EC1FvnCLjFJsLBAeUh s/tzeMPz5EUWosGKUPxir+i1Gc2tnU7UnAY7V0d0Ime0lTKuf/WmVOfmvHZRXWyX+6 BadN2PMXxclc3QmnY3Qew04Mq5EIyII8ypswP8GZbyynP6zQqantlRYEHV9h31EJuw ER3JdW+Sik2gqU2lEo+dF3j5ykDgqWJebOnp5MiFtQEsSfYXZWSHtWEatlS8NOxMGJ Q2DLG5Td5Lwlw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from Venus.speedport.ip ([84.162.7.17]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MsHns-1pBnTS2FRK-00tkHd; Sun, 20 Nov 2022 14:32:04 +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 v10 00/14] TPM IRQ fixes Date: Sun, 20 Nov 2022 14:31:20 +0100 Message-Id: <20221120133134.28926-1-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-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8jFEGZDKqB/51fjg/PQQG2kzZ4SDiSzeejl9Jc gHZzj3GgLnggxik3GPDcX/RNuNwZlLC1PrTzY1V47SvpL/S8xYB7EOrTvGpdj3GfIKJTwFD1U CR8OrVx+xwFyAb/LWCrNsHwY/elEC4pEgCcGvWzR7A0hQyShIpkCMW5HgiU+JaKCcStztr+I/ 3ahVlg== 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?1750022161881752693?= X-GMAIL-MSGID: =?utf-8?q?1750022161881752693?= |
Series |
TPM IRQ fixes
|
|
Message
Lino Sanfilippo
Nov. 20, 2022, 1:31 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
5).
Patch 6 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 7 moves the interrupt flag checks into an own function as suggested
by Jarkko.
Patch 8 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 9 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 10 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 11 makes sure that writes to the interrupt register are effective if
done in the interrupt handler.
Patch 12 makes sure that writes to the interrupt and INTERRUPT_VECTOR
and INTERRUPT_ENABLE registers are effective by holding the locality.
Patch 13 makes sure that the TPM is properly initialized after power cycle
before the irq test is done.
Patch 14 enables the test for interrupts by setting the required flag
before the test is executed.
Changes in v10:
- fix typo in subject line as pointed out by Jason Andryuk
- improve patch "tpm, tpm_tis: Claim locality before writing interrupt
registers" by extending the scope with held locality". For this reason
the "Reviewed-by" tag by Jarko and the "Tested-by" tag by Michael have
been removed.
- add fix to avoid TPM_RC_INITIALIZE after power cycle when testing irqs
(PATCH 13)
- add fix to restore the old interrupt vector at error (PATCH 4)
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: Enable interrupt test) 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 (14):
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, tpm_tis: Do not skip reset of original interrupt vector
tpm, tpm_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: startup chip before testing for interrupts
tpm, tpm_tis: Enable interrupt test
drivers/char/tpm/tpm-chip.c | 38 ++--
drivers/char/tpm/tpm.h | 1 +
drivers/char/tpm/tpm_tis.c | 2 +-
drivers/char/tpm/tpm_tis_core.c | 299 ++++++++++++++++++++------------
drivers/char/tpm/tpm_tis_core.h | 5 +-
5 files changed, 214 insertions(+), 131 deletions(-)
base-commit: 30a0b95b1335e12efef89dd78518ed3e4a71a763