Skip to content

drm/apple: dpavservep: test which AV service announcements are admitted - #2820

Merged
RyanTheTide merged 1 commit into
integration/aurorafrom
test-coverage/dpavserv-identity
Nov 22, 2026
Merged

RyanTheTide merged 1 commit into
integration/aurorafrom
test-coverage/dpavserv-identity

Conversation

@RyanTheTide

Copy link
Copy Markdown

Problem. dcpavserv_identity() picks which announced DP/HDMI AV service the AV client takes. It now has four admission shapes (classic AFK wire; AFKV2 on the V2 endpoint; AFKV2 on the classic DPAV endpoint, added for the M3/M4 Air in #2783; the native26 external role), and none of them had a test.

Change. A table-driven KUnit suite, apple-dcpavserv-identity, runs the production function on a fake service, endpoint and DCP. It has 30 rows: each admitted shape, plus the class, unit, channel and endpoint mismatches around it, including the channel bounds (0 and over U16_MAX). It's included from dpavservep.c under CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST, like the existing apple-dcpavserv-v14 suite. Tests only, no functional change.

Testing.

Still to run. Nothing on hardware: the change is test-only.

kunitconfig and command
CONFIG_KUNIT=y
CONFIG_ARCH_APPLE=y
CONFIG_OF=y
CONFIG_PM=y
CONFIG_MAILBOX=y
CONFIG_APPLE_MAILBOX=y
CONFIG_APPLE_RTKIT=y
CONFIG_DRM=y
CONFIG_BACKLIGHT_CLASS_DEVICE=y
CONFIG_DRM_APPLE=y
CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST=y
CONFIG_OF_OVERLAY=y

./tools/testing/kunit/kunit.py run --arch=arm64 --make_options LLVM=1 --kunitconfig=<above> 'apple-dcpavserv*'

Rows (role, endpoint): name gate on every role; legacy unit 0 admitted with any class/channel, unit 1 refused; v2 on 0x2a needs AppleDCPDP2HDMI/DCPDP13Service with unit == channel, 1..0xffff; v2 on 0x28 needs the same classes, unit 0 and channel 1..0xffff, and refuses unit == channel; v2 on another endpoint refused; native26 needs DCPDPService, unit 0, nonzero channel, endpoint 0x28 only.

Assisted-by: LLM (Claude:Opus 5.5)

dcpavserv_identity() decides which announced DP/HDMI AV service the AV
client takes: the classic AFK wire (unit 0), the AFKV2 wire on the V2
endpoint (unit equal to the channel), the AFKV2 wire on the classic DPAV
endpoint (unit 0, dynamic channel) and the native26 external role
(DCPDPService, unit 0). It had no test.

Add a table-driven KUnit suite, apple-dcpavserv-identity, that runs the
function on a fake service, endpoint and DCP for 30 announcements: each
admitted shape and the class, unit, channel and endpoint mismatches next
to it, including the channel bounds (0 and over U16_MAX).

No functional change. With dcpavserv_identity() as it was before the
classic-endpoint AFKV2 case was added, the three "v2 ep 0x28" admit rows
fail and the other 27 pass.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Author

Review at 96e069a.

The suite calls the real dcpavserv_identity(). The file is #included into dpavservep.c, so the static function is the one under test, not a copy. The rows match every branch at this head (dpavservep.c:37-58): the name gate, the ext26 branch (endpoint 0x28, unit 0, DCPDPService, nonzero channel), the legacy unit == 0, the shared class and channel bounds check for v2, and the 0x2a/0x28 split. Each condition in the function has a row that flips if that condition is dropped. The two "channel 0" rows are the clearest case: on 0x2a, unit 0 == channel 0, so that row can only fail on !service->channel. No driver code changes: the only change outside the new file is the one #include line.

Non-blocking:

  1. dpavservep-identity-test.c, "v2 other endpoint" row: 0x29 is AV_ENDPOINT in dcp-internal.h:108. Using the enum would make it clear the row means "a real, different DCP endpoint".
  2. CI does not run this suite. host-tests.yml runs tools/asahi/run-host-tests.py, and nothing under tools/ or .github/ enables CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST (only mt7932-kunit.yml runs KUnit). The 43/43 result therefore exists only from the local kunit.py run, and a later change to the identity rules will not be caught on a PR unless someone runs it by hand. That is the same as the existing v14 suite, but it would be worth wiring both into host-tests.

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Adversarial §1–§6 review at 96e069ad52d1f0b7455c654c6bd2ab0cb7710aa6: APPROVE (ready for MERGETRAIN-LINUX4).

Diff & Test Verification

  • Zero functional kernel change: Only drivers/gpu/drm/apple/epic/dpavservep-identity-test.c (+143) and a single #include "dpavservep-identity-test.c" inside the existing #if IS_ENABLED(CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST) block at dpavservep.c:830 (+1). Production code is untouched.
  • Coverage & branch fidelity: Verified all 30 rows in dpavid_cases[] against static bool dcpavserv_identity() (dpavservep.c:37-59). Because the test is #included into dpavservep.c, it exercises the real static production function, not a copy. Every admission shape and every guard condition has a discriminating row:
    • Name gate (NULL and non-matching strings across legacy, v2, ext26).
    • Classic wire (!wire_v2: unit == 0 admitted regardless of class/channel; unit == 1 refused).
    • AFKV2 on DPAVSERV_ENDPOINT_V2 (0x2a): both allowed classes (AppleDCPDP2HDMI, DCPDP13Service), unit == channel in 1..U16_MAX, plus mismatch, unit == 0, channel == 0 (catches !service->channel even when unit == channel == 0), channel > U16_MAX, NULL class, and wrong class.
    • AFKV2 on DPAVSERV_ENDPOINT (0x28, from #2783): both allowed classes with unit == 0 and channel 1..U16_MAX, plus unit == channel, channel == 0, channel > U16_MAX, NULL class, and wrong class.
    • AFKV2 on other endpoint (0x29) refused.
    • Native26 external role (dcp_is_ext26() asserted true via DCP_IOMFB_METHODS_J613_EXT26): DCPDPService + unit == 0 + nonzero channel + DPAVSERV_ENDPOINT only, with individual refusal rows for unit, channel, class, and DPAVSERV_ENDPOINT_V2.
  • Negative control validity: Reverting dcpavserv_identity() to pre-#2783 (DPAVSERV_ENDPOINT_V2 only for AFKV2) flips the three v2 ep 0x28 admit rows (rows 16–18) while leaving the remaining 27 passing.

§1–§6 Checklist

  • §1 No model gating: Pass (test-only; uses existing DCP_IOMFB_METHODS_J613_EXT26 enum solely to drive the existing dcp_is_ext26() branch).
  • §2 Production-ready / no hacks: Pass (zero production changes).
  • §3 Safety: Pass (test-only).
  • §4 Clean-room & attribution: Pass (single commit with human author/committer + human Signed-off-by: only, zero AI trailers in commit; PR body discloses Assisted-by:).
  • §5 Evidence: Pass for test-only PR (kunit.py run --arch=arm64 43/43 pass + negative control reported; CI host-tests green).
  • §6 Naming: Pass.

Non-blocking Notes

  1. dpavservep-identity-test.c:88: 0x29 can use AV_ENDPOINT (already in scope from ../dcp-internal.h:108) for readability.
  2. CI (host-tests.yml) does not currently build/run CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST (same existing gap as dpavservep-v14-test.c); wiring both display KUnit suites into CI as a follow-up would keep regressions caught automatically.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Author

Merge-train adversarial review (MERGETRAIN-LINUX4) at 96e069a: no blockers. Merges clean on integration/aurora.

Full review

VERDICT: NO BLOCKERS

  • Test-only: the one line outside the new file is the #include under CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST, next to the existing v14 suite, so the static dcpavserv_identity() at dpavservep.c:37-58 is the function under test.
  • Walked every branch against the table: name gate (4 rows, one per role); ext26 (endpoint 0x28, unit 0, DCPDPService, nonzero channel; each condition has a flipping row incl. the 0x2a endpoint); classic wire (unit == 0 only, class/channel ignored); AFKV2 class/channel bounds (no class, DCPDPService, channel 0, channel > U16_MAX on both endpoints); 0x2a unit == channel; 0x28 unit == 0 and the unit == channel refusal; any other endpoint. The expected results match the code at this head.
  • ep->wire_v2 is set for the ext26 role too, matching how the ext26 branch is reached before the wire check; the dcp_is_ext26() expectation guards the fixture itself.
  • Commit: author and Signed-off-by human, no agent trailers.

Nits (non-blocking, same as the earlier review): use AV_ENDPOINT for the 0x29 row; CI does not enable CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST, so this suite and the v14 one only run by hand until they are wired into host-tests.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide
RyanTheTide merged commit 120d6aa into integration/aurora Nov 22, 2026
1 check passed
@RyanTheTide

Copy link
Copy Markdown
Author

Post-merge run at integration/aurora 120d6aa (the merge of this PR), kunit.py arm64/qemu, LLVM=1, display kunitconfig: apple-dcpavserv-identity 30/30, together with apple-dcpavserv-v14 43/43, same as before the merge. No CI job runs these suites yet, so they are only checked when run by hand.

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