Repository navigation
Conversation
…nounced Each service announcement whose name is one of the seven services this driver knows queues a work item that registers a platform device with PLATFORM_DEVID_AUTO and adds it to the list of children. Nothing checks whether the service already has a device, so an announcement that arrives again adds another child with its driver bound, and the number of children is not bounded. The DCP driver's AFK transport (drivers/gpu/drm/apple/afk.c) ignores a repeated announcement on a channel whose service is still live, and the listener tables here already refuse a second listener for one service; only the child registration had no such check. Keep the record where the decision is made: the registration gate, which already orders queueing against removal, now holds the services that have a device, registered or queued, and the name table moves next to it into aop_services.rs. An unchanged repeat of an announcement is ignored. A known name announced on another channel, or a channel announced again under another name, gets no device; the endpoint counts it as a dropped message and logs it, with the announced name and channel, under the same throttle as its other dropped messages. The record holds at most one entry per entry of the table, reserved at probe, so announcements allocate nothing beyond the seven devices. A registration that fails gives up its claim, so the next announcement of that service tries again. This applies to every SoC this driver supports. The new KUnit suite apple_aop_services checks the record; tools/asahi/aop-service-tests.py builds register_service() against host stand-ins and checks the devices queued and the refusal's log line, and the code before this change fails it. Fixes: 3ed935e ("soc: apple: Add support for the AOP co-processor") Reported-by: Erik Bourget <erik@ebourget.net> Suggested-by: Erik Bourget <erik@ebourget.net> Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
|
The claim logic and the locking look right to me:
Two behaviour questions, both about firmware that announces more than audio:
Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Pre-PR checklist review on fbfeb1193f4a4068aa078d85e26326911025cc3b (CI: 7/7 checks green — host-tests, source, rust-build, kunit, and all three DWC3/ATC builds).
Code & Locking Audit
drivers/soc/apple/aop_services.rs&drivers/soc/apple/aop.rs: Clean design.Claims::new()reserves the full 7-entry capacity at probe time, so service announcements allocate nothing beyond the platform device work item.Claims::claim()enforces a strict bijection betweenEPICServiceand theDEVICESindex (unchanged repeats returnOk(None), conflicting channel or name returnsErr(EEXIST)and routes throughep.drop_message()with escapedBStrlogging and power-of-two throttling).- Error unwind & lock ordering verified:
AopServiceRegisterWork::run()dropssubdevicesbefore takingregistration_gateto release the claim onreserve()orplatform_device_register_full()failure;register_service()releases the claim ifAopServiceRegisterWork::new()fails;remove()dropsregistration_gatebefore drainingregistration_queueand takingsubdevices.ep.drop_message()takes no locks. No AB-BA lock inversion. - Tests:
apple_aop_servicesKUnit suite (gated via#[kunit_tests]->CONFIG_KUNIT="y") andtools/asahi/aop-service-tests.py(with--old-ref 24dc422773c9failing checks and passing controls) both pass in CI.
Pre-PR Checklist (§1–§6)
- §1 No model gating: Pass — no SoC/board/firmware gates.
- §2 Production-ready: Pass — default command line, no retries/sleeps/magic bounds.
- §3 Safety: Pass — no hardcoded hardware safety values; bounds child device creation cleanly to the 7 known services.
- §4 Clean-room & attribution: Pass — human author/committer and
Signed-off-byonly in commit;Assisted-by:disclosed in PR body. - §5 Evidence: Holding for additional hardware rows. The J775D A/B row is helpful, but on J775D AOP does not boot on stock
integration/aurora(it required carrying #2556 plus an unposted local DT patch) and only announces a single service (aop-audio), with 2 failed units on ALARM/RO-root. As noted in## Still to run, we still need §5 regression rows from AOP Macs where AOP boots directly onintegration/aurora(M1–M4 / M5 laptops announcing multiple services, plus T8140 suspend/resume re-announcement behavior). - §6 Naming: Pass.
Zero code, policy, or CI blockers — holding as COMMENT only for the remaining §5 multi-service / stock-base AOP hardware rows.
Assisted-by: LLM (Gemini 4 Neon)
RyanTheTide
left a comment
There was a problem hiding this comment.
Non-author review of fbfeb1193f4a. I tried to break it and could not; the code looks right to me. One row is still missing before merge, and I have two test requests that can be a follow-up.
Code
- The record does what the commit message says: an unchanged repeat is ignored, a known name on another channel or endpoint and a claimed channel under another name get no device, and an unknown name takes no claim (
aop_services.rs:39-58). The record is reserved for the table at probe, so announcements allocate nothing beyond the table's devices and their work items. - Locking: the receive path takes the gate under the endpoint lock (
aop.rs:1656); the work item dropssubdevicesbefore it takes the gate, and never holds the gate across the child's probe (aop.rs:1440-1446,1455-1462);remove()drops the gate before the drain. I see no lock-order problem. A release can only remove the claim of the registration that failed, because a present claim refuses every other announcement of that service. - A rebind starts with an empty record, so the services get their devices again. There is no firmware restart path in the driver today; if one is added, it has to unregister the children and clear the record.
- No chip, board or firmware gates, no parameters, no new
unsafe.
Tests I ran at this head
tools/asahi/aop-service-tests.py: 5 of 5 checks and 4 of 4 controls pass. With--old-ref 24dc422773c9the old code fails all 5 checks and passes the 4 controls.- KUnit on arm64 QEMU with
APPLE_AOP=y:apple_aop_services6/6 andapple_aop_ring17/17. With the refusal removed fromClaims::claim,a_name_or_channel_with_a_device_is_refusedfails, so the suite does test the change.
Hardware, before the change
On kernels without this change, where each announcement gets a device, the child list shows what the firmware announces:
| Mac | AOP children | Suspend exits that boot |
|---|---|---|
| A18 Pro (T8140) | als, audio | 2 |
| M4 Pro (T6040) | accel, gyro, las, als-temp, devmotion6, als, audio | 0 |
| M2 (T8112) | the same seven | 0 |
| M1 Pro (T6000) | the same seven | 2 |
Each known name is announced once, and the two Macs that had resumed twice had no extra children, so their firmware does not announce again after a resume. I expect this change to make no difference on these four.
Still to run before merge
- This change itself on a Mac whose AOP announces several services: boot and one short s2idle, the same children with their drivers bound, and no
dropped a messageline. The table above is without the change.
Requests, fine as a follow-up
- No CI job runs
apple_aop_services(orapple_aop_ring): thekunitjob usessep.kunitconfigwith theapple_sep*filter, andrust-buildcompilesapple-sep.oonly. A small AOP kunitconfig (KUNIT,ARCH_APPLE,OF,RUST,ARM64_16K_PAGES,IOMMU_SUPPORT,PM,APPLE_RTKIT,APPLE_MAILBOX,APPLE_AOP=y) and a CI step would run both. - The three places that give a claim back (
aop.rs:1446,1462,1683) have no test: deleting any one of them passes the host test and the KUnit suite. The one inregister_serviceis easy to cover in the host test by letting the work-item stand-in fail once and announcing again.
Nits, no change needed: the refusal text at aop.rs:1669 would also be printed for the ENOSPC arm of claim(), which cannot be reached; the "cannot happen" branch at aop.rs:1465 keeps its claim.
Assisted-by: LLM (Claude:Opus 5.5), LLM (Claude:Fable 5.2)
The AOP driver has two KUnit suites (apple_aop_ring and apple_aop_services), but no CI job builds or runs them: the SEP source workflow's kunit job uses sep.kunitconfig with an apple_sep* filter, and its rust-build job compiles only apple-sep.o. A regression in either AOP suite would not show up on a pull request. Add drivers/soc/apple/aop.kunitconfig with the minimal options needed to build APPLE_AOP=y on arm64, and add a step in the sep-source.yml kunit job that runs both suites on arm64 QEMU with the apple_aop* filter in a separate build directory (.kunit-aop). Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
AopData::register_service() and AopServiceRegisterWork::run() release a service's claim on three failure paths: work-item allocation failure, subdevice-slot reservation failure, and platform_device_register_full() returning an error pointer or NULL. Previously tools/asahi/aop-service-tests.py only built register_service() with an infallible work-item constructor, so deleting any of those three releases left both the host test and the KUnit suites green. Extend tools/asahi/aop-service-tests.py to also build and run the production AopServiceRegisterWork::run() against host stand-ins, with fault injection for work-item allocation, subdevice-slot reservation, and platform device registration (both error pointer and NULL), plus a lock-order assertion that subdevices is dropped before registration_gate is locked. Verify that each failed registration releases its claim so a subsequent announcement registers the device, while keeping repeats refused once registration succeeds. Add --mutation modes (no-work-release, no-slot-release, no-register-release) that drop each release line from the extracted production source and require its control to fail, and register them in tools/asahi/run-host-tests.py. Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
|
Thanks, Ryan and dj. Both test follow-ups are now in this PR (head
Refreshed J775D row: re-ran kit Note on Because the J775D AOP announces only Assisted-by: LLM (Gemini:Neon) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Formal §1–§6 pre-PR re-review at a0837b9f9b42021b9ce5c81848b666738ecbb12a (CI: 7/7 green — host-tests, kunit, rust-build, source, and all three DWC3/ATC builds; mergeable=true, clean and not superseded on integration/aurora).
Follow-up Verification (from fbfeb1193f4a)
- Runtime commit
fbfeb1193f4ais unchanged (previously audited: cleanClaimsbijection, probe-time capacity reservation, properdrop(subdevices)beforeregistration_gate.lock()on all unwind paths, zero AB-BA lock inversion). - Commit
7709c6ec1217cleanly addsdrivers/soc/apple/aop.kunitconfigand runsapple_aop*in.github/workflows/sep-source.yml'skunitjob — verified in live CI job137844293684(apple_aop_services6/6 passed,apple_aop_ring17/17 passed on arm64 QEMU). - Commit
a0837b9f9b42cleanly extendstools/asahi/aop-service-tests.pyto compile productionAopData::register_service()andAopServiceRegisterWork::run()together, covering all three claim-release failure paths (AopServiceRegisterWork::new,subdevices.reserve,platform_device_register_fullERR_PTR/NULL), assertingsubdevicesis dropped before takingregistration_gate, and registering--mutation {no-work-release,no-slot-release,no-register-release}plus--old-ref 24dc422773c9inrun-host-tests.py.
Pre-PR Checklist (§1–§6)
- §1 No model gating: Pass — no SoC/board/firmware gates.
- §2 Production-ready: Pass — default command line, no hacks.
- §3 Safety: Pass — bounds child platform-device creation to the 7 known services without hardcoded hardware limits.
- §4 Clean-room & attribution: Pass — all 3 commits (
fbfeb1193f4a,7709c6ec1217,a0837b9f9b42) carry human author/committer (Jeff Queisser <funkzy@users.noreply.github.com>) and humanSigned-off-by:only, zero AI trailers in commits;Assisted-by:disclosed in PR body. - §5 Evidence: Incomplete (blocking) — see below.
- §6 Naming: Pass.
Blocking Finding
- Missing multi-service + s2idle stock-base AOP hardware row (§5): The refreshed J775D A/B row at
a0837b9f9b42is helpful, but J775D AOP does not boot on stockintegration/aurora(requires#2890/#2556plus Aura patch), announces only a single service (aop-audio), and lacks upstream s2idle onintegration/aurora. As noted in## Still to run, before merge we still need a boot + short s2idle hardware row on a stock-baseintegration/auroraMac whose AOP announces multiple services (e.g. M1 Pro, M2, M4 Pro, or A18 Pro), confirming identical bound children, working sensors/audio,0"dropped a message"lines across boot and resume, and §5 regression counts (0 SELinux denials, 0 failed units, 0 new kernel errors).
Verdict
REQUEST_CHANGES — zero code, locking, test, or CI blockers (all 7 CI checks green, including the new arm64 QEMU apple_aop* KUnit step and mutation host tests); holding solely for the remaining §5 multi-service + s2idle stock-base hardware row.
Assisted-by: LLM (Gemini 4 Neon)
Problem
When the AOP firmware announces a service whose name is one of the seven this driver knows (
aop-audio,las,als,accel,gyro,devmotion6,als-temp),register_service()queues a work item that registers a platformdevice with
PLATFORM_DEVID_AUTO. Nothing records which services already have a device. An announcement that arrivesagain therefore adds another child, with its driver bound, for the same service, and the number of children has no
bound.
Why this shape
Which announcements become children was a
matchinregister_service(); whether a service already had one wasrecorded nowhere.
subdevicesfills in later, from the work item, under a lock held across the child's probe, so itcan't be checked under the endpoint lock. The listener tables here already refuse a second listener for one
EPICService, and the DCP driver's AFK transport (afk.c) ignores a repeated announcement on a live channel. A capon the number of children would be a new constant and would still bind two drivers to one service; checking
subdevicesin the work item would miss registrations still queued. So the registration gate, which already ordersqueueing against removal, holds the claims, keyed by the listener tables'
EPICServiceand the device name, with thename table beside it. Every SoC gets at most one child per known service, seven in all, with no per-announcement
allocation.
Change
fbfeb1193f4a(soc: apple: aop: one child device per service, however often it is announced):drivers/soc/apple/aop_services.rs(new): the table of service names and device names, andClaims, the record ofthe services that have a device, registered or queued. Its storage is reserved at probe for the whole table.
The endpoint counts it as a dropped message and logs the announced name and channel, under the same throttle as
its other dropped messages.
drivers/soc/apple/aop.rs:registration_gateholds theClaims, andregister_service()claims before itqueues. A registration that fails gives up its claim, so the next announcement of that service tries again.
7709c6ec1217(soc: apple: aop: run the KUnit suites in CI): addsdrivers/soc/apple/aop.kunitconfigand runsapple_aop*(apple_aop_servicesandapple_aop_ring) on arm64 QEMU in.github/workflows/sep-source.yml'skunitjob.a0837b9f9b42(soc: apple: aop: cover all three claim-release paths in the host test): extendstools/asahi/aop-service-tests.pyto extract bothAopData::register_service()andAopServiceRegisterWork::run()from
aop.rs, cover all three claim-release failure paths (AopServiceRegisterWork::new,subdevices.reserve, andplatform_device_register_fullreturningERR_PTRorNULL), assertsubdevicesis dropped beforeregistration_gateis locked, and register--mutation {no-work-release,no-slot-release,no-register-release}runsin
tools/asahi/run-host-tests.py.Testing
apple_aop_services(6/6 pass) andapple_aop_ring(17/17 pass) inkunit-vz(12 suites, 65 of 66 pass, 0 fail, 1 expected skip on
apple_mbox_g17_stall/apple_g17_rx_util_min_testwithoutCONFIG_UCLAMP_TASK). Standalonedrivers/soc/apple/aop.kunitconfigwas built and linked fromallnoconfig(all10 options resolve
=yand include both suites); the new CI step will exercisekunit.py runon push.tools/asahi/aop-service-tests.py): 6 of 6 checks and 8 of 8 controls pass.--old-reffails all 6checks. Deleting any of the three claim-release lines or either
drop(subdevices)line inaop.rsfails its test ortrips the lock assertion; all three
--mutationruns pass inrun-host-tests.py. Fullrun-host-tests.pyin thebuild VM: 459/459 pass on the base (
24dc422773c9), 464/464 pass with this series (only the 5 newaop-service-testsruns differ).
pr2779-3(windowpr2779r2@20261123-0216, auraaura-aopres1c:integration/auroraa4b51cdff0a7plus#2890, which enables the J775D AOP over its RTKitmailbox, plus all three commits of this PR at
a0837b9f9b42) against kitpr2779-3b(windowpr2779r2@20261123-0216, auraaura-aopres1c: the same base and#2890without this PR). One boot eachthrough the default 27.0 firmware stub and Aura carrying
aurora-silicon/aura#474at its earlier headadaf5a5f(which reserves the AOP's firmware pages when its DART is locked;
aura#474has since been revised), defaultkernel command line, read-only root (ALARM has no SELinux).
apple_aopbinds290c00000.aop, announcesaop-audio, and registers one childaudio.0.auto(
snd_soc_t8152_aop_audio), bringing upAppleJ775D(15 simple mixer controls fromamixer scontrolson botharms). 0
dropped a messagelines and 0 DART faults on both.both (
iwd.servicemissing kernel crypto options in integration's defconfig, andsystemd-networkd-persistent-storage.serviceon the read-only root).Note on
#2890: its branch is stacked on#2556's two AOP setup-port commits, so the#2890need above carriesthose commits into both arms.
Builds, checkpatch, and other open PRs
integration/auroradefconfig with AOP built in, and standaloneallnoconfig+drivers/soc/apple/aop.kunitconfig; no warnings.--strict: 0 errors across all three commits. Warnings are theReported-by:withoutCloses:onfbfeb1193f4aand the two new files (aop_services.rs,aop.kunitconfig), both covered bydrivers/soc/apple/*in MAINTAINERS.
aop.rs(#2556,#2519,#2351,#2800,#2906).Still to run
integration/aurora(the J775D announces only
aop-audioand does not yet have s2idle upstream onintegration/aurora), verifying thesame bound children and 0
dropped a messagelines.Assisted-by: LLM (Claude:Opus 5.5), LLM (Gemini:Neon)