From patchwork Sun Nov 20 13:31:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 13050029 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 ABED0C4332F for ; Sun, 20 Nov 2022 13:32:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229547AbiKTNcY (ORCPT ); Sun, 20 Nov 2022 08:32:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbiKTNcX (ORCPT ); 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 EB5D128E13; Sun, 20 Nov 2022 05:32:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1668951125; bh=vmr8i0HILdqGMwVhgOxfm//3j+C4M5iWtBnT+hrsrRw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=TMP3jz03SMBORLJ1Osq4NJBLaCq5d0dw8jsLS1ocyJhst++3mlOZzBTmQBqZWjKWv Voxzb/CQ6RCoeo7qn6/J/9C71Ry/WZsSFaulE6y7ESVN793wcmhDVAj4MNXBq0AP9i qdDmg6LDUbciSZdaXi+No2YJpxW3W0J+D//iRMt8zl5D6anEc723u8h63zHiFywoUn L2a+9hPW0AOGMc4wG450lLEID/gHX41CCJoWqkV1f9yuO2eIHhJmZlZoyMAvXHHPhG 29ZrSrj2z8vJlqhCF83PQLt/o1ecqy2FmXV2Y4U5L8n/yy4g2SHxLP58OTgMWQ8r8+ SWTw8fUQKRfOA== 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 1MXp5a-1oQt8j2T4W-00Y6vT; Sun, 20 Nov 2022 14:32:05 +0100 From: Lino Sanfilippo 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 03/14] tpm, tpm_tis: Disable interrupts if tpm_tis_probe_irq() failed Date: Sun, 20 Nov 2022 14:31:23 +0100 Message-Id: <20221120133134.28926-4-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221120133134.28926-1-LinoSanfilippo@gmx.de> References: <20221120133134.28926-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:b4C2M5Qz3awQq0TkuQ6vgiwoMtTbqIlRfmnv0OiMblSzZLZq228 BaaIfCHUp0oCYSs1lVBZoDmGSQvGKfk9Znbbm1oKwMdK2GDQaSlNOQZOsHVfh1BDxtrFT+k Yi6UqX2Us0VDNI6jgP4INwB8nW5Yb4JMr6X+4AO4MkeXetbnwqeuafOMSrROsMP/or/mK8t xuz7RZR61pEoZ12pTwE7A== UI-OutboundReport: notjunk:1;M01:P0:Z7y9UfKX6mM=;Q1Umg7DU5Dvyq+vxVLBm7PMycSI L2FyUFkk5FKNJrGCKp5FvID1bZEq0odl/FRjq0YEwP3L4dQQovH6krb1gCk14wDVhiVK4wJNu a8HELXz+JRZ512cQkSVNSAMkAcspVnucQY0pqK6jta2zxSIGp34sKkK/77stXgNHYbWwRdS6T fbW6ZWy7y7eaWYE5Ts3a9fFietpRoed7fxzdomjClJsP1RTUxJpMezu95k3UnsQjc4RFqZixf w9f/KP6fAWomT6HBgYx1CxSasp8jOgIZN7wUDOpRy3TUF+wUSGVX/ldKJKNtRJDFI82D1haMl syvZxABa8z0D+R6j3tpKL5VAmrlPShNx7y9JSaehAikJYGvLqnB+ezSLxGHBrrfZXPvMVmbj9 UeJ3OB/DQe2SLkLvX9noAAf5G9K3tOSXyB+YrgdRRF6DJ6NfK0sI+4AjYgOFgsxUil7UFky1a 687Ll/PTJXIfWnCJHh5wVC3GBhuU7ydCH9JuGT2PA/X+OtW1MYLORZKwWFEk1YgPQCCMTI2Kn /7oy/r4/IN8diVkGJ62JSEj6BhXqj7nNgMyFH2KHONxDMIm0Wk08mzEq/O3zEraaKB4daXJIP pmabEL0l3tts7IFCzaqBg65iFjtxDe8nOQvXtEEjU9tilCSCcc4mWmn8q9UIB1evQIFi55LM2 pohbrFj958CkB1EG9ZoRFwMFgp3W/yPhknNFV5JGKAq6cz0xSfk4Spd8EqUEAZ38kuycZT9nN y7VCtKo9PfT6zU9MUBbqfSWH1g0vsQQd2g4bk5xOZTkUtIfDhOn0R2d9TMfBEv5b3PXJDKtjw mLmZ2KSzWJRmgVpe87AAWYJNgLzkx7jXTU4hwvV+iDQ6wZAXBbkH3JHcC7up42Lggmn/r1Ec8 VoWJ8eq03qGNaAmXmXPCWlcslbajAJEYMIO4NC4UlCpljM7flBilgxD+o/HwV4ZgGnWEuC5x1 GnvWiA== 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 chip->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 Tested-by: Michael Niewöhner --- 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 d2c9c9d76893..603b82ca56da 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -1091,21 +1091,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); } }