Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4794377rwd; Tue, 23 May 2023 12:38:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Ymw85UwiZO2Zzw/sLFqE+cB4EIG5cXbWegnmpCmcH9FgE3jikdnG2ogjEGYcd39oWhmMA X-Received: by 2002:a05:6a20:2594:b0:109:38b4:a210 with SMTP id k20-20020a056a20259400b0010938b4a210mr15376166pzd.29.1684870695073; Tue, 23 May 2023 12:38:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684870695; cv=none; d=google.com; s=arc-20160816; b=C8VEKt5RHZzIDKHrQl1+iXQ1NyT13drGkq3LH6YB7B9vP6ZgRzNTTnJS0gG6mne8ub h+woZz0PPlnzl9sh0XZn27x5L4CFxLrIwwGSq5bkRlsTGgw0LC6sBS5MQTN2nYYeI0h0 wKrF+x0WiiqCixPG97jIzeWvAh/G1DO5OWJnFA1sYDkoXiGMBvHPNUcT5SVdQUQLLaK5 ImQznxrZhhQ88hWrIC43MfEPO4AekBg+sVBaYCsNPDL7m/pfomInDU+k/B1LLR835Z6H 14DkJ0uY/J36YR5GDWhkCKFqC/W6kSfEtIwBfUyo/130JgTSy9Z/1/cgZlRGr6fzOzGB GvBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:to:from:subject:cc :message-id:date:content-transfer-encoding:mime-version :dkim-signature; bh=e2+88Fpdes7sDNr1lFo4AJXADvwOPDkDtwtQu+Fn7KI=; b=lDaBj/aCffVBRDTOrrRAeSIUoFdL2ruYaDAgJGFIEgn2N6qos5K4FuYW+8jisSvZ+k 7C5ZXFS0+0eWGM8kzzCHJ97l267K6ztiU/Lf8Z8WTU9mO7NsJ1xRPKf+ChF8dTYYWOIx MzmgPeUIPetbvpT5HoggCPVHR57xHxPesjOn3AVnA2sx1DavTu/2NuyTlybPWvdgIweS tMxYRCawo5NlrE8a534jrgZQAc1bRbolh4zY9pNzhYseXUELr2izK6nA0aPVedAxSTU2 zeofuPlxDidVcyWXurIdBKOjps4bjGozsSGNiPT3yuvMbg34A7CCeeoLroe7El7/tR+6 Vafw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b2QDMZT7; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e8-20020a636908000000b00524d2e488f8si6733967pgc.809.2023.05.23.12.38.01; Tue, 23 May 2023 12:38:15 -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=@kernel.org header.s=k20201202 header.b=b2QDMZT7; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237019AbjEWTNI (ORCPT + 99 others); Tue, 23 May 2023 15:13:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237742AbjEWTNH (ORCPT ); Tue, 23 May 2023 15:13:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77BA1119; Tue, 23 May 2023 12:12:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 148E161D46; Tue, 23 May 2023 19:12:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 734AFC433D2; Tue, 23 May 2023 19:12:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684869174; bh=e2+88Fpdes7sDNr1lFo4AJXADvwOPDkDtwtQu+Fn7KI=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=b2QDMZT75fspvpIHJtMwx9QUeWemKM9oXLhFLuLu1clAf4QyCX3qnBEKSPNynYSkm Qr1B67ra1/wIb7+VxQpSPCHwkBD36PQ0cohLrYjUKdI/4CMh7W7RHnJh/egaFhJd8Z 4RHyIsIzuLStIRJC4yK/26NewusGaRaIO+ZTR9LoU24VEoiKhfW5PMjg6DqklUls49 5GK1fDtWjST3rRfTPbI13po7WIPuncvE/I5dy0oNVhqe89gwRITeNtt5aCHJMfUVDJ 0qyoXbed7BFafxuZk5FARJ2xN8wZIMiiK5lylPCpdTcorusPpk7Bq8pY/7g+txatVb 3TAc3gJrnO9PQ== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 23 May 2023 22:12:49 +0300 Message-Id: Cc: , , , , , , , , , , , Subject: Re: [PATCH 1/2] tpm, tpm_tis: Handle interrupt storm From: "Jarkko Sakkinen" To: "Jarkko Sakkinen" , "Lino Sanfilippo" , , X-Mailer: aerc 0.14.0 References: <20230522143105.8617-1-LinoSanfilippo@gmx.de> In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Tue May 23, 2023 at 9:53 PM EEST, Jarkko Sakkinen wrote: > On Mon May 22, 2023 at 5:31 PM EEST, Lino Sanfilippo wrote: > > From: Lino Sanfilippo > > > > Commit e644b2f498d2 ("tpm, tpm_tis: Enable interrupt test") enabled > > interrupts instead of polling on all capable TPMs. Unfortunately, on so= me > > products the interrupt line is either never asserted or never deasserte= d. > > > > The former causes interrupt timeouts and is detected by > > tpm_tis_core_init(). The latter results in interrupt storms. > > > > Recent reports concern the Lenovo ThinkStation P360 Tiny, Lenovo ThinkP= ad > > L490 and Inspur NF5180M6: > > > > https://lore.kernel.org/linux-integrity/20230511005403.24689-1-jsnitsel= @redhat.com/ > > https://lore.kernel.org/linux-integrity/d80b180a569a9f068d3a2614f062cfa= 3a78af5a6.camel@kernel.org/ > > > > The current approach to avoid those storms is to disable interrupts by > > adding a DMI quirk for the concerned device. > > > > However this is a maintenance burden in the long run, so use a generic > > approach: > > I'm trying to comprehend how you evaluate, how big maintenance burden > this would be. Adding even a few dozen table entries is not a > maintenance burden. > > On the other hand any new functionality is objectively a maintanance > burden of some measure (applies to any functionality). So how do we know > that taking this change is less of a maintenance burden than just add > new table entries, as they come up? > > > Detect an interrupt storm by counting the number of unhandled interrupt= s > > within a 10 ms time interval. In case that more than 1000 were unhandle= d > > deactivate interrupts, deregister the handler and fall back to polling. > > I know it can be sometimes hard to evaluate but can you try to explain > how you came up to the 10 ms sampling period and 1000 interrupt > threshold? I just don't like abritrary numbers. Also here I wonder how you came up with this computational model. This is not same as saying it is wrong. There's just whole stack of options. Out of top of my head you could e.g. window average the duration between IRQs. When the average goes beyond threshold, then you shutdown interrupts. The pro I would see in this that it is much easier intuitively discuss how much there should be time in-between interrupts that the kernel handles it, than how many IRQs you can stack into time interval, which blows my head tbh. BR, Jarkko