sxmo: postwake: show the human-readable wakeup reason

This commit is contained in:
Colin 2023-10-10 00:35:32 +00:00
parent bc8cf58b5a
commit e28e60769a
3 changed files with 40 additions and 8 deletions

View File

@ -75,6 +75,7 @@ let
};
postwake = pkgs.static-nix-shell.mkBash {
pname = "sxmo_hook_postwake.sh";
pkgs = [ "coreutils" ];
src = ./hooks;
};
rotate = pkgs.static-nix-shell.mkBash {
@ -90,7 +91,7 @@ let
suspend = pkgs.static-nix-shell.mkBash {
pname = "sxmo_suspend.sh";
src = ./hooks;
pkgs = [ "coreutils" "util-linux" ];
pkgs = [ "util-linux" ];
};
};
in

View File

@ -1,7 +1,42 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash
#!nix-shell -i bash -p coreutils
# the default sxmo_postwake handler checks if the modem is offline
# and if so installs a wakelock to block suspend for 30s.
# that's a questionable place to install that logic, and i want to keep stuff
# out of the wake-from-sleep critical path, so i'm overriding this hook to disable that.
declare -A newmap
wowlan_reason[0x0]="not wowlan"
# mappings are found in megi's linux: drivers/staging/rtl8723cs/include/hal_com.h
wowlan_reason[0x1]="RX_PAIRWISEKEY"
wowlan_reason[0x2]="RX_GTK"
wowlan_reason[0x3]="RX_FOURWAY_HANDSHAKE"
wowlan_reason[0x4]="RX_DISASSOC"
wowlan_reason[0x8]="RX_DEAUTH"
wowlan_reason[0x9]="RX_ARP_REQUEST"
wowlan_reason[0x10]="FW_DECISION_DISCONNECT"
wowlan_reason[0x21]="RX_MAGIC_PKT"
wowlan_reason[0x22]="RX_UNICAST_PKT"
wowlan_reason[0x23]="RX_PATTERN_PKT"
wowlan_reason[0x24]="RTD3_SSID_MATCH"
wowlan_reason[0x30]="RX_REALWOW_V2_WAKEUP_PKT"
wowlan_reason[0x31]="RX_REALWOW_V2_ACK_LOST"
wowlan_reason[0x40]="ENABLE_FAIL_DMA_IDLE"
wowlan_reason[0x41]="ENABLE_FAIL_DMA_PAUSE"
wowlan_reason[0x42]="RTIME_FAIL_DMA_IDLE"
wowlan_reason[0x43]="RTIME_FAIL_DMA_PAUSE"
wowlan_reason[0x55]="RX_PNO"
#ifdef CONFIG_WOW_KEEP_ALIVE_PATTERN
wowlan_reason[0x60]="WOW_KEEPALIVE_ACK_TIMEOUT"
wowlan_reason[0x61]="WOW_KEEPALIVE_WAKE"
#endif/*CONFIG_WOW_KEEP_ALIVE_PATTERN*/
wowlan_reason[0x66]="AP_OFFLOAD_WAKEUP"
wowlan_reason[0xfd]="CLK_32K_UNLOCK"
wowlan_reason[0xfe]="CLK_32K_LOCK"
wowlan_text="$(cat /proc/net/rtl8723cs/wlan0/wowlan_last_wake_reason)"
wowlan_bits="${wowlan_text/last wake reason: /}"
wowlan_reason="${wowlan_reason[$wowlan_bits]}"
echo "exited suspend: $wowlan_text ($wowlan_reason)"

View File

@ -1,5 +1,5 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p coreutils -p util-linux
#!nix-shell -i bash -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_ ...
@ -7,15 +7,11 @@
# this script is only called by sxmo_autosuspend, which is small, so if i wanted to
# be more proper i could instead re-implement autosuspend + integrations.
. sxmo_common.sh
suspend_time=300
sxmo_log "calling suspend for duration: $suspend_time"
echo "calling suspend for duration: $suspend_time"
rtcwake -m mem -s "$suspend_time" || exit 1
sxmo_log "exited suspend: $(cat /proc/net/rtl8723cs/wlan0/wowlan_last_wake_reason)"
sxmo_hook_postwake.sh