Skip to content

omamobile-modem-sit: a second start in the same boot gets data and IMS back - #376

Draft
W4HO-ham wants to merge 25 commits into
derekross:mainfrom
W4HO-ham:tegu-sitd-restart
Draft

W4HO-ham wants to merge 25 commits into
derekross:mainfrom
W4HO-ham:tegu-sitd-restart

Conversation

@W4HO-ham

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

Copy link
Copy Markdown
Contributor

Stacked on #374 (and through it #372, #371, #367 and #364); this PR's own change is the top commit.

Restarting omamobile-sitd (after a package update, say) failed straight away on the palmtop. First the LTE-only change refused because its saved original was still in /run. Then the bearer guard refused because the earlier run's records were still there, even though the modem had dropped those bearers when sitd stopped.

Now the LTE-only change is skipped when it's already made this boot; any other value still refuses. At start-up, the bearer and IMS registration records are cleared, but only when the modem lists no bearer at all. If it lists one, nothing is touched and the guard refuses as before.

On the palmtop a restart now comes back with mobile data and signal strength. IMS doesn't register again yet: the modem's IMS stack was never told the old session ended, so calls and SMS still need a reboot after a restart. That's the next step.

Tests: tests/packages omamobile-modem-sit (new tests for both changes), tools/pr-check.

@derekross

Copy link
Copy Markdown
Owner

Direction for this one is in my comment on #374, which covers #374, #375, #376, #378 and #380 together.

@W4HO-ham W4HO-ham changed the title omamobile-modem-sit 0.3.18: a second start in the same boot gets data back omamobile-modem-sit: a second start in the same boot gets data and IMS back Nov 3, 2026
@W4HO-ham
W4HO-ham force-pushed the tegu-sitd-restart branch 2 times, most recently from 7fdccbe to adf091d Compare November 3, 2026 14:04
@W4HO-ham

W4HO-ham commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Re-tested after the rebase (palmtop, daily kernel, sitd 0.3.36, this branch): it fails, as you expected. With the radio already on, start-up no longer cycles it, the modem still lists the earlier start's internet and IMS bearers, clear_stale() correctly leaves them alone, and activate() refuses ("existing target or unresolved bearer ownership"). A reboot brought everything back. Next: when the modem lists exactly the bearers our confirmed records own, release them in order (DelPdnInfo for IMS, then deactivate both, with the host data configuration down first) and set up again. Anything unconfirmed or unknown still refuses. I'll push that with tests and re-test on the palmtop before asking for review again.

@W4HO-ham

W4HO-ham commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Fixed and re-tested on the palmtop (2026-11-03, the daily kernel 7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty, this branch's top): systemctl restart omamobile-sitd with the modem up and the radio on. The journal reads: registered 0.1 s after start-up (the radio was already on), "IMS PDN notification removed", both bearers deactivated, "released the earlier start-up's bearers", new internet and IMS setups, then "IMS registration indication: state 2 (VoLTE registered)" and "Calls and SMS service ready", all within about a minute and without a reboot. The new commit: when the modem lists exactly the bearers our confirmed records own, start-up releases them (IMS first, DelPdnInfo then its bearer) and sets up again. A bearer we don't own, a missing one or an unconfirmed record still refuse; tests cover each. The no-bearers path (clear_stale) stays for a modem that dropped them.

Select the TAS2572 route only for google,tegu-aoc-snd-card. Save the
controls, verify sink mute, configure the stock microphone/TDM routes,
and start EP4 capture and EP5 playback as mono S16_LE at 8 kHz with
80-frame periods and two periods. Applying ALSA hardware parameters
prepares each PCM once; do not prepare the modem stream twice.

After PCM startup resets the amplifier profile, set both TAS digital
gains to index 180 (-20 dB) and verify read-back before unmuting. A gain
refusal unwinds the route and leaves call signalling available. Close
PCMs before restoring controls, keep mute on cleanup failure, and retain
the cheetah CS35L41 route and the default card=none configuration.

Add fake-ALSA fault tests and the voice-window audit. The existing SRAM
reservation is retained; no CPU mapping or phone operation is added.
Outgoing and incoming speakerphone calls with audio both ways, first on the daily kernel and then on in-tree drivers from the open kernel PRs, where data and a text ran too. The Modem cell says so, and what's left: echo cancellation, an earpiece, the modem's start at boot and the kernel PRs' merge.
Trace the existing app, session agent, ModemManager-compatible bridge and sitd path. Record the tegu installation and unit prerequisites still missing on main, and an attended bridge-only test that preserves the running modem stack.

Document the passing offline bridge and apps package suites, activation and audio limits, and the eventual board-specific image integration.
Keep sitd's canonical name while moving the modem dependency into device-owned policy drop-ins. Tegu checks an already running modem and CP ONLINE; cheetah and raven retain their existing starter relationship. Require the device policy capability during RIL upgrades.

Add an opt-in telephony package with a bridge policy and attended helper. It checks live sitd readiness, refuses legacy unit shadows and competing managers, and starts only mmd and the graphical user's agent. The service recovery check permits live calls and registration loss; no helper enables or recovers the modem.

Remove mmd's service-level conflict so a bridge start cannot stop another modem manager. Package exclusion and D-Bus name ownership remain. Retain the previously developed SIM, safe-release and audio changes in this stack.

Validate the helper, dependency policies and composed units offline; run all seven affected/dependency package suites and build the new architecture-independent package without installing dependencies.
…start the bridge, and a plan that reads as one

Record the palmtop run of Phone and Messages (kernel, versions, what passed, and that opening an app didn't start the agent), say which start fits which case, cite derekross#363 instead of a branch, and drop the lines that read like a task report.
…in 0.1.3, with this pull request

The plan and the README dated the removal of the unit's Conflicts=ModemManager.service to mmd 0.1.1, and the bullet above still listed it as built; this pull request is what removes it, in 0.1.3.
…WantedBy and tmp.mount, and a refusal isn't retried

With derekross#372's boot unit on and this package installed, the bridge's ExecStartPre refused every start: sitd wanted omamobile-mmd.service (the bridge's own WantedBy, once enabled) and both units wanted tmp.mount (systemd adds it). Neither pulls the RIL or the CP into a start, so both are allowed now. A refusal of --service-check exits 3, which the drop-in names in RestartPreventExitStatus=, so a refused bridge stays down instead of retrying every five seconds.
…ot, opt-in

The 9a's modem only started by hand, from a bring-up script outside the package. omamobile-tegu-modem-up is now packaged: the kernel's own CP drivers when it has them, else the bring-up modules; the NV check, then a sleep inhibitor, then the drivers; a latch written before the drivers and cleared at CP ONLINE, so a start that never got there stops later boots until a human looks; the once-per-boot refusal; and with --phone the phone service and, when installed, the Phone and Messages bridge. omamobile-tegu-modem-boot.service runs it at boot, installed but never enabled by the package. A scratch-root test covers the driver choice, the order, the latch and the refusals.
… CP drivers load

The profile's check also wants CPIF's ports, so before the drivers it refused ("the CPIF port is not loaded") and the first boot start on the palmtop failed there. It runs after the drivers again, as the bring-up script had it; the inhibitor and the latch still come before any driver.
…dem latch until a clean shutdown, and the 9a's screen-on at start

The latch was cleared as soon as the CP reached ONLINE, so a hang or reset after that would have started the modem again at every boot. It now stays until the modem profile's unit stops cleanly at shutdown (an ExecStopPost that runs only when the unit's result is success), and the next boot refuses while it's there, as TELEPHONY-PLAN 2.4 plans. The start also refuses a pcie_gs201_cp already loaded without allow_hw, as omamobile-modem-start does, and waits with wait-online instead of reading the state once a second.

The screen-on that makes the 9a's modem send signal reports is now set only by tegu's sitd drop-in (OMAMOBILE_SIT_SCREEN_ON_AT_START), so the 7 Pro's start-up is unchanged; derekross#381 already decodes the reports.

The README and the boot unit give the order, the preconditions (slot B marked successful, a kernel with linux-omarchy-mobile#172, the charger for the first boots) and the rollback; the test checks the latch is on disk before any driver loads, that it stays past ONLINE, and the allow_hw refusal.
… says the modem starts

The boot unit's 300 s timeout could run out while the start waited for sitd to register, and the bridge would never start. The start now queues sitd and the bridge (ordered after sitd) without waiting. The 9a's DEVICES cell no longer says the package doesn't start the modem: its opt-in boot unit does.
… the next boot its modem

reboot-to (and so bin/omamobile push) skips the clean stop that removes the latch, so the next boot refused the modem as if the last one had hung (derekross#390). The latch now names its boot and records ONLINE, and a latch from a boot that reached ONLINE and ended with reboot-to (its note, derekross#403) is cleared with the note. A start that never reached ONLINE, or a note for another boot, still refuses.
…y's Location switch

omamobile-gnss serves fixes only when the modem profile runs gnssd (OMAMOBILE_MODEM_GNSS=1), and the boot start didn't ask for it, so every Location request found no gnssd and the service hit its start limit. The boot unit now runs omamobile-tegu-modem-up --phone --gnss. The daily kernel keeps the PERIC0 GPIO bus clock critical, as linux-omarchy-mobile#172 does, so the modem's GNSS traffic can't hang the palmtop.
With the modem, the phone service and the bridge started at boot (this PR) the 9a's calls, texts and data need nothing by hand, and with gnssd started alongside, a session through Omarchy's Location switch had 133 of 135 GGA sentences fixed after a reboot (2026-11-03, first fix 48 s, 18 satellites). Both cells say works, with what's still open: the speakerphone echo, no earpiece route yet, and the in-tree kernel drivers in review.
Two reboots on the palmtop with the boot unit enabled, the NV check, the UFS count after a shutdown with the CP up and a phone-smoke report, as Derek asked before the README tells anyone to enable it.
…s again

The status words added in derekross#360 left each item's old sentence hanging after them. Each item now says what derekross#372 does and what is still the target, in whole sentences.
The profile unit's ExecStopPost removed the latch only when SERVICE_RESULT was success, and at a shutdown it never is: the CP's power-off in ExecStop ends rfsd or cbd before systemd's SIGINT, so the profile's supervisor exits 1. On the palmtop on 2026-11-03 a systemctl reboot with the modem up left the latch, and the next boot refused the modem. ExecStopPost now runs omamobile-tegu-modem-up --stopped, which removes this boot's latch once the start reached ONLINE, whatever the result, as omamobile-modem-start --stopped does on the Pixel 7 Pro. A hang or a reset never reaches it, so those still refuse the next boot.
…SS testing until the default, the latch's stop as it is now

DEVICES reserves works for on by default, and the boot unit is opt-in, so Modem and GNSS read testing until the follow-up that turns it on after kernel derekross#187. The latch is described as removed by the profile unit's stop at shutdown, the README gives the unit's --phone --gnss and says the reboot-to path is under test, and section 2.7 records the reboot that left the latch and the re-run on the fixed script.
…k and the reboot-to path passed (2.7)

The radio backup check after the day's reboots read every NV partition the same, and a reboot-to with the CP ONLINE cleared its latch and brought the modem back on its own at the next boot.
…audio

Stage the owner-provided APMg3 uplink and downlink protobufs through the AoC output tuning services, confirm bounded acknowledgements, and refuse another tuning attempt after an unknown outcome. Set the speaker echo reference before capture and disable AEC during confirmed cleanup.

Add a conservative top-speaker route with bottom attenuation and gain readback. Keep the complete amplifier profile 0: the examined native voice-handset case is a power-state delta, and the AoC sink bitmap controls are read-only. Document the distinction from stock voice/EM control and the attended qualification gate.

Extract six speaker/handset tuning files from the owner image, with synthetic extraction and service-record tests. Defaults leave tuning and call audio disabled; no phone trial is claimed.
…S back

Restarting omamobile-sitd failed at once on what the earlier run left in /run/omamobile-sit, though the modem had dropped its bearers when that sitd stopped. Now, after registration and before any setup, sitd clears the earlier start's bearer records, the IMS registration and the record of the modem's own bearers, but only when the modem lists no bearer at all, and only records whose setup had a confirmed outcome. An unanswered reservation stays, so activate() refuses and the start waits for a reboot. If the IMS registration was cleared, sitd sends stock's DelPdnInfo for the old PDN first, so the modem's IMS stack registers again. The LTE-only check also refuses a damaged saved original.

On the palmtop a restart got data and signal back (2026-11-02); IMS with the withdrawal hasn't run yet. The sitd unit's comment, MODEM-CLIENT and MODEM-PLAN now describe a second start-up after a clean stop; after a failed one, reboot.
… start's bearers

A start-up no longer cycles a radio that is already on, so after a sitd restart the modem still lists the earlier start's internet and IMS bearers, the stale-record cleanup rightly leaves them, and activate() refused (the palmtop, 2026-11-03). When the modem lists exactly the bearers our confirmed records own, start-up now releases them, IMS first (DelPdnInfo, then its bearer), and sets up again. A bearer we don't own, a missing one or an unconfirmed record still leave it to activate() to refuse, and a release that fails stops the start for an attended reboot.
… bring-up tests

The bring-up tests added with derekross#373 run start() with a client that answers SIM requests only, so the restart cleanup's bearer list failed to parse. They now stub clear_stale and release_owned, as the other bring-up tests do.
@derekross

Copy link
Copy Markdown
Owner

@W4HO-ham, a status note on this one, plus two small things I noticed going
through the restart change again. No hurry, since it's a draft.

First, main has moved under the chain: #367 landed as modem-sit 0.3.31, and
DEVICES and device-raven have changed since. This branch now conflicts in
docs/DEVICES.md, device-raven's version, modem-sit's voice_audio.py,
test_voice_audio.py and version, and tests/all. It still carries #367's
original commit and earlier copies of #371 and #372, so it needs a rebase
onto main and the current #372 and #374 before it leaves draft.

Second, the 7 Pro. modem-sit runs there at every boot, so this changes it
too. A first start in a boot is unchanged in effect: it makes two more
read-only data-call list requests and finds no records. A second start after
a clean stop is new on the 7 Pro, though: today it refuses and asks for a
reboot, and with this it releases the earlier bearers and sets up again. That
has only run on the 9a. Either is fine with me:

A small one either way: release_owned() sends its data-call list request
before it checks whether we own any records, so returning early when
owned_ids() is empty saves the first-start request.

Third, the docs. The 7 Pro's MODEM-PLAN now says a second start-up after a
clean stop "sets up again". That's what I asked for, but it reads as a 7 Pro
result. Could it say "on the 9a; not yet run on the 7 Pro" until my run (or
until the gate makes it 9a-only)? MODEM-CLIENT also still says IMS after the
withdrawal hasn't run, while your 11-03 test registered VoLTE after a
restart. Please record that run there, with its uname -r.

The rest is as before: the 9a's tools/phone-smoke report, and I'll set the
version at merge.

The commits under this pull request's own are on main now in their merged form (derekross#356 to derekross#372, derekross#590), so the result is today's main plus this pull request's own commits, replayed on it; only version files conflicted, and they keep main's numbers.
@derekross

Copy link
Copy Markdown
Owner

A status note, since this has sat for a while and main has moved a long way under it. No hurry: it's a draft.

First, to be clear about the rule this sits next to: AGENTS.md forbids restarting the modem in a boot, meaning the modem unit and the CP under it. This change is about the phone service on a CP that stays ONLINE, and nothing in it stops, starts or powers the modem, so it is on the allowed side. I'd like the files to say that in so many words, in the unit's comment and in MODEM-CLIENT: a second start of the phone service after a clean stop is supported; the modem unit is still never restarted in a boot.

What I'd like before it leaves draft:

  1. Rebuild it on main by itself. omamobile-telephony-tegu: Phone and Messages on the Pixel 9a through omamobile-mmd (stacked on #367 and #363) #371 and omamobile-device-tegu 0.2.12: start the Pixel 9a's modem and phone service at boot, opt-in #372 have merged and omamobile-modem-sit: opt-in 9a call tuning upload and earpiece audio #374 is going to narrow, so the stack under this is gone; the branch still carries an old copy of omamobile-modem-sit: opt-in 9a call tuning upload and earpiece audio #374's files and conflicts in four places. In lib/paths.py main's side must stay as it is (its follow_screen default is what the 7 Pro's sleep with the modem up reads); this change doesn't need that file at all.
  2. The 7 Pro question from the 8th is still open: a device flag in tegu's sitd drop-in so the 7 Pro keeps "refuse, reboot" for now, or every phone, with a restart on my 7 Pro first. Since the 7 Pro now sleeps with the modem up by default, Please make it the flag; the other phones can follow once it has run there.
  3. The records. The 3 November restart (VoLTE registered again within a minute) is only in this thread; it belongs in the 9a's plan as a dated result with uname -r, next to the plan's "no automatic CP or sitd restart" line, saying what an attended restart after a clean stop is. The 7 Pro's MODEM-PLAN should say "on the 9a; not yet run on the 7 Pro", and MODEM-CLIENT still says IMS after the withdrawal hasn't run.
  4. One way of bringing IMS back. omamobile-modem-sit 0.3.44: an IMS bearer the network ended no longer blocks the internet bearer's reconnect #881 (den-kloot) found the network ending both bearers at once on a 9a, with sitd running; his fix clears the IMS record so data returns, and he plans a follow-up for IMS itself. Your withdraw_stale() (DelPdnInfo, then register again) is that step. Could the two of you agree where it lives, so we don't get it twice?
  5. A run from the rebuilt head on the palmtop: attended, on the charger, the restart, IMS registered again, then the modem stopped and systemctl reboot; with the tools/phone-smoke report.

Small: release_owned() still asks the modem for its list before it checks whether we own anything.

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.

2 participants