diff --git a/packages/omamobile-device-tegu/README.md b/packages/omamobile-device-tegu/README.md index cba5a95ca..41b576889 100644 --- a/packages/omamobile-device-tegu/README.md +++ b/packages/omamobile-device-tegu/README.md @@ -10,7 +10,7 @@ packaged yet. What is here is what runs on in-tree drivers. | Path | Installs to | What it does | | --- | --- | --- | -| `bin/omamobile-tegu-graphics-start` + `vendor/systemd/system/omamobile-tegu-graphics.service` + `display-manager.service.d/10-omamobile-tegu.conf` | `/usr/bin`, `/usr/lib/systemd/system` (enabled by a vendor wants link) | Loads the GPU (panthor), the display controller (gs_decon), haptics (cs40l26_vibra), the torch (leds_lm3644), the battery gauge (max77779_battery) and the Bluetooth controller (hci_uart) at boot, in that order, after writing and syncing a marker. Each step keys on its own device node (`1f000000.gpu`, `19470000.display-controller`, the device-tree nodes of the rest), and the unit runs when the GPU or the display controller exists, so a DTB with the display but no GPU still gets its display. A load or bind that returns but fails (panthor without `mali_csffw.bin`, say) is logged and skipped, the rest still loads, and the marker is cleared; the unit then ends failed, and `--retry` tries the skipped steps again. Only a boot that hangs in a step leaves the marker: the next boot keeps all six off and says so, and `omamobile-tegu-graphics-start --retry` goes on from the step that failed (on the same boot too: the drivers already loaded stay as they are). Before `gs_decon`, and only when the command line says `exynos_drm.panel_name=google-tg4c`, it turns `gs_dsim_cmd.allow_tx` on, so the panel's DSI commands (brightness, sleep, 120 Hz; kernel #90) go to the panel the bring-up tested and no other: on another panel the display stays read-only at 60 Hz. The display manager waits for it. It also writes `/run/omamobile-tegu-display-card` (the display controller's DRM node by path, since the GPU may take card0) and, when the GPU came up, `/run/omamobile-tegu-gpu-ready.json` | +| `bin/omamobile-tegu-graphics-start` + `vendor/systemd/system/omamobile-tegu-graphics.service` + `display-manager.service.d/10-omamobile-tegu.conf` | `/usr/bin`, `/usr/lib/systemd/system` (enabled by a vendor wants link) | Loads the GPU (panthor), the display controller (gs_decon), haptics (cs40l26_vibra), the torch (leds_lm3644), the battery gauge (max77779_battery), the Bluetooth controller (hci_uart), NFC (nxp_nci_i2c) and Wi-Fi (the PCIe host, `phy_zuma_pcie` and `pcie_gs201` on a node that says `google,zuma-pcie`, else `pcie_zumapro`, then `brcmfmac`, only with the host's node, the Wi-Fi DMA pool and the board's BCM4383 firmware, `updates/brcm/brcmfmac4383-pcie.google,zumapro-tegu.bin` as `tools/extract-vendor-firmware` installs it) at boot, in that order, after writing and syncing a marker. Each step keys on its own device node (`1f000000.gpu`, `19470000.display-controller`, the device-tree nodes of the rest), and the unit runs when the GPU or the display controller exists, so a DTB with the display but no GPU still gets its display. A load or bind that returns but fails (panthor without `mali_csffw.bin`, say) is logged and skipped, the rest still loads, and the marker is cleared; the unit then ends failed, and `--retry` tries the skipped steps again. Only a boot that hangs in a step leaves the marker, and there is one marker for every step: a hang in the last step, Wi-Fi, also keeps the GPU and the display off on the next boot, so a boot with no display after a Wi-Fi hang is this marker, not a display fault. The next boot keeps all of them off and says so, and `omamobile-tegu-graphics-start --retry` goes on from the step that failed (on the same boot too: the drivers already loaded stay as they are). Before `gs_decon`, and only when the command line says `exynos_drm.panel_name=google-tg4c`, it turns `gs_dsim_cmd.allow_tx` on, so the panel's DSI commands (brightness, sleep, 120 Hz; kernel #90) go to the panel the bring-up tested and no other: on another panel the display stays read-only at 60 Hz. The display manager waits for it. It also writes `/run/omamobile-tegu-display-card` (the display controller's DRM node by path, since the GPU may take card0) and, when the GPU came up, `/run/omamobile-tegu-gpu-ready.json` | | `uwsm/env.d/omamobile-tegu-graphics` | `/usr/share/uwsm/env.d` | The session's side of the graphics start, sourced by uwsm (it walks `XDG_DATA_DIRS` too; a user's `~/.config/uwsm/env` runs after it): the KMS device from `/run/omamobile-tegu-display-card`, hardware GL when `/run/omamobile-tegu-gpu-ready.json` exists and llvmpipe otherwise, so a phone whose GPU did not come up still gets a desktop | | `vendor/modprobe.d/omamobile-tegu-guards.conf` | `/usr/lib/modprobe.d` | Keeps those drivers (and the Wi-Fi, PCIe and NFC ones, for the day they are in tree) from autoloading ahead of the guard. No `install` lines: they would break the guard's own modprobe | | `vendor/modprobe.d/omamobile-tegu-display.conf`, `omamobile-tegu-clk-acpm.conf` | `/usr/lib/modprobe.d` | 120 Hz as the ceiling and the panel really off on DPMS (the DSI commands themselves are allowed by the graphics start, for google-tg4c only); the GPU DVFS ceiling at 890 MHz | @@ -39,8 +39,10 @@ runs the package tests in a scratch root (`OMAMOBILE_TEGU_ROOT`), with no phone and no hardware. The package does not mark the boot slot successful (Derek decides how that -works on the 9a), does not start Wi-Fi, NFC, the modem, the charger driver -or the cameras, and carries no vendor files and no per-phone data. +works on the 9a) and does not start the modem. NFC and Wi-Fi come up from +the graphics start when the device tree describes them, and the charger and +the cameras load from the device tree on their own. It carries no vendor +files and no per-phone data. ## What the kernel command line has to stop carrying diff --git a/packages/omamobile-device-tegu/bin/omamobile-tegu-graphics-start b/packages/omamobile-device-tegu/bin/omamobile-tegu-graphics-start index ef55ab99e..7d13670cd 100755 --- a/packages/omamobile-device-tegu/bin/omamobile-tegu-graphics-start +++ b/packages/omamobile-device-tegu/bin/omamobile-tegu-graphics-start @@ -1,7 +1,7 @@ #!/bin/bash # SPDX-License-Identifier: MIT # Bring up the Pixel 9a's GPU, display, haptics, torch, battery gauge, -# Bluetooth controller and NFC at boot, hang-safe. All seven drivers are in the kernel +# Bluetooth controller, NFC and Wi-Fi at boot, hang-safe. All nine drivers are in the kernel # tree and blacklisted for autoload (modprobe.d/omamobile-tegu-guards.conf), # so this script is the only thing that loads them, in this order, after a # marker has been written and synced. Each step keys on its own device node @@ -44,6 +44,9 @@ torch_node=$dt/soc/usi@108b00c0/i2c@108b0000/led-controller@63 bluetooth_node=$dt/soc/usi@155d00c0/serial@155d0000/bluetooth nfc_node=$dt/soc/usi@10c900c0/i2c@10c90000/nfc@8 nfc=$root/sys/class/nfc/nfc0 +wifi_pcie=$root/sys/bus/platform/devices/13120000.pcie +wifi_pool=$dt/reserved-memory/wifi-dma-pool +wifi_fw=$root/usr/lib/firmware/updates/brcm/brcmfmac4383-pcie.google,zumapro-tegu.bin log() { echo "omamobile-tegu-graphics: $*"; } loaded() { [[ -d $root/sys/module/$1 ]]; } @@ -78,7 +81,7 @@ case ${1:-} in esac if [[ -e $marker ]]; then - log "the last start ($(cat "$marker" 2>/dev/null)) never finished; the GPU, display, haptics, torch, gauge, Bluetooth and NFC stay off this boot." + log "the last start ($(cat "$marker" 2>/dev/null)) never finished; the GPU, display, haptics, torch, gauge, Bluetooth, NFC and Wi-Fi stay off this boot." log "after checking the previous boot's log, retry with: omamobile-tegu-graphics-start --retry" exit 0 fi @@ -219,6 +222,42 @@ else log "no NFC with its clock in this DTB; skipped" fi +# Wi-Fi: the PCIe host for channel 1, whose probe brings the link up, then +# the BCM4383 on brcmfmac. The host is the shared zuma-family pair +# (phy_zuma_pcie, then pcie_gs201) when the node says google,zuma-pcie +# (linux-omarchy-mobile#178), else the older standalone pcie_zumapro (#168). +# Only with the host's node, the restricted DMA pool the endpoint needs, and +# the owner's firmware (tools/extract-vendor-firmware). Never unloaded: a +# reboot undoes it. +wifi_host=pcie_zumapro +[[ -f $dt/soc/pcie@13120000/compatible ]] && + tr -d '\0' < "$dt/soc/pcie@13120000/compatible" | grep -c 'google,zuma-pcie' >/dev/null && + wifi_host="phy_zuma_pcie pcie_gs201" +if [[ -e $wifi_pcie && -e $wifi_pool && -e $wifi_fw ]]; then + phase wifi + failed_host= + for m in $wifi_host; do modprobe "$m" || { failed_host=$m; break; }; done + if [[ -n $failed_host ]]; then + skip Wi-Fi "$failed_host failed (see dmesg)" + else + for _ in $(seq 20); do [[ -e $root/sys/bus/pci/devices/0000:01:00.0 ]] && break; sleep 0.25; done + if [[ ! -e $root/sys/bus/pci/devices/0000:01:00.0 ]]; then + skip Wi-Fi "no Wi-Fi endpoint on the PCIe link (see dmesg)" + elif ! modprobe brcmfmac; then + skip Wi-Fi "brcmfmac failed (see dmesg)" + else + wl= + for _ in $(seq 60); do + for d in "$root"/sys/class/net/wl*; do [[ -e $d ]] && wl=${d##*/} && break; done + [[ -n $wl ]] && break; sleep 0.5 + done + if [[ -n $wl ]]; then up+="${up:+, }Wi-Fi ($wl)"; else skip Wi-Fi "brcmfmac brought up no interface (see dmesg)"; fi + fi + fi +else + log "no Wi-Fi host, DMA pool or BCM4383 firmware in this boot; skipped" +fi + finish log "up: ${up:-nothing}" if [[ -n $failed ]]; then diff --git a/packages/omamobile-device-tegu/test/graphics-start b/packages/omamobile-device-tegu/test/graphics-start index ae69a723e..7bd7b74f0 100755 --- a/packages/omamobile-device-tegu/test/graphics-start +++ b/packages/omamobile-device-tegu/test/graphics-start @@ -45,6 +45,8 @@ case $1 in leds_lm3644) mkdir -p "$TEST_ROOT/sys/class/leds/white:torch"; echo "${TORCH_LIT:-0}" > "$TEST_ROOT/sys/class/leds/white:torch/brightness" ;; max77779_battery) mkdir -p "$TEST_ROOT/sys/class/power_supply/max77779-battery"; echo 77 > "$TEST_ROOT/sys/class/power_supply/max77779-battery/capacity" ;; nxp_nci_i2c) mkdir -p "$TEST_ROOT/sys/class/nfc/nfc0" ;; + pcie_zumapro|pcie_gs201) mkdir -p "$TEST_ROOT/sys/bus/pci/devices/0000:01:00.0" ;; + brcmfmac) mkdir -p "$TEST_ROOT/sys/class/net/wlan0" ;; esac echo "$*" >> "$TEST_LOG" EOF @@ -191,4 +193,23 @@ reset; out=$(FAIL_MODULE=nxp_nci_i2c "$script" || true) rm -f "$dt/soc/usi@10c900c0/i2c@10c90000/nfc@8/clocks"; reset; out=$("$script") [[ $(loads) == "$all" && $out == *"no NFC with its clock"* ]] || fail "an NFC node without clocks must be skipped: $(loads)" rm -rf "$dt/soc/usi@10c900c0/i2c@10c90000/nfc@8" +# Wi-Fi: with the host node, the DMA pool and the firmware, pcie_zumapro +# then brcmfmac load last and wlan0 counts as up; a missing endpoint skips it +reset +mkdir -p "$devices/13120000.pcie" "$dt/reserved-memory/wifi-dma-pool" "$OMAMOBILE_TEGU_ROOT/usr/lib/firmware/updates/brcm" +: > "$OMAMOBILE_TEGU_ROOT/usr/lib/firmware/updates/brcm/brcmfmac4383-pcie.google,zumapro-tegu.bin" +out=$("$script") +[[ $(loads) == "$all pcie_zumapro brcmfmac" ]] || fail "Wi-Fi load order: $(loads)" +[[ $out == *", Wi-Fi (wlan0)"* ]] || fail "Wi-Fi summary: $out" +reset; rm -rf "$OMAMOBILE_TEGU_ROOT/sys/bus/pci"; out=$(FAIL_MODULE=pcie_zumapro "$script" || true) +[[ $out == *"pcie_zumapro failed"* && $(loads) != *brcmfmac* && ! -e $marker ]] || fail "a failed host load skips brcmfmac: $out" +# the shared zuma-family host (#178's node): the PHY driver, then pcie_gs201 +reset; rm -rf "$OMAMOBILE_TEGU_ROOT/sys/bus/pci"; mkdir -p "$dt/soc/pcie@13120000" +printf 'google,zumapro-pcie\0google,zuma-pcie\0' > "$dt/soc/pcie@13120000/compatible" +out=$("$script") +[[ $(loads) == "$all phy_zuma_pcie pcie_gs201 brcmfmac" && $out == *", Wi-Fi (wlan0)"* ]] || fail "Wi-Fi on the shared host: $(loads)" +reset; rm -rf "$OMAMOBILE_TEGU_ROOT/sys/bus/pci"; out=$(FAIL_MODULE=phy_zuma_pcie "$script" || true) +[[ $out == *"phy_zuma_pcie failed"* && $(loads) != *pcie_gs201* && ! -e $marker ]] || fail "a failed PHY load skips the host: $out" +rm -rf "$dt/soc/pcie@13120000" +rm -rf "$devices/13120000.pcie" "$dt/reserved-memory" "$OMAMOBILE_TEGU_ROOT/usr/lib/firmware" "$OMAMOBILE_TEGU_ROOT/sys/bus/pci" echo 'ok - graphics-start: marker first, order kept, failures skipped and named, allow_tx for google-tg4c only, --retry works' diff --git a/packages/omamobile-device-tegu/vendor/modprobe.d/omamobile-tegu-guards.conf b/packages/omamobile-device-tegu/vendor/modprobe.d/omamobile-tegu-guards.conf index f81cfa230..51f8604cc 100644 --- a/packages/omamobile-device-tegu/vendor/modprobe.d/omamobile-tegu-guards.conf +++ b/packages/omamobile-device-tegu/vendor/modprobe.d/omamobile-tegu-guards.conf @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Loaded only by the package's hang-safe scripts, in their order, after a -# marker is written: omamobile-tegu-graphics-start (the first six, and -# nxp_nci_i2c for NFC) and, once a kernel ships them in tree, the Wi-Fi start. Blacklisting only +# marker is written: omamobile-tegu-graphics-start (the first six, then +# nxp_nci_i2c for NFC and pcie_zumapro and brcmfmac for Wi-Fi). Blacklisting only # stops udev from autoloading them ahead of the guard; "modprobe panthor" # still works. No "install X /bin/false" lines: those break the guard's own # modprobe. @@ -12,5 +12,7 @@ blacklist leds_lm3644 blacklist max77779_battery blacklist hci_uart blacklist pcie_zumapro +blacklist pcie_gs201 +blacklist phy_zuma_pcie blacklist brcmfmac blacklist nxp_nci_i2c diff --git a/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-graphics.service b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-graphics.service index 944e2b436..f0c3df367 100644 --- a/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-graphics.service +++ b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-graphics.service @@ -1,5 +1,5 @@ # SPDX-License-Identifier: MIT -# The GPU, display, haptics, torch, gauge, Bluetooth controller and NFC at boot, +# The GPU, display, haptics, torch, gauge, Bluetooth controller, NFC and Wi-Fi at boot, # enabled by the vendor multi-user.target.wants link. The drivers are # blacklisted for autoload (modprobe.d/omamobile-tegu-guards.conf), so this # hang-safe script is the only thing that loads them; if a start hangs, the @@ -8,7 +8,7 @@ # ConditionPathExists=| lines are ORed by systemd: a DTB with the display # but no GPU still gets its display. [Unit] -Description=Bring up the Pixel 9a GPU, display, haptics, torch, gauge, Bluetooth and NFC (hang-safe) +Description=Bring up the Pixel 9a GPU, display, haptics, torch, gauge, Bluetooth, NFC and Wi-Fi (hang-safe) After=local-fs.target systemd-modules-load.service Before=display-manager.service ConditionPathExists=|/sys/bus/platform/devices/1f000000.gpu diff --git a/packages/omamobile-device-tegu/version b/packages/omamobile-device-tegu/version index 717903969..abd410582 100644 --- a/packages/omamobile-device-tegu/version +++ b/packages/omamobile-device-tegu/version @@ -1 +1 @@ -0.2.3 +0.2.4