Bug 270489 - Laptop doesn't wake from suspend anymore with 13.2-RC5
Summary: Laptop doesn't wake from suspend anymore with 13.2-RC5
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.2-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Konstantin Belousov
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2023-03-27 21:20 UTC by Luís Henriques
Modified: 2024-01-10 04:42 UTC (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luís Henriques 2023-03-27 21:20:20 UTC
I've upgraded from 13.2-RC3 to 13.2-RC5 (RC4 was too fast for me to try it!) and my laptop stopped waking up from suspend -- when I open the lid nothing happens and I need to hard reboot it.  Fortunately, I still have a booenvironment with -RC3.

Looking at the kernel logs since RC3, I suspect this is related with commit:

commit 7622d3671cbef860d5dede0e4beace8fd152cd87
Author: Konstantin Belousov <kib@FreeBSD.org>
Date:   Fri Mar 17 15:02:03 2023 +0200

    amd64: properly recalculate mitigations knobs after resume

But this is only a guess, of course.  Here's what what's on dmesg about my T490 laptop CPU:

CPU: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz (1800.00-MHz K8-class CPU)
  Origin="GenuineIntel"  Id=0x806ec  Family=0x6  Model=0x8e  Stepping=12
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0x7ffafbbf<SSE3,PCLMULQDQ,DTES64,MON,DS_CPL,VMX,EST,TM2,SSSE3,SDBG,FMA,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,TSCDLT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND>
  AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM>
  AMD Features2=0x121<LAHF,ABM,Prefetch>
  Structured Extended Features=0x29c67af<FSGSBASE,TSCADJ,SGX,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,NFPUSG,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PROCTRACE>
  Structured Extended Features3=0xbc000600<MCUOPT,MD_CLEAR,IBPB,STIBP,L1DFL,ARCH_CAP,SSBD>
  XSAVE Features=0xf<XSAVEOPT,XSAVEC,XINUSE,XSAVES>
  IA32_ARCH_CAPS=0x20c2b<RDCL_NO,IBRS_ALL,SKIP_L1DFL_VME,MDS_NO>
  VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID
  TSC: P-state invariant, performance statistics

(Not sure if this is useful or where to get more useful information.)

Now, maybe this is a different issue, or maybe it is the same... but when I tried to compile a kernel with the above commit reverted in the 'releng/13.2' branch (and running -RC5), I had an hard-reboot (!).  As I said, I'm not sure if that's a different issue, because I had the 4 CPUs at 100%, so maybe it was an overheating issue.  When I booted back into RC3 kern.msgbuf had the following:

Fatal trap 9: general protection fault while in kernel mode
cpuid = 3; apic id = 06
instruction pointer     = 0x20:0xffffffff810a253a
stack pointer           = 0x28:0xfffffe012cdcbc20
frame pointer           = 0x28:0xfffffe012cdcbd60
code segment            = base rx0, limit 0xfffff, type 0x1b
                        = DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags        = interrupt enabled, resume, IOPL = 0
current process         = 15190 (cc)
trap number             = 9
panic: general protection fault
cpuid = 3
time = 1679950971
KDB: stack backtrace:
#0 0xffffffff80c53dc5 at kdb_backtrace+0x65
#1 0xffffffff80c06741 at vpanic+0x151
#2 0xffffffff80c065e3 at panic+0x43
#3 0xffffffff810b1fa7 at trap_fatal+0x387
#4 0xffffffff81088e78 at calltrap+0x8
#5 0xffffffff80f5645f at vmspace_exit+0x7f
#6 0xffffffff80bbc841 at exit1+0x591
#7 0xffffffff80bbc2ad at sys_sys_exit+0xd
#8 0xffffffff810b289c at amd64_syscall+0x10c
#9 0xffffffff8108978b at fast_syscall_common+0xf8
Uptime: 11m17s
Dumping 1470 out of 24183 MB: (CTRL-C to abort) ..2% (CTRL-C to abort) ..11%..21% (CTRL-C to abort) ..31% (CTRL-C to abort) ..41%..51% (CTRL-C to abort)  (CTRL-C to abort) ..61%..71%..81%..91% (CTRL-C to abort)  (CTRL-C to abort) ---<<BOOT>>---
Comment 1 Luís Henriques 2023-03-27 21:26:12 UTC
I'm adding the commit author to CC in this bug.
Comment 2 Dmitry Chagin freebsd_committer freebsd_triage 2023-03-27 21:36:10 UTC
Let’s try to experiment, could you please disable TPM feature in BIOS and try again?
Comment 3 Luís Henriques 2023-03-27 21:49:21 UTC
(In reply to Dmitry Chagin from comment #2)
> Let’s try to experiment, could you please disable TPM feature in BIOS and try again?

Done, but with the same result unfortunately.  I.e. I had to do an hard reboot after suspend.
Comment 4 Dmitry Chagin freebsd_committer freebsd_triage 2023-03-28 07:55:51 UTC
(In reply to Luís Henriques from comment #3)
That's sad, perhaps, there is a problem with waking up some other drivers,
try disabling microcode update, tpm rtsx module loading
Comment 5 Oleksandr Kryvulia 2023-03-28 14:08:57 UTC
I have the same problem on my T490 with CURRENT. Bisecting shows 02904a06c76be857307b78184863654b9e7b88ab as first bad commit.
Comment 6 Luís Henriques 2023-03-28 15:29:48 UTC
(In reply to Oleksandr Kryvulia from comment #5)
Awesome, thanks for confirming.  The commit I mention in the bug description is the backport to STABLE of that very commit.
Comment 7 Luís Henriques 2023-03-28 22:07:12 UTC
I don't really know what's happening at the low-level here in this patch, but I've done some blind testing here's what I learned: the system wakes up from suspend if I comment the following lines from the patch:

		...
		identify_cpu_ext_features();
		hw_ibrs_recalculate(true);
		/*
		 * hw_ssb_recalculate(true);
		 * amd64_syscall_ret_flush_l1d_recalc();
		 * x86_rngds_mitg_recalculate(true);
		 */
		mca_resume();
		if (vmm_resume_p != NULL)
			vmm_resume_p();
		...

If I uncomment the next line (hw_ssb_recalculate(true)) the laptop won't wakeup.  But as I said, I've no idea why, this was just blind testing.
Comment 8 Oleksandr Kryvulia 2023-03-29 15:15:47 UTC
Yes, if I comment hw_ssb_recalculate(true) laptop wakes up as usual.
Comment 9 Dmitry Chagin freebsd_committer freebsd_triage 2023-03-29 15:22:25 UTC
fyi, https://reviews.freebsd.org/D39302
Comment 10 Luís Henriques 2023-03-29 15:47:37 UTC
(In reply to Dmitry Chagin from comment #9)
Awesome, thanks a lot Dmitry (and everyone!).  I've just tried the patch and it does indeed fix this issue for me.
Comment 11 commit-hook freebsd_committer freebsd_triage 2023-03-29 18:46:39 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=cd137909c3097fe223ce2b49075eed42a4933bb5

commit cd137909c3097fe223ce2b49075eed42a4933bb5
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-03-28 23:51:44 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-03-29 18:45:20 +0000

    amd64 wakeup: recalculate mitigations after APICs are woken

    APICs are needed to broadcast IPIs for MSR writes.

    PR:     270489
    Reviewed by:    dchagin, emaste, jhb
    Tested by:      dchagin, manu
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D39302

 sys/amd64/acpica/acpi_wakeup.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
Comment 12 commit-hook freebsd_committer freebsd_triage 2023-03-29 22:39:23 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=738b20a47f7379b27ccf7a6d2af2c1bbfa11d05f

commit 738b20a47f7379b27ccf7a6d2af2c1bbfa11d05f
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-03-28 23:51:44 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-03-29 22:37:54 +0000

    amd64 wakeup: recalculate mitigations after APICs are woken

    PR:     270489
    Approved by:    re (cperciva)

    (cherry picked from commit cd137909c3097fe223ce2b49075eed42a4933bb5)

 sys/amd64/acpica/acpi_wakeup.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
Comment 13 commit-hook freebsd_committer freebsd_triage 2023-03-30 12:36:13 UTC
A commit in branch releng/13.2 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=878cd9623c8eaa747ec27269fec968b33b153e1d

commit 878cd9623c8eaa747ec27269fec968b33b153e1d
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-03-28 23:51:44 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-03-30 12:35:53 +0000

    amd64 wakeup: recalculate mitigations after APICs are woken

    PR:     270489
    Approved by:    re (cperciva)

    (cherry picked from commit cd137909c3097fe223ce2b49075eed42a4933bb5)
    (cherry picked from commit 738b20a47f7379b27ccf7a6d2af2c1bbfa11d05f)

 sys/amd64/acpica/acpi_wakeup.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
Comment 14 Mark Linimon freebsd_committer freebsd_triage 2024-01-10 04:42:19 UTC
^Triage: assign to committer that resolved and MFCed.