From 342c9bbbeffccb19beabd0db32eaaa1dc5d08de9 Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 13 Oct 2023 02:28:10 +0000 Subject: [PATCH] sxmo_suspend: track wifi IRQ count --- hosts/modules/gui/sxmo/default.nix | 2 +- hosts/modules/gui/sxmo/hooks/sxmo_suspend.sh | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hosts/modules/gui/sxmo/default.nix b/hosts/modules/gui/sxmo/default.nix index 92647f58..fdc14f2f 100644 --- a/hosts/modules/gui/sxmo/default.nix +++ b/hosts/modules/gui/sxmo/default.nix @@ -95,7 +95,7 @@ let }; suspend = pkgs.static-nix-shell.mkBash { pname = "sxmo_suspend.sh"; - pkgs = [ "coreutils" "rtl8723cs-wowlan" "time" "util-linux" ]; + pkgs = [ "coreutils" "findutils" "gnugrep" "rtl8723cs-wowlan" "time" "util-linux" ]; src = ./hooks; }; }; diff --git a/hosts/modules/gui/sxmo/hooks/sxmo_suspend.sh b/hosts/modules/gui/sxmo/hooks/sxmo_suspend.sh index 51b28900..64720bbf 100755 --- a/hosts/modules/gui/sxmo/hooks/sxmo_suspend.sh +++ b/hosts/modules/gui/sxmo/hooks/sxmo_suspend.sh @@ -1,5 +1,5 @@ #!/usr/bin/env nix-shell -#!nix-shell -i bash -p coreutils -p rtl8723cs-wowlan -p time -p util-linux +#!nix-shell -i bash -p coreutils -p findutils -p gnugrep -p rtl8723cs-wowlan -p time -p util-linux # yeah, this isn't technically a hook, but the hook infrastructure isn't actually # restricted to stuff that starts with sxmo_hook_ ... @@ -40,11 +40,15 @@ doas rtl8723cs-wowlan arp --dest-ip SELF echo "calling suspend for duration: $suspend_time" -start="$(date "+%s")" +time_start="$(date "+%s")" +irq_start="$(cat /proc/interrupts | grep 'rtw_wifi_gpio_wakeup' | tr -s ' ' | xargs echo | cut -d' ' -f 2)" + rtcwake -m mem -s "$suspend_time" || exit 1 -#We woke up again + +irq_end="$(cat /proc/interrupts | grep 'rtw_wifi_gpio_wakeup' | tr -s ' ' | xargs echo | cut -d' ' -f 2)" time_spent="$(( $(date "+%s") - start ))" -echo "suspended for $time_spent seconds" + +echo "suspended for $time_spent seconds. wifi IRQ count: ${irq_start} -> ${irq_end}" sxmo_hook_postwake.sh