Repository navigation
drm/apple: control the panel notch at run time - #2814
RyanTheTide wants to merge 3 commits into
Conversation
A panel with a camera housing has apple,notch-height rows at its top. Until now the driver read them once at probe: hidden for the whole boot unless the boot loader kept them (chosen asahi,show-notch) or a module parameter said otherwise, with no way to change it without a reboot, and the text console drew under the notch whenever the notch was shown. The panel always runs its native timing; what changes is how much of it is drawn on. Keep both geometries of each panel timing in the mode catalogue: the full panel and its notch-free twin, with the notch rows folded into the vertical sync exactly as the boot-time hidden mode did. The mode a commit carries decides where the frame is scanned out (the twin starts below the notch rows, which stay black), and switching between the twins keeps the panel's mode, so it is no mode set. Which geometry is offered follows a policy: the boot loader's choice, then the new "notch" connector property (enum: hidden, shown), which a compositor sets atomically, or /sys/class/drm/cardN-eDP-1/notch for scripts. A change re-probes userspace and the console. The notch-free modes are always offered; the full ones only while they are wanted and a DRM master owns the device. When no master does (a text-only system, a VT switch, a compositor that dropped master or exited), the console gets the notch-free geometry and re-probes into it; its surface is sized to it, so it never draws under the notch. A master that comes back gets its own mode again, as a fast switch. The M4 (T8132) pipe, which only took full-panel frames, gets the same two modes: a notch-free frame is placed with the swap's destination rectangle. The standalone firmware 14.7/26.6 pipes keep the boot loader's geometry for the boot. Nothing is selected by board: the rows come from apple,notch-height, which the boot loader takes from the ADT, and a panel without them is unchanged. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
DjDeveloperr
left a comment
There was a problem hiding this comment.
Pre-PR Checklist Review (§1–§6) — 0cb64c16fa63f3ffb439c4f1e9689092c9a1d55c
The overall design (twin modes in the catalogue, dcp_notch_offset scanout placement, atomic "notch" property, fastset between twin geometries) is clean and hardware-driven (§1, §3, §4, §6 pass), but there are several concrete blockers in the M4 (DCP_FIRMWARE_M4) path, teardown ordering, formatting, and §5 hardware coverage that need fixing before merge.
Blockers
-
M4 (
DCP_FIRMWARE_M4/iomfb_is_m4()) rejects notch-free modes in 3 un-updatediomfb.csites (§2):
PR #2814 updateddcp_crtc_atomic_check()(dcp.c:2025) to calldcp_notch_mode_known(), but missed three remainingiomfb_is_m4(dcp)mode checks indrivers/gpu/drm/apple/iomfb.cthat still requiredrm_mode_equal(mode, &fixed):dcp_mode_valid()(iomfb.c:3645-3650):drm_helper_probe_single_connector_modes()callsmode_valid()on every mode added bydcp_get_modes()and prunes anything returningMODE_BAD. On an M4DCP_FIRMWARE_M4(26.6.2) boot with notch hidden,dcp_get_modes()offers only the notch-free mode anddcp_mode_valid()immediately prunes it, leaving zero modes on the panel.dcp_crtc_atomic_modeset()(iomfb.c:3675-3683): rejects any real modeset to a notch-free mode with-EINVAL.dcp_crtc_mode_fixup()(iomfb.c:3854-3858): rejects any non-fastset modeset (initial enable, DPMS wake, suspend/resume) to a notch-free mode with-EINVAL.
(This escaped the J713 test because J713 ran firmware 27.2, where
iomfb_is_m4()isfalse.) All three sites should usedcp_notch_mode_known(dcp, ...). -
M4
atomic_checkvsdcp_flush()dst_ymismatch (§2):iomfb_m4_plane_frame()(iomfb_m4_present.h:37-41) computesdst_y = height < DCP_M4_PANEL_HEIGHT ? DCP_M4_PANEL_HEIGHT - height : 0without checkingdcp->notch_rows, whereasdcp_flush()(iomfb.c:4452-4454) computesdcp_notch_offset(&new->mode, READ_ONCE(dcp->notch_panel_rows), dcp->notch_rows).- On M4,
dcp->notch_panel_rowsis only populated insidedcp_get_modes()(iomfb.c:2810). If a commit runs beforedcp_get_modes()(e.g. retained modeset or restoring a cached mode),atomic_checksucceeds whiledcp_flush()computesdst_y = 0and fails mid-commit iniomfb_m4_present_at()->dcp_m4_frame_check()(-EINVAL->dcp_drm_crtc_error(-EIO)). Populatenotch_panel_rowswhen the M4 panel mode is established (or compute consistently fromiomfb_m4_get_mode()).
-
Teardown UAF / workqueue re-arm race in
apple_drm_uninit()(apple_drv.c:2278-2285) (§2):cancel_work_sync(&apple->notch_hotplug)andcancel_work_sync(&apple->notch_console)are placed beforedrm_dev_unplug(&apple->drm)anddrm_atomic_helper_shutdown(&apple->drm).- Until
drm_dev_unplug()unregisters sysfs and closes off DRM ioctls,notch_store(), an atomic commit, orapple_drm_master_drop()can re-queue either work item aftercancel_work_sync()returns, allowingdrm_kms_helper_hotplug_event()/drm_client_dev_hotplug()to run aftercomponent_unbind_all()/dcp_unlink(). - Move both
cancel_work_sync()calls afterdrm_dev_unplug()anddrm_atomic_helper_shutdown(), and guardnotch_store()withdrm_dev_enter()/drm_dev_exit().
-
Accidental deleted newline in
drivers/gpu/drm/apple/parser.h:237:/* Caller serializes readers against replacement. */int replace_modes(struct dcp_parse_ctx *handle,
Please restore the newline between the comment and prototype.
-
§5 Evidence incomplete (acknowledged in PR "Still to run"):
- Only J615 (pre-rebase, fw 27.2) and J713 (fw 27.2) have been tested so far.
- Missing hardware verification on: J616s (desktop 26.6), M1 Pro / M2 (older DCP fw), M4 26.6.2 (
DCP_FIRMWARE_M4path, which has blocker #1 above), a non-notch panel regression (e.g. MacBook Neo / external-only display), and the visual boot-logo check withshow-notchStage 2.
Non-blocking / ABI & Correctness Notes
- Commit message vs
dcp_notch_offer(): The commit message says "The notch-free modes are always offered; the full ones only while they are wanted and a DRM master owns the device", butdcp_notch_offer()actually hides notch-free modes whenevereffective == DCP_NOTCH_SHOWN && full_fits(only one geometry is offered at a time, as the PR body's Design notes describe). Please align the commit message. - Sysfs ABI documentation: The new writable
/sys/class/drm/cardN-eDP-1/notchsysfs attribute should be documented underDocumentation/ABI/testing/. - fbdev initial-probe /
master_drop()race: If a boot splash holds DRM master duringapple_drm_fbdev_probe(),drm_client_modeset_probe()has already selected the full-panel mode beforeapple_drm_fbdev_probe()shrinkssizes->surface_heightbynotch_rows, leaving the cached modeset mode taller than the fbdev surface until the asyncnotch_consolework runs; onmaster_drop(),drm_client_dev_restore()can race ahead ofschedule_work(&apple->notch_console). - Fastset
adjusted_mode: Clearingnew_cs->mode_changed = falseinapple_connector_notch_fastset()skipsmode_fixup()indrm_atomic_helper_check_modeset(), leavingcrtc_state->adjusted_mode.vdisplayat the previous geometry (currently harmless sincedrm/appleusescrtc_state->modeand clock/totals match, but worth copying or noting explicitly).
Assisted-by: LLM (Gemini 4 Neon)
|
Review at 0cb64c1.
|
Follow-up to "drm/apple: control the panel notch at run time": - M4 (T8132, firmware 26.6.2) pipe: mode_valid(), mode_fixup() and the CRTC mode set still required the full panel mode, so the probe pruned the notch-free twin (no mode at all with the notch hidden) and a real mode set of it failed. Accept the panel timing in either geometry everywhere, and place a frame from the timing the firmware reports rather than from a value get_modes() caches. - Teardown: cancel the notch work items after drm_dev_unplug() and the shutdown commit, and run them, the sysfs write and the master-drop scheduling only while the device is plugged. - A full timing that cannot have a twin is offered as it is under either policy, instead of being filtered out. - The physical height reported follows the geometry offered: the notch-free modes and the connector take the panel's adj-height-mm, or the full height scaled by rows. - The fast switch leaves the adjusted mode equal to the mode, as mode_fixup() would. - Drop the show_notch module parameter, now only read at bind: the boot loader sets the starting choice and the "notch" property changes it. - Document the property and the sysfs attribute (Documentation/gpu/apple-dcp-notch.rst, Documentation/ABI/testing/sysfs-class-drm-apple-notch). - Fix the parser.h line the first commit joined. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Thanks to both reviews. Fixed in 0c29a3e (follow-up commit; the first commit is unchanged):
On the earlier J713 row: on fleet80c with firmware 27.2, fbdev first-probe race: if a boot splash held master during the console's first probe, the surface is clamped notch-free and the stale full-height mode set is replaced at the next master drop. A restore that runs before that work item fails once (plane larger than the surface) and changes nothing on screen. It does not occur on a normal boot, where the first probe runs before any master. Host: apple-dcp 94/94 at this head, W=1 clean. Rows at 0c29a3e to follow: J713 (all steps, plus a short s2idle and DPMS off/on with the notch hidden), J615 (s2idle in each policy), J616s regression, M1 Pro and M2. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Pre-PR Checklist Re-Review (§1–§6) — 0c29a3e42b3d526f27219cbd9ca8414ed23b51f0
All three prior kernel blockers from the 0cb64c16 review (and the formatting/uAPI items) are resolved cleanly in 0c29a3e4:
- M4 (
DCP_FIRMWARE_M4/ 26.6.2) mode checks (resolved):dcp_mode_valid(),dcp_crtc_atomic_modeset(), anddcp_crtc_mode_fixup()indrivers/gpu/drm/apple/iomfb.cnow all usedcp_notch_mode_known(), matchingdcp_crtc_atomic_check(). - M4
dst_yconsistency (resolved):dcp_flush()now usesdcp_m4_notch_y(), deriving the scanout offset directly fromiomfb_m4_get_mode()+dcp_notch_twin_of()so it matchesiomfb_m4_plane_frame()even beforedcp_get_modes()runs. - Teardown ordering (resolved):
apple_drm_uninit()now cancelsnotch_hotplugandnotch_consoleafterdrm_dev_unplug()anddrm_atomic_helper_shutdown(), withdrm_dev_enter()/drm_dev_exit()guards innotch_store()and both work items, plus!drm_dev_is_unplugged(drm)inapple_drm_notch_owner(). - Other prior items (resolved):
parser.hnewline restored;show_notchmodule parameter dropped (pure default cmdline, §2);adj-height-mm/dcp_notch_free_mm()physical height wired up;notch_twinfallback preserves timings without twins; fastset copiesmodetoadjusted_mode; ABI & driver docs added (Documentation/ABI/testing/sysfs-class-drm-apple-notch,Documentation/gpu/apple-dcp-notch.rst). - §1, §2, §3, §4, §6: Pass (DT/ADT-driven with no model gating, human commits with human
Signed-off-byand no AI commit trailers,host-testsCI green).
Remaining Blocker
- §5 Hardware evidence at
0c29a3e4still pending:- No hardware runs have been posted for
0c29a3e4yet (which changeddcp.c,iomfb.c,apple_drv.c,dcp-notch.h, and droppedshow_notch). - As noted in the follow-up comment and PR body ("Still to run"), please post the
0c29a3e4hardware rows before merge: J713 (full steps + s2idle + DPMS off/on with notch hidden), J615 (s2idle in each policy), J616s (desktop 26.6 regression), M1 Pro / M2 template-pipe regression, and the visual boot-logo check with show-notch Stage 2 (each with 0 SELinux denials, 0 failed units, 0 new kernel errors).
- No hardware runs have been posted for
Non-blocking Notes
- Teardown hardening (
apple_drv.c:2307-2308): Switchingcancel_work_sync(&apple->notch_hotplug)/cancel_work_sync(&apple->notch_console)todisable_work_sync()(matchingapple_drm_quiesce_connectors()) would close the narrow window where an in-flightapple_drm_master_drop()(which does not holddrm_dev_enter()) or a nonblocking commit tail runningapple_commit_notch()afterdrm_atomic_helper_commit_hw_done()re-queues work aftercancel_work_sync(). - Async
dcp_set_dimensions()physical height (dcp.c:1509-1512):dcp_set_dimensions()writes fullheight_mmdirectly toconnector->display_info.height_mmwithout applyingdcp_notch_free_mm()whenREAD_ONCE(dcp->notch_free_offered)is true, so an asyncdimensions_wqrun can overwrite the notch-free physical height until the nextdcp_get_modes(). Also, cachingREAD_ONCE(dcp->notch_panel_rows)once indcp_update_connector_dimensions()avoids reading it twice.
Assisted-by: LLM (Gemini 4 Neon)
- Disable rather than cancel the notch work items at teardown, as the connector work items are: a master drop or a commit tail still in flight cannot queue them again. - dcp_set_dimensions() (the asynchronous DisplayAttributes update) reports the connector's size through dcp_update_connector_dimensions(), so it keeps the notch-free height while that geometry is offered. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Hardware rows at 4d7e97f. Each Mac ran fleet81 plus the three commits of this PR as a one-shot (driver diff identical to the PR), and each was restored to its default afterwards. Counts are 0 SELinux denials, 0 failed units, and no kernel error lines beyond the production boot's own.
Notes:
J615 rows at this head (with s2idle in each policy) follow when the Mac is free. The visual boot-logo check is still open. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Pre-PR Checklist Re-Review (§1–§6) — 4d7e97f68d519724f28f7859940bd0430bde3b42
Verified live at 4d7e97f68d519724f28f7859940bd0430bde3b42 (all 3 commits 0cb64c16 -> 0c29a3e4 -> 4d7e97f6):
- Delta at
4d7e97f6(clean):drivers/gpu/drm/apple/apple_drv.c: switchednotch_hotplugandnotch_consoleteardown inapple_drm_init()(err_unbind) andapple_drm_uninit()fromcancel_work_sync()todisable_work_sync(), closing the re-arm window noted on0c29a3e4.drivers/gpu/drm/apple/dcp.c:dcp_set_dimensions()now callsdcp_update_connector_dimensions()so asynchronousDisplayAttributesupdates preserve the notch-free physical height while that geometry is offered, anddcp_update_connector_dimensions()cachesREAD_ONCE(dcp->notch_panel_rows)once. (dcp_get_modes()recomputesmode->height_mmviadcp_notch_free_mm()when duplicating notch-free modes, so cataloguemode.height_mmstays consistent.)tools/testing/selftests/drivers/gpu/apple-dcp/edid.py: reordered extracted helper definitions to match the new call fromdcp_set_dimensions();host-testsCI is green (1/1).
- §5 Hardware evidence at
4d7e97f6(posted):- Hardware runs on
fleet81+ all 3 PR commits across three distinct notched Mac generations/pipes — J713 (M4 Air, fw 27.2: hidden/shown default, fast runtime toggle with 0 firmware modesets, VT3 &multi-user.targetnotch-free console, 15 s s2idle both policies), M2 Air (template pipe: toggle, VT3 console, DPMS off/on & 15 s s2idle both policies), and J616s (M4 Pro, desktop 26.6 ProMotion: 6 timings + 6 notch-free twins at row 74, toggle, DPMS off/on both policies) — all with 0 SELinux denials, 0 failed units, and 0 new kernel error lines.
- Hardware runs on
- §1, §2, §3, §4, §6: All pass. Pure DT/ADT-driven (
apple,notch-height, no model gating), default kernel command line (noshow_notchmodule param), clean human commit history (Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>on all 3 commits, zero AI commit trailers).
Non-blocking Follow-ups
- Please add the J615
4d7e97f6s2idle row and the visual boot-logo check when the machine is free. - Minor PR body housekeeping: the PR description's Design Notes still mention
show_notchbeing kept (removed in0c29a3e4) and "Still to run" still lists J616s/M2 (now completed at4d7e97f6).
Code, CI, and multi-generation §5 evidence at 4d7e97f6 are clean — approved and ready for MERGETRAIN-LINUX4.
Assisted-by: LLM (Gemini 4 Neon)
Problem
On a MacBook with a notch, the driver picked the panel geometry once, at probe. The notch rows were either hidden for the whole boot or shown for the whole boot (boot loader
chosen/asahi,show-notch). Changing it needed a reboot. When the notch was shown, the text console drew its top lines under the notch: on a text-only system, or after Ctrl+Alt+F3.Change
notch(enumhidden/shown), which a compositor can set atomically. The same switch is available as/sys/class/drm/cardN-eDP-1/notchfor scripts. It chooses which geometry compositors are offered, and a change sends a hotplug event so they follow. The default is the boot loader's choice.apple,notch-height, which the boot loader takes from the ADT. There is no board list and no command-line or module parameter to set. Panels without notch rows (Neo, external displays) are unchanged. The standalone firmware 14.7 / 26.6 pipes build their single mode from the boot framebuffer, so they keep the boot loader's geometry for the boot.dri/N/eDP-1/notch, reports rows, policy, whether a master owns the device, and the row offset of the last frame.For compositors
Nothing new is needed. A compositor is offered the geometry the policy asks for, and follows a change through the usual hotplug re-probe. GNOME does this unmodified (rows below). A compositor that wants to decide for itself can set
notchin the same atomic commit as the matching mode. Both modes are always accepted in a commit.Testing
panel-notch-geometryruns the production parser and catalogue code on the J615 panel timing: the twin is bit-identical to the old hidden mode, and the offer, offset and ownership rules hold. A mutation that breaks the console rule fails it.m4-notch-framechecks the swap destination (y 64, height 1600) on the J713 profile. W=1 arm64 build clean, checkpatch clean.Still to run
Hardware rows in detail
Evidence:
traces/display/20261122-notch-dyn/(lab store). Snapshots record the eDP mode list, sysfs and debugfs notch state, CRTC mode, VT/fbcon, the count ofset_digital_out_modecalls this boot, and kernel errors, AVCs and failed units.J615, kernel 7.3.0-aurora-g15nd1 = J615 default source + this commit (pre-rebase; differs only by the base and two whitespace fixes)
echo shownchvt 3chvt 2echo hidden/shownmodetest -a -w 49:notch:0, back to GNOMEmulti-user.targetJ713, kernel 7.3.0-aurora-f80cnd1+ = J713 default source (fleet80c) + this commit; same steps, 2560x1664 full / 2560x1600 notch-free, fbcon 320x100, 3 firmware mode sets per boot throughout.
Kernel error lines on every test boot are the production boot's own set: Bluetooth codec capabilities and AFK ep20 init props on the J615; AFK ep20, DFB layout, DCPDP13Service admission on the J713.
Design notes for reviewers
notch_freemarks the twin; twins are appended after the firmware's timings).dcp_nr_timings()keeps the "single fixed timing" decisions (firmware 27 boot-mode inheritance, desktop 26.x fixed panel) counting firmware timings. The panel EDID is built from the timings only.dcp_notch_offer()): the effective geometry only. Effective = policy while a master owns the device, else notch-free. A probe whose height limit is below the panel (the console's fbdev re-probe, bounded by its surface) is also offered the notch-free modes, so the console's stored mode set never loses the panel while a compositor holds full height. The connector'sfill_modesrecords that limit.apple_connector_notch_fastset()clearsmode_changedin the connector check, before the colour/EOTF logic below it can ask for a real mode set, only when the CRTC stays on, VRR is unchanged, and the new mode is the twin of the old one and in the catalogue.master_set/master_droprecord ownership. On drop, a work item runsdrm_client_dev_hotplug()(master_drop holds master_mutex, which the console restore takes).apple_drm_fbdev_probe()sizes the console surface notch-free if its first probe ever ran while a boot splash held master.notchproperty lives in a connector state subclass. The sysfs write commits it like a compositor would, and the commit tail updates the policy and schedules the hotplug.show_notchmodule parameter is kept for compatibility (it now only sets the starting policy). Nothing needs it.Assisted-by: LLM (Claude:Opus 5.5)