From patchwork Mon Oct 17 23:57:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 13009716 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 7C51CC433FE for ; Mon, 17 Oct 2022 23:58:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230120AbiJQX6O (ORCPT ); Mon, 17 Oct 2022 19:58:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229980AbiJQX6N (ORCPT ); Mon, 17 Oct 2022 19:58:13 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ADCD7E326; Mon, 17 Oct 2022 16:58:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1666051073; bh=KEA4wfis+vvcc4jeyKKQbKPArLj4tacnaogTuqRwocY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=VwkBy4qkAUamg/cyvpBu4RBbcyHXsIMZLp7MfHllM7E/XccXueflc0KjvJ7EvZURp C+1rcjVyhXtahFUyUcPbPmqXAAaK5Acfja85PmEseyHSzxQlZkXv45M9B6sx7kdLU4 Naz4aS8vvlQDja1ZUzZXiZWmmmMhPMMbOq78UlyU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.speedport.ip ([84.162.5.241]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N33ET-1p79Se1OIv-013NRz; Tue, 18 Oct 2022 01:57:53 +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, jandryuk@gmail.com, pmenzel@molgen.mpg.de, l.sanfilippo@kunbus.com, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com Subject: [PATCH v8 09/11] tpm, tpm_tis: Request threaded interrupt handler Date: Tue, 18 Oct 2022 01:57:30 +0200 Message-Id: <20221017235732.10145-10-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221017235732.10145-1-LinoSanfilippo@gmx.de> References: <20221017235732.10145-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:dIa9SZQTn6cWmM3h4lHDimeagtlxOyrDcI1LJ7rggPeOZ74g5CN oYk73lhX/30vNw/cn58H4fIerri4GH3ig0PE//0dzyzOxoTjOA6G1UxUSxq6V/rXDlXpyKY 9dNvexRXEScfOqcqJi9ZK3sAxs47CWUHQqUaa5YORsFHEPEq3/UI4gNTxfzTJFmB8Bo6mCl IQoX9wvsPKJEva/V76W/A== X-UI-Out-Filterresults: notjunk:1;V03:K0:qLWQza80+UM=:D8V6UTfb5HsVEY+PZLCnrS 6nxKEdsyN0TKelnMq3tzaUZs3ARqcFwxfgxkE85CeeR1m19VMQOOtgEtRV8KK84iClJHy4Qx9 QgF+nhXdjFqSj+2jslagWZrlv8pXPPAjUx2WflHiPyFoG9W7cnoJX7Uzbu1kJcuY176YXNMsy cq42t5u6EjwYBXDU5Vb5SuKLmPf3PAbu8/VeaE9hDYWVuYml4HLfcW0FnmYHxhLoMGN5eRxNe TQkUgooLH9MCceTGr4dwXAT9oRtyfwl3BQxIVczYOKEPFboZsqR6as0i5Ill7s5MotDDuX18/ OuGN4FR0hkIGDE9SsLbM0ewWvVJCol+MiogzWBs+PCl1zwnAJD3tS1bq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HAP+qAWcNk9BA5n3fzQALxvKOPcraL0YXcG5Y maV9FO8LUs4qeHqpgoIkXuJDj947YlzFvfh2v2mXljMc1/A8JtrGR0o/mCnbRQTJ+dnrvgutx TpEemKqb96ChCEkNofbO0yUou/5pXtd6yGl5dps/3ErQg 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 79dfab65976f..1e065e7ac460 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -813,8 +813,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;