From patchwork Thu Nov 24 13:55:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 13055011 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 0A635C47088 for ; Thu, 24 Nov 2022 13:56:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230155AbiKXN4k (ORCPT ); Thu, 24 Nov 2022 08:56:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230079AbiKXN4d (ORCPT ); Thu, 24 Nov 2022 08:56:33 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F22ED100B3E; Thu, 24 Nov 2022 05:56:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1669298173; bh=vnp21/mfPoqtAE/9hipMWqTIgnCW9bDnAe+K+uHJwrI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=LvEQYqwKKJlb5S4pUaX7RxL3noLuSJv1rRgUqNElsH5Cj44g9xXImgXuGiSPYNajp LoyxrJhhJ9LhlZ6AbdES/IB23dtxOMoPZnb4Sca0xWatzN7V0cClfoXv4qIJQsFwTz gd/j++4x6FZRihrfjkrruMbIdBHTrYKUl/Que9sCIazI00gRfqhHTBRebUlb7HJoDN gazlUgsJPGsHe3NfvvJ1+ILK1Q3ssp0zFMYiylySFkF8GFZJLpLTI/tV4M6pqEnVcb VCNiPtIZg6rUFdXCp1e74MeAsCB0B48FW3SXfHWuUe+2GKLeUuTEddvoS/kvQZPIO4 x5+G8YSkK+0Rw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from Venus.speedport.ip ([84.162.7.17]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MxUnz-1p8zDw1j8z-00xvZB; Thu, 24 Nov 2022 14:56:13 +0100 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, jandryuk@gmail.com, pmenzel@molgen.mpg.de, l.sanfilippo@kunbus.com, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com Subject: [PATCH v11 10/14] tpm, tpm_tis: Request threaded interrupt handler Date: Thu, 24 Nov 2022 14:55:34 +0100 Message-Id: <20221124135538.31020-11-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221124135538.31020-1-LinoSanfilippo@gmx.de> References: <20221124135538.31020-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:FpAKGsitxv+CMneiAfduiO2RrZijFQTQp+bMXElnc3uL6bI8p7F zTshYoLZPrT8axM3jWbcpMLVq9mDHDdAM3tEq1uBH7XummJ8qw+y0+qVRCRfiBBWWjPfPKR HxVBk5dWcGeX13WUf5W/H/MUSLp/5/IiDTX7Aojuz0RmODZhawY2YNzTV92vhwoK7k4mYYw I6ycvYQPwupnhA3TxH/4Q== UI-OutboundReport: notjunk:1;M01:P0:LNScq3ME++Q=;BKzLYTTefHVMCZH5KtkD/2MYx2g yEEGIXB0VrNAzG1MPNtuPEad1NpHbQnDBhREjjp2/F+WkVba7j3fnsy5VBRpIJH4wJ+85Kl4P w3YeiiTuCcv1C2PWe0jYoCbyq8Sc2jpJB48ohmPZAtcopjolLQy6NhIHFx+ZLWqSfBLzDI1cC U2lRinQ6QHVwAk5j9UEPsZ1DZ3oi755kiFg8cIc1qCjKvVdwVuNb/LPBY0ESyqDyzuezG90y1 wQKIBFR7v11f69N2jVBKyjm+Fyjt8Z9irgLHT5YA8Edflc9jEU8gf4XlZAyYRiJjBIROl5si/ rKZT1XI8wypgy4T6eWIB3EzKcLPqGvJJaIcLPB7xXbfKbXV8h1PpJzG+nRuhS2lHqAAjpB0Bm YL3Jl+dFIHYSqqjAlyuqVpGmgR8OY7UR3OtUuCmU9HoUYyzSaiPLtAvwUCInmXuQqFEep/6QW rlZOHn1eWdulQ3cYXq/99ZEptGZP44GnSBgo10kfT743jbVJGseynRiPgg0ULyS1fiItL3OJE SVXyBr1dosQpVdJ+JZzaNzYsWsEx5Y2w1oRTBrM0hljT8aLkF3ZSDmF2sbwZj00je7CVFXg4Z KB8KQYCpM4cXiX9cVlpCtEv4cQwcX0rlcOwHfJdaGIICsf30pTVN6PiQo8DNxROccjN297fMo L3EXLpEP/IclWwfi/wCSySfN3Ogn4nxD5aekud0T89sl45LR2CJT5iGY2etExs6KdQRCtPseO wg4hpy7Jo6jp7vQPlK763YN8d4GRcgInN2xb/2D4+0FzaETFqjJAHKX8qvCifjEJAd6HARFyy lUUhJsekePLsi19qReLqJePnVSCah0YyulLyC7axAhMQgtsBLML7ah1bcH5LeG2E5R7Hd6CCE vn75t6E8BowE7vcJGB9IT0Zru91gag8mt3KduLDx/X1WveZIiNnVhcjHNdQhOfl/aRQ60R47Z jxc/+A== Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org From: Lino Sanfilippo The TIS interrupt handler at least has to read and write the interrupt status register. In case of SPI both operations result in a call to tpm_tis_spi_transfer() which uses the bus_lock_mutex of the spi device and thus must only be called from a sleepable context. To ensure this request a threaded interrupt handler. Signed-off-by: Lino Sanfilippo Tested-by: Michael Niewöhner Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_tis_core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index f00f1057fd27..3891499f9877 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -805,8 +805,11 @@ 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) { + + rc = devm_request_threaded_irq(chip->dev.parent, irq, NULL, + tis_int_handler, IRQF_ONESHOT | flags, + dev_name(&chip->dev), chip); + if (rc) { dev_info(&chip->dev, "Unable to request irq: %d for probe\n", irq); return -1;