From 91ed6a22ef5e3ce34831ad7e8fc083a9738c9b14 Mon Sep 17 00:00:00 2001 From: Satya Benson Date: Sun, 29 Nov 2026 23:47:13 -0500 Subject: [PATCH] drm/apple: dcp: take a firmware-placed live OSLog buffer sized in bytes dcp_rtkit_live_parse() requires a firmware-placed (is_mapped == 1) buffer to be whole 4 KiB pages. That holds for crashlog, syslog and IOReport, which RTKit requests in pages, but OSLog states its size in bytes and only its address in pages, which is how RTKit itself takes an inherited OSLog buffer over (apple_rtkit_inherit_buffers()) and how the binding describes the cell. The T6050 external DCPs' firmware places its own OSLog buffer of 0x5ff8 bytes. A boot stage that hands such a DCP over running describes it as it is, and the adoption failed with a bare "Invalid live RTKit handoff" (-EINVAL), leaving the display processor unbound. Take a firmware-placed OSLog buffer of any size at a 4 KiB-aligned address; the other endpoints and loader-allocated buffers keep their rules. Say which tuple was refused, so the next such failure names it. The buffer must still lie in one of the DCP's no-map carveouts. Signed-off-by: Satya Benson --- drivers/gpu/drm/apple/dcp.c | 16 +++++++++++++--- drivers/gpu/drm/apple/dcp_handoff_test.c | 6 ++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index e90ac4e251c8e..6125397ee74eb 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -2104,6 +2104,12 @@ static void dcp_rtkit_live_unmap(struct dcp_rtkit_live *live) * a pre-mapped firmware carveout (for example T8103's crashlog at 0x276000 on a * 16 KiB host kernel); loader-allocated buffers (is_mapped == 0) sit in no-map * reserved-memory regions and must be host page-aligned. + * + * Crashlog, syslog and IOReport buffers are requested in 4 KiB pages. OSLog (8) + * states its size in bytes and only its address in pages, as RTKit takes it + * over (apple_rtkit_inherit_buffers()): a firmware that placed its own OSLog + * buffer may give a size that is not a whole page (T6050's external DCPs, + * 0x5ff8 bytes). */ static bool dcp_rtkit_live_buf_valid(u32 ep, u64 iova, u64 size, u32 is_mapped) { @@ -2111,9 +2117,11 @@ static bool dcp_rtkit_live_buf_valid(u32 ep, u64 iova, u64 size, u32 is_mapped) return false; if (!size || size > SZ_16M || iova + size < iova) return false; - if (is_mapped) - return IS_ALIGNED(iova, SZ_4K) && IS_ALIGNED(size, SZ_4K); - return PAGE_ALIGNED(iova) && PAGE_ALIGNED(size); + if (!is_mapped) + return PAGE_ALIGNED(iova) && PAGE_ALIGNED(size); + if (ep == 8) + return IS_ALIGNED(iova, SZ_4K); + return IS_ALIGNED(iova, SZ_4K) && IS_ALIGNED(size, SZ_4K); } /* @@ -2192,6 +2200,8 @@ static int dcp_rtkit_live_parse(struct apple_dcp *dcp, struct dcp_rtkit_live *li /* The system endpoints with shared buffers, as for other handoffs. */ if (!dcp_rtkit_live_buf_valid(t[0], iova, size, t[4])) { + dev_err(dcp->dev, "live RTKit buffer ep%u iova %#llx+%#llx (firmware-placed %u) is not valid\n", + t[0], iova, size, t[4]); ret = -EINVAL; goto fail; } diff --git a/drivers/gpu/drm/apple/dcp_handoff_test.c b/drivers/gpu/drm/apple/dcp_handoff_test.c index 533e7add8ca58..72aecbc55e696 100644 --- a/drivers/gpu/drm/apple/dcp_handoff_test.c +++ b/drivers/gpu/drm/apple/dcp_handoff_test.c @@ -117,6 +117,12 @@ static void dcp_handoff_live_rtkit_buf_valid(struct kunit *test) KUNIT_EXPECT_FALSE(test, dcp_rtkit_live_buf_valid(1, 0x276800, SZ_64K, 1)); KUNIT_EXPECT_FALSE(test, dcp_rtkit_live_buf_valid(1, 0x276000, 0x800, 1)); + /* A firmware-placed OSLog buffer gives its size in bytes (T6050 dcpext). */ + KUNIT_EXPECT_TRUE(test, dcp_rtkit_live_buf_valid(8, 0x100039b4000ULL, 0x5ff8, 1)); + KUNIT_EXPECT_FALSE(test, dcp_rtkit_live_buf_valid(8, 0x100039b4800ULL, 0x5ff8, 1)); + KUNIT_EXPECT_FALSE(test, dcp_rtkit_live_buf_valid(2, 0x100039b4000ULL, 0x5ff8, 1)); + KUNIT_EXPECT_FALSE(test, dcp_rtkit_live_buf_valid(8, 0x100039b4000ULL, 0x5ff8, 0)); + /* Loader-allocated (is_mapped == 0) must be host page-aligned. */ KUNIT_EXPECT_TRUE(test, dcp_rtkit_live_buf_valid(2, 0xf10004000ULL, PAGE_SIZE, 0)); KUNIT_EXPECT_TRUE(test, dcp_rtkit_live_buf_valid(4, 0xf10000000ULL, PAGE_SIZE, 0));