Skip to content

drm/apple: afk: match named compact services before the wildcard - #2757

Merged
niteria merged 1 commit into
aurora-silicon:integration/aurorafrom
niteria:afk-cut-before-wildcard
Nov 22, 2026
Merged

niteria merged 1 commit into
aurora-silicon:integration/aurorafrom
niteria:afk-cut-before-wildcard

Conversation

@niteria

@niteria niteria commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

afk_compact_match_service() matches a compact service announcement in two passes: exact names first, then truncated 31-byte names via afk_compact_cut_of(). Because pass 1 returned immediately upon seeing ops->name == "*":

  • Any truncated compact announcement (checked in pass 2) was swallowed by "*" before afk_compact_cut_of() ever ran.
  • Any named entry listed after "*" was also shadowed by "*" in pass 1.

At this head no in-tree table combines "*" with a compact_full entry or places "*" before a named entry, so this commit changes no current in-tree lookup on its own; it fixes the matcher contract for any endpoint table that mixes named/cut entries with a wildcard fallback.

Change

  • drivers/gpu/drm/apple/afk.c: record the first "*" entry during pass 1 (any = any ?: ops) and return it only as a last resort after both the exact-name pass and the cut-name pass fail, so named entries always win regardless of table order.
  • drivers/gpu/drm/apple/afk-parser-test.c: add afk_compact_cut_before_wildcard_test covering both a wildcard-last table and a wildcard-first table (exact named matches, truncated compact_full matches, and cut/uncut unknown fallbacks to "*").

Testing

  • scripts/checkpatch.pl --strict --git HEAD~1..HEAD (head 86a842b98e42): 0 errors, 0 warnings, 0 checks.
  • W=1 arm64 cross-compile of drivers/gpu/drm/apple/afk.o: 0 warnings.
  • Arm64 QEMU KUnit (CONFIG_DRM_APPLE_PARSER_KUNIT_TEST=y, suite apple-epic-parser): 10/10 passed, including the expanded afk_compact_cut_before_wildcard_test ("*"-last and "*"-first tables).
  • tools/asahi/run-host-tests.py: 451/452 passed (including apple-dcp 92/92; the 1 failure is pre-existing pmp-floor-tests.py --mutant class-twice hitting -Werror=unused-but-set-variable on gov.h:49 under both GCC and Clang).

Assisted-by: LLM (Google:Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

The matching change looks right to me. "*" now loses to any named entry, cut or not, and the second loop is safe on the wildcard entry because afk_compact_cut_of() needs compact_full (afk.c:821). A few points:

  • At this head no table has both a "*" entry and a compact_full entry. The wildcard tables are dcp_compact_aux_ops (dcp.c:4215), dcp_ext_av_service_ops (dcp.c:4260) and dcp_m4_probe_ops (iomfb_m4.c:2774). The compact_full tables (av.c:987, cec.c:1107, dcp-v27-sleep.inc:980) have no wildcard. So this commit changes no in-tree lookup. The J713 dcpext0 result in the description depends on a table from the external-DCP audio branch. Please say which PR carries that table, or move the hardware paragraph there, so this one isn't read as enabling external audio on its own.
  • This also changes ordering in a way the commit message doesn't mention. Pass 1 used to return "*" as soon as it reached it, so a wildcard listed before a named entry took that entry's exact-match services too. Now named entries always win (afk.c:788-801). That is the better rule, but please put it in the commit message and add a case with "*" listed first to afk_compact_cut_before_wildcard_test.

Assisted-by: LLM (Claude:Opus 5.5)

In afk_compact_match_service(), the first pass returned a "*" entry as
soon as it met one. That caused two surprises whenever an endpoint's
table included a wildcard:

- A compact announcement that filled its field arrives without the end
  of its name and is only checked against compact_full in the second
  pass, so "*" caught it before the cut-name pass ever ran.
- A "*" listed ahead of a named entry also shadowed that entry's exact
  matches in the first pass.

Record the first "*" entry and return it only as a last resort after
both the exact-name pass and the cut-name pass fail, so named entries
always win regardless of table order.

Signed-off-by: Bartosz Nitka <[email protected]>
@niteria
niteria force-pushed the afk-cut-before-wildcard branch from f20b4d1 to 86a842b Compare November 22, 2026 03:16
@niteria niteria changed the title drm/apple: afk: match a cut compact name before the wildcard drm/apple: afk: match named compact services before the wildcard Nov 22, 2026
@niteria

niteria commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Addressed both points in 86a842b98e42:

  1. Updated the PR description to state explicitly that no in-tree table combines "*" with compact_full (or lists "*" before a named entry) at this head, so this commit changes no in-tree lookup on its own, and dropped the out-of-tree J713 external-audio paragraph.
  2. Updated the commit message to document that named entries (exact or cut) now always beat "*" regardless of table order, and added a "*"-first table to afk_compact_cut_before_wildcard_test covering exact matches, cut matches, and fallbacks.

Re-verified on 86a842b98e42: scripts/checkpatch.pl --strict (0 errors, 0 warnings, 0 checks) and arm64 QEMU KUnit apple-epic-parser (10/10 passed).

Assisted-by: LLM (Google:Gemini 4 Neon)

@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.

Adversarial review at 86a842b98e42 against the pre-PR checklist.

Verified

  • §1–§3 (Code correctness & edge cases): afk_compact_match_service() records the first "*" entry (any = any ?: ops) and returns it only after both pass 1 (exact named match) and pass 2 (afk_compact_cut_of()) fail. Verified that afk_compact_cut_of() requires ops->compact_full (so "*" is safely ignored in pass 2), that short/uncut announcements return any, and that none of the in-tree wildcard tables (dcp_compact_aux_ops, dcp_ext_av_service_ops, dcp_m4_probe_ops) combine "*" with compact_full or place "*" ahead of a named entry — so this commit changes no current in-tree lookup while fixing the matcher contract cleanly. The KUnit test afk_compact_cut_before_wildcard_test covers both "*"-last and "*"-first tables across exact, cut, and fallback cases.
  • §4 (Clean-room & attribution): Clean. Human author/committer (Bartosz Nitka) + Signed-off-by: only, zero AI trailers in commit, Assisted-by: present in PR body.
  • §5 (Verification evidence): Complete for a pure matcher contract fix with zero in-tree runtime behavior change (checkpatch.pl --strict clean, W=1 arm64 build clean, arm64 QEMU KUnit apple-epic-parser 10/10 passing, apple-dcp host tests 92/92, GitHub CI host-tests green on 86a842b98e42).
  • §6 (Naming): Clean.

0 code, policy, attribution, or CI blockers.

Assisted-by: LLM (Gemini 4 Neon)

@niteria
niteria merged commit b21dcc6 into aurora-silicon:integration/aurora Nov 22, 2026
1 check 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.

3 participants