Skip to content

drm/apple: test apple_typec_port_rgb8_only() - #2833

Merged
RyanTheTide merged 1 commit into
integration/aurorafrom
test-coverage/typec-rgb8-only
Nov 22, 2026
Merged

RyanTheTide merged 1 commit into
integration/aurorafrom
test-coverage/typec-rgb8-only

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Problem

apple_typec_port_rgb8_only() (from #2783) decides whether a Type-C connector gets the BT.2020/PQ output properties: it must not when any pipeline that can drive the port runs the native26 (ext26) method set, which scans out XRGB8888 only. It had no test.

Change

Make the function visible to KUnit (VISIBLE_IF_KUNIT; builds without KUnit are unchanged) and add topology_rgb8_only_test to the apple-dcp-topology suite. It registers four ports over a 10-bit pipeline, an ext26 pipeline and one without drvdata. It then checks the any-pipeline and single-pipeline scopes, the port-candidate filter, a candidate without drvdata being skipped, a port with no routes, and an index past the last port. No functional change.

Testing

  • KUnit, arm64 qemu, LLVM=1, tests/topology.kunitconfig: apple-dcp-topology 7/7 (6/6 before). All suites in that config: 201 of 202 pass, with 1 skip (apple_g17_rx_util_min_test needs CONFIG_UCLAMP_TASK, unrelated).
  • Negative controls: 4 mutants of the function, and the new test kills all 4. Without the pipeline filter, 2 expectations fail. Without the candidate filter, 4 fail. Returning on the first candidate fails 3. Without the NULL drvdata check, the function oopses and KUnit marks the test failed.
  • checkpatch.pl --strict: clean.

Still to run

  • Nothing on hardware (test-only).

Assisted-by: LLM (Claude:Opus 5.5)

apple_typec_port_rgb8_only() decides whether a Type-C connector gets the
BT.2020/PQ output properties: it must not when any pipeline that can drive
the port runs the native26 (ext26) IOMFB method set, which scans out
XRGB8888 only. It had no test.

Make it visible to KUnit (VISIBLE_IF_KUNIT, no change for non-KUnit
builds) and add topology_rgb8_only_test to the apple-dcp-topology suite.
It registers four ports over a 10-bit pipeline, an ext26 one and one
without drvdata, and checks: no pipelines; any pipeline with an ext26
candidate after a 10-bit one; a single pipeline counting only its own
method set, including one that is not a candidate for the port; a port
the ext26 pipeline cannot drive; a candidate without drvdata being
skipped; a port without routes and an index past the last port.

No functional change.

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

Copy link
Copy Markdown
Contributor Author

Review at 17db3f1.

The test calls the real apple_typec_port_rgb8_only() (made non-static through VISIBLE_IF_KUNIT; the test is #included into dcp-fabric.c in the same appledrm module, so no export is needed) and the real dcp_typec_port_has_candidate() over ports added to the real dcp_typec_ports list. Non-KUnit builds are unchanged. Fine to merge. Two notes:

  1. drivers/gpu/drm/apple/dcp-fabric-topology-test.c:488: no case has the ext26 pipeline at index 0 of dcp[] (all puts it at 1, nodata_first at 2). The mutant for (i = 1; ...) at apple_drv.c:1279 survives. Adding { ext26, plain, nodata } with NULL, both -> true would kill it.
  2. CI: tests/topology.kunitconfig is not run by any workflow. host-tests.yml runs tools/asahi/run-host-tests.py, which does not touch KUnit, and mt7932-kunit.yml is wifi only. The new case runs only by hand. This gap predates this PR, but the suite's coverage claims depend on it.

@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 §1–§6 review at 17db3f1c46c43671d801f4d3d8a0da59afd85670: APPROVE (ready for MERGETRAIN-LINUX4).

Checklist Audit (§1–§6)

  • §1 No model gating: Pass — test-only change exercising hardware-derived DCP_IOMFB_METHODS_J613_EXT26 (dcp_is_ext26()).
  • §2 Production-ready / zero regressions: Pass — apple_drv.c only switches apple_typec_port_rgb8_only() from static to VISIBLE_IF_KUNIT (identical static linkage when CONFIG_KUNIT is off). dcp-fabric.h guards the prototype with #if IS_ENABLED(CONFIG_KUNIT), and apple_drv.c includes it via dcp.h, keeping -Wmissing-prototypes clean across KUnit on/off configs. Because dcp-fabric-topology-test.c is #included in dcp-fabric.c within the same appledrm module as apple_drv.c, no symbol export is needed.
  • §3 Safety / test hygiene: Pass — topology_rgb8_init() registers topology_rgb8_unlist() via kunit_add_action_or_reset(), which runs in LIFO order before kunit_kzalloc() / kunit_platform_device_* teardown and cleans up dcp_typec_ports under dcp_typec_fabric_lock even on init failure.
  • §4 Clean-room & attribution: Pass — single commit 17db3f1c46c4, human author/committer (Ryan Murray <ryan@aurorasilicon.org>) + human Signed-off-by: only, zero AI trailers in commit; PR body includes Assisted-by:.
  • §5 Evidence: Pass (test-only) — arm64 QEMU LLVM=1 with drivers/gpu/drm/apple/tests/topology.kunitconfig (apple-dcp-topology 7/7, 201/202 overall with 1 unrelated CONFIG_UCLAMP_TASK skip), 4/4 mutants killed (pipeline filter, candidate filter, early return on first candidate, NULL drvdata check), checkpatch.pl --strict clean.
  • §6 Naming: Pass.
  • CI & mergeability: host-tests SUCCESS; MERGEABLE (CLEAN) against integration/aurora.

Non-blocking Follow-up Notes (echoing @RyanTheTide's self-review)

  1. Surviving mutants (dcp-fabric-topology-test.c:488-527):
    • Neither all[] nor nodata_first[] puts ext26 at index 0, so for (i = 1; i < num_dcp; i++) in apple_drv.c:1279 survives. Adding a case with ext26 at index 0 (e.g., { ext26, plain, nodata } with NULL, both -> true) would kill it.
    • RGB8_PLAIN leaves iomfb_method_profile == 0 (DCP_IOMFB_METHODS_DEFAULT), so a mutant replacing dcp_is_ext26(d) with d->hw.iomfb_method_profile != DCP_IOMFB_METHODS_DEFAULT would also survive; setting a non-ext26 non-default profile (e.g., DCP_IOMFB_METHODS_H17G) on a plain pipeline would close that too.
  2. Pre-existing CI gap: drivers/gpu/drm/apple/tests/topology.kunitconfig is not wired into any .github/workflows/*.yml (host-tests.yml runs tools/asahi/run-host-tests.py only; mt7932-kunit.yml is Wi-Fi only). Worth wiring in a separate CI follow-up so the suite runs automatically on PRs.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

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

Full review

VERDICT: NO BLOCKERS

  • Linkage: apple_drv.o and dcp-fabric.o are both in appledrm-y (Makefile:5-6), and the topology test is #included into dcp-fabric.c, so the VISIBLE_IF_KUNIT symbol needs no export. The prototype in dcp-fabric.h is under IS_ENABLED(CONFIG_KUNIT), exactly when the function is non-static, so neither config trips -Wmissing-prototypes; without KUnit the function stays static and its one caller (apple_drv.c:1394) is unchanged.
  • The fixture registers its four ports on the real dcp_typec_ports list under dcp_typec_fabric_lock and removes them through a KUnit action, and indexes from dcp_typec_nr_ports() taken before the insert, so it does not disturb ports a real DCP registered earlier.
  • Expectations match the function: num_dcp == 0 false; any-pipeline scope true when an ext26 candidate exists (also with the no-drvdata pipeline first); single-pipeline scope follows pipeline; the ext26 pipeline that is not a candidate for the port is ignored; the no-drvdata ext26 pipeline is skipped.
  • Commit: human author and Signed-off-by, no agent trailers.

Nit (same as the earlier review): no case puts the ext26 pipeline at dcp[0], so a for (i = 1; ...) mutant survives; one more array would close it.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide
RyanTheTide merged commit 8b360dc into integration/aurora Nov 22, 2026
1 check passed
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Executed check at 8b360dc (integration/aurora tip, which is the #2833 merge of 17db3f1), arm64 qemu KUnit, LLVM=1, drivers/gpu/drm/apple/tests/topology.kunitconfig.

  • All suites in the config: 202 run, 201 pass, 1 skip (apple_g17_rx_util_min_test, needs CONFIG_UCLAMP_TASK). apple-dcp-topology 7/7, topology_rgb8_only_test passes. Same as the PR's numbers.
  • Four new mutants of apple_typec_port_rgb8_only() (apple_drv.c:1272-1291), 2 killed, 2 survive:
    • loop stops one short (i < num_dcp - 1): killed at dcp-fabric-topology-test.c:507 and :521.
    • missing drvdata treated as ext26 (!d || dcp_is_ext26(d)): killed at :519.
    • loop starts at 1 (i = 1): survives. This confirms the earlier note that no case has the ext26 pipeline at dcp[0].
    • d->hw.iomfb_method_profile != DCP_IOMFB_METHODS_DEFAULT instead of dcp_is_ext26(d): survives, because the plain pipeline is on the default method set. This confirms the other earlier note.
  • A follow-up test change kills both survivors. It adds a { ext26, plain, nodata } array with NULL, both -> true, and puts the plain pipeline on DCP_IOMFB_METHODS_H17G. With it the real function passes 7/7, start-at-1 fails at :513, and the profile mutant fails at :516 and :522. The diff is 6 added lines. It is not pushed and can go in a follow-up PR.
  • Nothing blocking. The test is merged and correct for the cases it has. The two gaps above are the only weak spots I found.

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