Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5137533rwd; Tue, 23 May 2023 19:13:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6liTLd4BoIOb+V1FY4mm6JJoZ+635YYnRbIaX+jqvUpI3W4GyJJP9qySOaZB9ehNAyuoZw X-Received: by 2002:a17:903:2310:b0:1aa:f53a:5e47 with SMTP id d16-20020a170903231000b001aaf53a5e47mr20290726plh.16.1684894395282; Tue, 23 May 2023 19:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684894395; cv=none; d=google.com; s=arc-20160816; b=y3NpvRCceJZFWcTsc8+K67dUIXMHlHCSBoejyPGeybCa3F9p9lIs1MU4ouDKuJYIPC NTnq4m9w/RzeBMMRjregK4s+aOYqGguGdgAptYnkBvRKVMll6i+vZ9OPmQ8d5gz1SA5J REAvRD0eT6+1LoQJ6HFEJbbHYZ73v67x4kpsuVs9bemm0GIt5T3swqZEgIqZH7aBqg0k O5uPUmLDaqg6ycXE/8M5cRCo83h0P0UgsS3C3M5tHMRq7nbEemwodqRruqxV9cCVJ6hr 7QfeDFOXlbp/xnQxN0yf82A5SH3NPOStDGpH7PVB0Zsqs3ecG2D8DLXSOGeoD7kZbMyU jThQ== 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=pOLpnJQcqY8MVQLPN/1IkOs1el4sjboXz/cLdxwhYmM=; b=bxoKuyIjCV0JzXtLCAG987TDzegHZ4Yo/0TRIsfNX+zMwE1JgMQevaNIyMK4y/dL+Z z1C911dK1ffA4CRlBYaAxvnLA4ZeXl7ba+vpLQDhqYv/pcEQMc8XoS/J7vR57SFE9SOS ywmkJvU73IYfokRZX0dRMlR505RWUx3BaDZfBFy/2729GWOBGN7cNrORu9nlftFlX8mf mNkCXJHAbzUpYCiCrBSI4ZrH7Ri14LQye+lE4lr2wM6gBdq8/V4uDb1AZrm3zWWDhydg 93LKwkF8eSGZ4yEqf+rfYDgeEvBuK1Wol4s0ynRBUMpGi3RsKOGqFpN3KKY+ZfesZVW/ ffdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SEvFtRJt; 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 c6-20020a170902d48600b001aafecaa768si285182plg.641.2023.05.23.19.13.00; Tue, 23 May 2023 19:13: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=SEvFtRJt; 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 S237460AbjEXBrG (ORCPT + 99 others); Tue, 23 May 2023 21:47:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231317AbjEXBrE (ORCPT ); Tue, 23 May 2023 21:47:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0F2E130; Tue, 23 May 2023 18:47:02 -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 77F3C6170E; Wed, 24 May 2023 01:47:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13E09C433D2; Wed, 24 May 2023 01:46:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684892821; bh=htgz3lE0eVnzLvjwGvmrJfm7OK1JybKFXOYQ7Xp39ss=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=SEvFtRJtMmkOmkKvuPr/zaDgPpJrI8zw/hpDkXgc/wR8OM6kpA3DvvqxK40cdYvP+ 2i4K4SPtyFbTkvj7wFOKdmxFN0v0L0GrnhdQpKF8epb6Yy+PX7HEKchKY7UrLkCXB0 6HJibV7PwCWvLTSsxswEOMMojol3YXNSVfhi430G15i3+LMuC1B8gzgF206Dr/ARvM NAEwwGm6Z4+hjx8zGRCE3ki3UZ9xJKPpyueV8xSGokJXfmgiUgzbL2cAXGU0pv9FzY KSSnpb1Mcz1KBXA66AseQ1FHZsJL6aBqz79PO8nW5ZUbXGjf6LkZW/szUv+wdb3R8i IlvCaWhcQ5zSw== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 24 May 2023 04:46:57 +0300 Message-Id: Cc: "Lino Sanfilippo" , , , , , , , , , , , , , Subject: Re: [PATCH 1/2] tpm, tpm_tis: Handle interrupt storm From: "Jarkko Sakkinen" To: "Lukas Wunner" X-Mailer: aerc 0.14.0 References: <20230522143105.8617-1-LinoSanfilippo@gmx.de> <20230523193745.GA5820@wunner.de> In-Reply-To: <20230523193745.GA5820@wunner.de> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 10:37 PM EEST, Lukas Wunner wrote: > > > +unhandled: > > > + tpm_tis_process_unhandled_interrupt(chip); > > > + return IRQ_HANDLED; > >=20 > > Shouldn't the return value be IRQ_NONE? > > No, absolutely not. If you return IRQ_NONE here then genirq code > will increase the spurious interrupt counter. That's bad because > the IRQ storm detection tpm_tis_core.c would race with the IRQ storm > detection in genirq code: > > Note that disablement of the interrupt must happen in a work_struct > here to avoid a deadlock. (The deadlock would occur because > devm_free_irq() waits for the interrupt handler to finish.) > > Now, let's say the 1000 unhandled interrupts limit has been reached > and the work_struct is scheduled. If the work_struct isn't run > quickly enough, you may reach the 99900 limit in note_interrupt() > (see kernel/irq/spurious.c) and then genirq code will force the > interrupt off completely. > > To avoid that you *have* to return IRQ_HANDLED here and thus pretend > towards genirq code that the interrupt was not spurious. This would deserve an inline comment. > > > struct tpm_tis_data { > > > + struct tpm_chip *chip; > > > u16 manufacturer_id; > > > struct mutex locality_count_mutex; > > > unsigned int locality_count; > > > int locality; > > > + /* Interrupts */ > >=20 > > Not relevant change for a bug fix. > > But not harmful either, is it? No but it is still spurious change in this context. > Thanks, > > Lukas BR, Jarkko