Quoting Herbert Xu (2019-06-24 07:26:54) > On Thu, Jun 20, 2019 at 06:03:17PM -0700, Stephen Boyd wrote: > > > > What do you think of the attached patch? I haven't tested it, but it > > would make sure that the kthread is frozen so that the hardware can be > > resumed before the kthread is thawed and tries to go touch the hardware. > > Looks good to me. > Thanks for checking. I haven't been able to reproduce the problem yet to confirm this is actually fixing anything, even after tweaking the sysctl values for khwrng to try and force the thread to run continuously. >From reading the bug report that caused this 'is_suspended' code to be added to the driver I'm fairly convinced this is the right solution. To give some more background, it looks like we use s2idle suspend (i.e. all CPUs are idle across suspend) and then we have the kthread running to ask the hardware for some more random numbers. The i2c transaction fails when asking the hwrng for data, and we see these messages printed on the resume path: i2c_designware i2c_designware.2: i2c_dw_handle_tx_abort: lost arbitration tpm tpm0: i2c transfer failed (attempt 3/3): -11 tpm0: tpm_transmit: tpm_send: error -11 hwrng: no data available Userspace tasks are thawed after this failure so it looks like something in the kernel kicks khwrng to grab more data before the i2c bus can be resumed.