Skip to content

platform/surface: Add s2idle/hibernate fix for Surface Laptop 5#162

Open
wowitsjack wants to merge 2 commits intolinux-surface:v6.18-surface-develfrom
wowitsjack:surface-laptop-5-s2idle-fix
Open

platform/surface: Add s2idle/hibernate fix for Surface Laptop 5#162
wowitsjack wants to merge 2 commits intolinux-surface:v6.18-surface-develfrom
wowitsjack:surface-laptop-5-s2idle-fix

Conversation

@wowitsjack
Copy link

Closes linux-surface/linux-surface#1782
Per request from @qzed in linux-surface/linux-surface#2011

Adds surface_s2idle_fix module to drivers/platform/surface/.

Problem

Intel INTC1055 pinctrl power-gating during s2idle corrupts pin 213's PADCFG0 register. The corruption fires a spurious SCI on GPE 0x52, which promotes to a full resume via acpi_any_gpe_status_set(). The system either never wakes (wakeup framework poisoned by pm_system_cancel_wakeup()) or wakes spuriously on every s2idle cycle.

Fix

The ACPI wakeup handler runs before acpi_ec_dispatch_gpe() in the s2idle wake decision path. The handler:

  1. Repairs PADCFG corruption (full register comparison, not just RXINV)
  2. Clears GPE 0x52 status so acpi_any_gpe_status_set() doesn't see it
  3. Returns false (no full wake)

Lid-open detection is deferred to an LPS0 check() callback which reads RXSTATE directly and only calls pm_system_wakeup() if the lid is genuinely open.

Key design decisions

  • GPE 0x52 masked during s2idle: VNN power-gating causes transient RXSTATE glitches that fire GPE 0x52 as SCI. Lid detection handled by 500ms poll timer reading RXSTATE directly.
  • GPE unmask delayed to PM_POST_SUSPEND: Stale GPE status from lid state changes fires immediately on unmask during resume_early, causing false lid events to logind.
  • Reference-counted GPE management: Uses acpi_enable_gpe/acpi_disable_gpe (not acpi_set_gpe) to maintain proper ACPI reference counting.
  • Full PADCFG0 corruption detection: Compares entire register (minus volatile GPIORXSTATE) instead of just RXINV, catching all VNN corruption.
  • 1ms GPIORXDIS toggle + 15s settling guard: Extended input buffer enable for reliable re-latching after PADCFG restore.

Additional layers

  • Failsafe re-suspend with exponential backoff (2s/4s/8s/15s)
  • RXSTATE polling for lid close detection
  • Suspend-to-lock mode (converts lid-open suspend to lock+blank)
  • Hibernate support with RTC time sync
  • SW_LID input events for userspace lid policy

Testing

Tested on Surface Laptop 5 (i5-1245U), Ubuntu 25.10, kernel 6.18.7-surface-1. s2idle cycles, hibernate cycles, extended sleep (11h+), repeated lid open/close, rapid-wake VNN cycles with failsafe re-suspend.

Intel INTC1055 pinctrl power-gating during s2idle corrupts pin 213's
PADCFG0 register. The corruption fires a spurious SCI on GPE 0x52,
which promotes to a full resume via acpi_any_gpe_status_set(). The
system either never wakes or wakes spuriously on every s2idle cycle.

Fix by intercepting in the ACPI wakeup handler (which runs before
acpi_ec_dispatch_gpe). The handler repairs PADCFG corruption, clears
GPE 0x52 status, and returns false. The actual lid-open decision is
deferred to an LPS0 check() callback which reads RXSTATE directly.

GPE 0x52 is kept masked during s2idle to prevent VNN RXSTATE glitches
from firing as SCI. Lid-open detection uses a 500ms poll timer reading
RXSTATE directly. GPE unmask is delayed to PM_POST_SUSPEND to avoid
stale GPE status causing false lid events during resume.

Additional features: failsafe re-suspend with exponential backoff,
RXSTATE polling for lid close detection, suspend-to-lock mode,
hibernate support with RTC time sync, and full PADCFG0 corruption
detection with 15s RXSTATE settling guard.

Link: linux-surface/linux-surface#1782
Signed-off-by: Jack <wowitsjack@users.noreply.github.com>
Removed old suspected root cause explanation for s2idle issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Surface Laptop 5 DMI ID Missing From GPE Modules List Leading to Failed Lid Suspend Events

1 participant