Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4314267rwd; Tue, 30 May 2023 03:46:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Kn0wzeJp+JBK4HgovJ+TBbC5N9/XVI/u321wmBepEa9e+JlAdOluyBxeZp//K2oGJ4mCE X-Received: by 2002:a17:902:d481:b0:1ad:dd21:2691 with SMTP id c1-20020a170902d48100b001addd212691mr2341163plg.10.1685443618547; Tue, 30 May 2023 03:46:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685443618; cv=none; d=google.com; s=arc-20160816; b=LrNDEhRzmeXwPHiQ39/JvfSmsOq90WSNniQLoNVP+sVjZOPZ4AJu8EzVMKLPK/x+rb nOn7fomZ+0MY8k91Oa15cA4ftSyDrd2ss2AybN8oVIDnrasg5pmBWf3v6RaPlk+erMVl Bt/EToYt/4GNLm8gOYvfyWTnBDtqe8NvXUkd6DH7U3YOFwFHB1iOhj6rhwWSU4EWJ6iD bAIjOPYZskB8TuLx7QSkBijtLE3IqnkS8fZ+Jp2UtuBIXtcvP6YljznLlVvYk/lDO8++ 5Sem5CzuLcqOrekZX+cYwHltfbFixPwVnstRvR7wcudaUNfZY+b6EOOcnZw3F9dYPKtE 3X2g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=CvHjMbRjyM5F98Uxsv7mOUGETS3YT96ti4ht97+bXsg=; b=na3j/dMNavOVH+U//k/mGPd8oXQ/KLI5JrApHs3sGgaZu7Uo9t4a/R3ICv4yYPdXU5 bminH5t+W4k/qoTXZrmChvGcgYCpr8RR4uwW9ylD8qBHIliIjTebpHGavlLaa/UauQ5I dc5uJ5zSLIGSLOlddlmzZb1nK7HUdI7XkZkjbyNSkYjvCcxhtdFTOYkcV51FPwMT1z0b 0TaYwkjtWGFmGRIqEtcBkA0vUMXIe3TbtX7Ujjc/iPXJ+Lta3bl45HE4YBXEiMbab5OQ N7DJUg181IWAn2ghsBK+t57eCkQRtpFuFeBrMhBeOAb/booywWkK8+12+rMRvXHb9mcX npjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=BrPAynvc; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j4-20020a170902da8400b001b05e96d85csi1093690plx.341.2023.05.30.03.46.45; Tue, 30 May 2023 03:46:58 -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.de header.s=s31663417 header.b=BrPAynvc; 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 S231484AbjE3Kce (ORCPT + 99 others); Tue, 30 May 2023 06:32:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231458AbjE3Kcb (ORCPT ); Tue, 30 May 2023 06:32:31 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BFFF93; Tue, 30 May 2023 03:32:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1685442714; i=linosanfilippo@gmx.de; bh=HLrwqdUJuqN16B/qjsE6jcWhUvILRIzmNm5SbVmJ4dY=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=BrPAynvcb6fpBI2DaSXRYjAr9zhgXRkTsbysxdy0gvSn00kbbPcFNbGT0ROmNuJue fd2xmSFnL0dGmANe0uxL2qoy/ScCYi/3opedQRCYOz7auHnmxu+/QRmuX8A9eFV8Qa QlFFBonjkHV+JtMYxIqbuYLNYmrl/2YnQm3QLGJwxFpKsTLQ3TDyufs4moKn8DnqIz nesByy0gXla/eJ4a0HwZ/AhMt05p5GULjW1Ac8/5t4mY4KbkQ6q9ZSw8GcDq5dsTRw /y2laYytEPXhaRCbjQOV32Hd9U6aVX9SZ+JXetr9NvYHbKl1CWFkUaRtQIznd7rTAi PKX5BKC/TYGTQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.2.37] ([84.162.2.106]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MnakX-1qSs0d0xqX-00jWHZ; Tue, 30 May 2023 12:31:54 +0200 Subject: Re: [PATCH 1/2] tpm, tpm_tis: Handle interrupt storm To: Jarkko Sakkinen , peterhuewe@gmx.de, jgg@ziepe.ca Cc: jsnitsel@redhat.com, hdegoede@redhat.com, oe-lkp@lists.linux.dev, lkp@intel.com, peter.ujfalusi@linux.intel.com, peterz@infradead.org, linux@mniewoehner.de, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, l.sanfilippo@kunbus.com, lukas@wunner.de, p.rosenberger@kunbus.com References: <20230522143105.8617-1-LinoSanfilippo@gmx.de> From: Lino Sanfilippo Message-ID: Date: Tue, 30 May 2023 12:31:47 +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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m5m6hfUX6h4T4SFblsDsb8QY8YYnl/A9M9PIl/ zFfbv+B0xLBCiHLZCaPPBeY1W/CixPj/joHPJJkkRexxAEUhVoYxSv/OrpyJO9BpxpK+M/mr7 noAAy5MLeiElSQRlNNfUzYN8HbObuQebmgPehRcHgccsJKgxpG5gp5qsAwxEbtxA8bdMpxLKB YCIu9A== X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 24.05.23 at 17:30, Jarkko Sakkinen wrote: > On Wed May 24, 2023 at 6:58 AM EEST, Jarkko Sakkinen wrote: >>> rc =3D tpm_tis_read32(priv, TPM_INT_STATUS(priv->locality), &interru= pt); >>> if (rc < 0) >>> - return IRQ_NONE; >>> + goto unhandled; >>> >>> if (interrupt =3D=3D 0) >>> - return IRQ_NONE; >>> + goto unhandled; >>> >>> set_bit(TPM_TIS_IRQ_TESTED, &priv->flags); >>> if (interrupt & TPM_INTF_DATA_AVAIL_INT) >>> @@ -780,10 +829,14 @@ static irqreturn_t tis_int_handler(int dummy, vo= id *dev_id) >>> rc =3D tpm_tis_write32(priv, TPM_INT_STATUS(priv->locality), interru= pt); >>> tpm_tis_relinquish_locality(chip, 0); >>> if (rc < 0) >>> - return IRQ_NONE; >>> + goto unhandled; >>> >>> tpm_tis_read32(priv, TPM_INT_STATUS(priv->locality), &interrupt); >>> return IRQ_HANDLED; >>> + >>> +unhandled: >>> + tpm_tis_process_unhandled_interrupt(chip); >>> + return IRQ_HANDLED; >>> } > > Some minor glitches I noticed. > > You could simplify the flow by making the helper to return IRQ_NONE. > > E.g. > > tpm_tis_relinquish_locality(chip, 0); > if (rc < 0) > return tpm_tis_process_unhandled_interrupt(chip); > > I'd recommend changing the function name simply tpm_tis_rollback_interru= pt(). > IMHO this name is worse, since this function does actually _not_ rollback = interrupts most of the times it is called. Only after an interrupt storm is detected = (so currently after it has been called at least 1000 times without rollback) it actually rolls back interrupts and falls back to polling. Maybe rather tpm_tis_check_for_interrupt_storm()? Regards, Lino