From patchwork Thu Nov 24 13:55:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 25547 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3411044wrr; Thu, 24 Nov 2022 05:58:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Q7np7uLuNM0F/QtHudcmDvGBkhr86X9Yj7FI73YIanGGdERZyDwiTQ3VW/yd1LqHtrQoR X-Received: by 2002:a17:906:8252:b0:7b8:3098:a067 with SMTP id f18-20020a170906825200b007b83098a067mr11569659ejx.701.1669298305191; Thu, 24 Nov 2022 05:58:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669298305; cv=none; d=google.com; s=arc-20160816; b=HXWvE90ixEwZVXevOBRI/5fMLkA7fiUbMsOqfmKSjMyA4MA6IORplpABkxchOY9H6U lw6YBSzxOMENLIEawU9wwykVwka5MfBd+/3+1FWJdhSpvq5SWnoaiu+V4pAK0i4KuLYt +b33m/fhTbWQ7RGoJMqWa594zhyNCL+Qa65SMZDDstPU7BHeUZvoHa5Q3UTizvBexENK cfPgzVkAslTbl1xT5F6TJg0ctYV4YOBcwXC//k2RCfRiM/rshoyeCO9iva+6BbpcpCJC dU65iUcQ4rH4tmTXI6Ai/SENceCFWZcWg3Qpcz+7SteqqKnzronYizraotWxbIl40wUd 7Xaw== 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=vmr8i0HILdqGMwVhgOxfm//3j+C4M5iWtBnT+hrsrRw=; b=QbVHEvJiJVGYGx46mstvZi9xmTA4xQdkonXDt5Pv7IPG1OhBBThH6C1PPPanZT50ZV f9XfhEWeDMK3cEisXlSFyaM9NXjP7M1M9VO3xXIu7GcODM4VJAsGC2wTFuXG4IEwkEVa DMhpkEznKxSZV73XkAVKgpEFuzLWAzVvn+treUJIAjDAcB/1wO9OCBZ7HZbj0nmDupN/ wkFehYN1BLKFci24/kXocAiUlD5oBxm+RrnveFWGqQUBDF69XYug2wqDKZnSO9zC6LJ9 BRLp4tQK7V4s5Zji7AQoh38BSsnPqg60YJ+7ALO1vhHdNqt0VttEhRleWhivnVYvWZA3 zIfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=aeYWtnKX; 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 dn3-20020a17090794c300b0078de4629958si1057881ejc.248.2022.11.24.05.58.01; Thu, 24 Nov 2022 05:58:25 -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=aeYWtnKX; 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 S230246AbiKXN5M (ORCPT + 99 others); Thu, 24 Nov 2022 08:57:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230127AbiKXN4g (ORCPT ); Thu, 24 Nov 2022 08:56:36 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B23ED116046; Thu, 24 Nov 2022 05:56:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1669298171; bh=vmr8i0HILdqGMwVhgOxfm//3j+C4M5iWtBnT+hrsrRw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=aeYWtnKXEc4nQzzb3bzdwrlz7OJzg4yLtj9IudBGnc9B+VDwKYdPnvW+V0kU78oFU VEX7a2ngjwnJc8Nop4ZG8m+DlbdsQAdv3QQLY3MrMRIReB1z6kSmG+msV8QGqN3xmO dugS+OIT6BYcl1FQQC9a2AvGkWM8v+xNaf65IHBcWHiyANnmo4TgrbFAJNXThXMCKB hmwOe1eVxr8u4YjM4NdfpEeHhzUBQ1gDIpZ9K0i5FXGd4nkfoOKFZBRCdZzfaPu8us BWLp9H78rm2TGSwuAUvTIbtBmB/qPOIOGoKr0CyK+4PrVkFJPqak1mHSL1kpl+hVzU mMWJZdBrGqy3Q== 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 1MCsU6-1opN0M3yoi-008p3Y; Thu, 24 Nov 2022 14:56:11 +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 v11 03/14] tpm, tpm_tis: Disable interrupts if tpm_tis_probe_irq() failed Date: Thu, 24 Nov 2022 14:55:27 +0100 Message-Id: <20221124135538.31020-4-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 X-Provags-ID: V03:K1:J4RfakH6lXbtsfGkrYwY7v5IByUOUdOvSQVf5Cc74pzRKb//+s1 uZCUlng01wMqRHxrd+8wsIdck8EFmK1mC/4hRDdvpb1HEj5oTC0n/V/RAITCJ8aIti8Kc0U OUDsMtfeL4iTStHyzP/FJSyjn78+465o/f2JWjxk6frWbS4dHIMpaJGZw1eMyzAoj0PX6ry 0jkVPHrN7ywsh+wlw2hPA== UI-OutboundReport: notjunk:1;M01:P0:ltTGGu0PJSg=;eIk+5LoGT7XTQjLpNW0DUWjp2Nw jzA33pBS5udjjETZrAL1VKho2FxCsHpjafOJCSzQqtASCj1sPzfWY7SVLGHJ0RhjZxe7BS1yE luJYLg2ZhhNWkudEskl1oUco6ChPSnxWtb5YXeFYAIi518ibB/AUplrlaAJDWa1j269vj6FIS M/GDvDsQP8KjsG1lUv0OfheHfrwtATphwZlDJ0L3LN1l/M2plYNvAfsR6xzDPOWNse89H3L3U x5ANK/79jk1M8Za3Zwbq6yl9QVx0PvdDbNqPwd1BiUEGuqtaFmeJ2J1Bgv/Lquhhv4tsjgB/o h/f0n4s8MoB+ZFJp8q+06E+r76SIyIt54kG4fQefccmo3mfd4YDtzI/QSMrOYvRJTc2xIdhXr x1XUTpwzvjx6TSeicWwq+Sl8/dirjGZeU4ASnyGyJNtJIgf+tHnuC0Hp752QZZDlK3WKbRAnT cLiZ9Rd2uD1E+iIZ1tyvg0EuLLZpycGw4GDlesevlRE4KtlYxvtIfYlaFLzrZGDR5XMYxorm+ b+TJzCdFtZPhxiW/XcRDIC9X0Terwy6khKZfEY2TUNGbqMd/LS4c3t9UL3+0bkr79eYFhJsn9 Qau2u40jUFQRpcXP1aJTZHsDDA0zwJC6rnM7pNJoXqcG+nSDT+5GnAfQFj+1AtyaKpkH1y/ux TXCNyrn80Qa854T7lC9joaYgPCGWvP1HMO6rtMAyp08TItH+Fbb/NonfqQBRPrFvAOvOEkzdl RCRdQ8X6RKyuPwMYfBdSAGXwHTH6+imoj3askaOHNdNgZ7zy5VptV+VpKOkN1qPwnMFyzwv+j s6Jnfw28NLUnMvVAXAq86iV1LX7gX+Jk8vTzYn6K1M4N1Y1QLTi+sozsA7MDuZmH4DYuzBdiO ZsYsVfYOWZujCFBuOa044k7d5ONle9uRKwzEafHBWMP1oBa2PZDQXRlpHkAHgk0up2paYkNIf RoY+Fw== 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750386139953154114?= X-GMAIL-MSGID: =?utf-8?q?1750386139953154114?= 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); } }