From 829898dedf30bea60d6487b2e238f0d7245be9c2 Mon Sep 17 00:00:00 2001 From: mattafaak Date: Tue, 2 Jun 2026 21:53:18 -0400 Subject: [PATCH 1/2] fix(RK3566): workaround reboot hang caused by DRM VBlank wait The Rockchip DRM driver's drm_atomic_helper_wait_for_vblanks() has no timeout, causing the kernel reboot notifier chain to hang indefinitely when there are pending display commits at shutdown time. This affects all RK3566 devices on ROCKNIX kernel 7.0.2 and manifests as the device appearing completely frozen after a reboot/shutdown is triggered (screen dark, power LED off, but device still powered with USB visible). Fix: add a systemd service that fires before essway/sway are stopped during shutdown. The service: 1. Disables sway display outputs via IPC, which calls drm_crtc_vblank_off() internally and wakes any pending VBlank waiters 2. Uses sysrq emergency restart (echo b > /proc/sysrq-trigger) which calls machine_emergency_restart() directly, bypassing the broken reboot notifier chain The Conflicts= directive ensures ExecStop fires during any shutdown/ reboot/halt sequence. The After=essway.service sway.service ordering ensures this runs before those services are stopped. Tested on: Anbernic RG ARC-D (RK3566) --- .../filesystem/usr/bin/rk3566-reboot-fix | 21 +++++++++++++++++++ .../rk3566-reboot-fix.service | 1 + .../systemd/system/rk3566-reboot-fix.service | 20 ++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100755 projects/ROCKNIX/devices/RK3566/filesystem/usr/bin/rk3566-reboot-fix create mode 120000 projects/ROCKNIX/devices/RK3566/filesystem/usr/lib/systemd/system/multi-user.target.wants/rk3566-reboot-fix.service create mode 100644 projects/ROCKNIX/devices/RK3566/filesystem/usr/lib/systemd/system/rk3566-reboot-fix.service diff --git a/projects/ROCKNIX/devices/RK3566/filesystem/usr/bin/rk3566-reboot-fix b/projects/ROCKNIX/devices/RK3566/filesystem/usr/bin/rk3566-reboot-fix new file mode 100755 index 00000000000..7a9f4d78562 --- /dev/null +++ b/projects/ROCKNIX/devices/RK3566/filesystem/usr/bin/rk3566-reboot-fix @@ -0,0 +1,21 @@ +#!/bin/sh +# Workaround for RK3566 DRM VBlank hang on reboot/shutdown. +# +# Root cause: drm_atomic_helper_wait_for_vblanks() in the Rockchip DRM driver +# has no timeout, causing the kernel reboot notifier chain to hang indefinitely +# when there are pending display commits at shutdown time. +# +# Fix: (1) disable sway outputs via IPC so pending VBlank waiters are woken +# cleanly, then (2) use sysrq emergency restart which bypasses the broken +# notifier chain and calls machine_emergency_restart() directly. +# +# Tested on: RG ARC-D (RK3566), ROCKNIX kernel 7.0.2 +SOCK=/var/run/0-runtime-dir/sway-ipc.0.sock +if [ -S "$SOCK" ]; then + XDG_RUNTIME_DIR=/var/run/0-runtime-dir SWAYSOCK=$SOCK swaymsg output '*' power off 2>/dev/null +fi +sleep 0.5 +echo 128 > /proc/sys/kernel/sysrq +echo s > /proc/sysrq-trigger +sleep 1 +echo b > /proc/sysrq-trigger diff --git a/projects/ROCKNIX/devices/RK3566/filesystem/usr/lib/systemd/system/multi-user.target.wants/rk3566-reboot-fix.service b/projects/ROCKNIX/devices/RK3566/filesystem/usr/lib/systemd/system/multi-user.target.wants/rk3566-reboot-fix.service new file mode 120000 index 00000000000..7286c20e900 --- /dev/null +++ b/projects/ROCKNIX/devices/RK3566/filesystem/usr/lib/systemd/system/multi-user.target.wants/rk3566-reboot-fix.service @@ -0,0 +1 @@ +../rk3566-reboot-fix.service \ No newline at end of file diff --git a/projects/ROCKNIX/devices/RK3566/filesystem/usr/lib/systemd/system/rk3566-reboot-fix.service b/projects/ROCKNIX/devices/RK3566/filesystem/usr/lib/systemd/system/rk3566-reboot-fix.service new file mode 100644 index 00000000000..6a4eb64f0de --- /dev/null +++ b/projects/ROCKNIX/devices/RK3566/filesystem/usr/lib/systemd/system/rk3566-reboot-fix.service @@ -0,0 +1,20 @@ +[Unit] +Description=RK3566 reboot workaround: clean DRM state before shutdown +Documentation=https://github.com/ROCKNIX/distribution/issues/ +# Without this service, drm_atomic_helper_wait_for_vblanks() in the Rockchip +# DRM driver hangs indefinitely during shutdown (no timeout), blocking the +# reboot notifier chain and preventing the device from rebooting. +DefaultDependencies=no +Conflicts=shutdown.target reboot.target halt.target +Before=shutdown.target reboot.target halt.target +After=multi-user.target essway.service sway.service + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/true +ExecStop=/usr/bin/rk3566-reboot-fix +TimeoutStopSec=20s + +[Install] +WantedBy=multi-user.target From f045775ab5c0473ab1172646c0a151bf2c820487 Mon Sep 17 00:00:00 2001 From: Plat4ma Dev Date: Wed, 3 Jun 2026 18:31:12 -0400 Subject: [PATCH 2/2] =?UTF-8?q?fix(RK3566):=20correct=20reboot=20hang=20wo?= =?UTF-8?q?rkaround=20=E2=80=94=20don't=20power=20off=20display?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous approach was based on two incorrect assumptions: 1. That swaymsg output power-off would wake pending VBlank waiters cleanly 2. That sysrq-b bypasses the DRM reboot notifier chain Both are wrong. Testing with persistent systemd journal shows: - Powering off the display stops hardware vblank interrupts, causing drm_atomic_helper_wait_for_vblanks() to hang for ~5 minutes - sysrq-b (machine_emergency_restart) traverses the same notifier chain on this kernel/platform — it does not bypass it Fix: remove the swaymsg display poweroff entirely. With the display active and vblanks still occurring when sysrq-b fires, the DRM notifier completes in <100ms. Measured result: Before: shutdown → new boot ≈ 6 minutes After: shutdown → new boot ≈ 17 seconds Co-Authored-By: Claude Sonnet 4.6 --- .../filesystem/usr/bin/rk3566-reboot-fix | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/projects/ROCKNIX/devices/RK3566/filesystem/usr/bin/rk3566-reboot-fix b/projects/ROCKNIX/devices/RK3566/filesystem/usr/bin/rk3566-reboot-fix index 7a9f4d78562..15a805d4211 100755 --- a/projects/ROCKNIX/devices/RK3566/filesystem/usr/bin/rk3566-reboot-fix +++ b/projects/ROCKNIX/devices/RK3566/filesystem/usr/bin/rk3566-reboot-fix @@ -1,20 +1,20 @@ #!/bin/sh -# Workaround for RK3566 DRM VBlank hang on reboot/shutdown. +# Workaround for RK3566 DRM VBlank hang on reboot/shutdown (kernel 7.0.2). # -# Root cause: drm_atomic_helper_wait_for_vblanks() in the Rockchip DRM driver -# has no timeout, causing the kernel reboot notifier chain to hang indefinitely -# when there are pending display commits at shutdown time. +# Root cause: drm_atomic_helper_wait_for_vblanks() has no timeout. It is called +# from the DRM reboot notifier chain, which runs for both normal reboots and +# sysrq-b (machine_emergency_restart does NOT bypass the notifier chain on this +# kernel/platform). If the display is powered off before reboot, hardware vblank +# interrupts stop and this wait hangs for ~5 minutes until an internal timeout. # -# Fix: (1) disable sway outputs via IPC so pending VBlank waiters are woken -# cleanly, then (2) use sysrq emergency restart which bypasses the broken -# notifier chain and calls machine_emergency_restart() directly. +# Fix: do NOT power off the display before rebooting. With the display active +# and hardware vblanks still occurring, the DRM notifier completes in <100ms. # -# Tested on: RG ARC-D (RK3566), ROCKNIX kernel 7.0.2 -SOCK=/var/run/0-runtime-dir/sway-ipc.0.sock -if [ -S "$SOCK" ]; then - XDG_RUNTIME_DIR=/var/run/0-runtime-dir SWAYSOCK=$SOCK swaymsg output '*' power off 2>/dev/null -fi -sleep 0.5 +# Verified with persistent systemd journal across reboots: +# Before fix: shutdown → new boot = ~6 minutes +# After fix: shutdown → new boot = ~17 seconds +# +# Device: RG ARC-D (RK3566), ROCKNIX 20260601, kernel 7.0.2 echo 128 > /proc/sys/kernel/sysrq echo s > /proc/sysrq-trigger sleep 1