Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp461274iob; Wed, 11 May 2022 19:22:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCQLXF4Wxsup4w3BiZHiH9Ldf/pKC7umrZdrIVj3BDPqJf57oVYFf4OdfaEhwMgOwuB8kL X-Received: by 2002:a17:907:110d:b0:6f5:64f4:9202 with SMTP id qu13-20020a170907110d00b006f564f49202mr25104387ejb.111.1652322140242; Wed, 11 May 2022 19:22:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652322140; cv=none; d=google.com; s=arc-20160816; b=y9vjLs5hV00JxoIryfV4oOwoF0HLMI6OpSpfw1E1HAnk/gT09reIWaAusp4Jg0M35R oH55M/T+Vn0SwYoPWKv3t2+HfAktFjqF3wdKXEUfVx70zeSXCj6K6bTbXsacAa9bR2hQ Qx07mVY1OtfBPyl9dhasyIJiooRzXSnM701xlc279NaHr2ZtNeiu/PMMXUENJ3cbaeZP DU7jTIk8A2xSErT9hCZnU2FZcD6mwFtIjw0KIxSjph2OPbNj/SkURlknx3LdLk79Duik 1f0lSFo9v9Xml0DYmBU2PQPDU7kDG4vnVb7aY3+zebtG2CcMWqHkxuuN2NdVcKbnyX9j oD5A== 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=mdaIHkwwwuFndJkg/X/ktuVcgnpbN/ZJ28zjTUrj/tY=; b=hHJJpLkLZBNNRVEutiwyjlRgyxxXgMBCYjee+njbKcFeQx89eDQjc0FZWWv5YdUIOs 2sVqVh0DIJ6pjjrjZlrJm017Pdy63uXhnbcWkADmSdZhxqmBtjfVhBEIWPG3aAYQ+TFz udeUtwlfkdvsJ4aTkVr+TBuGIZBu2AcC70W6U8Cy9yKLeRcRXAIZo8lCGIg1ynGZmL/m Vl0YGLl3H4IkaOLy+6LwOyXG53dwcLEI+hWYWvEm2IJxqW6AOF0R7+pHBwb6+KLMBgBk zaCc6xGOIgDRl0v9dEKGMrvv3UQecqbAEgSBO5+/YvtwKq0/OdxHlfql9zlzTkT5a/Zo VH3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b="T/woSgcw"; 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=fail (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 b11-20020a1709062b4b00b006e879dba1b4si4046073ejg.805.2022.05.11.19.21.54; Wed, 11 May 2022 19:22:20 -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.net header.s=badeba3b8450 header.b="T/woSgcw"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346737AbiEKTTK (ORCPT + 99 others); Wed, 11 May 2022 15:19:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242629AbiEKTTI (ORCPT ); Wed, 11 May 2022 15:19:08 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BF50541A4; Wed, 11 May 2022 12:19:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1652296720; bh=K6++BUf6/YdegjM4BnlUkF76z9/6nIa57i654gYKFwg=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=T/woSgcwitQUDyi8m4Ah7EDL3k3Q+Da+10SEgWnWKh0sUA4JgpT1SklBMUrgS/7Px D8gxGmYgirxBrzSJ8pBPm9iU0UrHIJnVkzAtZMabpyF+jK4TiGtpvbM8seF6PSrBPZ UBe83135XoH85ioxAGAsWB3ytCNWp6ovdMl8AmYI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.0.33] ([46.223.3.12]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MDhhX-1nfpJf2fN1-00AoPq; Wed, 11 May 2022 21:18:40 +0200 Subject: Re: [PATCH v4 1/6] tpm, tpm_tis_spi: Request threaded irq To: Jarkko Sakkinen Cc: peterhuewe@gmx.de, jgg@ziepe.ca, stefanb@linux.vnet.ibm.com, linux@mniewoehner.de, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo References: <20220509080559.4381-1-LinoSanfilippo@gmx.de> <20220509080559.4381-2-LinoSanfilippo@gmx.de> From: Lino Sanfilippo Message-ID: <486cec01-ec02-3f11-0b81-037e0700c503@gmx.de> Date: Wed, 11 May 2022 21:18:39 +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:isOjDfYGs9rj3rFvgoSSlcdFwtYl/xB/3PYo10NFQYguhcBoORe rkmEuS2ylsl5mRo+Vp03AnDvbURnm3Q7SO2594DDENp1KR1+oTibJb0s3puEH2UKmWNUu1J Lirp/k8iiPUnCf7X9f5QUROUHVOza7iI5YODuONcBJFxSdQHZukvOlah+wD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fEw0lNyw4tsUVwbXFZafYlssQlbhGDFgrJEHbn gS9EwEtQayq0Ro00BW/IzyRPAMftWZpcL0/qxjRLDeHnHPT9TEfmayvSWYlVVMKQgvC2200UX 1+DYY8txEaT5Ag= X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,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 Hi, On 11.05.22 at 13:22, Jarkko Sakkinen wrote: > On Mon, May 09, 2022 at 10:05:54AM +0200, Lino Sanfilippo wrote: >> From: Lino Sanfilippo >> >> Interrupt handling at least includes reading and writing the interrupt >> status register within the interrupt routine. Since accesses over the S= PI >> bus are synchronized by a mutex, request a threaded interrupt handler t= o >> ensure a sleepable context during interrupt processing. >> >> Fixes: 1a339b658d9d ("tpm_tis_spi: Pass the SPI IRQ down to the driver"= ) >> Signed-off-by: Lino Sanfilippo > > When you state that it needs a sleepable context, you should bring a > context why it needs it. This not to disregard the code change overally = but > you cannot make even the most obvious claim without backing data. > so what kind of backing data do you have in mind? Would it help to emphasi= ze more that the irq handler is running in hard irq context in the current code an= d thus must not access registers over SPI since SPI uses a mutex (I consider it a= s basic knowledge that a mutex must not be taken in hard irq context)? Regards, Lino >> --- >> drivers/char/tpm/tpm_tis_core.c | 15 +++++++++++++-- >> drivers/char/tpm/tpm_tis_core.h | 1 + >> drivers/char/tpm/tpm_tis_spi_main.c | 5 +++-- >> 3 files changed, 17 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis= _core.c >> index dc56b976d816..52369ef39b03 100644 >> --- a/drivers/char/tpm/tpm_tis_core.c >> +++ b/drivers/char/tpm/tpm_tis_core.c >> @@ -747,8 +747,19 @@ static int tpm_tis_probe_irq_single(struct tpm_chi= p *chip, u32 intmask, >> int rc; >> u32 int_status; >> >> - if (devm_request_irq(chip->dev.parent, irq, tis_int_handler, flags, >> - dev_name(&chip->dev), chip) !=3D 0) { >> + >> + if (priv->flags & TPM_TIS_USE_THREADED_IRQ) { >> + rc =3D devm_request_threaded_irq(chip->dev.parent, irq, NULL, >> + tis_int_handler, >> + IRQF_ONESHOT | flags, >> + dev_name(&chip->dev), >> + chip); >> + } else { >> + rc =3D devm_request_irq(chip->dev.parent, irq, tis_int_handler, >> + flags, dev_name(&chip->dev), chip); >> + } >> + >> + if (rc) { >> dev_info(&chip->dev, "Unable to request irq: %d for probe\n", >> irq); >> return -1; >> diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis= _core.h >> index 3be24f221e32..43b724e55192 100644 >> --- a/drivers/char/tpm/tpm_tis_core.h >> +++ b/drivers/char/tpm/tpm_tis_core.h >> @@ -86,6 +86,7 @@ enum tis_defaults { >> enum tpm_tis_flags { >> TPM_TIS_ITPM_WORKAROUND =3D BIT(0), >> TPM_TIS_INVALID_STATUS =3D BIT(1), >> + TPM_TIS_USE_THREADED_IRQ =3D BIT(2), >> }; >> >> struct tpm_tis_data { >> diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm= _tis_spi_main.c >> index 184396b3af50..f56613f2946f 100644 >> --- a/drivers/char/tpm/tpm_tis_spi_main.c >> +++ b/drivers/char/tpm/tpm_tis_spi_main.c >> @@ -223,9 +223,10 @@ static int tpm_tis_spi_probe(struct spi_device *de= v) >> phy->flow_control =3D tpm_tis_spi_flow_control; >> >> /* If the SPI device has an IRQ then use that */ >> - if (dev->irq > 0) >> + if (dev->irq > 0) { >> irq =3D dev->irq; >> - else >> + phy->priv.flags |=3D TPM_TIS_USE_THREADED_IRQ; >> + } else >> irq =3D -1; >> >> init_completion(&phy->ready); >> -- >> 2.36.0 >> > > > BR, Jarkko >