Re: [REGRESSION] suspend to ram fails in 6.2-rc1 due to tpm errors

From: Jarkko Sakkinen
Date: Wed Apr 26 2023 - 12:07:11 EST


On Wed Apr 26, 2023 at 4:32 AM EEST, Jason A. Donenfeld wrote:
> Nice work! Happy that you got it figured out. That trace seems
> consistent with what I was seeing in my traces, so I think you've
> spotted the right bug.
>
> Jason

Unfortunately there might be two bugs. Unless I interpreted logs
incorrectly also hwrng can race with resume (sorry, I forgot to
save it).

Looking at drivers/char/hw_random/core.c there seems to be no
binding to the PM so I guess that this it supports what I'm
observing [*].

So there's two ways to fix the issue:

1. Unregister hwrng for the course of suspend
2. Add something like TPM_CHIP_SUSPENDED, which is set by suspend and
cleared by the resume.

I try the 2nd option first because I see it less complicated.
Probably would make sense to turn chip flags as atomic while
at it.

[*] https://elixir.bootlin.com/linux/latest/source/drivers/char/hw_random/core.c

BR, Jarkko