From d4001bd6c15c0e9adb113f6b2ed868fde262f752 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 19 Nov 2026 23:03:25 +1100 Subject: [PATCH 1/2] drm/apple: turn framebuffer damage into a commit DCP shows only what a swap hands it. A client that draws into the scanout buffer without flipping is never seen once the firmware stops refreshing from that buffer, and on the M4 internal panel it does stop: after idle_cache_ms (1000 ms by default) without a flip, the DCP presents a cached copy of the last frame until the next swap. fbcon is such a client. The fbdev emulation only generates damage when the framebuffer has a dirty hook, and appledrm's framebuffers had none (drm_gem_fb_create), so the console wrote straight into the scanout buffer and never caused a swap. On a J713 with a text greeter on tty1 the panel froze about a second after KMS took over, while input and writes to /dev/tty1 kept working; blanking and unblanking fb0, which does commit, brought it back. The same holds for any DIRTYFB caller. Create framebuffers with drm_gem_fb_create_with_dirty, as the dcpext shadow driver already does. drm_fbdev_dma then runs the console through its shadowed, deferred-I/O path, and each damage batch reaches drm_atomic_helper_dirtyfb(), a plane commit of the same framebuffer. On M4 that is an ordinary iomfb_m4_present(), which also leaves the idle cache and re-arms it, so a static console still gets cached. The hook applies to every DCP generation: none of them shows drawing it was not given a swap for, and compositors that flip are unaffected because they do not call DIRTYFB. This removes the need for appledrm.idle_cache_ms=0 on console-only systems. Fixes: a150a02ca353 ("drm/apple: m4: Cache a static frame while nothing is flipping") Closes: https://github.com/aurora-silicon/linux/issues/1185 Signed-off-by: Ryan Murray --- drivers/gpu/drm/apple/apple_drv.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/apple/apple_drv.c b/drivers/gpu/drm/apple/apple_drv.c index ff047f59fd73f..4ed8c46b1ea47 100644 --- a/drivers/gpu/drm/apple/apple_drv.c +++ b/drivers/gpu/drm/apple/apple_drv.c @@ -783,7 +783,14 @@ static const struct drm_mode_config_funcs apple_mode_config_funcs = { .atomic_state_free = apple_atomic_state_free, .atomic_check = drm_atomic_helper_check, .atomic_commit = apple_atomic_commit, - .fb_create = drm_gem_fb_create, + /* + * DCP shows only what a swap gives it, and the firmware may keep + * presenting a cached copy of a frame that has stopped flipping (the + * M4 idle cache does). A client that draws into the scanout buffer + * without a flip (fbcon, a DIRTYFB caller) has its damage turned into + * a commit by the dirty hook, so the drawing reaches the display. + */ + .fb_create = drm_gem_fb_create_with_dirty, }; static void apple_atomic_commit_tail(struct drm_atomic_commit *state) From e4594e2bab08fa2524fb8da1e13d4863055515d5 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 28 Nov 2026 04:25:44 +1100 Subject: [PATCH 2/2] drm/apple: give only scanout-caching backends the dirty framebuffers The previous change gave every appledrm framebuffer the dirty hook. On the firmware interfaces that scan the framebuffer out, drawing into it already shows without a swap, so there it only added a shadow copy per fbdev client and a blit plus an atomic commit for every console update (an idle text VT keeps committing for the cursor blink). Its commit message also said that no DCP generation shows such drawing, which is wrong for those interfaces. Ask the backend instead. dcp_caches_scanout() is true for an interface that may keep presenting a cached copy of the last swapped frame: the M4 IOMFB backend with its idle cache. appledrm's fb_create hands out framebuffers with the dirty hook when one of its CRTCs is driven by such a backend, and plain ones otherwise, as before the previous change. The T8132 external CRTCs are not apple_crtcs and their presents never enter the idle cache, so they do not count. Signed-off-by: Ryan Murray --- drivers/gpu/drm/apple/apple_drv.c | 36 ++++++++++++++++++++++++------- drivers/gpu/drm/apple/dcp.c | 14 ++++++++++++ drivers/gpu/drm/apple/dcp.h | 1 + 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/apple/apple_drv.c b/drivers/gpu/drm/apple/apple_drv.c index 43fea42148f8b..fd419f14557d4 100644 --- a/drivers/gpu/drm/apple/apple_drv.c +++ b/drivers/gpu/drm/apple/apple_drv.c @@ -999,20 +999,40 @@ static int apple_atomic_check(struct drm_device *dev, return 0; } +/* + * A firmware interface that caches scanout (dcp_caches_scanout(): the M4 idle + * cache) keeps presenting a copy of a frame that has stopped flipping, so a + * client that draws into the scanout buffer without a flip (fbcon, a DIRTYFB + * caller) is not seen. Give such devices framebuffers with the dirty hook: + * the damage becomes a commit, and the fbdev emulation takes its shadowed, + * deferred-I/O path. Interfaces that scan the buffer out already show that + * drawing; they keep the plain framebuffers, with no shadow copy and no + * commit per console update. + */ +static struct drm_framebuffer *apple_fb_create(struct drm_device *dev, + struct drm_file *file, + const struct drm_format_info *info, + const struct drm_mode_fb_cmd2 *mode_cmd) +{ + struct drm_crtc *crtc; + + drm_for_each_crtc(crtc, dev) { + /* The T8132 external CRTCs are not apple_crtcs. */ + if (!t8132_ext_crtc(crtc) && + dcp_caches_scanout(to_apple_crtc(crtc)->dcp)) + return drm_gem_fb_create_with_dirty(dev, file, info, mode_cmd); + } + + return drm_gem_fb_create(dev, file, info, mode_cmd); +} + static const struct drm_mode_config_funcs apple_mode_config_funcs = { .atomic_state_alloc = apple_atomic_state_alloc, .atomic_state_clear = apple_atomic_state_clear, .atomic_state_free = apple_atomic_state_free, .atomic_check = apple_atomic_check, .atomic_commit = apple_atomic_commit, - /* - * DCP shows only what a swap gives it, and the firmware may keep - * presenting a cached copy of a frame that has stopped flipping (the - * M4 idle cache does). A client that draws into the scanout buffer - * without a flip (fbcon, a DIRTYFB caller) has its damage turned into - * a commit by the dirty hook, so the drawing reaches the display. - */ - .fb_create = drm_gem_fb_create_with_dirty, + .fb_create = apple_fb_create, }; static void apple_atomic_commit_tail(struct drm_atomic_commit *state) diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index ac0f8d7ba57da..53ccdbb920c69 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -4546,6 +4546,20 @@ bool dcp_fw_compat_is_desktop(struct platform_device *pdev) return dcp->fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP; } +/* + * Whether @pdev's firmware interface may keep presenting a cached copy of the + * last swapped frame instead of scanning out the framebuffer (the M4 IOMFB + * backend's idle cache, see iomfb_m4_idle_cache_work()). Drawing into the + * scanout buffer without a swap is then not seen until the next swap. The + * other interfaces scan the buffer out, so such drawing shows as it is made. + */ +bool dcp_caches_scanout(struct platform_device *pdev) +{ + struct apple_dcp *dcp = platform_get_drvdata(pdev); + + return iomfb_is_m4(dcp); +} + /* * Whether @pdev's internal panel can show PQ content as EDR: the panel has * EDR headroom (the ADT's EDRPotentialHeadroom, see dcp_panel_read_adt()), diff --git a/drivers/gpu/drm/apple/dcp.h b/drivers/gpu/drm/apple/dcp.h index 4ea6ebc535f5f..f8f6fb379081b 100644 --- a/drivers/gpu/drm/apple/dcp.h +++ b/drivers/gpu/drm/apple/dcp.h @@ -91,6 +91,7 @@ int dcp_get_connector_type(struct platform_device *pdev); bool dcp_fw_compat_is_12_x(struct platform_device *pdev); bool dcp_fw_compat_is_14_7(struct platform_device *pdev); bool dcp_fw_compat_is_desktop(struct platform_device *pdev); +bool dcp_caches_scanout(struct platform_device *pdev); bool dcp_panel_edr(struct platform_device *pdev); bool dcp_ext_color_props_supported(struct platform_device *pdev); unsigned int dcp_gamma_lut_size(struct platform_device *pdev);