Message ID | 20221124135538.31020-14-LinoSanfilippo@gmx.de |
---|---|
State | New |
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 q4csp3411274wrr; Thu, 24 Nov 2022 05:58:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf4cyhJFoz7t0rttP427UA/2RuGya3YRq4jRWy+yk7GTOLQO+V/12CPchAx1KlrFFaWEYHGJ X-Received: by 2002:a17:906:fa06:b0:7ae:72ae:264b with SMTP id lo6-20020a170906fa0600b007ae72ae264bmr11586317ejb.301.1669298335238; Thu, 24 Nov 2022 05:58:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669298335; cv=none; d=google.com; s=arc-20160816; b=EP97o9Dyzw7pWdUZfirSCcdKHNNNtZSMjaYxXfvzCxX0XdR88/W+tOR4tXm8PaJ+T9 8BacWRNFHCLpzuosi16yt6Gc2z8BAvRdOgbb7xdHvoNvF5NO2GBSJ59ItPR1U6GriXvE CFAs8ozK580LujTOEk7R3qB+b4t9QL9TuT03DFZZZ2Wdh6JDE80zMTxW2hwe6AKtI8zq 7+CMHCvMuDxK+ii8sBHZcBHL+PNsTW3SfcJEHwNIwQElRFXYqOnYQXWz+VSDbIfRUHi+ L+xjKT/ez5gFWvbn3YKm0K6zmizbVKrAKizkS6AEnUl1ppXlx18a3Mhnq7BlQHuQpDGi bPGg== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SccepFkG1BaYDhxThv4kTIw73gWWQ8B34c8oBRXziP8=; b=cYcU8dfQprYJ82U+JVfFeIdZNAMeUUD1yAJpCjd5HJ68YGoWF5IikN+R4CjA/vIvz3 OA/X/3WXXwvBasIZpcFZIcxeTRQOIVew8hmFdwJFiPhbQQRni82VwDxbrzcGplAxtB/K yaPF/udxjDH+mJismBgVSpFUDXPHVz9pr4SJpOdJ4cFipf3iUeDGykViKVTr+Ha4H9q0 XqasvHUBbysUPvf9BKtGUTIw1WXuf4LRZEAKDWEs+7FyvOA9rs99M8v+Gt4ikt2I9Fbi 4n6578euEs/AmQKoMJzs61gEXB3wESsoz8F/9nxoVSlh0HNF4FRJCh9pJ0b/4xKhZZxs 2+FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=N5oSIApe; 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 go36-20020a1709070da400b00781b6ce15e1si1196916ejc.101.2022.11.24.05.58.30; Thu, 24 Nov 2022 05:58:55 -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=N5oSIApe; 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 S230342AbiKXN50 (ORCPT <rfc822;fengqi706@gmail.com> + 99 others); Thu, 24 Nov 2022 08:57:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230236AbiKXN44 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 24 Nov 2022 08:56:56 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FCFFFFAA4; Thu, 24 Nov 2022 05:56:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1669298174; bh=SccepFkG1BaYDhxThv4kTIw73gWWQ8B34c8oBRXziP8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=N5oSIApeIyqhSeyC5gdSR0djmO35Q82/vTO7AnK+pUNovI047gP53VxHdyEh644Gs vDbkjFbFt4syPSalb34P3JmOTUqPiUORWZ3cu/CtvTl1I5MDTSI5LbrbRykKs3MPPB gDqmJMCbW/daQoZ5iTvHIoqr6zvwolRhD2aLsgkpb99iWmZybH3HfbmPqUJnkMNObK 4M2a2Ouq50SagnRldDSMKXrD4VUHBcq6CmZ+/BDhv32/We5dpWepTL9XotCwnkiFVu TYXuIvIFTdnNeOaR/smYBw2k8Rv1UALGd+DflsGFfHRtoG9vBH3jN5QSKi9OQr1Lm0 TWJ58lS+6OZLQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from Venus.speedport.ip ([84.162.7.17]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mg6e4-1pPH3Q1hnS-00hcyE; Thu, 24 Nov 2022 14:56:14 +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 v11 13/14] tpm, tpm_tis: startup chip before testing for interrupts Date: Thu, 24 Nov 2022 14:55:37 +0100 Message-Id: <20221124135538.31020-14-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221124135538.31020-1-LinoSanfilippo@gmx.de> References: <20221124135538.31020-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 Content-Transfer-Encoding: base64 X-Provags-ID: V03:K1:zL2CNXLyU474XTdrXuPgbob0QK0DB8meDAMR4XbMdR/tbE5lv3k k6dilEu5PY/7pIfCkYcsG9ONqgIh7Yw14eA/C71RO2XlIIRNDC/vszFhWB6E7PjthtspBOF bnGzBzzik2FbNsoASv1b3OfHAbGE6h6nhndFb/bw8w++/zya1A07LDjeoY7MMXfTDUMrYbf bxYBAriPFhSep3+hjLCSQ== UI-OutboundReport: notjunk:1;M01:P0:1LYpu2fBXps=;CrGmYwKDDI8dwJQBn3y2fmWp8Gs IA7PqgPDCI0YelnX1m174eoQ7ICsvUkRLf1qhlw0+1kEcAK/s11cWQO+JCsG2tBuUYf6t/N+s 4dXVf06KzusaVhyfHT9ULvmQtbNi53Bex54+G9IBwrvtHJzY3SDYxpA9KfYYrOATllrP9XKGe ytOWAHB6oOlnLA1OPJd70P9KkALdtKQq187b2MY6T7GN7NCcsoz3AVromPiCdF1PLIfZdWdsH CSwfcRCgOlL6tzkTLO5HdsRlGBQDto3v9YpHtHqKwPtSqgL529thm0QvOy7DpAcYfG0UacLCk l/RrWNlHMjSzjYLDqmjDU6hrMG+wJ1qGq9SP8Ag5RhPIzJkvXFVWpLX2UzNF0w54Oly8nYZkh 6JLFhVMRhZJyqxlKIc09Rn8JSf6jaEwHsOlGs8wk9Q35d4H2LWF9CatxP3A6q02Ebg/pnFx41 mj7jZk4qEGpvEqEqSUd7lTtEMRIbJr8T5J4oRMasG2bXXTok66l+ecll1GWZzvZqnrBo8+sqf 2vENlVO5QQiHp+7CYFzhVyaL2kfGIBHJ90QCKc2FRI81DYEz+Sudd000dC/TMmjA+gOAxwrqE 4dZM/+C223BAwUhs6oJRZieLki5Gm+BXafGFJWENkDez2vfSTqaObWy1O0+3Fsg5K67R2Be5n PSQKkM6gUaWh7oI9xMVfrzOq2NYGjQDmhS/dtqOFM2p/w2xAZOF52M3EhYEhIEh9JmtmDJfhy CdMQCRHDF5Cm9pIRuLdV1IDx/MmcxYg2MhwON1ghtxxte5TYdXZ+QIpebHcJdIFDnfGKJs4XO 4GOu4AKLF9SNddSHjn1qu/b67IKA4NLdlFiEB4QYUQhpL0nsFgH9aBIqZebPWX9tG84Tz6cgR 5PXiwM0vVzJRDLlq5Jj3PJc29ZfEBRVsIlCC7fTsVyDIDlSR3vya9bCIdI6r7b1Qd5yws60o0 be2bAg== X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,MIME_BASE64_TEXT, 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?1750386170779736746?= X-GMAIL-MSGID: =?utf-8?q?1750386170779736746?= |
Series |
TPM IRQ fixes
|
|
Commit Message
Lino Sanfilippo
Nov. 24, 2022, 1:55 p.m. UTC
From: Lino Sanfilippo <l.sanfilippo@kunbus.com> In tpm_tis_gen_interrupt() a request for a property value is sent to the TPM to test if interrupts are generated. However after a power cycle the TPM responds with TPM_RC_INITIALIZE which indicates that the TPM is not yet properly initialized. Fix this by first starting the TPM up before the request is sent. For this the startup implementation is removed from tpm_chip_register() and put into the new function tpm_chip_startup() which is called before the interrupts are tested. Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> --- drivers/char/tpm/tpm-chip.c | 38 +++++++++++++++++++++------------ drivers/char/tpm/tpm.h | 1 + drivers/char/tpm/tpm_tis_core.c | 5 +++++ 3 files changed, 30 insertions(+), 14 deletions(-)
Comments
On 24.11.22 14:55, Lino Sanfilippo wrote: > From: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > In tpm_tis_gen_interrupt() a request for a property value is sent to the > TPM to test if interrupts are generated. However after a power cycle the > TPM responds with TPM_RC_INITIALIZE which indicates that the TPM is not > yet properly initialized. > Fix this by first starting the TPM up before the request is sent. For this > the startup implementation is removed from tpm_chip_register() and put > into the new function tpm_chip_startup() which is called before the > interrupts are tested. > > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> > --- > drivers/char/tpm/tpm-chip.c | 38 +++++++++++++++++++++------------ > drivers/char/tpm/tpm.h | 1 + > drivers/char/tpm/tpm_tis_core.c | 5 +++++ > 3 files changed, 30 insertions(+), 14 deletions(-) > > diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c > index 783d65fc71f0..370aa1f529f2 100644 > --- a/drivers/char/tpm/tpm-chip.c > +++ b/drivers/char/tpm/tpm-chip.c > @@ -543,6 +543,30 @@ static int tpm_get_pcr_allocation(struct tpm_chip *chip) > return rc; > } > > +/* > + * tpm_chip_startup() - performs auto startup and allocates the PCRs > + * @chip: TPM chip to use. > + */ > +int tpm_chip_startup(struct tpm_chip *chip) > +{ > + int rc; > + > + rc = tpm_chip_start(chip); > + if (rc) > + return rc; > + > + rc = tpm_auto_startup(chip); > + if (rc) > + goto stop; > + > + rc = tpm_get_pcr_allocation(chip); > +stop: > + tpm_chip_stop(chip); > + > + return rc; > +} > +EXPORT_SYMBOL_GPL(tpm_chip_startup); > + > /* > * tpm_chip_register() - create a character device for the TPM chip > * @chip: TPM chip to use. > @@ -558,20 +582,6 @@ int tpm_chip_register(struct tpm_chip *chip) > { > int rc; > > - rc = tpm_chip_start(chip); > - if (rc) > - return rc; > - rc = tpm_auto_startup(chip); > - if (rc) { > - tpm_chip_stop(chip); > - return rc; > - } > - > - rc = tpm_get_pcr_allocation(chip); > - tpm_chip_stop(chip); > - if (rc) > - return rc; > - > tpm_sysfs_add_device(chip); > > tpm_bios_log_setup(chip); > diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h > index 24ee4e1cc452..919bb0b88b12 100644 > --- a/drivers/char/tpm/tpm.h > +++ b/drivers/char/tpm/tpm.h > @@ -190,6 +190,7 @@ static inline void tpm_msleep(unsigned int delay_msec) > delay_msec * 1000); > }; > > +int tpm_chip_startup(struct tpm_chip *chip); > int tpm_chip_start(struct tpm_chip *chip); > void tpm_chip_stop(struct tpm_chip *chip); > struct tpm_chip *tpm_find_get_ops(struct tpm_chip *chip); > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > index ddaf362e62c1..94a2bfb244b3 100644 > --- a/drivers/char/tpm/tpm_tis_core.c > +++ b/drivers/char/tpm/tpm_tis_core.c > @@ -1129,6 +1129,11 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, > /* INTERRUPT Setup */ > init_waitqueue_head(&priv->read_queue); > init_waitqueue_head(&priv->int_queue); > + > + rc = tpm_chip_startup(chip); > + if (rc) > + goto out_err; > + > if (irq != -1) { > /* > * Before doing irq testing issue a command to the TPM in polling mode Jarko, thanks for the review so far. What about this patch, are there any concerns from your side? Regards, Lino
On Thu, Nov 24, 2022 at 02:55:37PM +0100, Lino Sanfilippo wrote: > From: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > In tpm_tis_gen_interrupt() a request for a property value is sent to the > TPM to test if interrupts are generated. However after a power cycle the > TPM responds with TPM_RC_INITIALIZE which indicates that the TPM is not > yet properly initialized. > Fix this by first starting the TPM up before the request is sent. For this > the startup implementation is removed from tpm_chip_register() and put > into the new function tpm_chip_startup() which is called before the > interrupts are tested. > > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> > --- > drivers/char/tpm/tpm-chip.c | 38 +++++++++++++++++++++------------ > drivers/char/tpm/tpm.h | 1 + > drivers/char/tpm/tpm_tis_core.c | 5 +++++ > 3 files changed, 30 insertions(+), 14 deletions(-) > > diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c > index 783d65fc71f0..370aa1f529f2 100644 > --- a/drivers/char/tpm/tpm-chip.c > +++ b/drivers/char/tpm/tpm-chip.c > @@ -543,6 +543,30 @@ static int tpm_get_pcr_allocation(struct tpm_chip *chip) > return rc; > } > > +/* > + * tpm_chip_startup() - performs auto startup and allocates the PCRs > + * @chip: TPM chip to use. > + */ > +int tpm_chip_startup(struct tpm_chip *chip) > +{ > + int rc; > + > + rc = tpm_chip_start(chip); > + if (rc) > + return rc; > + > + rc = tpm_auto_startup(chip); > + if (rc) > + goto stop; > + > + rc = tpm_get_pcr_allocation(chip); > +stop: > + tpm_chip_stop(chip); > + > + return rc; > +} > +EXPORT_SYMBOL_GPL(tpm_chip_startup); > + > /* > * tpm_chip_register() - create a character device for the TPM chip > * @chip: TPM chip to use. > @@ -558,20 +582,6 @@ int tpm_chip_register(struct tpm_chip *chip) > { > int rc; > > - rc = tpm_chip_start(chip); > - if (rc) > - return rc; > - rc = tpm_auto_startup(chip); > - if (rc) { > - tpm_chip_stop(chip); > - return rc; > - } > - > - rc = tpm_get_pcr_allocation(chip); > - tpm_chip_stop(chip); > - if (rc) > - return rc; > - > tpm_sysfs_add_device(chip); > > tpm_bios_log_setup(chip); > diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h > index 24ee4e1cc452..919bb0b88b12 100644 > --- a/drivers/char/tpm/tpm.h > +++ b/drivers/char/tpm/tpm.h > @@ -190,6 +190,7 @@ static inline void tpm_msleep(unsigned int delay_msec) > delay_msec * 1000); > }; > > +int tpm_chip_startup(struct tpm_chip *chip); > int tpm_chip_start(struct tpm_chip *chip); > void tpm_chip_stop(struct tpm_chip *chip); > struct tpm_chip *tpm_find_get_ops(struct tpm_chip *chip); > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > index ddaf362e62c1..94a2bfb244b3 100644 > --- a/drivers/char/tpm/tpm_tis_core.c > +++ b/drivers/char/tpm/tpm_tis_core.c > @@ -1129,6 +1129,11 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, > /* INTERRUPT Setup */ > init_waitqueue_head(&priv->read_queue); > init_waitqueue_head(&priv->int_queue); > + > + rc = tpm_chip_startup(chip); > + if (rc) > + goto out_err; > + > if (irq != -1) { > /* > * Before doing irq testing issue a command to the TPM in polling mode > -- > 2.36.1 > Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org> BR, Jarkko
On Mon, Nov 28, 2022 at 01:53:35PM +0100, Lino Sanfilippo wrote: > > On 24.11.22 14:55, Lino Sanfilippo wrote: > > From: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > > > In tpm_tis_gen_interrupt() a request for a property value is sent to the > > TPM to test if interrupts are generated. However after a power cycle the > > TPM responds with TPM_RC_INITIALIZE which indicates that the TPM is not > > yet properly initialized. > > Fix this by first starting the TPM up before the request is sent. For this > > the startup implementation is removed from tpm_chip_register() and put > > into the new function tpm_chip_startup() which is called before the > > interrupts are tested. > > > > Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> > > --- > > drivers/char/tpm/tpm-chip.c | 38 +++++++++++++++++++++------------ > > drivers/char/tpm/tpm.h | 1 + > > drivers/char/tpm/tpm_tis_core.c | 5 +++++ > > 3 files changed, 30 insertions(+), 14 deletions(-) > > > > diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c > > index 783d65fc71f0..370aa1f529f2 100644 > > --- a/drivers/char/tpm/tpm-chip.c > > +++ b/drivers/char/tpm/tpm-chip.c > > @@ -543,6 +543,30 @@ static int tpm_get_pcr_allocation(struct tpm_chip *chip) > > return rc; > > } > > > > +/* > > + * tpm_chip_startup() - performs auto startup and allocates the PCRs > > + * @chip: TPM chip to use. > > + */ > > +int tpm_chip_startup(struct tpm_chip *chip) > > +{ > > + int rc; > > + > > + rc = tpm_chip_start(chip); > > + if (rc) > > + return rc; > > + > > + rc = tpm_auto_startup(chip); > > + if (rc) > > + goto stop; > > + > > + rc = tpm_get_pcr_allocation(chip); > > +stop: > > + tpm_chip_stop(chip); > > + > > + return rc; > > +} > > +EXPORT_SYMBOL_GPL(tpm_chip_startup); > > + > > /* > > * tpm_chip_register() - create a character device for the TPM chip > > * @chip: TPM chip to use. > > @@ -558,20 +582,6 @@ int tpm_chip_register(struct tpm_chip *chip) > > { > > int rc; > > > > - rc = tpm_chip_start(chip); > > - if (rc) > > - return rc; > > - rc = tpm_auto_startup(chip); > > - if (rc) { > > - tpm_chip_stop(chip); > > - return rc; > > - } > > - > > - rc = tpm_get_pcr_allocation(chip); > > - tpm_chip_stop(chip); > > - if (rc) > > - return rc; > > - > > tpm_sysfs_add_device(chip); > > > > tpm_bios_log_setup(chip); > > diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h > > index 24ee4e1cc452..919bb0b88b12 100644 > > --- a/drivers/char/tpm/tpm.h > > +++ b/drivers/char/tpm/tpm.h > > @@ -190,6 +190,7 @@ static inline void tpm_msleep(unsigned int delay_msec) > > delay_msec * 1000); > > }; > > > > +int tpm_chip_startup(struct tpm_chip *chip); > > int tpm_chip_start(struct tpm_chip *chip); > > void tpm_chip_stop(struct tpm_chip *chip); > > struct tpm_chip *tpm_find_get_ops(struct tpm_chip *chip); > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > > index ddaf362e62c1..94a2bfb244b3 100644 > > --- a/drivers/char/tpm/tpm_tis_core.c > > +++ b/drivers/char/tpm/tpm_tis_core.c > > @@ -1129,6 +1129,11 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, > > /* INTERRUPT Setup */ > > init_waitqueue_head(&priv->read_queue); > > init_waitqueue_head(&priv->int_queue); > > + > > + rc = tpm_chip_startup(chip); > > + if (rc) > > + goto out_err; > > + > > if (irq != -1) { > > /* > > * Before doing irq testing issue a command to the TPM in polling mode > > Jarko, thanks for the review so far. What about this patch, are there any concerns from your side? No concerns on this one. BR, Jarkko
diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index 783d65fc71f0..370aa1f529f2 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -543,6 +543,30 @@ static int tpm_get_pcr_allocation(struct tpm_chip *chip) return rc; } +/* + * tpm_chip_startup() - performs auto startup and allocates the PCRs + * @chip: TPM chip to use. + */ +int tpm_chip_startup(struct tpm_chip *chip) +{ + int rc; + + rc = tpm_chip_start(chip); + if (rc) + return rc; + + rc = tpm_auto_startup(chip); + if (rc) + goto stop; + + rc = tpm_get_pcr_allocation(chip); +stop: + tpm_chip_stop(chip); + + return rc; +} +EXPORT_SYMBOL_GPL(tpm_chip_startup); + /* * tpm_chip_register() - create a character device for the TPM chip * @chip: TPM chip to use. @@ -558,20 +582,6 @@ int tpm_chip_register(struct tpm_chip *chip) { int rc; - rc = tpm_chip_start(chip); - if (rc) - return rc; - rc = tpm_auto_startup(chip); - if (rc) { - tpm_chip_stop(chip); - return rc; - } - - rc = tpm_get_pcr_allocation(chip); - tpm_chip_stop(chip); - if (rc) - return rc; - tpm_sysfs_add_device(chip); tpm_bios_log_setup(chip); diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 24ee4e1cc452..919bb0b88b12 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -190,6 +190,7 @@ static inline void tpm_msleep(unsigned int delay_msec) delay_msec * 1000); }; +int tpm_chip_startup(struct tpm_chip *chip); int tpm_chip_start(struct tpm_chip *chip); void tpm_chip_stop(struct tpm_chip *chip); struct tpm_chip *tpm_find_get_ops(struct tpm_chip *chip); diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index ddaf362e62c1..94a2bfb244b3 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -1129,6 +1129,11 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, /* INTERRUPT Setup */ init_waitqueue_head(&priv->read_queue); init_waitqueue_head(&priv->int_queue); + + rc = tpm_chip_startup(chip); + if (rc) + goto out_err; + if (irq != -1) { /* * Before doing irq testing issue a command to the TPM in polling mode