fix(sway): only force a post-resume modeset when the stall is actually present

recover-output-after-resume.sh existed to work around the old ThinkPad's
/etc/modprobe.d/i915.conf, which forced PSR2 and the deepest display
C-states; the flip pending across suspend never completed, so every later
commit returned EBUSY and only a full modeset cleared it.

That file is gone and this laptop's iGPU is driven by `xe` (Panther Lake has
no i915 support at all), so the original cause cannot recur. The modeset is
now conditional on the user journal actually reporting "Atomic commit
failed"/"Page-flip failed" within the last 3 minutes.

Unconditional disable/enable + `shikanectl reload` on every resume was itself
a hazard: it is the exact sequence that re-triggers the shikane
VariantInProgress deadlock the watchdog exists to recover from.

hypridle.conf's comment no longer references the deleted i915.conf.
This commit is contained in:
jozamudi committed 2026-10-27 18:32:33 -07:00
1 parent 078f9acf71
commit 0ceec0b4ab
2 files changed
+95 -21

No files matched your search

+35 -21
View File
@@ -1,34 +1,48 @@
# Idle / lock for SWAY (wlroots), not Hyprland.
#
# Two things in the original Hyprland template silently did nothing under sway:
# * `loginctl lock-session` -> sway implements no freedesktop login1 Session
# Lock protocol, so it is a no-op. Lock directly.
# * `hyprctl dispatch dpms` -> "HYPRLAND_INSTANCE_SIGNATURE not set!".
# Use `swaymsg "output * power on|off"`.
# Also: a hyprlock instance can outlive a sway session and then make the
# `pidof hyprlock || hyprlock` guard a permanent no-op; the sway config kills
# leftovers at login (`exec --no-startup-id pkill -x hyprlock`).
general {
lock_cmd = pidof hyprlock || hyprlock # avoid starting multiple hyprlock instances.
before_sleep_cmd = loginctl lock-session # lock before suspend.
after_sleep_cmd = hyprctl dispatch dpms on # to avoid having to press a key twice to turn on the display.
lock_cmd = pidof hyprlock || hyprlock
# pre-suspend uses swaylock: fast, sway-native, exits cleanly (no leak)
before_sleep_cmd = swaylock -f -c 000000
# DPMS "power on" alone does not clear a post-resume eDP page-flip stall
# ("Atomic commit failed: Device or resource busy" for tens of minutes).
# The script does a full disable/enable (forced modeset) but ONLY when the
# journal actually shows the stall -- it used to fire unconditionally, which
# risked the shikane VariantInProgress deadlock on healthy resumes. The
# original i915 PSR2/DC4 cause is gone; this laptop uses the `xe` driver.
# Lid-aware so it does not race shikane's "External Display" profile.
after_sleep_cmd = /home/work/.config/sway/scripts/recover-output-after-resume.sh
}
listener {
timeout = 150 # 2.5min.
on-timeout = brightnessctl -s set 10 # set monitor backlight to minimum, avoid 0 on OLED monitor.
on-resume = brightnessctl -r # monitor backlight restore.
timeout = 150 # 2.5min
on-timeout = brightnessctl -s set 10
on-resume = brightnessctl -r
}
# turn off keyboard backlight, comment out this section if you dont have a keyboard backlight.
listener {
timeout = 150 # 2.5min.
on-timeout = brightnessctl -sd rgb:kbd_backlight set 0 # turn off keyboard backlight.
on-resume = brightnessctl -rd rgb:kbd_backlight # turn on keyboard backlight.
# keyboard backlight
listener {
timeout = 150
on-timeout = brightnessctl -sd rgb:kbd_backlight set 0
on-resume = brightnessctl -rd rgb:kbd_backlight
}
listener {
timeout = 300 # 5min
on-timeout = loginctl lock-session # lock screen when timeout has passed
timeout = 300 # 5min -> lock
on-timeout = pidof hyprlock || hyprlock
}
listener {
timeout = 330 # 5.5min
on-timeout = hyprctl dispatch dpms off # screen off when timeout has passed
on-resume = hyprctl dispatch dpms on && brightnessctl -r # screen on when activity is detected after timeout has fired.
}
listener {
timeout = 1800 # 30min
on-timeout = systemctl suspend # suspend pc
timeout = 330 # 5.5min -> output power off
on-timeout = swaymsg "output * power off"
on-resume = swaymsg "output * power on" && brightnessctl -r
}
+60
View File
@@ -0,0 +1,60 @@
#!/bin/sh
# recover-output-after-resume -- clear a post-resume eDP page-flip stall.
#
# Symptom (see journalctl --user --since -5m | grep 'Atomic commit failed'):
# [wlr] backend/drm/atomic.c:82 connector eDP-1: Atomic commit failed:
# Device or resource busy
# [sway] desktop/output.c:307 Page-flip failed on output eDP-1
# ...repeatedly for tens of minutes after a resume.
#
# HISTORY: this was originally a workaround for the old ThinkPad's
# /etc/modprobe.d/i915.conf, which forced PSR2 and the deepest display C-states
# (options i915 enable_guc=3 enable_psr=2 enable_dc=4 enable_rc6=1 -- both of
# which taint the kernel). With PSR2 forced on, the flip pending across suspend
# never completed, so every later commit returned EBUSY, and DPMS "power on"
# alone did not clear it -- only a full modeset did.
#
# STATUS: that file is gone. This machine is a Framework Laptop 13 Pro whose
# iGPU is driven by `xe` (Panther Lake has no i915 support at all), so the
# original cause cannot recur. The modeset below is therefore CONDITIONAL and
# only fires when the stall is actually present in the journal.
#
# Why conditional: an unconditional disable/enable plus `shikanectl reload`
# after every resume is exactly the sequence that re-triggers the shikane
# 1.1.1 VariantInProgress deadlock (see shikane-watchdog.sh). No point paying
# that risk on resumes that are already healthy.
#
# Lid-aware on purpose: a blind `output eDP-1 enable` raced shikane's
# "External Display" profile (which keeps eDP-1 off) and caused
# "Atomic commit failed: Device or resource busy" churn in clamshell mode.
# See the note in clamshell-mode.sh.
set -u
LID_STATE="${LID_STATE:-/proc/acpi/button/lid/LID/state}"
OUTPUT="${OUTPUT:-eDP-1}"
# Always undo the idle DPMS-off first (this is what after_sleep_cmd used to do).
swaymsg "output * power on" 2>/dev/null
# Only escalate to a modeset if the page-flip stall is actually being reported.
# sway runs inside the user session, so its stderr is in the user journal.
if command -v journalctl >/dev/null 2>&1; then
if ! journalctl --user --since '-3 min' --no-pager 2>/dev/null \
| grep -qE 'Atomic commit failed|Page-flip failed on output'; then
exit 0 # healthy resume -> do not disturb shikane
fi
fi
# The modeset below is lid-gated only.
[ -r "$LID_STATE" ] || exit 0
grep -q 'open' "$LID_STATE" || exit 0 # lid closed -> leave layout to shikane
# Give the driver a moment to finish re-training the link before we modeset.
sleep 1
swaymsg "output $OUTPUT disable" 2>/dev/null
sleep 1
swaymsg "output $OUTPUT enable" 2>/dev/null
# Re-assert the shikane profile (mode/scale/position) on top of the modeset.
command -v shikanectl >/dev/null 2>&1 && shikanectl reload 2>/dev/null
exit 0