On Thu, Dec 29, 2022 at 05:03:44AM +0100, Jason A. Donenfeld wrote: > I recall seeing something pretty similar to this report with the > selftest as well. Basically, the call to tpm1_do_selftest can race with > the call to tpm1_get_random, presumably because tpm1_get_random doesn't > do any locking on its own. So it might be a good idea to make sure that > tpm1_get_random() isn't running before tpm1_do_selftest() or any other > TPM commands run. The other locking angle is that tpm1_pm_suspend() should wait for tpm1_get_random() to finish or cancel tpm1_get_random(), if that's not already happening. IIRC, the selftest gets tripped up when it's triggered on resume due to an already in-flight tpm1_get_random() from prior to sleep, that never completed.