Skip to content

soc: apple: sep: notify sysfs on diag/keystore and diag/touchid transitions - #3168

Merged
RyanTheTide merged 1 commit into
mainfrom
feat/sep-sysfs-notify
Nov 26, 2026
Merged

RyanTheTide merged 1 commit into
mainfrom
feat/sep-sysfs-notify

Conversation

@jgoyvaerts

@jgoyvaerts jgoyvaerts commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What

Userspace helpers (aurora-sep-load, aurora-sep-ready) currently poll diag/keystore in a 100 ms sleep loop while waiting for SEP bring-up to finish.

Cache the kernfs_node references for diag/keystore and diag/touchid during sep_diag_register() (releasing them via devm_add_action_or_reset() before the attribute group is removed) and call kernfs_notify() on state transitions so userspace can wait with poll(POLLPRI | POLLERR) and zero polling delay.

Also add matching linux/kernfs.h, linux/spinlock.h, kobj.sd, and devm_add_action_or_reset() stubs in tools/aurora-sep/tests/test_diag_sensor.py and verify kernfs_notify() counts during the host test.

Closes #2313.

Tested: J616s (MacBook Pro 16-inch M4 Pro, T6040) at c72e93d on 7.3.0-m4.190: scripts/checkpatch.pl --strict 0 errors / 0 warnings; python3 -m unittest tools/aurora-sep/tests/test_diag_policy.py tools/aurora-sep/tests/test_diag_sensor.py -v (and -O) pass; booted live on J616s, verified diag/keystore and diag/touchid sysfs nodes register cleanly and deliver POLLPRI | POLLERR notifications on state transition, 0 failed units, Touch ID and SEP healthy.

Not yet: hardware test row from a second Mac generation (shared apple-sep path).

Risk: two-way · all Macs with Apple SEP (apple-sep)

@jgoyvaerts
jgoyvaerts requested review from a team as code owners November 25, 2026 16:38

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Audited full diff at ca59f54: caching diag/keystore and diag/touchid kernfs_node references in sep_diag_register() with a devm_add_action_or_reset() cleanup registered after devm_device_add_group() (so LIFO unwind puts references before group removal), guarding pointer access under sep_diag_kn_lock, and firing kernfs_notify() only on actual atomic_xchg/atomic_cmpxchg state transitions is race-free and safe from atomic context. Verified checkpatch clean and J616s live POLLPRI/POLLERR results.

@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merge readiness at c72e93d2: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at c72e93d2
Conflicts ok none
PR text ok Risk: two-way · all Macs with Apple SEP (apple-sep)

Areas: area:platform

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot added the ci-failing A check failed at the PR head (bot) label Nov 25, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source CI job (tools/aurora-sep/tests/test_diag_sensor.py) fails to compile drivers/soc/apple/diag_shim.c in both test_diag_goes_bound_attached_ready_and_back and test_matching_follows_the_guard:

drivers/soc/apple/diag_shim.c:22:10: fatal error: linux/kernfs.h: No such file or directory

Please add the linux/kernfs.h stub (and matching kobj.sd / kernfs_* stubs) to tools/aurora-sep/tests/test_diag_sensor.py so the host test compiles and passes cleanly (and once green, this shared SEP path will also need a second hardware generation test row before merge).

@github-actions github-actions Bot added changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 25, 2026
…itions

Userspace helpers (aurora-sep-load, aurora-sep-ready) currently poll
diag/keystore in a 100 ms sleep loop while waiting for SEP bring-up to
finish (#2313). Cache kernfs_node references for
diag/keystore and diag/touchid at sep_diag_register() time (released via
devm_add_action_or_reset() before the attribute group is removed) and
call kernfs_notify() on state transitions so userspace can wait via
poll(POLLPRI | POLLERR) with zero polling delay.

Signed-off-by: Jonathan Goyvaerts <jonathan.goyvaerts@gmail.com>
@jgoyvaerts
jgoyvaerts force-pushed the feat/sep-sysfs-notify branch from ca59f54 to c72e93d Compare November 25, 2026 22:08
@jgoyvaerts

Copy link
Copy Markdown
Contributor Author

Amended at c72e93d2202c0: added linux/kernfs.h, linux/spinlock.h, kobj.sd, and devm_add_action_or_reset() stubs in tools/aurora-sep/tests/test_diag_sensor.py (verified locally with test_diag_policy.py and test_diag_sensor.py under both python3 and python3 -O, plus kernfs_notify() count assertions), and listed the second Mac generation hardware row under Not yet: in the PR body.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified the added linux/kernfs.h, linux/spinlock.h, kobj.sd, and devm_add_action_or_reset() stubs plus touchid_kn.notifies assertion in tools/aurora-sep/tests/test_diag_sensor.py. Holding merge until CI completes green and a second Mac generation row is posted.

@github-actions github-actions Bot removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 25, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

c72e93d2202c (batched cleanly in J616s Batch #2 5b411e230229 over main 95a983c08be4, 0 merge-tree diffs across all 2 changed files) J616s (MacBook Pro 16" M4 Pro, T6040, Apple M4 Pro (G16S B1), macOS 26.6.2 fw, guarded one-shot 7.3.0-aurora-pr2905+, default cmdline, stock Stage 2 1.0.0b17, boot_id=de17fad3) PASS: 0 failed units, Enforcing, 0 new AVC (1 matching baseline), 0 GPU faults, 0 errors in this subsystem, real rtc1 s2idle 2/2 (success=2 fail=0), eDP connected pre/post-sleep, 406600000.sep + 514600000.mtp RTKit v12 (AppleMTPFirmwareMac-5340.61.4~502, HID keyboard/trackpad/accel/actuator/touch) clean, Borealis VK dEQP-VK.api.smoke.* 8/8 (pre & post-sleep) + glsl.loops.* 624/624, Wi-Fi 3/3 ping pre/post-sleep; stock 7.3.0-aurora-fleet89 restored & verified (b67edc6c).

@RyanTheTide
RyanTheTide merged commit acb316f into main Nov 26, 2026
26 of 28 checks passed
@RyanTheTide
RyanTheTide deleted the feat/sep-sysfs-notify branch November 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

apple_sep: trusted-key callbacks wait up to 90 s under key_construction_mutex, and diag/keystore cannot be waited on

3 participants