From patchwork Mon May 9 08:05:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12843170 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D00B7C4167B for ; Mon, 9 May 2022 08:44:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237081AbiEIIq1 (ORCPT ); Mon, 9 May 2022 04:46:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235757AbiEIIOx (ORCPT ); Mon, 9 May 2022 04:14:53 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3842130C5B; Mon, 9 May 2022 01:10:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1652083626; bh=y3wkeJ7ZYRxjhV+SmNN+0jvODpsGU4EpwvD7/wY3xLY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=JwAQrkge+fYwTqZgi96aUV3rd1GrvJ6hobZrcDdBGezzjV1JV2jx/G+lVOKfea2YO LjlkkZZKHwauOsp/4vOP97upxsEQO2/2y9zRfWy8xAy0ahKEIncJHgQHKe88hJv9ev f8jfz31p2sLCzRgqWB55ETHxN33aXKFPa+OkSDxc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([46.223.3.89]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MF3HU-1nYcL33stc-00FUCT; Mon, 09 May 2022 10:07:06 +0200 From: Lino Sanfilippo To: peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca Cc: stefanb@linux.vnet.ibm.com, linux@mniewoehner.de, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo Subject: [PATCH v4 1/6] tpm, tpm_tis_spi: Request threaded irq Date: Mon, 9 May 2022 10:05:54 +0200 Message-Id: <20220509080559.4381-2-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220509080559.4381-1-LinoSanfilippo@gmx.de> References: <20220509080559.4381-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:VEe9AQBEptDU/mhnL5y7j/e8z2rQQDtj6jhRmqTdV+HuixTmL63 9rK++fzpomo40G4KKg3h0Nqk99a925rN3ikK7h5TL+0/qaV1KfltA42T6nh+MWAtJmF9oar 4miIyP4VTLgn6Jxj6thQiLyZ/ZtvUhTpMk8xjO9ZVT+94/vGPqug/xi0g9f1kZ3up9qsPZ+ nshBxZycf9c11gvVlJM1Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:RD6S0MjoskY=:V1yn4RcqaWhPTh5QOMXWZv y8IguvIC2ztdh2IpQJxoyvQiFc7JoVd5/wKo+BoFzOmboF/abX5yw11PRi8PhVIcveQcopGD0 vY1ZKhmry02BixB0bH92yleD32xupfOM6oO0/kiO7XU6D8GCXfHc/TWZ+Ncsgz1bwMy//Gfuf ucAkAaBlAw522e4zwnpSR+iPD/Csk3jJA25kRjhbtehXggZ7qwGklnwPXEkZN5Lfo3fVeLWqc lfqoVkJwrND/1XnGkyHhKaJI2aeP+PCuHTwqqjs/NFC3i9wdBHksFdjbzlQicwnyR5sZUl2vh dWkxO7fKx29A3D9vf79yyTB7cRm4lIMsvvkR261mESN8h4BQOW2jSgkCeZrjbniSQNp/FN7ir xSyP7xiDRtf5HkYhoGmeXa03FKk7HHUdExVMSTCxVXcxe0AIiBjgJUzhE/VpSxh2zWdHRxzqw n6PMft+NkRWWCVEWyP6Rc1XTryrrZjZAAHKpZpRvSVDc3PWLoYG/pFUvjLl8xsYe3vRQYHTm3 SAk05jmthyTEBT4i7y34GweQpNeMTLcLTpAyvjvOGneBJLvKzFO+Moet1x7ghteMXGfGuXHGN NcwTgF1RSeEXCSmvPrl5DglNQBo4D9x5DyH0MAnzFvTwNgnulBb2wEOrDkV2mGQCqA457jtlU FQNkeFqWScZSOALYM0pwdO5TIuGB692MXIn/cYM1qvzhS7MT9q+pXyNyQfwF5DgteUrcqHXXO QaKy7LDEIpMnEGCyU2OiVbXzK8UkYaH0qPQFD+e+226lxEvxXwChbYvb0Dzq1x83bv7G45247 V3GmOyRnIpOcFO8T1s87vbx37sUK4EezEQZLwD2ZMoIRa/9LaUivk7v/vvq24vrfwYAfWoR9u 3uiHUGQFgHn6u1F+ILk3JMyYj81c9kGg2Bw9wd4Wn/ZOzy4GHy/Zo/A7ydBeDZ4J+cyQ/b+bQ tTcK4DCg5TcARGsg+MIbIGvXFgtTIAVZbDwyT/+G7IZLsduiWIspBTBKElKsuyUokGlEM/DFy G1VUq6XhydKhQM7L4b81s6hWJ3zgRk6K9hF69lu9cpQyrpZJ7Coyoz6JCYohurF+M3YaOxlcY M7kRElkorBTw+k= Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org From: Lino Sanfilippo Interrupt handling at least includes reading and writing the interrupt status register within the interrupt routine. Since accesses over the SPI bus are synchronized by a mutex, request a threaded interrupt handler to 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 --- 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_chip *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) != 0) { + + if (priv->flags & TPM_TIS_USE_THREADED_IRQ) { + rc = devm_request_threaded_irq(chip->dev.parent, irq, NULL, + tis_int_handler, + IRQF_ONESHOT | flags, + dev_name(&chip->dev), + chip); + } else { + rc = 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 = BIT(0), TPM_TIS_INVALID_STATUS = BIT(1), + TPM_TIS_USE_THREADED_IRQ = 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 *dev) phy->flow_control = tpm_tis_spi_flow_control; /* If the SPI device has an IRQ then use that */ - if (dev->irq > 0) + if (dev->irq > 0) { irq = dev->irq; - else + phy->priv.flags |= TPM_TIS_USE_THREADED_IRQ; + } else irq = -1; init_completion(&phy->ready);