Created attachment 265477 [details] dmesg I've upgraded my CURRENT laptop to 82d8a5029a80 and noticed it couldn't resume from suspend anymore. After discussing it on mailing lists and bisecting changes between previous version I figured out that RANDOM_ENABLE_TPM kernel option is the culprit. Removing it from kernel makes the system to work as expected. FreeBSD e14 16.0-CURRENT FreeBSD 16.0-CURRENT #43 main-n281906-82d8a5029a80-dirty: Mon Nov 17 14:50:55 -03 2025 root@e14:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG amd64
*** Bug 291085 has been marked as a duplicate of this bug. ***
Could you test this patch? https://reviews.freebsd.org/D53835
Please note that a system without TPM 2.0 cannot enter S3 sleep state. Please note also that building a kernel with "nooptions RANDOM_ENABLE_TPM" doesn't solve the issue for this system. Is the patch proposed in review D53835 also fix these issues, and will the hardware with TPM 1.2 be able to enter sleep state?
(In reply to Mark Johnston from comment #2) It didn't work and system still crashes after resuming
I have also tested it, and the affected system is still unable to fully enter the sleep S3 state.
(In reply to Renato Botelho from comment #4) That's a bit surprising. Can you try the latest revision? If that doesn't work, I'm not sure where the problem is. (In reply to Marek Zarychta from comment #3) Does the problem go away if you remove "device tpm" from the kernel config?
(In reply to Mark Johnston from comment #6) >Does the problem go away if you remove "device tpm" from the kernel config? Yes, removing "device tpm" solves the problem. It took me some time yesterday to find the problematic commit range, so I wasn't able to investigate its content. Thank you for the solution, and yes, the TPM device, even when loaded as a module, was always breaking suspend on this machine.
(In reply to Mark Johnston from comment #6) I think my patch is indeed not sufficient, we are missing some tpm start command in tpm20_resume().
(In reply to Mark Johnston from comment #8) Latest version works fine. Thanks!
(In reply to Mark Johnston from comment #8) Nevermind my previous command. After applying most recent version of that patch, system is able to resume, but after that I can't halt it. I ran `halt -p` and it hangs there forever. If I boot and do not suspend it I can halt it without any trouble.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=16f8ea6a81b59a82d8c27c6b3aa380617485bfd2 commit 16f8ea6a81b59a82d8c27c6b3aa380617485bfd2 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2026-01-08 14:54:15 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2026-01-08 14:54:15 +0000 amd64: Remove tpm(4) from GENERIC for now It breaks suspend/resume and no one has had time to investigate and fix it. PR: 291067 Reviewed by: emaste Fixes: 3deb21f1afd5 ("random: TPM_HARVEST should have been named RANDOM_ENABLE_TPM") Differential Revision: https://reviews.freebsd.org/D54587 sys/amd64/conf/GENERIC | 3 ++- sys/amd64/conf/MINIMAL | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
I will leave the bug report open until the underlying problem is fixed.
(In reply to Renato Botelho from comment #10) Can you re-add tpm to your kernel (or load the module, I suppose) and test with https://reviews.freebsd.org/D55074, please?
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=38a4995eb52db21116f8b37ed942e66a8c2f050f commit 38a4995eb52db21116f8b37ed942e66a8c2f050f Author: Kyle Evans <kevans@FreeBSD.org> AuthorDate: 2026-02-05 03:35:01 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2026-02-05 03:35:10 +0000 tpm20: fix suspend/resume and entropy harvesting There were a few problem here: - TPM2_Shutdown results in a response that we need to either process or ignore, otherwise any tpm20_write or tpm20_harvest call will trivially hang on an `sc->pending_data_length != 0` - We should have a matching TPM2_Startup upon resume to restore any state that should have persisted - We must drain the harvest task before we suspend to avoid problems there This commit is sufficient to avoid breaking suspend/resume. PR: 291067 Fixes: a2d5ed9442bb ("Introduce driver for TPM 2.0 in CRB and [...]") Fixes: 4ee7d3b0118c ("Allow using TPM as entropy source.") Co-authored-by: markj (D53835) Tested by: garga Differential Revision: https://reviews.freebsd.org/D55074 sys/dev/tpm/tpm20.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++ sys/dev/tpm/tpm20.h | 1 + sys/dev/tpm/tpm_crb.c | 1 + sys/dev/tpm/tpm_tis_core.c | 1 + 4 files changed, 68 insertions(+)
This is actually an older bug and I don't see a reason not to fix tpm.ko on older branches.
Are there any plans to remove or fix TPM 1.2 ? It's also incompatible with suspend/resume and Giant locked[1]. So really, it's a useless device driver in its current state. [1]:WARNING: Device "tpm" is Giant locked and may be deleted before FreeBSD 16.0.
(In reply to Marek Zarychta from comment #16) *glances around for a tpm maintainer* I guess no plans anywhere around there, but if I could find a way to test it I'd be willing to take a look.
(In reply to Kyle Evans from comment #17) That's good news. Please let me know if I can help you with anything.
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=21fcae1958672a08726d20a95baaf91940511faa commit 21fcae1958672a08726d20a95baaf91940511faa Author: Kyle Evans <kevans@FreeBSD.org> AuthorDate: 2026-02-05 03:35:01 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2026-04-12 03:15:13 +0000 tpm20: fix suspend/resume and entropy harvesting There were a few problem here: - TPM2_Shutdown results in a response that we need to either process or ignore, otherwise any tpm20_write or tpm20_harvest call will trivially hang on an `sc->pending_data_length != 0` - We should have a matching TPM2_Startup upon resume to restore any state that should have persisted - We must drain the harvest task before we suspend to avoid problems there This commit is sufficient to avoid breaking suspend/resume. PR: 291067 Co-authored-by: markj Tested by: garga (cherry picked from commit 38a4995eb52db21116f8b37ed942e66a8c2f050f) sys/dev/tpm/tpm20.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++ sys/dev/tpm/tpm20.h | 1 + sys/dev/tpm/tpm_crb.c | 1 + sys/dev/tpm/tpm_tis_core.c | 1 + 4 files changed, 68 insertions(+)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=c0356f4cd02255419a4d4309f393998185c8de2d commit c0356f4cd02255419a4d4309f393998185c8de2d Author: Kevin Bowling <kbowling@FreeBSD.org> AuthorDate: 2026-08-26 10:32:34 +0000 Commit: Kevin Bowling <kbowling@FreeBSD.org> CommitDate: 2026-09-01 18:17:58 +0000 tpm: Correct the TPM 1.2 suspend transaction The legacy driver wrote TPM_ORD_SaveState directly to the command FIFO, but used ordinal 156 instead of the TPM 1.2 ordinal 152 and never completed the transaction through the transport start and end methods. On a TIS device this omitted TPM_STS_GO, and the response read used the header length as flags instead of requesting the complete parameter size. The legacy Atmel reader would also dereference the null byte-count pointer. Send the header-only command through the normal transport lifecycle, validate the response header and TPM result, and retry TPM_WARN_RETRY for a bounded five seconds. Fail suspend rather than enter S3 after an unsuccessful state save. This follows the TPM 1.2 SaveState command definition and the bounded retry policy used by other TPM 1.2 implementations. The stock driver failed to resume a ThinkPad T440p with its STMicro TPM 1.2 Security Chip enabled; disabling the chip made S3 reliable. With this change and the following TIS resume restoration, the enabled TPM completed two consecutive S3 cycles. PCR 0 was readable with the same value before and after each cycle, and no TPM errors were logged. PR: 291067 Reviewed by: kevans MFC after: 2 weeks Sponsored by: BBOX.io Differential Revision: https://reviews.freebsd.org/D59192 sys/dev/tpm/tpm.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 80 insertions(+), 13 deletions(-)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=96ed6005082fc63d633408ba3ad697e8757e80f9 commit 96ed6005082fc63d633408ba3ad697e8757e80f9 Author: Kevin Bowling <kbowling@FreeBSD.org> AuthorDate: 2026-08-26 10:33:38 +0000 Commit: Kevin Bowling <kbowling@FreeBSD.org> CommitDate: 2026-09-01 18:19:50 +0000 tpm: Restore TPM 1.2 TIS state after resume Firmware restores the state saved by TPM_ORD_SaveState, but the TIS interrupt, locality, and command FIFO state are not guaranteed to survive S3. The legacy driver previously treated resume as a no-op. Revalidate the interface and device identity, disable and acknowledge stale interrupts, restore the configured interrupt vector, reacquire locality zero, and return the FIFO to command-ready state. Also disable TIS interrupts during initial setup when the device uses polling so firmware settings cannot leave an unhandled interrupt enabled. TIS 1.3 Table 22 makes the interrupt control registers locality protected. Acquire locality before disabling or programming them during initial setup and resume rather than relying on probe retaining locality. Keep TPM self-test outside the resume critical path. It can take minutes on some TPM 1.2 devices and is not required to restore the transport state. The two-commit suspend and resume series completed two consecutive S3 cycles on a ThinkPad T440p with its STMicro TPM 1.2 Security Chip enabled. PCR 0 was readable with the same value before and after each cycle, and no SaveState or TIS restoration errors were logged. The locality ordering completed another two consecutive S3 cycles on a ThinkPad T430 with the same STMicro TPM in polling mode. PCR 0 again remained stable, and TPM access recovered without errors after each resume. PR: 291067 Reviewed by: kevans Sponsored by: BBOX.io MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D59193 sys/dev/tpm/tpm.c | 91 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 70 insertions(+), 21 deletions(-)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=cb2964f840e873d03a0739f41eed5921922f93a0 commit cb2964f840e873d03a0739f41eed5921922f93a0 Author: Kevin Bowling <kbowling@FreeBSD.org> AuthorDate: 2026-08-28 00:14:02 +0000 Commit: Kevin Bowling <kbowling@FreeBSD.org> CommitDate: 2026-09-12 22:01:32 +0000 amd64, powerpc: Enable tpm(4) in supported kernels tpm(4) was removed from amd64 GENERIC because it broke suspend and resume. The preceding lifecycle, state-save, interrupt, locality, and teardown fixes address those failures for both TPM 1.2 and TPM 2.0. Restore the driver to amd64 GENERIC and MINIMAL, where TPM entropy harvesting remained enabled. Enable the driver and entropy harvesting in the MPC85XX and QORIQ64 configurations, which already provide FDT, spibus, and the platform SPI controller required by FDT-attached TPMs. Leave the generic AIM and POWER configurations unchanged because they have no TPM attachment bus. The TPM 1.2 path completed repeated S3 cycles and command tests on ThinkPad T430 and T440p systems. The TPM 2.0 path completed repeated device and full-system suspend/resume cycles on a ThinkPad P51. The PowerPC configuration matrix was checked to retain tpm(4) only where its FDT SPI attachment path is present. PR: 291067 Reviewed by: kevans Tested by: Marek Zarychta <zarychtam_plan-b.pwste.edu.pl> (tpm1.2) Fixes: 16f8ea6a81b5 ("amd64: Remove tpm(4) from GENERIC for now") MFC after: 1 month Relnotes: yes Sponsored by: BBOX.io Differential Revision: https://reviews.freebsd.org/D59247 sys/amd64/conf/GENERIC | 5 ++--- sys/amd64/conf/MINIMAL | 5 ++--- sys/powerpc/conf/MPC85XX | 2 ++ sys/powerpc/conf/QORIQ64 | 2 ++ 4 files changed, 8 insertions(+), 6 deletions(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=63c33b5f1192e2869e33d139ac3d583ec4f966cf commit 63c33b5f1192e2869e33d139ac3d583ec4f966cf Author: Kevin Bowling <kbowling@FreeBSD.org> AuthorDate: 2026-08-26 10:32:34 +0000 Commit: Kevin Bowling <kbowling@FreeBSD.org> CommitDate: 2026-09-18 00:07:28 +0000 tpm: Correct the TPM 1.2 suspend transaction The legacy driver wrote TPM_ORD_SaveState directly to the command FIFO, but used ordinal 156 instead of the TPM 1.2 ordinal 152 and never completed the transaction through the transport start and end methods. On a TIS device this omitted TPM_STS_GO, and the response read used the header length as flags instead of requesting the complete parameter size. The legacy Atmel reader would also dereference the null byte-count pointer. Send the header-only command through the normal transport lifecycle, validate the response header and TPM result, and retry TPM_WARN_RETRY for a bounded five seconds. Fail suspend rather than enter S3 after an unsuccessful state save. This follows the TPM 1.2 SaveState command definition and the bounded retry policy used by other TPM 1.2 implementations. The stock driver failed to resume a ThinkPad T440p with its STMicro TPM 1.2 Security Chip enabled; disabling the chip made S3 reliable. With this change and the following TIS resume restoration, the enabled TPM completed two consecutive S3 cycles. PCR 0 was readable with the same value before and after each cycle, and no TPM errors were logged. PR: 291067 Reviewed by: kevans Sponsored by: BBOX.io Differential Revision: https://reviews.freebsd.org/D59192 (cherry picked from commit c0356f4cd02255419a4d4309f393998185c8de2d) sys/dev/tpm/tpm.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 80 insertions(+), 13 deletions(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=74f94f11dd6915b1d23d64bf92aaf037c4b31fc9 commit 74f94f11dd6915b1d23d64bf92aaf037c4b31fc9 Author: Kevin Bowling <kbowling@FreeBSD.org> AuthorDate: 2026-08-26 10:33:38 +0000 Commit: Kevin Bowling <kbowling@FreeBSD.org> CommitDate: 2026-09-18 00:07:45 +0000 tpm: Restore TPM 1.2 TIS state after resume Firmware restores the state saved by TPM_ORD_SaveState, but the TIS interrupt, locality, and command FIFO state are not guaranteed to survive S3. The legacy driver previously treated resume as a no-op. Revalidate the interface and device identity, disable and acknowledge stale interrupts, restore the configured interrupt vector, reacquire locality zero, and return the FIFO to command-ready state. Also disable TIS interrupts during initial setup when the device uses polling so firmware settings cannot leave an unhandled interrupt enabled. TIS 1.3 Table 22 makes the interrupt control registers locality protected. Acquire locality before disabling or programming them during initial setup and resume rather than relying on probe retaining locality. Keep TPM self-test outside the resume critical path. It can take minutes on some TPM 1.2 devices and is not required to restore the transport state. The two-commit suspend and resume series completed two consecutive S3 cycles on a ThinkPad T440p with its STMicro TPM 1.2 Security Chip enabled. PCR 0 was readable with the same value before and after each cycle, and no SaveState or TIS restoration errors were logged. The locality ordering completed another two consecutive S3 cycles on a ThinkPad T430 with the same STMicro TPM in polling mode. PCR 0 again remained stable, and TPM access recovered without errors after each resume. PR: 291067 Reviewed by: kevans Sponsored by: BBOX.io Differential Revision: https://reviews.freebsd.org/D59193 (cherry picked from commit 96ed6005082fc63d633408ba3ad697e8757e80f9) sys/dev/tpm/tpm.c | 91 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 70 insertions(+), 21 deletions(-)
A commit in branch stable/15 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=7fdc748c0c3d0f2f7c1c0725f9ff2a5085fc36ec commit 7fdc748c0c3d0f2f7c1c0725f9ff2a5085fc36ec Author: Kevin Bowling <kbowling@FreeBSD.org> AuthorDate: 2026-08-28 00:14:02 +0000 Commit: Kevin Bowling <kbowling@FreeBSD.org> CommitDate: 2026-10-11 01:21:08 +0000 amd64, powerpc: Enable tpm(4) in supported kernels tpm(4) was removed from amd64 GENERIC because it broke suspend and resume. The preceding lifecycle, state-save, interrupt, locality, and teardown fixes address those failures for both TPM 1.2 and TPM 2.0. Restore the driver to amd64 GENERIC and MINIMAL, where TPM entropy harvesting remained enabled. Enable the driver and entropy harvesting in the MPC85XX and QORIQ64 configurations, which already provide FDT, spibus, and the platform SPI controller required by FDT-attached TPMs. Leave the generic AIM and POWER configurations unchanged because they have no TPM attachment bus. The TPM 1.2 path completed repeated S3 cycles and command tests on ThinkPad T430 and T440p systems. The TPM 2.0 path completed repeated device and full-system suspend/resume cycles on a ThinkPad P51. The PowerPC configuration matrix was checked to retain tpm(4) only where its FDT SPI attachment path is present. PR: 291067 Reviewed by: kevans Tested by: Marek Zarychta <zarychtam_plan-b.pwste.edu.pl> (tpm1.2) Fixes: 16f8ea6a81b5 ("amd64: Remove tpm(4) from GENERIC for now") Relnotes: yes Sponsored by: BBOX.io Differential Revision: https://reviews.freebsd.org/D59247 (cherry picked from commit cb2964f840e873d03a0739f41eed5921922f93a0) sys/amd64/conf/GENERIC | 2 +- sys/amd64/conf/MINIMAL | 2 +- sys/powerpc/conf/MPC85XX | 2 ++ sys/powerpc/conf/QORIQ64 | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-)