From patchwork Fri Jun 10 11:08:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12877470 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D691C43334 for ; Fri, 10 Jun 2022 11:09:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347847AbiFJLJX (ORCPT ); Fri, 10 Jun 2022 07:09:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347236AbiFJLJW (ORCPT ); Fri, 10 Jun 2022 07:09:22 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1FF014558E; Fri, 10 Jun 2022 04:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1654859344; bh=h2TS/0VnUJCYBFtIAAMCfO7jV4vdocdBAuzudeNWs78=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=WjH8K5MYxkrE9XH9tqAaaWBGobyqIbELAYNFCfZY0+/uuu3VB0Ripvn8SsocTSvfp OK1IYksTcIcgxf4QLrcZpAktfy44NQsc7G5cT8xWxrMrFy3mi622ueJOO827bgyIJm ZCCoc0+sa+b4HxNnO+lbEyE/E2kGhw4l6ovl9Gy4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.3.165]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M8QS2-1o42M42AGO-004TUg; Fri, 10 Jun 2022 13:09:04 +0200 From: 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, l.sanfilippo@kunbus.com, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com Subject: [PATCH v5 03/10] tpm, tpm_tis: Disable interrupts if tpm_tis_probe_irq() failed Date: Fri, 10 Jun 2022 13:08:39 +0200 Message-Id: <20220610110846.8307-4-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220610110846.8307-1-LinoSanfilippo@gmx.de> References: <20220610110846.8307-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:zej+GdlgXsvMXt3EbX2BjWswFuyOPmIPYQx4w9z5fZzqNm6LNTt AfMQ9LTVtzbAi7sUVxkkFwB2e+1Wq4nw7lEGktZ2qGpbHIH18HiE8yijd4Ym9dmR8Sswg8j LL2rzSj8oy+tm4nZqW+0gO9jZRnHNnqXod09yLcPYmeUKBsfv4M7cWFNTNvhbKgeAgSYFfw XAqh1TU8W6CD8VsX2Qb6A== X-UI-Out-Filterresults: notjunk:1;V03:K0:JOGJB6hq7Jc=:aTOoYZ6VFme8TfugIDvXLC DJ4lWjuNI3UAvHrEuPQ88SOo1XEWj/eu9SDsOqtQ+P9Ls0RhpeZHPZ8hF7wfZbMKDus/s+4A0 XRD6A40MHSjtIiEkuuAylCHtxPZgwitA5bnowWewBSi6c4JpLtTJmgmG6XCeGRrcC7mAlWMya rvi573aCV8SYwNzo3sWq2v4ZJUUPh/mHasK1sZDJ+DWMXRzAB4VFi+bTa+w0cUm6UbJZbs1aR NES14k66PkD1MWGgla9YNZ9jggx2yP+FOvLdhk1uKuT4t5kkELLnRsxj/GQihR07UKMbd+TVA /QiR2J3JwKcoOmqUIuJs7XTnptsRDcYfA9sGuaH8Xte9s9YebJ0pU39a2yG9qiNxmOROFmwGu oLWCrezKCvDO0uKe05Lo8MWTuXTPBCNb6xZhP+6gEyNy7Um/kp9prg97bBgGVCKtR6QcCNIKT u29k2JY3vSliz2JEkADC0pcLTVX5a1dtS/IxQ0Vj1JShrGiWmmR34zfWWmD2Pf9kT5AmGsZ8G 495ZFgxiCH980qq8p0bYCYgsAcyNYPsioGPA+WZha4E+X61880fEtLAh0EeKS9RDkE4wl3Cgj HM0d/gtCTzlxoqGaAhS3j4dr9YOSPNDRPL7GihQx+bc9dXcWe/q0Z1EMEBG7yl03oeR/9AuT3 S8Z57M/0E8IqAeKH0iaHgVdKlxMiyJ7wPpQSdsXskT1d34btOyRkGaHi/AecoE0w7Ib/EdKpm gx+pDFax1prFvozKJV8OFcrNnuTCNjFkjGZFMPbnLqqzBj8K3JGu/Yg7TsX938tVgEJVCmvkv JiD5ly4fSps5dRvhzPSuIrWN7pmRgU3EyLTZhGHCvSDGnwWqGU5Ffe2PNL1oyktX0QXmforLc kPMi4SrZk9xxleUx8nqAb5JttOGY+HVldw1nTc5k9+8Pj9LCNzEDT5HNEIjhsyjCBxhEPfvRK yWBYvlb/I/SRaJnZqu5Qpo5nFTRNfmtsgVBs83W6SWkuUALLl93fVidUVlyt+g8GnClRPaqz9 BbI+bhcjWVf5ffFNZEJZPTUHbw5NN7+J0uSdcDfXaxNw2EFR/aRnWhPyxJvDQ09Ez/SLfXJk0 gX86p6IQM8n1Eqfo5a1e6pnX9DroIGSGv482hTWo/VdoOL27BoE2uHgFA== Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org From: Lino Sanfilippo Both functions tpm_tis_probe_irq_single() and tpm_tis_probe_irq() may setup the interrupts and then return with an error. This case is indicated by a missing TPM_CHIP_FLAG_IRQ flag in chips->flags. Currently the interrupt setup is only undone if tpm_tis_probe_irq_single() fails. Undo the setup also if tpm_tis_probe_irq() fails. Signed-off-by: Lino Sanfilippo Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_tis_core.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index ee6b48c55ac9..dee701609b80 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -1077,21 +1077,21 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, goto out_err; } - if (irq) { + if (irq) tpm_tis_probe_irq_single(chip, intmask, IRQF_SHARED, irq); - if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) { - dev_err(&chip->dev, FW_BUG + else + tpm_tis_probe_irq(chip, intmask); + + if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) { + dev_err(&chip->dev, FW_BUG "TPM interrupt not working, polling instead\n"); - rc = request_locality(chip, 0); - if (rc < 0) - goto out_err; - disable_interrupts(chip); - release_locality(chip, 0); - } - } else { - tpm_tis_probe_irq(chip, intmask); + rc = request_locality(chip, 0); + if (rc < 0) + goto out_err; + disable_interrupts(chip); + release_locality(chip, 0); } }