From patchwork Thu Nov 10 15:25:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 18182 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp212838wru; Thu, 10 Nov 2022 07:30:26 -0800 (PST) X-Google-Smtp-Source: AMsMyM7MVXEqUlsnL5XJ3I6U+Wcsc8uhYcp5OXHIqPK+9sBJZvbNYfgx9lsQk+BNPtlhRQ9S50OX X-Received: by 2002:a17:907:9941:b0:7a5:f8a5:6f80 with SMTP id kl1-20020a170907994100b007a5f8a56f80mr3134486ejc.202.1668094226552; Thu, 10 Nov 2022 07:30:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668094226; cv=none; d=google.com; s=arc-20160816; b=k3sv+eYaUKvm5M6Aumik2mgeC9MVpH7ceBmoBkz8yPBYMVDi0iHn8/PPyZS6C8E6ql kOBf/cyNAC9Z6uOsfYQdoXBRvWd/VMD1tlR9HbfATpFKCtRgyJ9E+bPOagnpn/4oE28e idgxWpJASznhfSMmuz/rZX8eMhVw6xxrmm8rWbhwV4a0QSUqSyvHp5dHBXdp+h215M/J bwh5JuYQeWzrfUwZTDjNeGV0RFLDjSsqIpWHDBWB+YlY0E7TVTgivqMQtnKOZGgm/YTf WwEtf3rTpCkExaaQb3Bmowy1OQVVGOraUO3AbFlRnQOPVaHtRKi7fL9YXyvR5EErq3H0 uFCQ== 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=NZ0b2tOq2Jj1mWbGc2AGV1zg/VmCzKBMKS0JDk1OzUg=; b=Zi/QfSZdx657bncAaqkpFk+Tg0AdYTB2FjWtDqI9I0cZzOyNDO2Wrj6Za4j0mnC329 64t6Qv7zPrcFlPQu8DRFFQ4IVJSPvtWTplSkhKydbQnMAZunGpvR0a7lqNN87qaD5u4f BYMokknLUqNo60/O478L1hchdeBVMpsj9dC/Y3ZF4+4AVuh5l4lnt6FthsGcpNcI/ESM 8dyoExUJpXHHtADDBO9SxtSXlQtJRKVwTk1LAgw0YwdzKfb+m4iLH+7qVRqAMEm6n2Ln q0dW4DsOOke2XIa9fIczuuoZI7XO+MM75imlRV9PzzAIu/hWJ874147PAQKr974NBoTs AicQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=JraCJdsK; 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 e8-20020a056402148800b0045d088f4b79si16534328edv.258.2022.11.10.07.29.59; Thu, 10 Nov 2022 07:30:26 -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=JraCJdsK; 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 S231567AbiKJP05 (ORCPT + 99 others); Thu, 10 Nov 2022 10:26:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231569AbiKJP01 (ORCPT ); Thu, 10 Nov 2022 10:26:27 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFB513C6FF; Thu, 10 Nov 2022 07:26:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1668093945; bh=NZ0b2tOq2Jj1mWbGc2AGV1zg/VmCzKBMKS0JDk1OzUg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=JraCJdsKpqTaJ1tCduuIEmE+jAYDJpzWpdV2jYswMKYAuEZ/y5xjAMMDFv9Jpt43E JEtjkNPZYzBB7ZdZsimenVC5Ar4VddpJGl5M45xvFFDhgrS5tJQVGojoJJZc3NxM50 QSbQalNEqu0fhhstUAqwqPQbmR+L6PJPJq8XhGHU0Btozc/wtR7vHFJoiYF/YfbweI T6Z3AMYN9R6k0tD3wvEy/Vz8qcX/9FS6BZ99vRoBPwws4NeYwr2ZzOcuDe3/bZFgR8 KoLuErV2A1UuK+RzW4TyTw1zouoR8DLVHKyYXBy0gyd5AV3ufL4BZeBNhy44RskGd2 QRffVo0oqmM/A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from Venus.speedport.ip ([84.162.7.17]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MwQTF-1p9Zj20CdZ-00sNBA; Thu, 10 Nov 2022 16:25:45 +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 v9 07/12] tpm, tpm_tis: do not check for the active locality in interrupt handler Date: Thu, 10 Nov 2022 16:25:28 +0100 Message-Id: <20221110152533.24243-8-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221110152533.24243-1-LinoSanfilippo@gmx.de> References: <20221110152533.24243-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:GxP0aibOPHfomqlU2L62HC78GYwnrsSmJt5Ub7ZOMwbOcAXKjiZ TmH7+V1qV/nkWal0Chqm7Ie45EULFTBztt0nz6MsGxyDfTmEJYv5fktsf6RET4B7IT3benQ /vnTRy7nbIafZMQrbmt27nnhrsr1ZPIeME8jRZtj52XunV4xRG2EDK5Yq75ez6jNrcgOUoN lbI0d8/n0/8QfFEAvE6dg== UI-OutboundReport: notjunk:1;M01:P0:pE9h/nbfKPo=;amtKpgOOFt18QFUb+vzjAWN2835 uIquYovDCbBjPUvi+DhHtFa4miXr+EkvA+4+GmktxmLK8CYEkbqgK4PTlzqTDWvcaLH0PrW2Y R7k/Ic16SBH1ldZA8W5K52+FfKc9TwXzeTU3htqPcekjX3SGMswS/0vsEXzb/1hedV5y68VcL CRCh3dS51SrmROZBG6UQ10GMx5FFDfxVLzIaCAnJqoYg0XZoyo5okMQrtQF7SGcwRXMEN2qFr 39WaWxhjHrI5Y/e41Rz0OofushHhXXIVY2VK0J42R+Lmbxj17mL8A9ZNqH0l1gFLBrBDvuWo+ y6K+AWEEYFh/FHvZG9qq3WDRAz+27whaqJ2xXzLCjZBZzTJJhu1d/A6MVddZaix7J+LBewaTZ HCnSOp88z4gl8LO846ws3993XKNXuJrq/9rkI0Q/W/IH8l/1vGVt5uX+Wz3Gl5VcVD+AdaeoX D31efIBIBiUFNqdEkKVDENVM+awbqPfbkwKN9UAey91bo+/3NcbKzyulGOErleHaOE/cWFaZf pzQQOrizAmB+h/EBHY9ox4r9CF+pZ5ZhgqmayPb1zi+nqJTwzXsP3KU+/Vpqpj/BW795aVv/a 3kqJvNiLWR1LxxArrfjOFe21PusJxyUxX6VaBMB0IpHby6i1Twvn2WzdHW/0LYC+44xyK9m3K a3h0okqcUV89d3zetbXB/JpI7+Xgeeg662/MbSuJLAzFe9IzgHPr7vorVqGg1e0Zny3wFnIZe fLecKn3to3Okx0v0N4qpp/SJfvLRMGV8wc+l8/aJnXwgM3KHZcvC6+H9e4Y/tew7P5c4bQmzM /vJrw01ZLN3Gr+N8tcSZ/HDVT1C5LyZmIvF1jvvMUN3xSlJ409K6ygKU9vGYVIZpq67yYT3is LR3cFWhFf+t2QR+q9tjnQAjwZzsrZKbjPCi3qxuDdpwNeh2cUv3XmwK9ZQHeQ6wPSN+tg8fLd itOuV3FeF/lcPF52bGJ6c5OV/H0= X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,MIME_BASE64_TEXT, 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?1749123571735946881?= X-GMAIL-MSGID: =?utf-8?q?1749123571735946881?= From: Lino Sanfilippo After driver initialization tpm_tis_data->locality may only be modified in case of a LOCALITY CHANGE interrupt. In this case the interrupt handler iterates over all localities only to assign the active one to tpm_tis_data->locality. However this information is never used any more, so the assignment is not needed. Furthermore without the assignment tpm_tis_data->locality cannot change any more at driver runtime, and thus no protection against concurrent modification is required when the variable is read at other places. So remove this iteration entirely. Signed-off-by: Lino Sanfilippo Acked-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_tis_core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 181c291b0bb8..4336f7ea8c2b 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -728,7 +728,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id) struct tpm_chip *chip = dev_id; struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); u32 interrupt; - int i, rc; + int rc; rc = tpm_tis_read32(priv, TPM_INT_STATUS(priv->locality), &interrupt); if (rc < 0) @@ -740,10 +740,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id) set_bit(TPM_TIS_IRQ_TESTED, &priv->flags); if (interrupt & TPM_INTF_DATA_AVAIL_INT) wake_up_interruptible(&priv->read_queue); - if (interrupt & TPM_INTF_LOCALITY_CHANGE_INT) - for (i = 0; i < 5; i++) - if (check_locality(chip, i)) - break; + if (interrupt & (TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_STS_VALID_INT | TPM_INTF_CMD_READY_INT))