Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp4046806pxy; Tue, 4 May 2021 16:40:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwE0Ay3ghVoAsZxTBYIU+a0N/NH+fAJSvJWYYYDBDyPTBiYyUOmRmJCb8s1xc/4zNccxOIa X-Received: by 2002:a50:cc8f:: with SMTP id q15mr13412685edi.322.1620171653673; Tue, 04 May 2021 16:40:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620171653; cv=none; d=google.com; s=arc-20160816; b=G2s9lgwXcDmpwk7QrbLtzkCc2GwouaW0AKhpIUMoQqvP9e5LIjjZozgtKqP6uBJgFo kVJrTzim70dbpbYY42X4/vbhhYFflyVex2eP5nBEvBiuqAdhUm59T/NMxnInJLhlk9E8 P3NcTzGz/U62I5zgPA/p0oGyaDLBLrsL+Q71IWzuja4pO3OzFy0efuB/LzUAi5/sm+TE yp2yDs8NaeBFxV+fGGcLSJA3Z5E6jBASsBwGKy66SYE7VMVRTVTr4zgYmiyQ/GkNT0oJ VpbQ2cRqZQBCqM30nFiX0mjuJFu3VWuzqUC57kGjeq4LsPars/2mzbEeku2bVECzaCKC UhqQ== 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=ubG/kS7AScb90Ufm+oSktEDCndVwahDaJzlZusrEB9I=; b=r5GVVmyKF9aqjilQeuy4+PWvgXL/aF/ce32Hs5rzkT0QwAt8DfZXokPXx05ZGJjg5V 0zTS18Gt/iBQcWCtgneerZXid9BfkA4qatinrtrqEphwHE0Zl0ow5HKmAybx51E0BOo4 b1O8h7FxgKp9wGAvQLrZ1lYVnrMxcX+cR52Wkk9utrxbV8V5arJzBJKfkPo/+yE0sQb2 FDSELi9nSWT+tHhaIdYpEJy5p5yOfv5qcejPklfiNMCjfJZvchjvTiaXStx+x5zWFNbU eJq7czcoEJWq9hIUY8Skfavqqfo0fIaNk+hQpBZudOkASB1T+5Kzn+KmqW4SM4/m6G/E 2Yrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=jKTJYemW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si3568069ejc.339.2021.05.04.16.40.30; Tue, 04 May 2021 16:40:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=jKTJYemW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231246AbhEDXTP (ORCPT + 99 others); Tue, 4 May 2021 19:19:15 -0400 Received: from mout.gmx.net ([212.227.17.22]:37367 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231226AbhEDXTO (ORCPT ); Tue, 4 May 2021 19:19:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1620170286; bh=7+/WkLlrUW6nYbt1rR9XMX2K5sSRfuIx97po5iq3Bl4=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=jKTJYemWjN8OTMWMJUpHaE8IISxB/5rGotHGlOa3cNwVgoUncXiGQt5b6MaHrC/q7 vF+8JLQomowP2hOk0LaDvXkMU1Jo2dAi2tdU4z/GdfAS1tNhms8/pmqSjI+zxe3V+x ZsEQVRK5LtgYRwfkKY0LQuWwiORCHoPVjAQbhbPw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.51] ([78.42.220.31]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mlf0U-1lE7Ce07V4-00imJL; Wed, 05 May 2021 01:18:06 +0200 Subject: Re: [PATCH v3 3/4] tpm: Fix test for interrupts To: Jarkko Sakkinen Cc: peterhuewe@gmx.de, jgg@ziepe.ca, stefanb@linux.vnet.ibm.com, James.Bottomley@hansenpartnership.com, keescook@chromium.org, jsnitsel@redhat.com, ml.linux@elloe.vision, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, LinoSanfilippo@gmx.de References: <20210501135727.17747-1-LinoSanfilippo@gmx.de> <20210501135727.17747-4-LinoSanfilippo@gmx.de> From: Lino Sanfilippo Message-ID: Date: Wed, 5 May 2021 01:18:05 +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:0R+Txwn8tbP0MWRU0y0WdKIP3EqnGHISFlV7trkpOFQI5J9ja3w iUsVCZEPYGRciezP8wOsT5SZvqvWZVMsdG7IYtbm0mEapITuqfguGE6YpgS+zBiF6JWv6XL AGiqIHlgm5sUTnc6KGe9rOYx3/9vWYvxodtfvbcKHKIyid0zHaNGriAtNjJpoiloz4kzJBn IlKZfcEwv5TlDApKD1tBQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:tEtWiAJGYO0=:jza5X506Qi8Tob9V5djziN +jTmn1Sxbu+GWOkTHCpSitj6GM7BUjUPKaDT85KBFgROHJAfrWhUNbZcBnn8JjWiF1MM9OF+M AL5XGRfQKUmIv0nl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XPUmkiCFGHb Ahpf3Ny5tAg8x/fXgsuxnb1jRYZrcUYBxL5kmfti+dal6ul5DsL7Ot6HrpNRzSogSeeDn2+yf ayfK2TDfVIXHo5sAp Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03.05.21 at 17:52, Jarkko Sakkinen wrote: > On Sat, May 01, 2021 at 03:57:26PM +0200, Lino Sanfilippo wrote: >> The current test for functional interrupts is broken in multiple ways: >> 1. The needed flag TPM_CHIP_FLAG_IRQ is never set, so the test is never >> executed. >> 2. The test includes the check for two variables and the check is done = for >> each transmission which is unnecessarily complicated. > > Unnecessary complicated is again terminolgy that I don't decipher, > unfortunately. I get "something that works" or "has a regression". > We don't polish things for nothing. In this case "unnecessary complicated" means that we can achieve the same effect (test for interrupts) with fewer code and fewer runtime impact. Note that in the current code we do the same check for irq for each transm= ission: if (!(chip->flags & TPM_CHIP_FLAG_IRQ) || priv->irq_tested) return tpm_tis_send_main(chip, buf, len); With this patch the check for irqs has already be done at this time, so we= dont have to do this over and over again for each transmission. >> 3. Part of the test is setting a bool variable in an interrupt handler = and >> then check the value in the main thread. However there is nothing that >> guarantees the visibility of the value set in the interrupt handler for >> any other thread. Some kind of synchronization primitive is required fo= r this purpose. >> >> Fix all these issues by a reimplementation: >> Instead of doing the test in tpm_tis_send() which is called for each >> transmission do it only once in tpm_tis_probe_irq_single(). Furthermore >> use proper accessor functions like get_bit()/set_bit() which include th= e >> required synchronization primitives to guarantee visibility between the >> interrupt handler and threads. >> Finally remove one function which is no longer needed. >> >> Signed-off-by: Lino Sanfilippo > > Not sure why to take this patch. All I can say is that this patch is supposed to - fix one bug: "...Part of the test is setting a bool variable in an interrupt handler an= d then check the value in the main thread. However there is nothing that guarantees the visibility of the value set in the interrupt handler for any other thread. Some kind of synchronization primitive is required for = this purpose..." - simplify the irq test - provide interrupts instead of polling If this is worth taking is up to you, of course. Regards, Lino