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));