Re: [PATCH] tpm: tpm_tis_spi: Use wait_woken() in wait_for_tmp_stat()

2026-05-15 Thread Jarkko Sakkinen
On Mon, May 11, 2026 at 10:10:21AM +0200, Linus Walleij wrote:
> On Sat, May 9, 2026 at 8:51 PM Jarkko Sakkinen  wrote:
> 
> > wait_event_interruptible_timeout() evaluates its condition after setting
> > the current task state to TASK_INTERRUPTIBLE.
> >
> > With CONFIG_DEBUG_ATOMIC_SLEEP this triggers a warning when the IRQ wait
> > path is used:
> >
> > tpm_tis_status()
> >   tpm_tis_spi_read_bytes()
> > tpm_tis_spi_transfer_full()
> >   spi_bus_lock()
> > mutex_lock()
> >
> > Address this with the following measures:
> >
> > 1. Call wait_tpm_stat_cond() only while tasking is running.
> > 2. Use wait_woken() to wait for changes.
> >
> > Cc: [email protected] # v4.19+
> > Cc: Linus Walleij 
> > Reported-by: Stefan Wahren 
> > Closes: 
> > https://lore.kernel.org/linux-integrity/[email protected]/
> > Fixes: 1a339b658d9d ("tpm_tis_spi: Pass the SPI IRQ down to the driver")
> > Signed-off-by: Jarkko Sakkinen 
> > ---
> > Linus' change only unmasked a pre-existing bug but it is the change
> > realizes it in tpm_tis_spi.
> 
> Took me a while to understand this but looks right to me!
> Reviewed-by: Linus Walleij 

Thank you.

> 
> Yours,
> Linus Walleij

BR, Jarkko



Re: [PATCH] tpm: tpm_tis_spi: Use wait_woken() in wait_for_tmp_stat()

2026-05-15 Thread Jarkko Sakkinen
On Sun, May 10, 2026 at 10:45:52PM +0200, Stefan Wahren wrote:
> Am 09.05.26 um 20:51 schrieb Jarkko Sakkinen:
> > wait_event_interruptible_timeout() evaluates its condition after setting
> > the current task state to TASK_INTERRUPTIBLE.
> > 
> > With CONFIG_DEBUG_ATOMIC_SLEEP this triggers a warning when the IRQ wait
> > path is used:
> > 
> >  tpm_tis_status()
> >tpm_tis_spi_read_bytes()
> >  tpm_tis_spi_transfer_full()
> >spi_bus_lock()
> >  mutex_lock()
> > 
> > Address this with the following measures:
> > 
> > 1. Call wait_tpm_stat_cond() only while tasking is running.
> > 2. Use wait_woken() to wait for changes.
> > 
> > Cc: [email protected] # v4.19+
> > Cc: Linus Walleij 
> > Reported-by: Stefan Wahren 
> > Closes: 
> > https://lore.kernel.org/linux-integrity/[email protected]/
> > Fixes: 1a339b658d9d ("tpm_tis_spi: Pass the SPI IRQ down to the driver")
> > Signed-off-by: Jarkko Sakkinen 
> > 
> The issue isn't reproducible anymore. Thanks
> 
> Tested-by: Stefan Wahren 

Thank you.

BR, Jarkko



Re: [PATCH] tpm: tpm_tis_spi: Use wait_woken() in wait_for_tmp_stat()

2026-05-11 Thread Linus Walleij
On Sat, May 9, 2026 at 8:51 PM Jarkko Sakkinen  wrote:

> wait_event_interruptible_timeout() evaluates its condition after setting
> the current task state to TASK_INTERRUPTIBLE.
>
> With CONFIG_DEBUG_ATOMIC_SLEEP this triggers a warning when the IRQ wait
> path is used:
>
> tpm_tis_status()
>   tpm_tis_spi_read_bytes()
> tpm_tis_spi_transfer_full()
>   spi_bus_lock()
> mutex_lock()
>
> Address this with the following measures:
>
> 1. Call wait_tpm_stat_cond() only while tasking is running.
> 2. Use wait_woken() to wait for changes.
>
> Cc: [email protected] # v4.19+
> Cc: Linus Walleij 
> Reported-by: Stefan Wahren 
> Closes: 
> https://lore.kernel.org/linux-integrity/[email protected]/
> Fixes: 1a339b658d9d ("tpm_tis_spi: Pass the SPI IRQ down to the driver")
> Signed-off-by: Jarkko Sakkinen 
> ---
> Linus' change only unmasked a pre-existing bug but it is the change
> realizes it in tpm_tis_spi.

Took me a while to understand this but looks right to me!
Reviewed-by: Linus Walleij 

Yours,
Linus Walleij



Re: [PATCH] tpm: tpm_tis_spi: Use wait_woken() in wait_for_tmp_stat()

2026-05-10 Thread Stefan Wahren

Am 09.05.26 um 20:51 schrieb Jarkko Sakkinen:

wait_event_interruptible_timeout() evaluates its condition after setting
the current task state to TASK_INTERRUPTIBLE.

With CONFIG_DEBUG_ATOMIC_SLEEP this triggers a warning when the IRQ wait
path is used:

 tpm_tis_status()
   tpm_tis_spi_read_bytes()
 tpm_tis_spi_transfer_full()
   spi_bus_lock()
 mutex_lock()

Address this with the following measures:

1. Call wait_tpm_stat_cond() only while tasking is running.
2. Use wait_woken() to wait for changes.

Cc: [email protected] # v4.19+
Cc: Linus Walleij 
Reported-by: Stefan Wahren 
Closes: 
https://lore.kernel.org/linux-integrity/[email protected]/
Fixes: 1a339b658d9d ("tpm_tis_spi: Pass the SPI IRQ down to the driver")
Signed-off-by: Jarkko Sakkinen 


The issue isn't reproducible anymore. Thanks

Tested-by: Stefan Wahren