Skip to content

omamobile-gnss 0.2.12: Location after a reboot, and the receiver off when a session ends, on the Pixel 9a - #921

Open
W4HO-ham wants to merge 4 commits into
derekross:mainfrom
W4HO-ham:gnss-wait-for-gnssd
Open

W4HO-ham wants to merge 4 commits into
derekross:mainfrom
W4HO-ham:gnss-wait-for-gnssd

Conversation

@W4HO-ham

@W4HO-ham W4HO-ham commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Three faults in the Pixel 9a's location sessions, found in the same boot runs: two ways a reboot left Location without GNSS, and a receiver that kept running after every session. The first three commits are one fix each; the fourth is from reviewing them again.

1. A request before gnssd is up. gnssd starts some 20 s after the modem is ONLINE (OMAMOBILE_MODEM_GNSS_DELAY). A location request in that window found no @GNSSND, and omamobile-gnss-start exited at once with "nothing to do". GeoClue reconnects at once, so the unit started five times in a second, systemd's start limit failed it, and omamobile-gnss-nmea.socket with it, for the rest of the boot: GeoClue answered "Connection refused" every 5 s and Location stayed dead until it was switched off and on. This is the first request after a boot in my runs on #864.

Now the start waits before it writes the marker, so a give-up leaves nothing behind:

  • While the modem unit is up or starting with OMAMOBILE_MODEM_GNSS=1, it waits for gnssd, 90 s at most, and goes on as soon as it listens.
  • Otherwise it holds the client's connection for 60 s, looking every 5 s whether the modem's unit has started (an early request at boot, or a modem started by hand), and then says "nothing to do". A client that reconnects at once can't run the unit into the start limit; one that keeps asking with the modem off starts the unit once a minute at most.
  • Neither holds the sleep inhibitor (see 4).

2. A reboot during a session. At a reboot, and at the bridge's idle exit, the NMEA bridge stops before the GNSS stack it is ordered after. The 9a's client then wrote NMEA into a FIFO with no reader, SIGPIPE killed it, and the profile stopped itself ("a service exited") before systemd's stop came. With the main process gone, --stop asked for no marker cleanup, so the hang marker stayed and every later boot skipped GNSS ("the last bring-up ... never finished") until --retry: apps got only GeoClue's IP positions, 25 km out. The skip also exited at once, so GeoClue's reconnects hit the socket's trigger limit and failed it for the rest of the boot.

Now the profile spawns the client with SIGPIPE ignored (inherited across the exec; its sed prefixer gets it too, the HAL and the rest don't), so it stays until systemd stops the stack. The stack is ordered after omamobile-tegu-modem.service (ordering only), so at shutdown it stops before gnssd goes. The skip on a leftover marker holds the connection as "nothing to do" does. The marker's rule is unchanged: only a stop systemd asked for clears it.

3. The receiver after a session. The client stops positioning through the HAL (stopNmea, then stop) when it gets TERM, but the runner's stop signals every daemon of the profile at once, and the HAL went before the client's stop reached it. gnssd then kept the receiver running, with the GNSS core streaming over SPI, until the next boot. Found looking for why the palmtop runs warm in a pocket with the screen off.

Now the gnss-slsi profile has a graceful stop (profile_stop, which the runner already calls from the host before systemd signals the daemons, as the 7 Pro's profile has): it signals the client alone, while the HAL is still there, and waits up to 3 s.

That touches the shared runner (lib/omamobile-vendor-chroot, which the modem profile uses too) in one place: profile_stop writes a stop-requested file in the profile's run directory first, and when a daemon's exit wakes the runner with that file there, it stops the rest with 0 and without the line "a service exited". This keeps the log and the exit code right. It is not what clears the marker: under systemd-inhibit the main process ends by the runner's group TERM, which systemd counts as success whether the runner exits 0 or 1, and the marker follows --stop having found the main process alive. A profile that never writes the file behaves as before, and every start removes an old file before it enters its namespaces. If you'd rather no shared code moved for a log line, I'll drop that hunk.

4. The sleep inhibitor (from my own review). The unit ran the whole start under systemd-inhibit, so with the hold of the first commit a 9a with its modem off would have been kept awake by any client that kept asking: a start every 5 s, each under a block inhibitor. The unit now starts the script itself, and the script takes the same inhibitor: at once on the 7 Pro (it re-executes itself under systemd-inhibit, so the 7 Pro's start is under it from the same point as before), and on the 9a only around the session.

On my palmtop

Pixel 9a, Location on, indoors at the same spot, Wi-Fi up. Each boot run: a clean systemctl reboot, then where-am-i -t 240 as the session user as soon as SSH answered, reporting each position's accuracy and GeoClue's description of its source, never a position.

what ran on commit result
1 alone, daily kernel (7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty) da6e36d the unit started at 14.4 s and logged "waiting for gnssd", went on at 36.9 s, positions with no off and on
1 and 2, published kernel (7.3.0-rc6-omamobile-push1-g26867fc4e826, overlays public-ramoops, which only adds the pstore region, and modem-cpif) 4a875b2 the bridge stopped first during a session: clean stop, marker cleared. 28 reboots, each during a session: no boot found a marker; 25 had a GNSS fix ("GPS GGA", 3 m) 75 to 119 s after the boot
the same, daily kernel 4a875b2 16 reboots, a GNSS fix in each, 76 to 114 s after the boot
3, daily kernel, modem up, screen off, cable in with the charger's buck off d12c26a (the same code as 5e92a41) below; then one reboot, with the modem's stop and start clean

The final head (f326aef), 2026-11-20, daily kernel, modem up at boot:

what ran result
8 reboots, a request 18 s into each boot, the next reboot during the session each start logged "waiting for gnssd" and went on when it listened; a GNSS fix ("GPS GGA", under 100 m) in 8 of 8, 69 to 93 s after the boot; the seven reboots a later boot looked back at each stopped their session with the runner's "stopping" and no "a service exited"; no boot found a marker; one sleep inhibitor ("Omarchy Mobile GNSS") during each session
the receiver after a session gnss_spi lines 156 a second during, 0 after the stack stopped and 0 again 90 s later; gnssd's CPU 137 ms a second during, 0 after
a marker left by hand, a client asking for 130 s one start, held, "the last bring-up ... never finished; skipping GNSS"; the marker stayed, the socket stayed active, no inhibitor at any look, only GeoClue's other sources answered; after --retry a GNSS fix in 14 s
the modem off for the boot (its boot unit masked), a client asking for 150 s one start, "gnssd isn't running ...; nothing to do" once, the unit's result success, the socket still active, no marker, no block sleep inhibitor of any kind at any of 15 looks
the modem back, a request with gnssd already listening the session started at once, a GNSS fix 50 s after the request

In the two runs with a client that kept asking, the unit started once in 130 s and once in 150 s, not once a minute: after the give-up GeoClue did not ask the socket again in that time. No failed unit, no UFS error and no oops line in any of these boots.

All of these ran with omamobile-gnss 0.2.11-1 from #864 installed and this branch's files copied over it (for the runner: #864's file with this branch's change).

The 3 boots without a fix in the 28 are not this pull request: where-am-i's own call to start GeoClue timed out after 25 s, each time with the request about 16 s into the boot, and GeoClue's log stops after its start. Cause open; it hasn't recurred in the 36 boots since.

After a session ended and its stack had stopped (three 60 s means for the drain):

before 3 with 3
gnss_spi lines in the log 171 a second (a bring-up kernel's debug print) 0
gnssd's CPU 86 ms a second 0
drain 400, 406, 418 mA 298, 303, 288 mA

A fresh boot with gnssd idle read 317, 301, 309 mA, and the modem without gnssd 304, 327, 304 mA: gnssd costs nothing until a session.

Tests

test/all runs the start with stand-ins for systemctl, systemd-inhibit and the runner:

  • A request with no gnssd and no modem gives up after the hold and not later; a stopped modem unit and a modem without GNSS aren't waited for (upper bounds); a modem bringing gnssd that never comes gives up after the wait; gnssd appearing during the wait starts the session at once; a modem that starts during the hold is seen and waited for.
  • Every give-up leaves no marker, no session file and takes no inhibitor; the 7 Pro's start and the 9a's session take it once.
  • A leftover marker skips GNSS after the hold and stays.
  • The profile ignores SIGPIPE for the client's spawn only; profile_stop writes the stop-requested file before the client gets its signal; the runner's own stop and supervision lines, run under setsid, end with 0 and no "a service exited" with the file and as before without it.

Seventeen mutations of the new code (the three you'd expect of gnssd_coming, the hold and the wait removed, the inhibitor moved, the marker written early, the file written after the signal, the runner's check made a no-op or unconditional, the SIGPIPE lines moved or removed, the ordering removed) each fail the suite with a FAIL line. tests/all and tools/pr-check origin/main pass.

Not run

Only omamobile-gnss changes. The version is 0.2.12 and assumes #864's 0.2.11 lands first; only version conflicts with #864, and I'll rebase when it lands.

…r it on the Pixel 9a

The 9a's gnssd starts some 20 s after the modem is ONLINE (OMAMOBILE_MODEM_GNSS_DELAY). A location request in that window found no @GNSSND, and omamobile-gnss-start exited at once with "nothing to do". GeoClue reconnected at once, so the unit started five times in a second; systemd's start limit then failed it, and omamobile-gnss-nmea.socket with it, for the rest of the boot. GeoClue answered "Connection refused" every 5 s and Location stayed dead until it was switched off and on (derekross#864, the first request after a boot).

Now, when the modem unit is up or starting with OMAMOBILE_MODEM_GNSS=1, the start waits for gnssd, 90 s at most, and goes on as soon as it listens. Where gnssd won't come (the modem off, or started without GNSS), the start still says "nothing to do", but holds the client's connection 5 s first, so a client that reconnects at once can't run the unit into the start limit.

Tested: test/all gains four cases with a stand-in systemctl: no gnssd and none coming gives up after the hold; a modem without GNSS doesn't wait; a modem bringing gnssd that never comes gives up after the wait; gnssd appearing during the wait starts gnss-slsi.

On a Pixel 9a after a clean reboot, a where-am-i request at 5 s of uptime, before the modem unit had started: the start logged the wait at 14 s, went on at 37 s as gnssd listened, and the first position came at 63 s, with no off and on and nothing at the start limit.
…eaves GNSS off on the Pixel 9a

At a reboot, and at the bridge's idle exit, the NMEA bridge stops before the GNSS stack it is ordered after. The 9a's client then wrote NMEA into a FIFO with no reader, SIGPIPE killed it, and the profile stopped itself before systemd's stop came: an unexpected exit, so the hang marker stayed, and every later boot skipped GNSS ("the last bring-up ... never finished") until --retry, leaving apps only GeoClue's IP positions. The skip also exited at once, so GeoClue's reconnects hit the socket's trigger limit and failed it for the rest of the boot, and a request after --retry found nothing listening.

Now the profile spawns the client with SIGPIPE ignored, so it stays until the stack is stopped; the stack is ordered after the 9a's modem unit, so at shutdown it also stops before gnssd goes; and the skip holds the connection 5 s, as "nothing to do" does.

Tested: test/all checks the client's SIGPIPE disposition around its spawn, the ordering and the hold on a leftover marker. On a Pixel 9a on the published kernel, with the bridge stopped first during a session, the stack stopped cleanly and the marker went; then 8 reboots, each with a session running at the reboot, left no marker, where before the fix 4 of 8 boots skipped GNSS after the first such reboot.
@W4HO-ham W4HO-ham changed the title omamobile-gnss 0.2.12: a location request before gnssd is up waits for it on the Pixel 9a omamobile-gnss 0.2.12: Location works after a reboot on the Pixel 9a Nov 19, 2026
W4HO-ham added a commit to W4HO-ham/omarchy-mobile that referenced this pull request Nov 19, 2026
…pt-in), with the runs on the published branch

Location now works whenever the modem is up, and the modem's start at boot is opt-in for the reason the Modem cell names, so the cell takes the same form as the Modem and Suspend cells. The record has the runs on the published omamobile at 26867fc4e with derekross#864 and derekross#921: a GNSS fix in 25 of 28 boots from a request made before gnssd was up, each reboot made during a session, none skipping GNSS; GeoClue's own start stalled in the other 3, cause open; and five switch-offs and -ons with a fix 7.5 to 9.4 s after each request.
@W4HO-ham W4HO-ham changed the title omamobile-gnss 0.2.12: Location works after a reboot on the Pixel 9a omamobile-gnss 0.2.12: Location after a reboot, and the receiver off when a session ends, on the Pixel 9a Nov 19, 2026
…tion session ends

The client stops positioning through the HAL (stopNmea, then stop) when it gets TERM, but the runner's stop signals every daemon of the profile at once, and the HAL went before the client's stop reached it. gnssd then kept the receiver running, with the GNSS core streaming over SPI, until the next boot: after any location request, gnssd used about 10 % of a core and the kernel's SPI driver on a bring-up kernel logged over 100 lines a second.

Now the gnss-slsi profile has a graceful stop (profile_stop, which the runner calls from the host before systemd signals the daemons): it signals the client alone, while the HAL is still there, and waits up to 3 s. A stop-requested file in the profile's run directory, written first, tells the runner that this exit is part of the stop, so it stops the rest cleanly instead of reporting "a service exited", and the hang marker's clean-stop rule still holds. A new start removes an old file.

Tested: test/all runs profile_stop with a stand-in client and checks the file, the signal and the runner's clean-stop line. On a Pixel 9a after a session: before the change, gnss_spi logged 171 lines a second and gnssd used 86 ms of CPU a second after the stack had stopped, and the drain with the screen off was 408 mA against 309 mA after a fresh boot; with it, both fell to 0 when the stack stopped, the marker cleared, and the drain read 296 mA.
@W4HO-ham
W4HO-ham force-pushed the gnss-wait-for-gnssd branch from d12c26a to 5e92a41 Compare November 19, 2026 09:49
…nhibitor, and the hold watches for the modem

Reading my own three commits again: with the modem off, the 5 s hold made the unit start every 5 s for as long as a client asked, each time under the unit's sleep inhibitor, so a 9a with no modem was kept awake by a position it couldn't have.

The unit now starts the script itself and the script takes the inhibitor: at once on the 7 Pro, as its unit always did, and on the 9a only around a session. The hold is 60 s and looks every 5 s whether the modem's unit has started, then waits for its gnssd; a client that keeps asking with the modem off starts the unit once a minute, not kept awake. The wait reads /proc/net/unix with a builtin.

The stop finds the client with pgrep -o (procps-ng is now a dependency), and the unit's comment says which unit stops first.

Tests: the "doesn't wait" cases have upper bounds, a give-up is checked to leave no marker, session or inhibitor, the stop-requested file is checked to exist when the client gets its signal, and the runner's own stop and supervision lines are run with and without the file. Seventeen mutations of the new code each fail the suite with a FAIL line. Not yet run on a phone.
@W4HO-ham
W4HO-ham marked this pull request as draft November 19, 2026 20:58
@W4HO-ham
W4HO-ham marked this pull request as ready for review November 20, 2026 00:52
W4HO-ham added a commit to W4HO-ham/omarchy-mobile that referenced this pull request Nov 20, 2026
…s#921's final head, and the GeoClue stall's cause

Eight more boots on the published kernel with derekross#921's final head had a GNSS fix
in seven; the eighth was GeoClue's start stall again, and this time its
backtrace was taken. It is a lock-order deadlock between GLib's VFS and proxy
resolver setups, reproduced without a boot (7 of 80 cold starts) and gone with
GLib's built-in resolver (derekross#942). The record no longer calls the cause open, and
says which overlay isn't in the tree.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant