From a6426241a5e003a6ff22ac24a896e43332d4a6cc Mon Sep 17 00:00:00 2001 From: Tom Vincent Date: Mon, 13 Nov 2023 22:32:05 +0000 Subject: [PATCH 1/4] feat(framework): add suspend udev hint --- framework/13-inch/7040-amd/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/framework/13-inch/7040-amd/default.nix b/framework/13-inch/7040-amd/default.nix index 128ace8..2d98f17 100644 --- a/framework/13-inch/7040-amd/default.nix +++ b/framework/13-inch/7040-amd/default.nix @@ -31,6 +31,10 @@ services.udev.extraRules = '' # Ethernet expansion card support ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0bda", ATTR{idProduct}=="8156", ATTR{power/autosuspend}="20" + + # Prevent wake when plugging in AC during suspend. Trade-off: keyboard wake disabled. See: + # https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/45 + #ACTION=="add", SUBSYSTEM=="serio", DRIVERS=="atkbd", ATTR{power/wakeup}="disabled" ''; # Needed for desktop environments to detect/manage display brightness From c0fa269fe95b48af852ff93263ef5a5f57721086 Mon Sep 17 00:00:00 2001 From: Tom Vincent Date: Mon, 13 Nov 2023 22:40:45 +0000 Subject: [PATCH 2/4] Update README.md --- framework/13-inch/7040-amd/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/framework/13-inch/7040-amd/README.md b/framework/13-inch/7040-amd/README.md index 63608d1..8ad0dbb 100644 --- a/framework/13-inch/7040-amd/README.md +++ b/framework/13-inch/7040-amd/README.md @@ -15,3 +15,17 @@ Then run ``` - [Latest Update](https://fwupd.org/lvfs/devices/work.frame.Laptop.Ryzen7040.BIOS.firmware) + +## Suspend/wake workaround + +As of firmware v03.03, a bug in the EC causes the system to wake if AC is connected _despite_ the lid being closed. The following works around this, with the trade-off that keyboard presses also no longer wake the system. + +```nix +services.udev.extraRules = '' +# Prevent wake when plugging in AC during suspend. Trade-off: keyboard wake disabled. See: +# https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/45 +ACTION=="add", SUBSYSTEM=="serio", DRIVERS=="atkbd", ATTR{power/wakeup}="disabled" +''; +``` + +See [Framework AMD Ryzen 7040 Series lid wakeup behavior feedback](https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/45). From f2d7c0b23c507e0823508948f3b002c9c6d5a586 Mon Sep 17 00:00:00 2001 From: Jack Kelly Date: Thu, 16 Nov 2023 10:19:02 +1000 Subject: [PATCH 3/4] framework AMD 7040: Add config option for wake-on-AC fix --- framework/13-inch/7040-amd/default.nix | 42 +++++++++++++++++++------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/framework/13-inch/7040-amd/default.nix b/framework/13-inch/7040-amd/default.nix index 3d4277d..9f31c6b 100644 --- a/framework/13-inch/7040-amd/default.nix +++ b/framework/13-inch/7040-amd/default.nix @@ -1,18 +1,38 @@ -{ lib, pkgs, ... }: { +{ config, lib, pkgs, ... }: + +let + cfg = config.hardware.framework.amd-7040; +in +{ imports = [ ../common ../common/amd.nix ]; - # Newer kernel is better for amdgpu driver updates - # Requires at least 5.16 for working wi-fi and bluetooth (RZ616, kmod mt7922): - # https://wireless.wiki.kernel.org/en/users/drivers/mediatek - boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "6.1") (lib.mkDefault pkgs.linuxPackages_latest); + options = { + hardware.framework.amd-7040.preventWakeOnAC = lib.mkOption { + type = lib.types.bool; + default = false; + description = '' + Stop the system waking from suspend when the AC is plugged + in. The catch: it also disables waking from the keyboard. - # Custom udev rules - services.udev.extraRules = '' - # Prevent wake when plugging in AC during suspend. Trade-off: keyboard wake disabled. See: - # https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/45 - #ACTION=="add", SUBSYSTEM=="serio", DRIVERS=="atkbd", ATTR{power/wakeup}="disabled" - ''; + See: + https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/45 + ''; + }; + }; + + config = { + # Newer kernel is better for amdgpu driver updates + # Requires at least 5.16 for working wi-fi and bluetooth (RZ616, kmod mt7922): + # https://wireless.wiki.kernel.org/en/users/drivers/mediatek + boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "6.1") (lib.mkDefault pkgs.linuxPackages_latest); + + services.udev.extraRules = lib.optionalString cfg.preventWakeOnAC '' + # Prevent wake when plugging in AC during suspend. Trade-off: keyboard wake disabled. See: + # https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/45 + ACTION=="add", SUBSYSTEM=="serio", DRIVERS=="atkbd", ATTR{power/wakeup}="disabled" + ''; + }; } From eb903ed873af4063bf400ac988b03465fef51129 Mon Sep 17 00:00:00 2001 From: Tom Vincent Date: Thu, 16 Nov 2023 10:54:41 +0000 Subject: [PATCH 4/4] Update README.md --- framework/13-inch/7040-amd/README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/framework/13-inch/7040-amd/README.md b/framework/13-inch/7040-amd/README.md index 8ad0dbb..be3293e 100644 --- a/framework/13-inch/7040-amd/README.md +++ b/framework/13-inch/7040-amd/README.md @@ -21,11 +21,9 @@ Then run As of firmware v03.03, a bug in the EC causes the system to wake if AC is connected _despite_ the lid being closed. The following works around this, with the trade-off that keyboard presses also no longer wake the system. ```nix -services.udev.extraRules = '' -# Prevent wake when plugging in AC during suspend. Trade-off: keyboard wake disabled. See: -# https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/45 -ACTION=="add", SUBSYSTEM=="serio", DRIVERS=="atkbd", ATTR{power/wakeup}="disabled" -''; +{ + hardware.framework.amd-7040.preventWakeOnAC = true; +} ``` See [Framework AMD Ryzen 7040 Series lid wakeup behavior feedback](https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/45).