Skip to content

AGENTS: on the 9a, NFC needs the ST54L's NFC mode on (linux-omarchy-mobile#131), not a power-off hook - #137

Merged
derekross merged 6 commits into
derekross:mainfrom
W4HO-ham:agents-tegu-nfc-power
Oct 30, 2026
Merged

derekross merged 6 commits into
derekross:mainfrom
W4HO-ham:agents-tegu-nfc-power

Conversation

@W4HO-ham

Copy link
Copy Markdown
Contributor

The follow-up you asked for on #131. The 9a gotcha now says what #132 found: after an s2idle wake, NFC stays dead until neard powers the adapter off and on, so the hook should power it off, not only stop polling. It also says the power-off version isn't proven. In its first RTC test on the palmtop (2026-10-28) the palmtop didn't wake, and I don't know why yet, so the next try is attended.

After an s2idle wake the ST54L has lost its NCI state until neard powers the adapter off and on (derekross#132), so the sleep hook should power it off rather than only stop polling. The first test of that hook didn't wake, so it stays attended.
@derekross

Copy link
Copy Markdown
Owner

Thanks, @W4HO-ham, for turning the #131 follow-up around so quickly. I checked the new text against #132 and your NOTES entry on #131, and it matches what you reported: the Error -6 on the first send, the NCI timeouts after it, the power off and on that brings it back, and the hook's first RTC test not waking. It's good that the entry says plainly that the power-off version isn't proven and should be tested attended. The policy checks pass. The red Tests job isn't caused by this PR: the CI runner picked up a new simdjson that today's nodejs wasn't built against (libsimdjson.so.34: cannot open shared object file), so every PR from about 01:50Z failed the two Node-based package tests. I'll fix the runner and re-run the job.

A few changes before it merges:

  1. Say which hook to run until the new one is proven. As written, "So the hook should power the adapter off before the sleep and on after it" reads as an instruction. The stop-poll hook has woken 35 times out of 35. The power-off hook is at 0 out of 1. Someone following AGENTS.md could switch to the version that hasn't woken yet. Could you put it the other way round? Keep the stop-poll hook for now, and describe the power-off hook as the candidate under test, to be tried attended.

  2. A power-off hook has to stop the poll loop first and check that the power-off took effect. neard's Powered = false goes straight to the kernel as a device-down (set_powered() → __near_netlink_adapter_enable() → NFC_CMD_DEV_DOWN in neard 0.20). nfc_dev_down() in net/nfc/core.c returns -EBUSY while the device is polling or has an active target. So if the hook powers off without stopping the poll loop first, the power-off fails, and the phone suspends with NFC still polling, which is the very case that reset the palmtop on 10-27. I don't know what your hook does, so this is a question and not a diagnosis of the 10-28 run. Still, it's worth checking the hook's log from that run for a "Device or resource busy" error. Either way, the gotcha should say: stop the poll loop, power off, check that Powered reads false, and only then let the sleep go ahead. (nfc: stop polling before taking the device down on an rfkill block linux-omarchy-mobile#71 fixes the same EBUSY for an rfkill block only. The neard path still hits it.)

  3. Record the new results in a plan, with the kernel release. The entry still points to MODEM-PLAN's "Suspend with the modem on", but none of the new facts are in that section: the NACK and the recovery, or the 10-28 run that didn't wake. Could you add a short dated paragraph there? Please include uname -r for the 10-28 run (Pixel 9a: the ST54L stops answering on I2C when idle without its NFC mode #132 gives it for the NACK, but not for that run). Another option is to point the entry at device/tegu/NOTES.md once device/tegu: USB-C host mode through TCPM, and the 10-28 evening findings #131 has merged. The link to Pixel 9a: the ST54L stops answering on I2C when idle without its NFC mode #132 is a good addition, and it can stay.

  4. Small wording point. What we actually see is that the controller doesn't ACK its I2C address. nxp-nci retries the send after 110 ms, so that's two NACKs. Whether it has "lost its NCI state" is a guess about why. Something like "after a wake the ST54L doesn't answer on I2C (Error -6 on I2C send, also after the driver's retry)" says what was observed.

Here is one way to write the end of the entry, from "so stop polling by hand first" onwards, with your facts and the points above. Change it as you like:

Stopping the poll keeps the palmtop up but not NFC: after a wake the ST54L doesn't answer on I2C (Error -6 on I2C send, also after the driver's retry) and every NCI request then times out, until neard powers the adapter off and on, which runs a fresh NCI init (#132). A hook that powers the adapter off before the sleep and on after it is being tested, but it isn't proven: in its first RTC test (2026-10-28, <uname -r>) the palmtop didn't wake, cause unknown. Until it wakes in attended runs, keep the stop-poll hook. neard's Powered = false is a device-down that the kernel refuses (EBUSY) while the adapter polls, so such a hook stops the poll loop first and checks that Powered reads false before the sleep.

Merge order: #100 edits the same line (it adds the kernel release after "all woke"), so whichever of the two merges second needs a rebase. Please keep #100's release in the line when you rebase.

Thanks again. This gotcha has already stopped one bad suspend, and the sharper version will save the next person a lot of guessing.

…one wakes

Review: the gotcha now says what was observed (no I2C ACK after the wake), keeps the stop-poll hook, and describes the power-off hook as the candidate under test that must stop polling and check Powered first. MODEM-PLAN's suspend section records the 10-28 results with the kernel release.
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Thanks. All four are in the new head:

  1. The entry now keeps the stop-poll hook, and describes the power-off hook as the candidate under test, to be tried attended. I used your wording almost exactly.
  2. My hook does call StopPollLoop before Powered false, but it throws away neard's errors and never checks that Powered reads false. So I can't rule out the EBUSY case. I also couldn't check the log: none of the journals kept from 10-28 shows that sleep. The entry now says a hook has to stop the poll loop, power off, check Powered reads false, and only then let the sleep go ahead. I'll make my hook do that, and log, before the attended run.
  3. MODEM-PLAN's "Suspend with the modem on" section has a dated paragraph with 7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty (the palmtop ran that release all of 10-28, the no-wake run included).
  4. The entry says the controller doesn't answer on I2C, also after the driver's retry, instead of "lost its NCI state".

I'll keep #100's release in the line when I rebase, whichever of the two goes second.

@W4HO-ham
W4HO-ham force-pushed the agents-tegu-nfc-power branch from 0bb9e84 to 5f2ae68 Compare October 29, 2026 02:49
The NACK after a wake was the controller idling without its NFC mode on; linux-omarchy-mobile#131 turns it on, and NFC then polls after a wake with the stop-poll hook alone.
@W4HO-ham W4HO-ham changed the title AGENTS: on the 9a, stopping NFC polling keeps the palmtop up but not NFC AGENTS: on the 9a, NFC needs the ST54L's NFC mode on (linux-omarchy-mobile#131), not a power-off hook Oct 29, 2026
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

This changed overnight: the NACK wasn't about sleep. Without its NFC mode turned on, the ST54L goes silent about 2 s after init whenever it isn't discovering, sleep or not. linux-omarchy-mobile#131 turns the mode on, as ST's HAL does, and with it NFC polls again after a wake with the stop-poll hook alone. The entry now says that, with the kernel release, and drops the power-off-hook advice. #132 has the test details. The MODEM-PLAN paragraph in this PR still describes the 10-28 state; I'll add the result there too if you'd like it in the same PR.

@derekross

Copy link
Copy Markdown
Owner

Thanks, @W4HO-ham. All four points from my last comment were taken in the 02:49 push. The gotcha kept the stop-poll hook, the power-off hook got its "stop polling, check Powered" rule, MODEM-PLAN got a dated paragraph with the release, and the wording said what was observed. Then the 05:57 push replaced most of that with the actual cause, which is better still. The policy checks and both CI jobs pass on this head, and it merges cleanly onto today's main.

A few things before it merges:

  1. Please update the MODEM-PLAN paragraph in this PR, as you offered. Right now the two files disagree. AGENTS.md says "no power-off hook is needed", while the plan paragraph it links to still ends with "The stop-poll hook stays until a power-off hook that checks Powered wakes in attended runs". A short dated follow-on is enough. Keep the 10-28 paragraph as the record of that day. Then add the 10-29 results: the no-sleep A/B/C table from Pixel 9a: the ST54L stops answering on I2C when idle without its NFC mode #132 (the NACK from about 3 s of idle, with and without the set-config, with and without quick retries), the fix in nfc: nxp-nci: Turn the ST54L's NFC mode on after init linux-omarchy-mobile#131, and what passed with it. That's idle times from 3 s to 3 minutes, and the two RTC-woken s2idle cycles, one with the power-off hook and one without.

  2. Give the count, and say what the hook did. "With device/tegu: USB-C host mode through TCPM, and the 10-28 evening findings #131, NFC polls again after a wake with the stop-poll hook alone" rests on one cycle, if I read Pixel 9a: the ST54L stops answering on I2C when idle without its NFC mode #132 right. That's worth saying in the line ("one RTC-woken cycle so far"), next to the 35 of 35 the stop-poll rule rests on. Also, Pixel 9a: the ST54L stops answering on I2C when idle without its NFC mode #132 describes that cycle as "without the hook", and device/tegu: USB-C host mode through TCPM, and the 10-28 evening findings #131 as the adapter "left powered". Was the poll loop stopped for that sleep? If it wasn't, the palmtop slept while polling, which is what reset it on 10-27, and that's a result worth recording on its own. If it was, the line is right as it stands.

  3. Name the build, not only the release. The release in the line, 7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty, is also the release of the 10-28 runs without the fix, so it doesn't show which build passed. In the plan paragraph, please add the blob id of the core.c you built (git hash-object drivers/nfc/nxp-nci/core.c in that tree). If it's device/tegu: USB-C host mode through TCPM, and the 10-28 evening findings #131's, that's 77fc35b61da5.

  4. Merge order. The line describes device/tegu: USB-C host mode through TCPM, and the 10-28 evening findings #131's fix as if it were in the kernel, so I'll merge this PR after nfc: nxp-nci: Turn the ST54L's NFC mode on after init linux-omarchy-mobile#131, and I've asked for a few changes there first. In a file in the repository, "linux-omarchy-mobile#131" doesn't become a link, so please write it as a link, the way Pixel 9a: the ST54L stops answering on I2C when idle without its NFC mode #132 is.

As before, #100 edits the same AGENTS line (the release after "all woke"), so whichever of the two goes second needs a rebase that keeps both changes.

Thanks for following this all the way down. The gotcha now tells the next person the cause, not just a workaround.

W4HO-ham added a commit to W4HO-ham/omarchy-mobile that referenced this pull request Oct 29, 2026
…erekross#127 line

The 10-28 evening entry still says the sleep hook has to power the NFC adapter off, and that fingerprint matching doesn't work. Both are out of date: the ST54L's NFC mode (linux-omarchy-mobile#131, derekross#137) makes the power-off hook unnecessary, and one try of such a hook failed to wake, and matching works since FINGERPRINT-PLAN F9/F10 (derekross#138). Point forward from both bullets so nobody builds the hook from the old note, and wrap the sentence about derekross#127 like the rest of the entry.
…ld, derekross#131 as a link

The plan's NFC paragraph still ended with the 10-28 rule (keep the stop-poll hook until a power-off hook wakes) while AGENTS.md said no power-off hook is needed. The 10-28 paragraph stays as that day's record, and a dated 10-29 paragraph follows it: the hook reworked to check Powered woke 1 of 1 but NFC had already failed before the sleep; the no-sleep A/B/C table from derekross#132 (NACK from about 3 s of idle, with and without the set-config, with and without quick retries); the cause (the ST54L's NFC mode never turned on) and its fix, linux-omarchy-mobile#131; what passed with it (3 s to 3 minutes of idle, two RTC-woken s2idle cycles); and what was ruled out, including how the clock pad was forced on (a test module through the kernel's PMU regmap, not userspace).

The release is the same for the runs with and without the fix, so both files name the tested core.c by its blob id, 77fc35b61da5, the head of derekross#131. The AGENTS line now gives the count behind "polls after a wake with the stop-poll hook alone": one RTC-woken cycle without the power-off hook, for which it isn't recorded whether polling was stopped, so it needs a re-run with the hook's log; the stop-poll rule itself still rests on the 35 of 35 of 10-27. linux-omarchy-mobile#131 is written as a full link wherever it appears, since a bare cross-repository reference doesn't become one in a file.
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Done in 47180f5. The plan's 10-28 paragraph stays as that day's record, and a dated 10-29 paragraph follows it with the A/B/C table from #132, the cause, the fix as a link, and what passed with it: polling after 3 s to 3 minutes of idle, and after two RTC-woken s2idle cycles, one with the power-off hook and one without.

On your point 2: for the cycle without the hook I didn't record whether the poll loop was stopped, so both files now say that, count it as the one cycle behind "polls after a wake with the stop-poll hook alone", and call for a re-run with the hook's log. The stop-poll rule itself still rests on the 35 of 35 from 10-27.

The tested core.c is blob 77fc35b61da5, #131's head at the time, named in both files next to the release. Since then #131 has moved to the reset-notification wait you asked for (core.c c96704ddd480, re-tested today, see there); the plan line names the blob the 10-29 results came from. linux-omarchy-mobile#131 is a full link everywhere it appears. I'll rebase onto #100 if it goes in first.

@derekross

Copy link
Copy Markdown
Owner

Thanks, @W4HO-ham. All four points are in: the plan now has a dated 10-29 paragraph that matches AGENTS.md, the no-hook cycle is described honestly as "not recorded", the tested core.c is named next to the release, and #131 is a link everywhere. The checks and both CI jobs pass on this head, and it merges cleanly onto today's main.

Two small wording fixes before it merges:

  1. Which device/tegu: USB-C host mode through TCPM, and the 10-28 evening findings #131 the results are from. The AGENTS line says "With device/tegu: USB-C host mode through TCPM, and the 10-28 evening findings #131 (core.c blob 77fc35b61da5 …)", but device/tegu: USB-C host mode through TCPM, and the 10-28 evening findings #131 has since moved to the reset-notification wait (c96704ddd480), and that's the version that will land. The idle and s2idle results came from the first version. The new one has had the six power-ons and polling at 3 s and 30 s. You mentioned on device/tegu: USB-C host mode through TCPM, and the 10-28 evening findings #131 that you'd quote that re-run in the plan. Could you add it as one sentence after the 10-29 results, and make the AGENTS parenthesis say the same? Something like: "the results above on 77fc35b61da5, device/tegu: USB-C host mode through TCPM, and the 10-28 evening findings #131's first version; the merged version, c96704ddd480, re-run for six power-ons and polling at 3 s and 30 s". That way nobody reads the s2idle cycles as tested on the merged code.

  2. A quotation of a sentence that's gone. The AGENTS line ends with "…so 'polls after a wake with the stop-poll hook alone' rests on that one cycle". That phrase was in the previous version of the line, which this push replaced, so the quote now points at nothing. Maybe: "so whether NFC comes back after a wake with the stop-poll hook alone rests on that one cycle and needs a re-run with the hook's log."

Thanks for the clock-pad detail in the plan as well. Doing it through the kernel's PMU regmap was the right way.

As before, I'll merge this after derekross/linux-omarchy-mobile#131. I'll write the squash message myself, because the earlier commits' messages describe the power-off hook plan that this PR ends up replacing.

…re from

The idle and s2idle results of 10-29 ran on linux-omarchy-mobile#131's first version (core.c blob 77fc35b61da5, a fixed 200 ms wait after the reset). The version that merges waits for the controller's CORE_RESET_NTF instead (c96704ddd480) and was re-run the same day for six power-ons and polling at 3 s and 30 s after power-on, with no NACK. Both files now say which build each result is from, so nobody reads the s2idle cycles as tested on the merged code.

The AGENTS line also quoted a phrase that the previous push removed, so the quotation pointed at nothing. It now says plainly that whether NFC comes back after a wake with the stop-poll hook alone rests on that one cycle and needs a re-run with the hook's log.
@W4HO-ham

Copy link
Copy Markdown
Contributor Author

Both in fab2290. The plan and the AGENTS line now say the idle and s2idle results are from #131's first version (77fc35b61da5) and that the merged one (c96704ddd480) was re-run for six power-ons and polling at 3 s and 30 s, and the dead quotation is replaced with your wording. Fine by me on the squash message.

@derekross

Copy link
Copy Markdown
Owner

Thanks, both wording fixes are in, and the plan and the AGENTS line now agree. Since then #100 has merged and added the kernel release after "all woke" on the same line, so this now conflicts there. It's a one-line fix, and I'll do it at merge: your line with (7.3.0-rc6-omamobile-tegu-s2mpg15-m1) put back after "all woke". I'll merge this right after derekross/linux-omarchy-mobile#131. Heads-up: your #166 rewrites the end of the same sentence, so whichever goes second will need the same kind of hand merge. Later, in a separate PR, the 10-30 clock-pad finding from #131's thread would be worth a line in the plan.

@derekross
derekross merged commit 9332a78 into derekross:main Oct 30, 2026
2 checks passed
@derekross

Copy link
Copy Markdown
Owner

Merged right after derekross/linux-omarchy-mobile#131, thank you. The AGENTS line came out identical to main's once the kernel release was back after "all woke" (your #100 had carried the same wording), so this lands the MODEM-PLAN side.

robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
…dem plan's corrections (derekross#137)

MODEM-PLAN's NFC and sleep notes now agree with the AGENTS line about the Pixel 9a's NFC polling through s2idle (a suspend with neard polling reset the palmtop; with polling stopped, 35 RTC-woken s2idle cycles all woke), and the plan names the merged nxp-nci core change (linux-omarchy-mobile#131) it relies on. Merged with main's AGENTS line, which already carried the same wording plus the kernel release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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