Skip to content

omamobile-shell 0.2.32: the NFC tile really switches NFC - #78

Merged
derekross merged 1 commit into
derekross:mainfrom
W4HO-ham:shell-nfc-rfkill
Oct 27, 2026
Merged

derekross merged 1 commit into
derekross:mainfrom
W4HO-ham:shell-nfc-rfkill

Conversation

@W4HO-ham

@W4HO-ham W4HO-ham commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

On the palmtop, the NFC tile's "off" left the radio polling. There were two reasons:

omamobile-nfc-open now follows NFC's rfkill switch. On a block it powers the adapter off through neard. On an unblock it restarts neard, which finds the adapter again, powers it (DefaultPowered), and polling resumes. The service also starts from a fresh neard, so a stale view from before it ran can't leave NFC unpowered.

Tested on the palmtop with the fixed nfc.ko. I counted the controller's interrupts over 5 s after each step: about 65 while polling, 0 when blocked, polling again after each unblock. That held over three block and unblock cycles and a restart of the service. I tested only with #71 applied. Without it, the block depends on neard stopping its own poll when it powers the adapter off, which I haven't verified.

test/all gained two checks. Locally, everything passes except the known Switcher.qml parse on a laptop whose qmlformat is Qt 5's (#67). tools/pr-check passes.

Kernel for the counts above: 7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty on the Pixel 9a (the integration kernel, with kernel #71).

@derekross

Copy link
Copy Markdown
Owner

Thanks, the diagnosis is right: on my Pixel 7 Pro the tile's "Off" has been a no-op for the same reason, and neard is never told when the kernel takes the radio down. The gate and the package test pass. Two things need changing before this can go in, one of them because of how systemd treats the service's own unit.

  1. systemctl restart neard from this service restarts the service itself, and it loops. omamobile-nfc-open.service has Requires=neard.service, and systemd.unit(5) says of Requires=: "this unit will be stopped (or restarted) if one of the other units is explicitly stopped (or restarted)". So each restart_neard() (at every start when NFC is unblocked, and at every unblock) also restarts omamobile-nfc-open; the new instance sees NFC unblocked, restarts neard again, and so on. I reproduced it on my laptop with two user units standing in for the pair (a sleep as neard, a script that restarts it from inside, with Requires= and After=): five cycles in 180 ms, then Start request repeated too quickly, neard's stand-in Failed with result 'start-limit-hit' and the dependent Job … failed with result 'dependency'. Upstream's neard.service sets no start limit, so the default of 5 starts in 10 s applies to neard itself. On a phone each cycle is slower, so it ends either there, with neard failed and the service dead, or with neard restarted every couple of seconds for as long as NFC is on. Polling comes back in both cases only because neard's DefaultPowered and ConstantPoll re-power the adapter after each restart. Could you check journalctl -b -u neard -u omamobile-nfc-open on your phone? I expect to see neard started many times.

    This matters on the Pixel 7 Pro at every boot: my device setup enables omamobile-nfc-open, st-nci binds at boot and the switch is unblocked, so main() takes the restart branch and tag links would stop working here.

    The fix is Wants=neard.service in place of Requires= (same pull-in and ordering, no restart propagation; the service talks to neard by bus name and survives its restart). With that, the unconditional restart at start costs one extra neard start per boot; I can live with that, or skip it when the service starts within a few seconds of neard. A test line that fails while Requires=neard and restart_neard coexist would catch it coming back.

  2. Version: Suspend tier 1: auto-sleep on screen-off (off by default), Power wakes, and three bugs found on the phone #64 (open, mine) already takes omamobile-shell to 0.2.29, and my phone runs it. Please make this 0.2.30, in the title too, once Suspend tier 1: auto-sleep on screen-off (off by default), Power wakes, and three bugs found on the phone #64 has landed; I'll merge in that order.

Then kernel #71 lands right after this one, since each is only half a fix without the other (without #71 the block leaves neard polling; without this the unblock powers nothing), and I'll run one block/unblock cycle on the Pixel 7 Pro before calling it done. The kernel release (uname -r) your interrupt counts came from would be good to have in the description.

@W4HO-ham W4HO-ham changed the title omamobile-shell 0.2.29: the NFC tile really switches NFC omamobile-shell 0.2.30: the NFC tile really switches NFC Oct 27, 2026
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

You're right, thanks for reproducing it. Pushed, rebased onto main after #64:

  1. Wants=neard.service in place of Requires=, with a comment saying why. The package test now fails if Requires=neard comes back while the service restarts neard. I checked that it fails with the old line. The startup restart stays as it is (one extra neard start per boot). The 9a didn't show the loop because its bring-up runs this as a transient unit without Requires=: journalctl -b -u neard shows two starts this boot, the initial one and the service's restart.
  2. Now 0.2.30, in the title too.

The kernel release for the interrupt counts is in the description.

@derekross

Copy link
Copy Markdown
Owner

Thanks, this is exactly the fix. I re-ran my two-unit test with your new unit line. With Wants= the dependent started once, neard's stand-in twice (its own start plus the service's restart, just as your 9a journal shows), and nothing hit a start limit. A neard restart from outside, like an unblock, left the service running with the same PID. With Requires= put back, the same test still loops into start-limit-hit, and your new package test fails on it. So the guard works. The gate and the shell package's tests pass on the branch merged onto today's main, and thanks for adding the kernel release to the description.

I'm sorry, but one thing moved under you: my touch batch 4 (#90) landed today as omamobile-shell 0.2.30, after you'd rebased. Git merges your version file without a word because both sides say 0.2.30, but the two packages would share a version with different contents. My next shell batch is already on 0.2.31, so could you make this 0.2.32, in the title too? Then I'll merge it, kernel #71 straight after, and run one block/unblock cycle of the tile on my Pixel 7 Pro.

The tile blocks NFC through rfkill, but neard isn't told when the kernel takes the radio down, and the kernel refused to take it down at all while polling (kernel PR derekross#71). Now omamobile-nfc-open follows the rfkill switch: a block powers the adapter off through neard, an unblock restarts neard so it powers the adapter again and polling resumes, and the service starts from a fresh neard.

The service pulls neard in with Wants=, not Requires=: with Requires= its own neard restart would restart it too, and the new instance would restart neard again, until neard hit its start limit. The package test fails if Requires=neard comes back.
@W4HO-ham W4HO-ham changed the title omamobile-shell 0.2.30: the NFC tile really switches NFC omamobile-shell 0.2.32: the NFC tile really switches NFC Oct 27, 2026
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

No problem. It's 0.2.32 now, in the title and the commit, rebased onto today's main after your #90. The shell package test passes.

@derekross

Copy link
Copy Markdown
Owner

Thanks for the quick bump. 0.2.32 is free (main is on 0.2.30 and my next batch on 0.2.31), and nothing else changed since I last looked. On the branch merged onto today's main, the gate and the shell package's tests pass, and my two-unit test gives the same result as before. I'm merging this now. Next I'll put kernel #71 on my Pixel 7 Pro and run the tile check, and merge #71 after it.

@derekross
derekross merged commit 16a6f30 into derekross:main Oct 27, 2026
2 checks passed
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