From patchwork Tue Jun 21 13:24:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12889296 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 2D29FCCA481 for ; Tue, 21 Jun 2022 13:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232268AbiFUNeS (ORCPT ); Tue, 21 Jun 2022 09:34:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351719AbiFUNbC (ORCPT ); Tue, 21 Jun 2022 09:31:02 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 897822AE1D; Tue, 21 Jun 2022 06:25:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1655817937; bh=DRphZ/l39/9GYPej7UvI8/O4Gz2dDgvZS7UWsf3aqIE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=XsfFdQGesBGo+d6jFBt7KwUZyTkzPntZJYZaf75N5WdwuZW474pAeYAuMFtGR1Vh0 j9irPZA4O5C6NvLxP+VSYGJev/m+N/SelnMmIns9CCCHjMysqXFFpqoYxl7nV3LQkv I1/3z8DWt6oUZ2t0HRzLVvLSx4BcwllkXT0HyyTE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.2.162]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MXp9i-1oBKRh0p6y-00Y7wW; Tue, 21 Jun 2022 15:25:37 +0200 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, l.sanfilippo@kunbus.com, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com Subject: [PATCH v6 3/9] tpm, tpm_tis: Disable interrupts if tpm_tis_probe_irq() failed Date: Tue, 21 Jun 2022 15:24:41 +0200 Message-Id: <20220621132447.16281-4-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220621132447.16281-1-LinoSanfilippo@gmx.de> References: <20220621132447.16281-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:9JtmR9KMEqWCGdhBCxpCM1SHKiKG1NG9K14z71jAmxvmXo5bQfg +tNzkMCHEl8sWEscHLU1ZFgKfu9EIrIpopTa1Tf29SK0KVSi1m4J+WVZ1+MOWQwlEyonhfu M1f0J9+HBuZDaBCBadHeFXh5pfZDT9zwTrI8akaplIBlF8btvbBbiYLEzO+8w2NiSIP4qjk opGtv1y09cwHytfpSsVZA== X-UI-Out-Filterresults: notjunk:1;V03:K0:QH/j+wn9piI=:V69SuUQHmNngJbKTt60HnZ yVkHYgg5fmaOaCILpalYehML/iHQooumiaBIn4dttRRqSg+9tZ9955FMX26Jf/S+Wk77PZCAq fi0L8LU3YeSIsqNBE2Dxq6kihAtJx+KUPVMihtF/bKlt+meY9DC8q1DeeqRS3spPuyQ+P2Ii0 cdNhPXNWcj8y87idsaWBTS80wKpRVOCW9dpSP3mGXfKODw27eUwslCNc9hg5j5RHG6qC8MjQs AkEx117fOHvQLS3Y5tRQN8NSDwsr+fG+dv464+MSoQisFLuiTVIIjFBaj38a8j8QaEcfaPPOx EN1n/9gr3uHiQNndosSw0KfQUDeUMMwuxd4n3x7jl/P1Y2a/78VnOpkz/loHcjrDFUiEH/mKU HuCLr7KIUuLI5yY1040orbBSqFzkSXloap1Nt4cHeSzVIcLnfemliOnzc6AnT6YwYTGmn+rPV GizeVzBFOYAHFKtW7Aw//R6j41NRUDLL3nrQcB1KBevqWJ5+Ookq8hOC4WXGxSdGm4e8SdODT OGrLAnFzQIEFxVUC8X5EffoPsMjs0UGdMMZD88wsMzcbcIclElcqekOUaC1P1OXM+dhYl8sBA chp0egkVnImTuTxdop9J8Sl3RQOR37qcYk2VL7WEiNe4aiG7sGJxB/D/ukd2loLVVtebgaNhc N1ZR478vdTnigULh4B9oEXISCZJ2f6sRrSTRBct8mPEQMqS0KOGpDXW3Py2ssJ11/d9zGlGkE ENCre6P1AxK/pIu6G94s2qs/wLOkiOI39aWtovRmKcZNSNXpI9Ea/JAbY7s/SSbkXMUdJwdSO 4tDt8eMgY9IGE27AftZu40VCmVS41J4RrfvDu5ncf2SIelKvciswNiw2mbVWuXpmt1aTe8jeK /8fcT9p0SOn6PxuMnJ/6levV4ztKgJ7X/ZPqTb3uBNljkngZXNRvtowUcd4tN4SS7oQnH8aur WbNsmwfx2jv42HX8EAvdBgxyDQxVqayyTGm4HRaWEvi+9IuBf6eYxIP3kFvt/IikLBg7Mk7PA GSakP8NWbihfB9e0xyNxf0UyMvTCkGi53aqYkmUAGrR9NYyNKn0VFhXw+zjzvcjCxFS17OPmy 0LIizjyBx3Qejgx5SHhehptSNmdp7mezbkGQatGFMqe8p/7weIYIsHuXQ== 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 --- 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 0e68e4502a56..d32e93c86f48 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); } }