#!/bin/sh # License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree. # # Reboot the phone N times and record, per boot, what the screen shows # (tools/phone-screen.sh: a camera on the phone, 0 black console .. 255 # white) next to what the kernel did: SMMU faults on the display, the # compression state the panel reported at handoff, when msm initialised, # when ath10k loaded, and how many display (msm) and DSI interrupts come in # 2 s -- whether frames still reach the panel. For the white-display defect of hotdogb # (devices/hotdogb/AGENTS.md), so that no one has to watch the phone. # A clean reboot each time (runit stage 3); the camera frame of each boot # is kept next to LOG. # # Usage: display-loop.sh N LOG set -u . "$(dirname "$0")/lib.sh" [ $# -eq 2 ] || { echo "usage: $0 N LOG" >&2; exit 2; } n=$1 log=$2 dir=${log%.log}.d mkdir -p "$dir" i=1 while [ "$i" -le "$n" ]; do a=$(phone_addr) || { echo "run $i: phone not reachable" | tee -a "$log"; exit 1; } phone_ssh "$a" 'sync; reboot' >/dev/null 2>&1 sleep 20 t=0 while ! a=$(phone_addr 2>/dev/null) && [ "$t" -lt 150 ]; do sleep 3; t=$((t + 3)) done if [ -z "$a" ]; then echo "run $i: NOT REACHABLE" | tee -a "$log" break fi t=0 until phone_ssh "$a" '[ $(cut -d. -f1 /proc/uptime) -ge 30 ]' 2>/dev/null || [ "$t" -ge 120 ]; do sleep 3; t=$((t + 3)) done screen=$(sh "$(dirname "$0")/phone-screen.sh" "$dir/run$i.jpg" 2>/dev/null || echo "?") k=$(phone_ssh "$a" ' f=$(dmesg | grep -c "Unhandled context fault") c=$(dmesg | sed -n "s/.*handoff: .*compression_mode=0x\([0-9a-f]*\).*/\1/p" | head -n 1) m=$(dmesg | sed -n "s/^\[ *\([0-9.]*\)\].*Initialized msm.*/\1/p" | head -n 1) w=$(dmesg | sed -n "s/^\[ *\([0-9.]*\)\].*ath10k_snoc 18800000.wifi:.*/\1/p" | head -n 1) irq() { awk "/ $1\$/ { s = 0; for (i = 2; i <= 9; i++) s += \$i; print s }" /proc/interrupts; } m1=$(irq msm) d1=$(irq dsi_isr); sleep 2; m2=$(irq msm) d2=$(irq dsi_isr) printf "faults=%s cmp=%s msm=%s ath10k=%s irq2s_msm=%s irq2s_dsi=%s" \ "$f" "${c:-?}" "${m:-?}" "${w:-?}" $((m2 - m1)) $((d2 - d1))') state=good case $screen in '?') state=unknown ;; *) [ "$screen" -lt 128 ] || state=WHITE ;; esac echo "run $i: screen=$screen $state $k" | tee -a "$log" i=$((i + 1)) done