Skip to content

drm: apple: #203 follow-ups: sleep drain on a dead DCP, seeded backlight level, DCP node references - #208

Merged
RyanTheTide merged 3 commits into
aurora-wipfrom
fix/dcp-sleep-backlight-followups
Oct 8, 2026
Merged

RyanTheTide merged 3 commits into
aurora-wipfrom
fix/dcp-sleep-backlight-followups

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Three follow-ups to #203 from its post-merge review, one commit each. Commit 3 fixes a reference-count bug that predates #203.

Commits

  1. drm: apple: skip the H17P sleep drain on a crashed or stopped DCP.
    • Before system sleep, the H17P drain runs up to four passes to settle a pending brightness change.
    • A crashed or stopped DCP rejects every present, and the queue drain reports it idle at once. A level that was dirty when the DCP stopped therefore stays pending.
    • All four passes then ran and the suspend logged "brightness change still pending at suspend", although nothing could be sent.
    • The drain now returns as soon as the DCP has crashed or its queue has stopped. The crash itself is already reported.
    • Fixes: 6d4dc0a94dc9 ("drm: apple: settle H17P brightness retries before system sleep")
  2. drm: apple: treat a seeded H17P backlight level as known.
    • The policy re-sends a level on the firmware's request only when Linux knows what the panel shows: the loader's reported level, or one a completed present carried.
    • dcp_bl_seed() puts a decoded powerlog sample, which is the loader's level, into the state before Linux takes control, but did not mark the level as known.
    • The helper has no caller in the driver yet, so nothing goes wrong today. Wiring it up later, for example to let a late powerlog report correct a registration default, would hit this.
    • A seeded level is now known. A new KUnit case covers an accepted seed (known, re-sendable, presented at the seeded level) and refused seeds (out of range, or after Linux took control).
    • Fixes: 73dd5dedcc77 ("drm: apple: never re-send a guessed H17P backlight level")
  3. drm: apple: stop dropping DCP node references inside the match loops.
    • for_each_matching_node() drops each node's reference itself when it moves on.
    • apple_drm_init_dcp() and add_dcp_components() also called of_node_put() on every node they visited. So every probe of the display subsystem dropped one reference more than it took on each DCP node, and every bind dropped another.
    • The nodes are static and their platform devices hold further references, so nothing has been freed. But with CONFIG_OF_DYNAMIC, repeated probe and bind attempts walk the counts towards a "Bad of_node_put()" error.
    • The loops now leave the references to the iterator.
    • Fixes: f2bc92ff49a9 ("drm/apple: Add DCP display driver")

Testing

Hardware-tested on all three machines. M2 MacBook Air (J413) and M1 Pro MacBook Pro (J316s), kernel 7.1.12-aurora-fu1-mac+ (same composition), compared with the previous kernel: every DCP binds with its device-tree nodes and no refcount errors (M1 Pro: both DCPs plus DCP audio). MacBook Neo (J700), kernel 7.1.12-aurora-j700-fu1+ (all seven follow-ups merged onto aurora-wip 35c7d87), compared item for item with the default kernel built from that base: DCP binds on every boot, brightness 2–525 nits follows every request, 5 DPMS cycles pass, results identical to the default kernel. The sleep drain on a crashed DCP (needs a suspend) and the seeded backlight level are covered by the KUnit tests only.

  • KUnit, the Apple DCP suites under QEMU (kunit.py --arch=arm64 LLVM=1):

    Tree Result
    aurora-wip 29/29
    This branch 30/30
    All follow-up branches merged 30/30
    • apple-dcp-backlight goes from 11 to 12 cases.
    • The new case fails on aurora-wip with only the test applied, and passes with the fix.
  • Native backlight harness: tools/testing/apple/check-backlight-retry.py does not compile on aurora-wip itself. Its fixture lacks min() and trips -Wunused-function on dcp_bl_resend(). With those two compile shims passed through --cc, it passes both before and after this branch. The harness itself is not changed here.

  • Builds, W=1 on the touched directories, then a full Image + modules + dtbs, on two configurations:

    • the J700 configuration with arch/arm64/configs/j700-radio.config;
    • arm64 defconfig + asahi.config with every Apple Silicon driver as a module (16K pages, Rust).
  • Warnings: every commit builds with no new warnings compared with aurora-wip (35c7d87921c0).

  • checkpatch --strict: clean, apart from the project's Assisted-by: LLM trailer-format warning.

  • Merge check: merges cleanly with aurora-wip, with the other follow-up branches, and with open PR drm/apple: support independent dual dock DP streams on J414s #46, which also touches apple_drv.c and dcp.c.

Provenance

Written for this PR from the public driver source and the review findings.

🤖 Generated with Claude Code

Before system sleep, the H17P drain runs up to four passes to settle a
pending brightness change. A crashed or stopped DCP rejects every
present, and the queue drain reports it idle at once, so a level that
was dirty when it stopped stays pending: all four passes run and the
suspend logs "brightness change still pending at suspend", although
there is nothing left that could be sent.

Return from the drain as soon as the DCP has crashed or its queue has
stopped. The crash itself is already reported.

Fixes: 6d4dc0a ("drm: apple: settle H17P brightness retries before system sleep")
Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
The H17P backlight policy re-sends a level on the firmware's request
only when Linux knows what the panel shows: the loader's reported level
or one that a completed present carried. dcp_bl_seed() puts a decoded
powerlog sample, which is the loader's level, into the state before
Linux takes control, but it does not mark the level as known. A seed
over a registration default therefore leaves a real level that cannot
be re-sent, and the state disagrees with its own definition.

The seeding helper has no caller in the driver yet, so nothing goes
wrong today, but wiring it up later, for example to let a late powerlog
report correct a registration default, would hit this. Mark a seeded
level as known and cover both the accepted and the refused seed in
KUnit.

Fixes: 73dd5de ("drm: apple: never re-send a guessed H17P backlight level")
Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
for_each_matching_node() hands each node to the loop body with a
reference held and drops that reference itself when it moves on to the
next node. apple_drm_init_dcp() also calls of_node_put() on every node
it visits, and add_dcp_components() does the same, so every probe of
the display subsystem drops one reference more than it took on each
DCP node, and binding it drops another.

The nodes are static and their platform devices keep further
references, so nothing has been freed, but the counts are wrong, and
repeated probe and bind attempts walk them towards a "Bad
of_node_put()" error with CONFIG_OF_DYNAMIC. Leave the references to
the iterator.

Fixes: f2bc92f ("drm/apple: Add DCP display driver")
Assisted-by: LLM
Signed-off-by: Ryan Murray <[email protected]>
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.

1 participant