Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp865804iob; Thu, 12 May 2022 06:22:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrbtUvzUCM1jwK04DR9sFEBQKb2jNEeXeuzVErqR4F/6m6Fa8dH0cGvaP55UGOPVuL1vXO X-Received: by 2002:a17:906:1691:b0:6f3:a3bf:451a with SMTP id s17-20020a170906169100b006f3a3bf451amr30592339ejd.61.1652361776556; Thu, 12 May 2022 06:22:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652361776; cv=none; d=google.com; s=arc-20160816; b=oVOL4ycu3+pBJTt+bP29Cx6nlUPwBBmcSsEl2L2NNpcZXzX+EKJ0P29kqLexoB4faQ E5EOlMR1bS3T8PBeQkDDVPJZXdxWxuDEQtaco9ECGe03Hhpo471zbiH0InjIQNO+ce/E EQc+4Jy3TqJ9O/98GU26zXkypHEFRUHnvGV7VrxLQ7cq4FMzjjYnfx777val+yeI6izM jFmdKiG0rG5YF3XsnxKIS936T8uhlQNdBBwrtnA2p7kHiMEqeLG/VZZRLVLh6Ptz0zT8 agqODwDaicpOOrAff4K6SZxR1nv6TkXaWCS07Uv/x0+WJloCrf19uiR+NCcExmLSiPmC BLWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=p3i4eievqMHOmVus2HNBfYpLIB7xvo03gjpioa9moOI=; b=Q4KxRvF9JxdZxhdGJ/XqWBQ9uegJGgFTb/1GpbYbJXNQRr/StWHvGRDiTOWVuT2/fU gueNBx5orj2Tl/Qjr75guC8Cxz39UdqfYg/e/xAlm3Si7CQU/gy+qIkZVeeW7xG6tFWh iYvTfbobHlgnv0eeN/mrpN/LmCRzHnWudPZ/6H68lrfyw9sy7jBZafRuUhhY7BlhOS0R VbOYDb8Rr/B6PbXTWpPdmbgR++KFG91DS3cLuDcOXDLi2musAHvP7Mq1A6DJPexNTzYr jdD//cgUAjNQ1r7v83/duraDJnpAukF90YuKwmquKxrwsw/m+USYANiNpcbDJsRHlPgC M9XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=XaeAFU5c; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm21-20020a170907949500b006f3a88ccf8dsi6423159ejc.333.2022.05.12.06.22.28; Thu, 12 May 2022 06:22:56 -0700 (PDT) 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.net header.s=badeba3b8450 header.b=XaeAFU5c; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347405AbiEKT6S (ORCPT + 99 others); Wed, 11 May 2022 15:58:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245113AbiEKT6Q (ORCPT ); Wed, 11 May 2022 15:58:16 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A9911F9A0C; Wed, 11 May 2022 12:58:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1652299081; bh=DnQi+kYGURjHNKQ+4HyqoMBrfpTbkeC+W88d7BnxadA=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=XaeAFU5cHhFJWlL+ynCzu4CxMhRIval4oYAoM+7gtsOqTbiBj4gJ8ahbTvwNoR0Xs t1YaY3SsfiusNCL8vS8bubCKL2DwmrCBVH1dwSJf+d6lt1bE80nA/wiGQzIAKY5gGz kPPxVWG2FHkwe7MVqaoXV52j5FfwQCBgr6ROQghM= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.0.33] ([46.223.3.12]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MBm1U-1ncoir0WmC-00CC6e; Wed, 11 May 2022 21:58:01 +0200 Subject: Re: [PATCH v4 6/6] tpm, tpm_tis: Only enable supported IRQs To: Jarkko Sakkinen Cc: peterhuewe@gmx.de, jgg@ziepe.ca, stefanb@linux.vnet.ibm.com, linux@mniewoehner.de, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo References: <20220509080559.4381-1-LinoSanfilippo@gmx.de> <20220509080559.4381-7-LinoSanfilippo@gmx.de> From: Lino Sanfilippo Message-ID: Date: Wed, 11 May 2022 21:58:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:VrLsUIij1zuxMSkL4gXWVBDdedrrX5LON4oknD+NladcBShhD12 HOQWEkxL6k822imPobS8j9Hqh8ko4JFbIBiVEvoJ3GS1PoGyh7uSFM+MmOVIsJjspNT8o87 vKb32pEX+UQsETuroodq/SW+e5+VQiG9NcyjdMAd2TV01SEAZo2bPAN7666FsQfTjgMI5tC MQlABrAKyUE9Y7ZzlkwEg== X-UI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3ItJ4hwf 1XR0ud0g6WVO1lvNI55xJZ0qfL0fEuCtHz5SaVPxJ4WDOlq6d+jTxhnHVsJjmpDhj11BFA52V N7VQQX6h7A6KGY= X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On 11.05.22 at 17:08, Jarkko Sakkinen wrote: > On Mon, May 09, 2022 at 10:05:59AM +0200, Lino Sanfilippo wrote: >> From: Lino Sanfilippo >> >> Instead of blindly trying to enable all possible interrupts, use the re= sult >> from the capability query and request only the interrupts that are actu= ally >> supported. >> >> Signed-off-by: Lino Sanfilippo >> --- >> drivers/char/tpm/tpm_tis_core.c | 67 ++++++++++++++++++--------------- >> drivers/char/tpm/tpm_tis_core.h | 1 + >> 2 files changed, 37 insertions(+), 31 deletions(-) >> >> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis= _core.c >> index 4c65718feb7d..784e153e2895 100644 >> --- a/drivers/char/tpm/tpm_tis_core.c >> +++ b/drivers/char/tpm/tpm_tis_core.c >> @@ -976,13 +976,46 @@ int tpm_tis_core_init(struct device *dev, struct = tpm_tis_data *priv, int irq, >> goto out_err; >> } >> >> + /* Figure out the capabilities */ >> + rc =3D tpm_tis_read32(priv, TPM_INTF_CAPS(priv->locality), &intfcaps)= ; >> + if (rc < 0) >> + goto out_err; >> + >> + dev_dbg(dev, "TPM interface capabilities (0x%x):\n", >> + intfcaps); >> + if (intfcaps & TPM_INTF_BURST_COUNT_STATIC) >> + dev_dbg(dev, "\tBurst Count Static\n"); >> + if (intfcaps & TPM_INTF_CMD_READY_INT) { >> + priv->supported_irqs |=3D TPM_INTF_CMD_READY_INT; >> + dev_dbg(dev, "\tCommand Ready Int Support\n"); >> + } >> + if (intfcaps & TPM_INTF_INT_EDGE_FALLING) >> + dev_dbg(dev, "\tInterrupt Edge Falling\n"); >> + if (intfcaps & TPM_INTF_INT_EDGE_RISING) >> + dev_dbg(dev, "\tInterrupt Edge Rising\n"); >> + if (intfcaps & TPM_INTF_INT_LEVEL_LOW) >> + dev_dbg(dev, "\tInterrupt Level Low\n"); >> + if (intfcaps & TPM_INTF_INT_LEVEL_HIGH) >> + dev_dbg(dev, "\tInterrupt Level High\n"); >> + if (intfcaps & TPM_INTF_LOCALITY_CHANGE_INT) { >> + priv->supported_irqs |=3D TPM_INTF_LOCALITY_CHANGE_INT; >> + dev_dbg(dev, "\tLocality Change Int Support\n"); >> + } >> + if (intfcaps & TPM_INTF_STS_VALID_INT) { >> + priv->supported_irqs |=3D TPM_INTF_STS_VALID_INT; >> + dev_dbg(dev, "\tSts Valid Int Support\n"); >> + } >> + if (intfcaps & TPM_INTF_DATA_AVAIL_INT) { >> + priv->supported_irqs |=3D TPM_INTF_DATA_AVAIL_INT; >> + dev_dbg(dev, "\tData Avail Int Support\n"); >> + } >> + >> /* Take control of the TPM's interrupt hardware and shut it off */ >> rc =3D tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask)= ; >> if (rc < 0) >> goto out_err; >> >> - intmask |=3D TPM_INTF_CMD_READY_INT | TPM_INTF_LOCALITY_CHANGE_INT | >> - TPM_INTF_DATA_AVAIL_INT | TPM_INTF_STS_VALID_INT; >> + intmask |=3D priv->supported_irqs; >> intmask &=3D ~TPM_GLOBAL_INT_ENABLE; >> >> tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); >> @@ -1009,32 +1042,6 @@ int tpm_tis_core_init(struct device *dev, struct= tpm_tis_data *priv, int irq, >> goto out_err; >> } >> >> - /* Figure out the capabilities */ >> - rc =3D tpm_tis_read32(priv, TPM_INTF_CAPS(priv->locality), &intfcaps)= ; >> - if (rc < 0) >> - goto out_err; >> - >> - dev_dbg(dev, "TPM interface capabilities (0x%x):\n", >> - intfcaps); >> - if (intfcaps & TPM_INTF_BURST_COUNT_STATIC) >> - dev_dbg(dev, "\tBurst Count Static\n"); >> - if (intfcaps & TPM_INTF_CMD_READY_INT) >> - dev_dbg(dev, "\tCommand Ready Int Support\n"); >> - if (intfcaps & TPM_INTF_INT_EDGE_FALLING) >> - dev_dbg(dev, "\tInterrupt Edge Falling\n"); >> - if (intfcaps & TPM_INTF_INT_EDGE_RISING) >> - dev_dbg(dev, "\tInterrupt Edge Rising\n"); >> - if (intfcaps & TPM_INTF_INT_LEVEL_LOW) >> - dev_dbg(dev, "\tInterrupt Level Low\n"); >> - if (intfcaps & TPM_INTF_INT_LEVEL_HIGH) >> - dev_dbg(dev, "\tInterrupt Level High\n"); >> - if (intfcaps & TPM_INTF_LOCALITY_CHANGE_INT) >> - dev_dbg(dev, "\tLocality Change Int Support\n"); >> - if (intfcaps & TPM_INTF_STS_VALID_INT) >> - dev_dbg(dev, "\tSts Valid Int Support\n"); >> - if (intfcaps & TPM_INTF_DATA_AVAIL_INT) >> - dev_dbg(dev, "\tData Avail Int Support\n"); >> - >> /* INTERRUPT Setup */ >> init_waitqueue_head(&priv->read_queue); >> init_waitqueue_head(&priv->int_queue); >> @@ -1101,9 +1108,7 @@ static void tpm_tis_reenable_interrupts(struct tp= m_chip *chip) >> if (rc < 0) >> goto out; >> >> - intmask |=3D TPM_INTF_CMD_READY_INT >> - | TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_DATA_AVAIL_INT >> - | TPM_INTF_STS_VALID_INT | TPM_GLOBAL_INT_ENABLE; >> + intmask |=3D priv->supported_irqs | TPM_GLOBAL_INT_ENABLE; >> >> tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); >> >> diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis= _core.h >> index c8972ea8e13e..3d6b05c6fdba 100644 >> --- a/drivers/char/tpm/tpm_tis_core.h >> +++ b/drivers/char/tpm/tpm_tis_core.h >> @@ -97,6 +97,7 @@ struct tpm_tis_data { >> u16 manufacturer_id; >> int locality; >> int irq; >> + unsigned int supported_irqs; >> unsigned long irqtest_flags; >> unsigned long flags; >> void __iomem *ilb_base_addr; >> -- >> 2.36.0 >> > > Does the existing code cause issues in a some specific environment? > > BR, Jarkko > Not that I know of. This patch is not supposed to be a bugfix but an impro= vement of the existing code by using the information about supported interrupts whic= h is collected during the capability query. After the query we know exactly which irqs are suppo= rted, so why not use this knowledge when setting the irq mask? Regards, Lino