linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lino Sanfilippo <LinoSanfilippo@gmx.de>
To: Jarkko Sakkinen <jarkko@kernel.org>
Cc: peterhuewe@gmx.de, jgg@ziepe.ca, stefanb@linux.vnet.ibm.com,
	James.Bottomley@hansenpartnership.com, keescook@chromium.org,
	jsnitsel@redhat.com, ml.linux@elloe.vision,
	linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/4] tpm: Use a threaded interrupt handler
Date: Thu, 29 Apr 2021 00:37:40 +0200	[thread overview]
Message-ID: <495e816a-afba-4ea0-560c-bc748df26337@gmx.de> (raw)
In-Reply-To: <YIikDCTBcMMxjots@kernel.org>


Hi,

On 28.04.21 at 01:53, Jarkko Sakkinen wrote:
> On Mon, Apr 26, 2021 at 01:47:17AM +0200, Lino Sanfilippo wrote:
>> Interrupt handling at least includes reading and writing the interrupt
>> status register from the interrupt routine. However over SPI those accesses
>> require a sleepable context, since a mutex is used in the concerning
>> functions.
>> For this reason request a threaded interrupt handler which is running in
>> (sleepable) process context.
>>
>> Signed-off-by: Lino Sanfilippo <LinoSanfilippo@gmx.de>
>> ---
>>  drivers/char/tpm/tpm_tis_core.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
>> index e7d1eab..0959559 100644
>> --- a/drivers/char/tpm/tpm_tis_core.c
>> +++ b/drivers/char/tpm/tpm_tis_core.c
>> @@ -781,8 +781,10 @@ 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 (devm_request_threaded_irq(chip->dev.parent, irq, NULL,
>> +				      tis_int_handler, IRQF_ONESHOT | flags,
>> +				      dev_name(&chip->dev), chip) != 0) {
>>  		dev_info(&chip->dev, "Unable to request irq: %d for probe\n",
>>  			 irq);
>>  		return -1;
>> --
>> 2.7.4
>>
>
> Why?
>
> https://elixir.bootlin.com/linux/v5.12/source/drivers/char/tpm/tpm_tis_core.c#L670
>
> I don't see anything that sleeps there.
>
> /Jarkko1
>

The problem are the register read/write functions which we use to access the status register in
the interrupt handler. In case of SPI they result in taking the spi_bus_lock which is a mutex.

E.g tpm_tis_spi_read32: tpm_tis_spi_read_bytes->tpm_tis_spi_transfer->spi_bus_lock->mutex_lock

Using a threaded interrupt handler seemed to me the easiest way to avoid this issue.

Regards,
Lino



  reply	other threads:[~2021-04-28 22:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-25 23:47 [PATCH v2 0/4] Fixes for TPM interrupt handling Lino Sanfilippo
2021-04-25 23:47 ` [PATCH v2 1/4] tpm: Use a threaded interrupt handler Lino Sanfilippo
2021-04-26 14:37   ` Stefan Berger
2021-04-27 23:53   ` Jarkko Sakkinen
2021-04-28 22:37     ` Lino Sanfilippo [this message]
2021-04-29  6:58       ` Jarkko Sakkinen
2021-05-01  9:01         ` Lino Sanfilippo
2021-04-25 23:47 ` [PATCH v2 2/4] tpm: Simplify locality handling Lino Sanfilippo
2021-04-27 23:49   ` Jarkko Sakkinen
2021-04-28  7:13     ` Peter.Huewe
2021-04-28 22:44     ` Lino Sanfilippo
2021-04-25 23:47 ` [PATCH v2 3/4] tpm: Fix test for interrupts Lino Sanfilippo
2021-04-26 14:49   ` Stefan Berger
2021-04-28 22:13     ` Lino Sanfilippo
2021-04-25 23:47 ` [PATCH v2 4/4] tpm: Only enable supported irqs Lino Sanfilippo
2021-04-26  5:08   ` kernel test robot
2021-04-26 14:23   ` Stefan Berger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=495e816a-afba-4ea0-560c-bc748df26337@gmx.de \
    --to=linosanfilippo@gmx.de \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=jsnitsel@redhat.com \
    --cc=keescook@chromium.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ml.linux@elloe.vision \
    --cc=peterhuewe@gmx.de \
    --cc=stefanb@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).