Skip to content

drm/apple: dcp: leave the bind's clocks to its devres group - #2832

Merged
RyanTheTide merged 1 commit into
integration/aurorafrom
m2mini/dcp-unbind-clk
Nov 22, 2026
Merged

RyanTheTide merged 1 commit into
integration/aurorafrom
m2mini/dcp-unbind-clk

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

Problem

dcp_comp_unbind() releases dcp->clk with devm_clk_put(). That walks every devm clock entry on the device. The optional clock-194 lookup leaves an entry with a NULL clock on nodes that have no such clock, and devm_clk_match() warns on it. So every unbind of such a DCP prints a WARNING with a stack trace. On the M2 Mac mini (J473) it shows each time the HDMI DCP fails to bind and the component framework unbinds the DCP that already bound.

Change

Both clocks are got during bind, inside the devres group the component framework opens for that bind. component_unbind() releases the group right after the unbind callback. So drop the explicit put and only clear the pointers, as the code already did for clk_194. No behaviour change apart from the missing warning.

Testing

  • J473 (T8112, macOS 27.2 stub), lab trial in which the HDMI DCP refuses to bind and the primary DCP is unbound again:
    • Before (this tree without the patch): WARNING: drivers/clk/clk-devres.c:323 at devm_clk_match, called from devm_clk_put in dcp_comp_unbind.
    • After: the same bind failure with 0 warnings in the whole boot journal. Enforcing, 0 AVC.
  • Apple DCP host suite (tools/asahi/run-host-tests.py --only dcp): 34/34 pass, including the KUnit apple-dcp run that calls dcp_comp_unbind().
  • Default kernel command line; no parameters.

Still to run

  • An unbind or bind-failure row on another Mac with a DCP (M1/M2 ref Macs). The path is shared with no chip-specific code.
Reviewer detail
  • The warning comes from devm_clk_match(): if (!c || !*c) { WARN_ON(!c || !*c); return 0; }. devm_clk_get_optional(dev, "clock-194") registers a devres whose clock is NULL when the property is absent, and devm_clk_put(dev, dcp->clk) runs the match over every devm_clk_release entry of the device.
  • dcp->clk and dcp->clk_194 are acquired in dcp_comp_bind_pipe(), which the component framework calls inside devres_open_group(component->dev, component, ...). component_unbind() calls devres_release_group(component->dev, component) after ->unbind(), which puts both clocks.
  • dcp_platform_shutdown() also calls dcp_comp_unbind() directly on some paths. There the clock reference is left to the device's lifetime, which is harmless at power-off. Nothing else used the put for ordering (no clk_disable in unbind).
  • Hardware rows: the trial in which the warning was seen and the one without it are on the lab store (M2MINI-LINUX lane, traces/display/20261123-j473-live-rtkit, rows 1 and 4). The trigger there was an experimental loader handoff that Linux rejects on purpose. Any DCP bind failure after another DCP has bound takes the same unbind path.

Assisted-by: LLM (Claude:Opus 5.5)

dcp_comp_unbind() put dcp->clk with devm_clk_put(). That walks every
devm clock entry of the device, and the optional "clock-194" lookup
leaves an entry whose clock is NULL when the node has no such clock.
devm_clk_match() warns on that entry (clk-devres.c), so every unbind
of a DCP without clock-194 printed a WARNING with a stack trace. On a
J473 this shows whenever another DCP fails to bind and the component
framework unbinds the DCP that already bound.

Both clocks are got during bind inside the devres group the component
framework opens for it, and component_unbind() releases that group
right after the unbind callback. Drop the explicit put and only clear
the pointers, as was already done for clk_194.

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

Copy link
Copy Markdown
Contributor Author

Review at 419a05c.

Correct. dcp->clk and dcp->clk_194 are both got in dcp_comp_bind_pipe() (dcp.c:6651-6659), which only runs from dcp_comp_bind(), i.e. inside the devres group the component framework opens for the bind, so component_unbind() puts both right after the callback. devm_clk_put() walking every devm_clk_release entry and hitting the NULL clock-194 entry in devm_clk_match() explains the WARNING exactly.

Notes, none blocking:

  1. The two direct dcp_comp_unbind(&pdev->dev, NULL, NULL) calls in dcp_platform_shutdown() (dcp.c:8015, 8023) now keep the clock reference until the device goes away instead of dropping it. Nothing disables the clock in unbind, so at power-off that is harmless, as the body says; a one-line note in the commit message would save the next reader the same check.
  2. The ext_failsafe path in dcp_comp_bind() returns 0 after a failed bind, so the group (and both clocks) stays held until the next unbind. Same as before this patch; just confirming the comment's "released with the bind's devres group" holds there too.
  3. Still owed, as listed: one unbind/bind-failure row on an M1 or M2 ref Mac (shared path).

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

Pre-PR Checklist Review (§1–§6) — 419a05c37b8071c7e1d01cb3df8af45a08e8edea

Reviewed full diff, devres/component lifecycle, error paths, commit metadata, and CI status. LGTM.

  • Root cause & devres lifetime verified: Both dcp->clk (devm_clk_get_optional/devm_clk_get) and dcp->clk_194 (devm_clk_get_optional) are acquired in dcp_comp_bind_pipe() (dcp.c:6649-6664) inside the component bind devres group (component_bind() -> devres_open_group(component->dev, component, ...)). When clock-194 is absent, devm_clk_get_optional() registers a devm_clk_state with state->clk == NULL. Calling devm_clk_put(dev, dcp->clk) in dcp_comp_unbind() walked devm_clk_release entries in LIFO order, hit the NULL clk_194 entry first, and tripped WARN_ON(!c || !*c) at drivers/clk/clk-devres.c:323.
  • Teardown & error paths verified:
    • Normal unbind: component_unbind() immediately calls devres_release_group(component->dev, component) (drivers/base/component.c:600), putting both clocks cleanly (clk_put(NULL) is a no-op).
    • Bind failure / -EPROBE_DEFER: component_bind() rolls back the devres group automatically on error; ext_failsafe retains the group until unbind/remove (and already bypassed devm_clk_put() via the ext_dead early return).
    • Teardown ordering: dcp->clk and dcp->clk_194 are never clk_prepare_enable()/clk_disable_unprepare()'d in dcp.c (only rate-queried), and both pointers are cleared to NULL before returning from dcp_comp_unbind(), so deferring clk_put() to the immediately following devres_release_group() has no ordering impact.
    • Direct dcp_comp_unbind(&pdev->dev, NULL, NULL) in dcp_platform_shutdown() (dcp.c:8013, 8021): harmless at power-off (M4 never gets clocks in dcp_comp_bind_pipe(), and retain_dma H17P external intentionally keeps its bind devres group across shutdown).
  • §1–§6 Checklist:
    • §1 No model gating: Pass (shared component unbind path, zero chip/board checks).
    • §2 Production-ready: Pass (default cmdline, removes broken explicit devm_clk_put()).
    • §3 Safety: Pass.
    • §4 Clean-room & attribution: Pass (human author/committer Ryan Murray <ryan@aurorasilicon.org>, human Signed-off-by, zero AI trailers in commits).
    • §5 Evidence: Verified before/after A/B on J473 (M2 Mac mini, T8112) eliminating the devm_clk_match WARNING with 0 warnings in boot journal, enforcing, 0 AVC; plus run-host-tests.py --only dcp 34/34 and CI host-tests green. (Non-blocking: the PR notes an optional follow-up unbind row on another M1/M2 ref Mac, and a one-line mention of dcp_platform_shutdown() in the commit message would be nice-to-have if amended.)
    • §6 Naming: Pass.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merge-train adversarial review (MERGETRAIN-LINUX4) at 419a05c: no blockers. Merges clean on integration/aurora, alone and together with #2828-#2832.

Full review

VERDICT: NO BLOCKERS

Blockers: none.

Checked:

  • Root cause, drivers/clk/clk-devres.c:319-336 (tip): devm_clk_match() WARNs on an entry whose clk is NULL.
    devres_release() walks the list newest first. clk_194 (dcp.c:6659, devm_clk_get_optional) is got after
    dcp->clk (:6651/:6653), so its NULL entry is checked first and warns. This matches the commit message.
  • Normal component path: dcp_comp_bind() (:6790) -> dcp_comp_bind_pipe() (:6450) gets both clocks inside
    component_bind's devres group, and component_unbind releases that group right after dcp_comp_unbind()
    (:7002-7008). Nothing in dcp.c enables or disables these clocks (they are only used for rates:
    iomfb_template.c:1483, iomfb_h17p.c:316-317), so deferring the clk_put by a few calls changes nothing.
    The old code put only dcp->clk, so dropping its explicit put cannot cause a double put, and clk_194 was
    already left to the group.
  • Bind failure: the component framework releases the group. With ext_failsafe, dcp_comp_bind returns 0 and
    the group is held until unbind, the same as before.
  • Direct calls outside the component framework, dcp.c:8015/8023 (dcp_platform_shutdown) and the KUnit callers
    (av-lifetime-test.c:66/652/659, dcp_external_announce_test.c:241/309): no test checks clock puts, and at
    shutdown keeping the ref is harmless.

Nits (not blocking):

  1. The commit message says "Both clocks are got during bind inside the devres group the component framework
    opens". That is not always true. Retained externals (dcp_is_retained_external(), dcp.c:677: H17P external
    and ext26) call dcp_comp_bind(dev, NULL, NULL) from probe at dcp.c:7717-7719, outside any component group,
    so their clocks land in the device-lifetime devres. The old devm_clk_put dropped that dcp->clk ref on a
    component unbind; now it is held until driver detach. This is bounded, not a per-cycle leak: on rebind,
    external_prepared makes dcp_comp_bind_pipe return early at :6484 before the clocks are got again. Ask
    for a one-line mention in the commit message, next to the shutdown note.
  2. Old behaviour, unchanged by this PR: after a component unbind/rebind of a retained external, dcp->clk and
    clk_194 stay NULL (rebind takes the early return at :6484), so iomfb_h17p.c:316-317 reads 0 Hz. With this
    patch the clock reference is still held there, so clearing the pointer is arguably the wrong half to
    keep. Worth a follow-up, not this PR.
  3. Still open from the earlier reviews: the shutdown note for the commit message, and the unbind or
    bind-failure row on an M1/M2 ref Mac that the PR lists as still to run. I did not run any lab rows.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide
RyanTheTide merged commit d84d1c5 into 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.

2 participants