From 0136657c82677ac7c698efa73cc38dde3767a3f3 Mon Sep 17 00:00:00 2001 From: knalekar <53238848+knalekar@users.noreply.github.com> Date: Sun, 15 Nov 2026 02:41:43 -0500 Subject: [PATCH] drm/apple: t6030: swap timing words and early flip for 120 Hz 14.7 firmware on the T6030 ProMotion panel completes swaps every second refresh: with the swap record's presentation timing words all zero, swaps complete 16.7 ms apart even though the panel scans out at 120 Hz, so compositors pace everything at 60 fps (omacom/linux-aurora #31). Set the existing per-board .swap_timestamps flag on the T6030 record. dcp_v14_swap_locked() then stamps the three presentation timing words (offsets 0x00, 0x08 and 0x30, as on the 12.x/13.x/26.6 paths) through dcp_v14_swap_timestamps(). With the target long past, the firmware presents each swap at the next refresh, i.e. at 120 Hz. Report an internal panel's flip before dcp_v14_present() instead of after it. dcp_v14_swap() blocks until the firmware completes the swap, so the compositor could not start its next frame until then. The next commit still waits for this swap (v14->lock and the CRTC commit dependencies), and displaced framebuffers stay pinned until the swap completes, so nothing is freed while the firmware may still scan it. A 3-buffer swapchain renders into the buffer from two flips back, which is already off screen. This is not board-specific and now applies to every internal 14.x panel; external processors keep their present path. On j514s (MacBook Pro 14", M3 Pro, T6030) with GNOME/mutter 50.6, stock paces everything at ~60 fps while the panel reports 120 Hz; with these changes UFO tester and visual checks confirm ~120 fps, stable across several boots with no GPU faults, flip failures or display errors. The swap timestamps were also validated on j516s (omacom/linux-aurora #31). The early flip has only been tested on T6030. Assisted-by: LLM --- drivers/gpu/drm/apple/iomfb_v14_7.c | 21 +++++++++++++++++++++ drivers/gpu/drm/apple/v14-board-test.c | 16 ++++++++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/apple/iomfb_v14_7.c b/drivers/gpu/drm/apple/iomfb_v14_7.c index a99bfed67183f..501012b69910f 100644 --- a/drivers/gpu/drm/apple/iomfb_v14_7.c +++ b/drivers/gpu/drm/apple/iomfb_v14_7.c @@ -103,6 +103,8 @@ static const struct dcp_v14_board dcp_v14_board_t6030 = { .firmware_uuid = DCP_V14_FIRMWARE_UUID, .handoff = "apple,t6030-handoff", .promotion = true, + /* Without the swap timestamps this panel presents at 60 fps. */ + .swap_timestamps = true, .panel_nits = true, }; @@ -3364,6 +3366,25 @@ void iomfb_v14_7_flush(struct apple_dcp *dcp, struct drm_crtc *crtc, if (!dcp->external) dcp_v14_configure_backlight(dcp); dcp->swap_start = ktime_get(); + /* + * The internal panel's swap blocks until the firmware completes it, so + * report the flip before the swap: the compositor builds its next + * frame while this one is still in the firmware. The next commit + * cannot overtake this swap (v14->lock and the CRTC commit + * dependencies), and displaced framebuffers stay pinned until the + * swap completes, so none is freed while the firmware may still scan + * it. A 3-buffer swapchain renders into the buffer from two flips + * back, which is already off screen. + */ + if (!dcp->external && dcp->v14 && fb && !READ_ONCE(dcp->v14->failed)) { + dcp_drm_crtc_page_flip(dcp, ktime_get()); + if (dcp_v14_present(dcp->v14, fb, fb->width, fb->height, + dcp->notch_height, cs)) + dcp_release_all_retained_framebuffers(dcp); + else + dcp_v14_cancel_event(dcp); + return; + } if (dcp->v14 && dcp_v14_present(dcp->v14, fb, fb ? (dcp->external ? p->src_w >> 16 : fb->width) : 0, fb ? (dcp->external ? p->src_h >> 16 : fb->height) : 0, diff --git a/drivers/gpu/drm/apple/v14-board-test.c b/drivers/gpu/drm/apple/v14-board-test.c index f9b84ab36a7cc..d1375bedf4ae5 100644 --- a/drivers/gpu/drm/apple/v14-board-test.c +++ b/drivers/gpu/drm/apple/v14-board-test.c @@ -3,9 +3,9 @@ * The 14.x IOMFB board records: which record a DCP gets on which machine, * and which DCP firmware image a record admits. The J516C (T6031) record * admits only the T6030 image, whose IOMFB layouts were validated, and - * refuses every other; the existing records are unchanged. Which DCPs stamp - * their swaps: the internal panel of a T6031 record; the T6030 and T8122 - * panels and external processors keep zero timestamps, byte for byte. + * refuses every other. Which DCPs stamp their swaps: the internal panel of a + * T6030 board and of the J516C record; the J514C and T8122 panels and external + * processors keep zero timestamps, byte for byte. */ #include #include @@ -139,7 +139,7 @@ static void v14_board_j516c_image(struct kunit *test) KUNIT_EXPECT_FALSE(test, dcp_v14_board_admits(b, "00000000-0000-0000-0000-000000000000")); } -/* The records that were there before are what they were. */ +/* The other fields of the records that were there before are unchanged. */ static void v14_board_unchanged(struct kunit *test) { const struct dcp_v14_board *b; @@ -178,7 +178,7 @@ static void v14_board_unchanged(struct kunit *test) KUNIT_EXPECT_TRUE(test, known); } -/* Only the internal panel of the J516C record stamps its swaps. */ +/* The T6030 and J516C internal panels stamp their swaps. */ static void v14_board_swap_timestamps(struct kunit *test) { const struct dcp_v14_board *j516c_b, *j514c_b, *t6030_b, *j613_b; @@ -192,14 +192,14 @@ static void v14_board_swap_timestamps(struct kunit *test) KUNIT_EXPECT_TRUE(test, j516c_b->swap_timestamps); KUNIT_EXPECT_FALSE(test, j514c_b->swap_timestamps); - KUNIT_EXPECT_FALSE(test, t6030_b->swap_timestamps); + KUNIT_EXPECT_TRUE(test, t6030_b->swap_timestamps); KUNIT_EXPECT_FALSE(test, j613_b->swap_timestamps); KUNIT_EXPECT_TRUE(test, dcp_v14_board_stamps_swaps(j516c_b, false)); - /* The J514C, the external role, the T6030 (J514S, J516S) and T8122 panels, no record. */ + /* The J514C, the external role, the T8122 panel, no record. */ KUNIT_EXPECT_FALSE(test, dcp_v14_board_stamps_swaps(j514c_b, false)); KUNIT_EXPECT_FALSE(test, dcp_v14_board_stamps_swaps(j516c_b, true)); - KUNIT_EXPECT_FALSE(test, dcp_v14_board_stamps_swaps(t6030_b, false)); + KUNIT_EXPECT_TRUE(test, dcp_v14_board_stamps_swaps(t6030_b, false)); KUNIT_EXPECT_FALSE(test, dcp_v14_board_stamps_swaps(j613_b, false)); KUNIT_EXPECT_FALSE(test, dcp_v14_board_stamps_swaps(NULL, false)); KUNIT_EXPECT_FALSE(test, dcp_v14_board_stamps_swaps(NULL, true));