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>
Contributor
|
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
Contributor
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.
Testing
The behaviour change is shown by two new tests:
apple_aop_services(6 cases): first announcements get their device, unknown names nothing, anunchanged repeat nothing, a name or channel that already has a device is refused, at most one device per table
entry over 64 channels, and a released claim can be taken again.
tools/asahi/aop-service-tests.py(registered inrun-host-tests.py): it buildsregister_service()from
aop.rsunchanged against host stand-ins and counts the device registrations it queues and the droppedmessages it logs. Its
--old-refrun requires the code before this change to fail, and it does: that code queuesone device per announcement.
J775D (Mac Studio, M5 Ultra), a no-regression row for a service announced once, as this board's firmware does. One
boot each with and without this change (fbfeb11), through the 27.2 firmware, read-only root, the usual J775D
command line plus the test boot's watchdog dead-man.
board's AOP doesn't come up on integration, so no announcement would reach the changed code.
audio.0.autoon the AOP'saudionode) with its driver bound, and no dropped-message lines. The same sound card (AppleJ775D, the same 17controls, headphone and headset jacks), and the same co-processors (SMC, NVMe, both DCPs, both AVD decoders).
needs (
CRYPTO_USER_API_HASH,CRYPTO_USER_API_SKCIPHER,KEY_DH_OPERATIONS). systemd-networkd-persistent-storagefails because the test boots mount the root read-only. The Hyprland session doesn't start on either: integration
has no J775D GPU node yet.
SELinux, so there is no AVC count.
The J775D device-tree change in the row's base (4c1e148e352f, not posted)
This board's AOP firmware never services the setup port, so the row gives the AOP its RTKit mailbox alone. It
overrides two properties, and with #2556 the driver then takes the boot without the setup port. How the Studio's AOP
should be described is still being discussed, so it isn't part of this PR.
Builds, host tests, KUnit totals, checkpatch, other open PRs
2 skip (the same two skips).
run-host-tests.pyin a build VM: 459 of 459 pass on the base, 461 of 461 with this change (the new test and its--old-refrun are the 2 added).--strict: no errors. Its two warnings are aReported-by:without aCloses:link and a new file,which
drivers/soc/apple/*in MAINTAINERS covers, as it coversaop_ring.rs.aop.rs(soc: apple: aop: take the setup-port boot only with a "setup" mailbox #2556, soc: apple: aop: check the firmware segments wherever the loader lists them (T8112 on 27.2) #2519, soc: apple: aop: start the T8122 AOP as on T6040 #2569, soc: apple: aop: refuse EPIC calls once the firmware has crashed #2342, soc: apple: aop: explain the AFK init resend after a full mailbox #2351).Still to run
and their drivers with and without this change, and
dmesg | grep "dropped a message". A firmware that announcedone service name on two channels would now log a dropped message naming the service and the second channel,
instead of getting a second device.
sleep_undo())? If it does, the code before this change added children on every resume, and with it the repeatsare ignored.
Assisted-by: LLM (Claude:Opus 5.5)