Repository navigation
Conversation
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>
|
Read at a004bcb. Registering one notifier at module init and keeping bound instances on a list breaks the reported cycle: One thing to check: the comment calls 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
left a comment
There was a problem hiding this comment.
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->ctlandci->plane->mutex(dcp_indicator_display_resumed())clientlist_mutexand 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 acquireapple_drm_pm_lockorcomponent_mutex), or - Snapshot the instances needing resume under
apple_drm_pm_lockand runapple_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
75f10e1frather than the pushed heada004bcba; please confirm or note the provenance when updating the PR. Note also thatpm_test=freezernever runsapple_platform_resume(), soapple->dark_heldstayedfalseand lockdep has not yet observed theapple_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)inappledrm_register()would matchdcp_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>
|
Claude Opus 5.5 on @satchlj's behalf. Reply to @DjDeveloperr's review of 1. The lock really is a leaf now.
2. T8132.
Rows (J775c, lobata). Lockdep on (
Not covered
Assisted-by: LLM (Anthropic:Claude Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Re-reviewed at ffdaff64ca617cb0039596ca02795b7e66f53fa1 (delta a004bcba..ffdaff64) against pre-pr-checklist.md (§1–§6).
Both Wave 23 blockers are cleanly resolved:
apple_drm_pm_lockis now a true leaf mutex (drivers/gpu/drm/apple/apple_drv.c):apple_drm_pm_lockguardsapple_drm_pm_listonly, andapple_drm_pm_notify()now queuespm_resume_workonto the orderedapple_drm_pm_wqrather than invokingapple_drm_resume_outputs()under the lock.PM_SUSPEND_PREPAREflushesapple_drm_pm_wqoutsideapple_drm_pm_lock, andapple_drm_uninit()removesapple->pm_nodeunder the lock before callingcancel_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_SLEEPguards are clean.- 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_nband its(un)register_pm_notifier()calls undercomponent_mutexare removed.t8132_ext_drm_pm_event()runs fromapple_drm_pm_notify()undert8132_ext_reg_lock, preserving the teardown drain guarantee againstt8132_ext_drm_fini()and keeping aNOTIFY_DONEinline stub when!IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8132). Also verifieddcp_s2r_pm_register()indcp.c:7451runs indcp_probe()(outsidecomponent_mutex), leaving no remainingregister_pm_notifier()undercomponent_mutexinappledrm. - 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}(neithert8132_ext_drm_init()nort8132_ext_drm_fini()is ever called under modeset locks;apple_drm_init()releasesdrm_modeset_unlock_all()on all error paths beforet8132_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 tocomponent_mutex,pm_chain_head.rwsem, orapple_drm_pm_lock.
- CI, §4 & §5:
host-testsCI passes atffdaff64ca61; both commits carry human author/committer andSigned-off-by:only (zero AI commit trailers); J775c (lobata) re-verification ata004bcba + ffdaff64passed 3 ×pm_test=freezeron tip and 3 × realrtcwake -m freeze -s 12with XDomain peer + HDMI (debug_locks1 -> 1, 0 lockdep reports, 0 SELinux denials).
Non-blocking notes:
- As noted under Not covered, the laptop dark-wake restore path (
pm_resume_workwithdark_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:903still refers tot8132_ext_pm_notify()instead oft8132_ext_drm_pm_event().
Assisted-by: LLM (Gemini 4 Neon)
|
Re-read at ffdaff6.
Assisted-by: LLM (Claude:Opus 5.5) |
|
Merge-train adversarial review (MERGETRAIN-LINUX3) at ffdaff6: blockers (below). Merges clean on integration/aurora 933a43f. Full reviewVERDICT: BLOCKERS Two commits (a004bcb, ffdaff6). The
Blockers:
Nits:
Missing rows:
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>
|
Claude Opus 5.5 on @satchlj's behalf. @RyanTheTide
Testing:
Assisted-by: LLM (Anthropic:Claude Opus 5.5) |
|
Checked f604f5d. Assisted-by: LLM (Claude:Opus 5.5) |
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:component_mutex→pm_chain_head.rwsemapple_drm_bind()→apple_drm_init()→register_pm_notifier()(drivers/gpu/drm/apple/apple_drv.c)acio->lock→tb->lock→component_mutexapple_cio_tbt_switch_set()holdsacio->lockaroundof_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->lockpm_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 undercomponent_mutex.apple_drm_pm_lock) at the end ofapple_drm_init(), and leaves it at the start ofapple_drm_uninit(). The notifier walks the list.component_mutexand below the notifier chain, so it adds no edge back.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->lockaround the NHI populate or out of the PM notifier, and both guard the cable state machine.Testing
integration/auroraf5f023bc9b62with and without this commit. Both useCONFIG_PROVE_LOCKING,DEBUG_LOCKDEP,DEBUG_ATOMIC_SLEEPandDETECT_HUNG_TASK, built from the same config.0-1). Then 3 system-sleep attempts withpm_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.fa1c46f4, Imagef81d1142)75f10e1f, Image53958092)pm_test=freezercyclesrtcwakeon lobata's candidate kernel (boot47ceebba), which was the original find.--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)