Skip to content

drm/apple: register the system-sleep notifier at module init - #2786

Open
satchlj wants to merge 3 commits into
integration/aurorafrom
satchlj/apple-drm-pm-notifier-module-20261122
Open

satchlj wants to merge 3 commits into
integration/aurorafrom
satchlj/apple-drm-pm-notifier-module-20261122

Conversation

@satchlj

@satchlj satchlj commented Nov 22, 2026

Copy link
Copy Markdown
Member

Claude Opus 5.5 on @satchlj's behalf.

Problem

lockdep reports a circular locking dependency on the first suspend of a J775c (Mac Studio, M5 Max) with a Thunderbolt link. It is on the current integration/aurora, through three drivers:

Edge Where
component_mutex → pm_chain_head.rwsem apple_drm_bind() → apple_drm_init() → register_pm_notifier() (drivers/gpu/drm/apple/apple_drv.c)
acio->lock → tb->lock → component_mutex apple_cio_tbt_switch_set() holds acio->lock around of_platform_populate(), which probes the NHI: apple_nhi_probe() → tb_domain_add() → usb4_port_device_add() → component_add() (drivers/thunderbolt/apple.c, usb4_port.c)
pm_chain_head.rwsem → acio->lock pm_suspend() → apple_cio_dp_pm_notify() (drivers/thunderbolt/apple.c)

A suspend, a cable event and the display bind running at the same time would each wait on the next.

Change

  • register_pm_notifier() no longer runs under component_mutex.
  • appledrm registers one system-sleep notifier at module init.
  • A bound display subsystem joins a list under a new leaf mutex (apple_drm_pm_lock) at the end of apple_drm_init(), and leaves it at the start of apple_drm_uninit(). The notifier walks the list.
  • The new mutex is taken only below component_mutex and below the notifier chain, so it adds no edge back.
  • Behaviour is unchanged: the notifier acts only on PM_POST_SUSPEND, for a bound device whose outputs a dark wake held.

The Thunderbolt side stays as it is. Breaking the cycle there would mean dropping acio->lock around the NHI populate or out of the PM notifier, and both guard the cable state machine.

Testing

  • Machine: J775c, lobata.
  • Kernels: integration/aurora f5f023bc9b62 with and without this commit. Both use CONFIG_PROVE_LOCKING, DEBUG_LOCKDEP, DEBUG_ATOMIC_SLEEP and DETECT_HUNG_TASK, built from the same config.
  • DTB: the same J775c DTB for both. The tip's own J775c DTB is an inventory stub that doesn't boot, so this is lobata's carry DTB.
  • Run: default cmdline, one boot each. The boot binds the display, and Thunderbolt comes up with an XDomain peer (0-1). Then 3 system-sleep attempts with pm_test=freezer, which runs the PM notifier chain but suspends no devices; this tip hangs in a real s2idle without phy: apple: atc-t6050: keep active combo PHY domains powered across s2idle #2664.
Tip (fa1c46f4, Image f81d1142) Tip + this commit (75f10e1f, Image 53958092)
pm_test=freezer cycles 3, rc 0 3, rc 0
lockdep reports 1: the cycle above, at the first cycle 0
  • The same cycle also appeared at the first real rtcwake on lobata's candidate kernel (boot 47ceebba), which was the original find.
  • 0 SELinux denials on both boots.
  • One failed unit on both: lobata's own "power on after a power loss" service, which needs an SMC attribute this tip lacks.
  • checkpatch --strict: clean.

Not covered: a real s2idle cycle on this tip (it needs #2664), and boards other than J775c.

Assisted-by: LLM (Anthropic:Claude Opus 5.5)

apple_drm_init() registers its PM notifier at the end of the component
bind, so register_pm_notifier() takes the PM notifier chain's rwsem
under component_mutex. With the Apple CIO driver that closes a cycle,
which lockdep reports on the first suspend of a J775c (Mac Studio,
M5 Max) with a Thunderbolt link:

  component_mutex -> pm_chain_head.rwsem
	apple_drm_bind() -> register_pm_notifier()
  acio->lock -> tb->lock -> component_mutex
	apple_cio_tbt_switch_set() holds acio->lock around
	of_platform_populate(), which probes the NHI: tb_domain_add() and
	usb4_port_device_add() -> component_add()
  pm_chain_head.rwsem -> acio->lock
	pm_suspend() -> apple_cio_dp_pm_notify()

With a suspend, a cable event and the display bind at the same time,
each waits on the next.

Register one notifier at module init instead. A bound display
subsystem joins a list under a new leaf mutex at the end of init and
leaves it at the start of uninit, and the notifier walks that list.
register_pm_notifier() then never runs under component_mutex, and the
new mutex is taken only below component_mutex and the notifier chain.
The notifier still acts only on PM_POST_SUSPEND for a bound device
whose outputs a dark wake held, as before.

Signed-off-by: Satya Benson <satya@benson.earth>
@RyanTheTide

Copy link
Copy Markdown
Contributor

Read at a004bcb. Registering one notifier at module init and keeping bound instances on a list breaks the reported cycle: register_pm_notifier() no longer runs under component_mutex, and unbind's list_del_init() under the new mutex means the notifier can't walk an instance that is being torn down.

One thing to check: the comment calls apple_drm_pm_lock a leaf, but apple_drm_resume_outputs() runs under it, and that path takes the DRM modeset locks (and whatever the output resume needs). So the lock order is now pm_chain_head.rwsem -> apple_drm_pm_lock -> modeset locks, and unbind takes component_mutex -> apple_drm_pm_lock. That's fine as long as nothing holding a modeset lock (or component_mutex) can wait on apple_drm_pm_lock. Please either say so in the comment instead of "leaf", or collect the instances that need resuming under the mutex and call apple_drm_resume_outputs() after dropping it, with a reference to keep each instance alive.

Rows: the J775c first suspend with lockdep on and a Thunderbolt link (no splat), plus a bind racing a suspend if you can provoke it. On our side a J713 and J616s suspend with an external display would show the dark-wake resume path still runs.

Assisted-by: LLM (Claude:Opus 5.5)

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

Reviewed at a004bcbadd2c5b3473e36fdeb744b43b87c64c82 against the pre-PR checklist (§1–§6).

The core approach—registering a single module-level PM notifier in appledrm_register() / appledrm_unregister() and tracking bound apple_drm_private instances on a list—breaks the reported component_mutex -> pm_chain_head.rwsem edge in apple_drv.c. Module init/exit ordering, apple->aborted handling, multi-instance list management, !CONFIG_PM_SLEEP compilation, §4 commit metadata, and host-tests CI are all clean.

Two blockers before merge:

1. apple_drm_pm_lock is not a leaf mutex (apple_drv.c:89 & commit message)

Both the comment (apple_drv.c:89: "apple_drm_pm_lock is a leaf below both") and the commit message describe apple_drm_pm_lock as a leaf mutex. In apple_drm_pm_notify(), however, apple_drm_pm_lock is held across apple_drm_resume_outputs(), which acquires a deep stack of locks:

  • dcp->hpd_mutex (apple_drm_hold_resume_events() → dcp_hold_resume_event())
  • DRM modeset locks, console_lock, fbdev and DCP locks (drm_mode_config_helper_resume())
  • ci->ctl and ci->plane->mutex (dcp_indicator_display_resumed())
  • clientlist_mutex and client hotplug locks (drm_kms_helper_hotplug_event())

Holding apple_drm_pm_lock across apple_drm_resume_outputs() is actually useful for lifetime exclusion against apple_drm_uninit() (note that simply dropping the lock with drm_dev_get() would still allow drm_dev_unplug() / component_unbind_all() to race unless also paired with drm_dev_enter()/drm_dev_exit()). As @RyanTheTide noted, please either:

  • Update the comment and commit message to drop the "leaf" claim and document the real lock order ({component_mutex, pm_chain_head.rwsem} -> apple_drm_pm_lock -> {dcp->hpd_mutex, DRM modeset locks, ci->ctl, ...}, noting that none of those paths may acquire apple_drm_pm_lock or component_mutex), or
  • Snapshot the instances needing resume under apple_drm_pm_lock and run apple_drm_resume_outputs() outside it with proper lifetime/unplug protection (drm_dev_get() + drm_dev_enter()/drm_dev_exit()).

2. Sibling register_pm_notifier() / unregister_pm_notifier() under component_mutex in t8132_ext_drm.c (§1)

apple_drm_init() → apple_drm_init_dcp() → t8132_ext_drm_init() (drivers/gpu/drm/apple/t8132_ext_drm.c:1220) still calls register_pm_notifier(&t8132_ext_pm_nb) under component_mutex, and apple_drm_uninit() → t8132_ext_drm_fini() (t8132_ext_drm.c:1057) still calls unregister_pm_notifier(&t8132_ext_pm_nb) under component_mutex.

On T8132 systems with adopted external outputs (apple,t8132-dcpext) and Thunderbolt active, the exact same component_mutex -> pm_chain_head.rwsem -> acio->lock -> tb->lock -> component_mutex cycle remains live in appledrm. Since t8132_ext_pm_nb is already a single static notifier guarded by t8132_ext_reg_lock, moving its registration to module init/exit alongside apple_drm_pm_nb (or explicitly scoping this commit to apple_drv.c if t8132_ext_drm.c is fixed in a companion commit/PR) would keep the fix consistent across all Macs.

Non-blocking notes

  • §5 evidence / SHA binding: The testing table cites local commit 75f10e1f rather than the pushed head a004bcba; please confirm or note the provenance when updating the PR. Note also that pm_test=freezer never runs apple_platform_resume(), so apple->dark_held stayed false and lockdep has not yet observed the apple_drm_pm_lock -> apple_drm_resume_outputs() edge (worth validating once a dark-wake/real-suspend run is available).
  • Nit: Checking the return value of register_pm_notifier(&apple_drm_pm_nb) in appledrm_register() would match dcp_s2r_pm_register().

Assisted-by: LLM (Gemini 4 Neon)

Two gaps in the previous commit:

- apple_drm_pm_lock was described as a leaf, but apple_drm_pm_notify()
  held it across apple_drm_resume_outputs(), which takes the hotplug,
  modeset, fbdev and DCP locks and clientlist_mutex. The notifier now
  only queues each held device's restore (pm_resume_work) on an ordered
  workqueue under the lock, and the restore runs from the work. The next
  PM_SUSPEND_PREPARE flushes the queue, outside the lock, so a restore
  never overlaps the next suspend; apple_drm_uninit() cancels its
  device's after taking it off the list. PM_POST_SUSPEND already runs
  after user space is thawed (suspend_finish()), so moving the restore
  to a work item does not change that order.

- The T8132 external outputs registered and unregistered their own PM
  notifier from t8132_ext_drm_init()/_fini(), which run inside the same
  component bind and unbind, so the cycle stayed open on T8132. Their
  sleep handling is now t8132_ext_drm_pm_event(), called from appledrm's
  one notifier. It still holds t8132_ext_reg_lock throughout, so fini,
  which empties the registry under that lock, still waits for a call
  under way, as the unregister did.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj

satchlj commented Nov 22, 2026 •

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf. Reply to @DjDeveloperr's review of a004bcba. Both blockers are fixed in a new commit, ffdaff64.

1. The lock really is a leaf now.

  • apple_drm_pm_notify() no longer calls apple_drm_resume_outputs() under apple_drm_pm_lock. At PM_POST_SUSPEND it only queues each held device's restore (pm_resume_work) on an ordered workqueue (appledrm-pm), under the lock. The restore runs from the work.
  • The next PM_SUSPEND_PREPARE flushes the queue, outside the lock, so a restore never overlaps the next suspend.
  • apple_drm_uninit() takes the device off the list, then cancel_work_sync()s its work.
  • Order relative to user space: unchanged. PM_POST_SUSPEND already runs after suspend_thaw_processes() (suspend_finish()).
  • Init fails with -ENOMEM if the workqueue can't be allocated.

2. T8132.

  • t8132_ext_pm_nb and its register/unregister in t8132_ext_drm_init()/_fini() are gone.
  • The T8132 sleep handling is now t8132_ext_drm_pm_event(), called first from appledrm's one notifier, which is registered at module init. It still holds t8132_ext_reg_lock throughout, so t8132_ext_drm_fini(), which empties the registry under that lock, still waits for a call under way, as the unregister did.
  • A failed PM_SUSPEND_PREPARE still rolls its own outputs back before returning the error.

Rows (J775c, lobata). Lockdep on (PROVE_LOCKING, DEBUG_LOCKDEP, DEBUG_ATOMIC_SLEEP), debug_locks read from /proc/lockdep_stats before and after.

Tree What ran debug_locks before → after lockdep reports
integration/aurora f5f023bc boot + 3 × pm_test=freezer — 1, the cycle in the description
tip + a004bcba + ffdaff64 (Image 1574c3a5, boot 2b4c52ca) boot + 3 × pm_test=freezer 1 → 1 0
lobata's candidate (has #2664) + both commits (Image 814bc1df, boot 119dbab5) boot with an XDomain peer, then 3 × real rtcwake -m freeze -s 12 1 → 1 0
  • In the real-s2idle row, HDMI came back connected/enabled/On after each cycle, and Thunderbolt networking pinged at +16 s each time.
  • 0 SELinux denials on all three.
  • The failed unit on the tip boots is lobata's own power-on-after-loss service, which needs an SMC attribute this tip lacks.
  • checkpatch --strict: clean. apple_drv.o and t8132_ext_drm.o build with W=1 and no warnings, with CONFIG_DRM_APPLE_DCP_T8132 both on and off.

Not covered

  • The moved restore path itself. dark_held is only set on a dark wake, which on this tree comes from macsmc (lid-type events) or deep sleep. J775c is a desktop without deep sleep, so the work never had anything to restore here. A laptop row is needed: lid closed during s2idle, then opened.
  • T8132: compile-only. It needs a J713 row with an external output across s2idle.
  • Unbind/rebind: on this kernel the display subsystem doesn't rebind, with or without this PR. Both DCPs report "external display processor unusable", and there's a devm_kfree WARN in the DCP component bind. The next s2idle then hangs. So the bind path after an unbind isn't covered. The unbind itself ran under lockdep with 0 reports, on a004bcba alone (boot 0a9c3c3e), before these fixes. Rows no longer unbind on this machine.

Assisted-by: LLM (Anthropic:Claude Opus 5.5)

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

Re-reviewed at ffdaff64ca617cb0039596ca02795b7e66f53fa1 (delta a004bcba..ffdaff64) against pre-pr-checklist.md (§1–§6).

Both Wave 23 blockers are cleanly resolved:

  1. apple_drm_pm_lock is now a true leaf mutex (drivers/gpu/drm/apple/apple_drv.c): apple_drm_pm_lock guards apple_drm_pm_list only, and apple_drm_pm_notify() now queues pm_resume_work onto the ordered apple_drm_pm_wq rather than invoking apple_drm_resume_outputs() under the lock. PM_SUSPEND_PREPARE flushes apple_drm_pm_wq outside apple_drm_pm_lock, and apple_drm_uninit() removes apple->pm_node under the lock before calling cancel_work_sync(&apple->pm_resume_work) prior to teardown. Module init/exit unwind (alloc_ordered_workqueue / destroy_workqueue, register_pm_notifier / unregister_pm_notifier) and #ifdef CONFIG_PM_SLEEP guards are clean.
  2. Sibling T8132 PM notifier folded into apple_drm_pm_nb (drivers/gpu/drm/apple/t8132_ext_drm.c, t8132_ext_drm.h): t8132_ext_pm_nb and its (un)register_pm_notifier() calls under component_mutex are removed. t8132_ext_drm_pm_event() runs from apple_drm_pm_notify() under t8132_ext_reg_lock, preserving the teardown drain guarantee against t8132_ext_drm_fini() and keeping a NOTIFY_DONE inline stub when !IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8132). Also verified dcp_s2r_pm_register() in dcp.c:7451 runs in dcp_probe() (outside component_mutex), leaving no remaining register_pm_notifier() under component_mutex in appledrm.
  3. Lock ordering verified ABBA-free:
    • {component_mutex, pm_chain_head.rwsem} -> apple_drm_pm_lock (leaf)
    • {component_mutex, pm_chain_head.rwsem} -> t8132_ext_reg_lock -> {DRM modeset locks, t8132_ext_lock} (neither t8132_ext_drm_init() nor t8132_ext_drm_fini() is ever called under modeset locks; apple_drm_init() releases drm_modeset_unlock_all() on all error paths before t8132_ext_drm_fini())
    • {component_mutex, pm_chain_head.rwsem} -> apple_drm_pm_wq / pm_resume_work -> {dcp->hpd_mutex, modeset locks, ci->ctl, clientlist_mutex} with no cycle back to component_mutex, pm_chain_head.rwsem, or apple_drm_pm_lock.
  4. CI, §4 & §5: host-tests CI passes at ffdaff64ca61; both commits carry human author/committer and Signed-off-by: only (zero AI commit trailers); J775c (lobata) re-verification at a004bcba + ffdaff64 passed 3 × pm_test=freezer on tip and 3 × real rtcwake -m freeze -s 12 with XDomain peer + HDMI (debug_locks 1 -> 1, 0 lockdep reports, 0 SELinux denials).

Non-blocking notes:

  • As noted under Not covered, the laptop dark-wake restore path (pm_resume_work with dark_held = true) and J713 T8132 external-output s2idle path remain compile-checked / uncovered on J775c (worth confirming on a laptop + J713 when available).
  • Minor comment nit: drivers/gpu/drm/apple/t8132_ext_drm.c:903 still refers to t8132_ext_pm_notify() instead of t8132_ext_drm_pm_event().

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-read at ffdaff6.

  • The leaf point from my last comment is fixed. apple_drm_pm_notify() only queues under apple_drm_pm_lock, and list_del_init() followed by cancel_work_sync() in apple_drm_uninit() covers the lifetime. The notifier can't requeue a device it no longer finds on the list. I also checked flush_workqueue() at PM_SUSPEND_PREPARE. It runs before the freeze, on a non-freezable queue, and holds nothing the work takes, so I don't see a deadlock. The T8132 fold-in leaves no register_pm_notifier() under component_mutex, and T8132 outputs are still found by the apple,t8132-dcpext compatible. Thanks for the J775c lockdep rows.

  • One ordering problem remains, and it comes from moving the registration to module init. At the base, appledrm's notifier was registered at the end of the bind, after every DCP had probed, so it ran after each DCP's dcp_s2r_pm_nb (dcp.c:9435). On PM_POST_SUSPEND, dcp_s2r_dark_finish() (dcp.c:9383) restarted a held DCPEXT's firmware first, and only then did appledrm restore the outputs. The old T8132 notifier was ordered the same way. Now apple_drm_pm_nb is registered right after dcp_register(). A DCP whose probe defers, or that is rebound, ends up after it in the chain. The restore then runs on the kworker while the PM thread may still be inside dcp_s2r_dark_finish(), and t8132_ext_drm_pm_event() replays before DCPEXT is back. Giving apple_drm_pm_nb a lower priority than the DCPs' (for example .priority = -1, with a comment saying why) brings back the old order for both calls. The queued work then always starts after the DCP restart.

  • Rows: the restore path that moved, dark wake then a suspend that fails before ->prepare(), and the T8132 external-output s2idle are still untested, as you say. A J713 row with an external display across s2idle would cover both. A J616s lid-close dark wake would cover the internal side.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Merge-train adversarial review (MERGETRAIN-LINUX3) at ffdaff6: blockers (below). Merges clean on integration/aurora 933a43f.

Full review

VERDICT: BLOCKERS

Two commits (a004bcb, ffdaff6). The component_mutex -> pm_chain_head.rwsem edge is gone. register_pm_notifier now runs only at
appledrm_register() (apple_drv.c:2234). The T8132 notifier is folded in and is no longer registered from bind. Checked and OK:

  • Init unwind: if the workqueue allocation fails, the code goes to unregister_dcp. If platform_driver_register fails, it unregisters
    the notifier and destroys the workqueue (2238-2239).
  • Exit: the notifier is unregistered after platform_driver_unregister and the workqueue is destroyed last (2257-2259). Between those
    two steps the list is empty and the T8132 registry is empty, so the callback is a no-op.
  • The notifier cannot run before the workqueue exists: it is allocated before registration.
  • apple->aborted devices: they return at 1842 before the list_add_tail, so the early return in uninit (1918) never leaves a node
    on the list.
  • list_del_init and then cancel_work_sync in uninit (1921-1926) are correct, because queuing happens only under
    apple_drm_pm_lock while the device is on the list.
  • !CONFIG_PM_SLEEP: the stub apple_drm_pm_notify (2186-2190) and the guarded INIT_WORK/cancel build. The work is never queued.
  • I see no deadlock from flush_workqueue at PM_SUSPEND_PREPARE (2165). It runs before the freeze, the queue is not freezable, and
    the work takes neither system_transition_mutex nor the notifier rwsem.

Blockers:

  1. The PM_POST_SUSPEND order between DCP and appledrm now depends on probe timing. At the base, the appledrm notifier and the T8132
    notifier were registered at the end of the component bind. By then every DCP had probed, and each DCP registers
    dcp->s2r_pm_nb from probe (dcp.c:7451 -> dcp_s2r_pm_register() dcp.c:9428-9439, same priority 0). So DCP always came first
    in the chain. Now apple_drm_pm_nb (apple_drv.c:109, no .priority) is registered at apple_drv.c:2234, right after
    dcp_register(). Any DCP whose probe defers past module init, or that is unbound and rebound, ends up after appledrm, because
    equal priority appends. Every DCPEXT probe path has -EPROBE_DEFER legs (dcp.c:7027-7067, 7800-7834, 7868-7934).
    Failure scenario: an H17P DCPEXT (dcp_s2r_ext_capable(), dcp.c:8601-8607) has a dark wake. The following suspend fails before
    ->prepare(), which is exactly the case this notifier exists for (comment at 2147). On PM_POST_SUSPEND, appledrm now runs first:

    • t8132_ext_drm_pm_event() replays synchronously.
    • apple_drm_pm_resume_work is queued on a kworker that can start at once. It runs drm_mode_config_helper_resume() while the PM
      thread has not yet reached, or is inside, dcp_s2r_dark_finish() (dcp.c:9383-9396). That function restarts the DCPEXT firmware
      (dcp_s2r_ext_start).

    The modeset races the firmware restart, or reaches a DCPEXT that is still down, and the output stays dark or gets a BAD link.
    Before this PR, the firmware restart always finished first.

    The fix is one line: .priority = -1 on apple_drm_pm_nb, with a comment saying why. A lower priority runs later, which brings
    back "DCPs first" for both calls. RyanTheTide raised this on the PR after ffdaff6 and it is not addressed at this head.

Nits:

  1. Stale comments:
    • t8132_ext_drm.c:903 still names t8132_ext_pm_notify().
    • The header at t8132_ext_drm.c:996-999 still says "The layer's one PM notifier ... the chain rolls back only the notifiers before
      this one". It is now a helper called from appledrm's notifier, and its rollback position is appledrm's.
    • The comment at apple_drv.c:2147 ("It failed before ->prepare() ...") now sits on the work function rather than the notifier.
  2. Behaviour change worth stating in the commit message. With appledrm possibly before a DCP in the chain, a PREPARE refusal from
    dcp_s2r_pm_notify (J714s crashed DCPEXT, dcp.c:9409-9414) now rolls back appledrm with PM_POST_SUSPEND. This queues the restore
    of a dark_held device. At the base, appledrm was after the refusing DCP and got no POST.
  3. PM_HIBERNATION_PREPARE does not flush apple_drm_pm_wq (2164-2165), so a restore queued by the last PM_POST_SUSPEND can overlap
    a hibernation freeze. The queue is not freezable. This is theoretical on these Macs; consider flushing on any *_PREPARE.
  4. register_pm_notifier()'s return value is ignored (2234). It cannot fail today, but dcp_s2r_pm_register() checks it.

Missing rows:

  • The moved dark-wake restore (pm_resume_work with dark_held=true) has never run. Only J775c (desktop, no dark wake) was tested,
    and its pm_test=freezer runs never set dark_held. Needed: a laptop lid-close dark wake, e.g. J616s or J713.
  • T8132 external-output s2idle is compile-only. Needed: a J713 run with an external display across s2idle.
  • A dark wake followed by a suspend that fails before prepare, on an H17P DCPEXT Mac. This is the path in blocker 1.
  • Unbind/rebind is not covered (the J775c DCPs do not rebind on this kernel).

Hygiene: both commits have a human author and committer with Signed-off-by only. No agent trailers.

Registering apple_drm_pm_nb at module init put it ahead of any DCP that
probes after the module loads (a deferred probe, or an unbind and rebind),
since the PM chain appends equal priorities. At PM_POST_SUSPEND the restore
of a dark-held device could then start before a DCPEXT's dark-wake firmware
restart (dcp_s2r_dark_finish()), and a DCP that refuses PM_SUSPEND_PREPARE
would roll appledrm back with a PM_POST_SUSPEND it did not get at bind.
Priority -1 keeps it below the DCPs' notifiers (priority 0) whatever the
probe order, which is the order the bind-time registration gave.

Also flush the restore queue at every *_PREPARE, not only the suspend one,
check register_pm_notifier()'s result, and bring the comments that still
describe a separate T8132 notifier up to date.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj

satchlj commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf.

@RyanTheTide f604f5df (a new commit) addresses the merge-train review.

  • Blocker 1: apple_drm_pm_nb now has .priority = -1, with a comment explaining why.
    • It runs below the DCPs' dcp_s2r_pm_register() notifiers (priority 0), whatever the probe order. That is the order the bind-time registration gave.
    • The T8132 external handling is called from this notifier, so it now runs after the DCPs at PM_SUSPEND_PREPARE too. At the base it was registered at the end of component bind, so it ran after them then as well.
  • Nit 1, stale comments: fixed in t8132_ext_drm.c (the t8132_ext_pm_notify() reference and the header of t8132_ext_drm_pm_event()) and at the restore work function.
  • Nit 2, the behaviour change: with priority -1, a DCP that refuses PM_SUSPEND_PREPARE again rolls back only the notifiers before it, so appledrm gets no PM_POST_SUSPEND for it, as at the base. The commit message says so.
  • Nit 3, hibernation: the restore queue is flushed at PM_SUSPEND_PREPARE, PM_HIBERNATION_PREPARE and PM_RESTORE_PREPARE. Restores are still queued only at PM_POST_SUSPEND. dark_held is set only on the suspend path, as at the base.
  • Nit 4: register_pm_notifier()'s result is checked, and a failure unwinds through the workqueue destroy.

Testing:

  • Compiled: only drivers/gpu/drm/apple/apple_drv.o, with W=1 on aarch64 gcc and 0 warnings, with DRM_APPLE_DCP_T8132 off. That build uses the t8132_ext_drm_pm_event() stub and does not compile t8132_ext_drm.c.
  • Not compiled: t8132_ext_drm.c. Its diff is comments only.
  • Not run: no boot of this head. lobata is currently unavailable.
  • Rows you listed as missing, still missing: a laptop dark wake (J616s/J713), J713 external display across s2idle, the H17P DCPEXT dark wake followed by a failed suspend, and unbind/rebind.

Assisted-by: LLM (Anthropic:Claude Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Checked f604f5d. apple_drm_pm_nb at .priority = -1, with the comment, restores the bind-time order whatever the probe order: the DCPs' dcp_s2r_pm_register() notifiers run first at both edges, and the T8132 external handling follows them. The commit message documents the refusal and rollback behaviour, the stale comments are fixed, and flushing at the hibernation and restore prepare events is the right extra guard. Code-wise this is approved from my side. The rows are still open: the dark-wake restore path, T8132 external outputs across s2idle (J713 with an external display), and a J616s lid-close dark wake.

Assisted-by: LLM (Claude:Opus 5.5)

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