From 186be17549d0ba4f756e62b444252d216a9f76f2 Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Tue, 17 Nov 2026 19:45:15 -0500 Subject: [PATCH 1/3] drm/apple: send a paired mode set's calls in the engine's firmware 27 build The paired mode set (a mode too wide for one engine, run on two) sends its IOMFB calls through dcp_peer_video_call_stream(), naming them by their 27.0 IDs. Firmware 27.2 renumbered the IOMobileFramebufferAP methods, and an ID the firmware does not know panics it: on a 27.2 stub the paired prepare's set_display_device went out as A411 and crashed both engines. Translate each call's ID through the engine's build-selected table (iomfb_v27_tag()): a method the tables name takes this build's ID, and on 27.2 another A4xx ID (A449) moves up by 50 with the rest of IOMobileFramebufferAP. Other IDs, and every ID on 27.0, are sent as before. Developed with Claude Code. Signed-off-by: Erik Bourget --- .../drm/apple/dcp-peer-video-probe-v27.inc | 3 +- drivers/gpu/drm/apple/iomfb.h | 2 + drivers/gpu/drm/apple/iomfb_v27.c | 42 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/apple/dcp-peer-video-probe-v27.inc b/drivers/gpu/drm/apple/dcp-peer-video-probe-v27.inc index 3560cfc447a99..e5c896ae44013 100644 --- a/drivers/gpu/drm/apple/dcp-peer-video-probe-v27.inc +++ b/drivers/gpu/drm/apple/dcp-peer-video-probe-v27.inc @@ -46,7 +46,8 @@ static int dcp_peer_video_call_stream(struct apple_dcp *dcp, bool independent, wait = kzalloc(sizeof(*wait), GFP_KERNEL); if (!wait) return -ENOMEM; - memcpy(method.tag, tag, sizeof(method.tag)); + /* The calls name 27.0 IDs: this engine's build may number them differently. */ + iomfb_v27_tag(dcp->v27_methods, tag, method.tag); wait->size = out_size; init_completion(&wait->done); kref_init(&wait->refs); diff --git a/drivers/gpu/drm/apple/iomfb.h b/drivers/gpu/drm/apple/iomfb.h index e230a9eac9c5c..1d52ca712b119 100644 --- a/drivers/gpu/drm/apple/iomfb.h +++ b/drivers/gpu/drm/apple/iomfb.h @@ -220,6 +220,8 @@ struct dcp_method_entry { /* The IOMFB method table of a firmware 27.x build, by its compat string; NULL if unknown. */ const struct dcp_method_entry *iomfb_v27_methods(const char *compat); +bool iomfb_v27_methods_renumbered(const struct dcp_method_entry *methods); +void iomfb_v27_tag(const struct dcp_method_entry *methods, const char *tag, char *out); const struct dcp_method_entry *iomfb_v27_methods_j714s(struct device *dev, const struct dcp_method_entry *methods); /* The first method of a firmware 27.x table that has no ID, NULL if none. */ diff --git a/drivers/gpu/drm/apple/iomfb_v27.c b/drivers/gpu/drm/apple/iomfb_v27.c index a1ccdb537d54f..d98df23791908 100644 --- a/drivers/gpu/drm/apple/iomfb_v27.c +++ b/drivers/gpu/drm/apple/iomfb_v27.c @@ -2,6 +2,7 @@ /* Copyright The Asahi Linux Contributors */ /* Copyright 2026 Aurora Silicon */ +#include #include #include @@ -269,6 +270,47 @@ const struct dcp_method_entry *iomfb_v27_methods(const char *compat) return NULL; } +/* + * @tag, a 27.0 ID the paired-mode calls name directly, in the build of @methods + * (into @out, 4 bytes). A method the tables name takes this build's ID; on 27.2, + * which moved IOMobileFramebufferAP up by 50, another A4xx ID (and A500) does too. + * Anything else keeps its 27.0 ID. + */ +void iomfb_v27_tag(const struct dcp_method_entry *methods, const char *tag, char *out) +{ + unsigned int i, id; + char in[4]; + + memcpy(in, tag, 4); + tag = in; + memcpy(out, tag, 4); + if (!iomfb_v27_methods_renumbered(methods)) + return; + for (i = 0; i < dcpep_num_methods; i++) { + if (dcp_methods_27_0[i].tag[0] && !memcmp(dcp_methods_27_0[i].tag, tag, 4) && + methods[i].tag[0]) { + memcpy(out, methods[i].tag, 4); + return; + } + } + if (methods != dcp_methods_27_2 || tag[0] != 'A' || !isdigit(tag[1]) || + !isdigit(tag[2]) || !isdigit(tag[3])) + return; + id = (tag[1] - '0') * 100 + (tag[2] - '0') * 10 + (tag[3] - '0'); + if (id < 400 || id > 500) + return; + id += 50; + out[1] = '0' + id / 100; + out[2] = '0' + id / 10 % 10; + out[3] = '0' + id % 10; +} + +/* Whether @methods is a build's table whose AP method IDs differ from 27.0's. */ +bool iomfb_v27_methods_renumbered(const struct dcp_method_entry *methods) +{ + return methods && (methods == dcp_methods_27_2 || methods == dcp_methods_27_3); +} + /* * The 27.0 table for the J714s, the board the firmware 27 sleep has run on (dcp->v27_j714s): a * copy with the sleep's A500 added. The shared table keeps the methods it had, so every other From f5e28012ecb907c4711e2a0de0c1e0a21e0be332 Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Tue, 17 Nov 2026 19:45:15 -0500 Subject: [PATCH 2/3] drm/apple: send the firmware 27 calls named by ID in the engine's build Besides the paired calls, the firmware 27 paths name some calls by their 27.0 IDs: the primary's paired mode set (A413) and power step (A484), the paired background swap (A408), the sleep's power and A500 steps, the display stage calls and A442. On 27.2, which renumbered IOMobileFramebufferAP, several of those IDs are other methods: the paired mode's power step ran one and failed, and the second engine of a 4K240 mode never started. Translate each of them through the engine's build-selected table (iomfb_v27_tag()). The J714s's A407 swap keeps its ID, which only its 27.0 table names, and its diagnostic now refuses a pair whose engines take different swap forms. 27.0 sends what it sent. Developed with Claude Code. Signed-off-by: Erik Bourget --- drivers/gpu/drm/apple/dcp-peer-modeset-probe-v27.inc | 10 ++++++---- drivers/gpu/drm/apple/dcp-peer-swap-probe-v27.inc | 8 ++++++-- drivers/gpu/drm/apple/iomfb.c | 10 +++++----- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-peer-modeset-probe-v27.inc b/drivers/gpu/drm/apple/dcp-peer-modeset-probe-v27.inc index a5aa449b446dd..3d73c5f47dbe0 100644 --- a/drivers/gpu/drm/apple/dcp-peer-modeset-probe-v27.inc +++ b/drivers/gpu/drm/apple/dcp-peer-modeset-probe-v27.inc @@ -7,11 +7,12 @@ static int dcp_peer_probe_power(struct apple_dcp *dcp, struct apple_dcp *peer, bool on) { struct dcp_peer_video_wait *wait; - struct dcp_method_entry method = { .name = "peer_power_test", - .tag = {'A', '4', '8', '4'} }; + struct dcp_method_entry method = { .name = "peer_power_test" }; u8 power[16] = {}, response[8]; int ret; + iomfb_v27_tag(dcp->v27_methods, "A484", method.tag); + wait = kzalloc(sizeof(*wait), GFP_KERNEL); if (!wait) return -ENOMEM; @@ -134,13 +135,14 @@ static int dcp_peer_probe_modeset(struct apple_dcp *dcp, struct apple_dcp *peer, bool firmware_requires_merge) { struct dcp_peer_video_wait *wait; - struct dcp_method_entry method = { .name = "peer_modeset_test", - .tag = {'A', '4', '1', '3'} }; + struct dcp_method_entry method = { .name = "peer_modeset_test" }; __le32 mode[2] = {video->color_id, video->timing_id}; u32 primary_id, peer_id, phase, status; unsigned long deadline; int ret; + iomfb_v27_tag(dcp->v27_methods, "A413", method.tag); + { guard(mutex)(&dcp_peer_lock); if (dcp->peer_reserved != peer || peer->peer_owner != dcp || diff --git a/drivers/gpu/drm/apple/dcp-peer-swap-probe-v27.inc b/drivers/gpu/drm/apple/dcp-peer-swap-probe-v27.inc index ed73f355eda7e..5a87e1973b9f2 100644 --- a/drivers/gpu/drm/apple/dcp-peer-swap-probe-v27.inc +++ b/drivers/gpu/drm/apple/dcp-peer-swap-probe-v27.inc @@ -26,10 +26,11 @@ static void dcp_peer_background_start(struct apple_dcp *dcp, { struct dcp_peer_background *background = container_of(transaction, struct dcp_peer_background, transaction); - struct dcp_method_entry method = { .name = "peer_background_test", - .tag = {'A', '4', '0', '8'} }; + struct dcp_method_entry method = { .name = "peer_background_test" }; struct dcp_swap_submit_resp_v27 failed = { .ret = ~0U }; + iomfb_v27_tag(dcp->v27_methods, "A408", method.tag); + background->sent = true; if (!dcp_present_begin_h17p(&dcp->present_state_h17p, background->wire.swap.swap_id)) { @@ -185,6 +186,7 @@ static void dcp_peer_a407_background_start(struct apple_dcp *dcp, { struct dcp_peer_a407_background *background = container_of(transaction, struct dcp_peer_a407_background, transaction); + /* The J714s's 27.0 swap form, whose table names A407 (iomfb_v27_methods_j714s()). */ struct dcp_method_entry method = { .name = "peer_background_test", .tag = {'A', '4', '0', '7'} }; struct dcp_swap_submit_resp_v27 failed = { .ret = ~0U }; @@ -345,6 +347,8 @@ static ssize_t peer_swap_test_store(struct device *dev, dcp->crtc->base.state->active || peer->crtc->base.state->active || dcp->fw_compat != DCP_FIRMWARE_V_27_0 || peer->fw_compat != DCP_FIRMWARE_V_27_0 || + /* Both engines must take the swap form the owner sends. */ + dcp->v27_a407 != peer->v27_a407 || !device_trylock(peer->dev)) { ret = -EBUSY; goto out; diff --git a/drivers/gpu/drm/apple/iomfb.c b/drivers/gpu/drm/apple/iomfb.c index 1f3e97e6c5e9f..e7f6a4e8df361 100644 --- a/drivers/gpu/drm/apple/iomfb.c +++ b/drivers/gpu/drm/apple/iomfb.c @@ -892,11 +892,11 @@ static void iomfb_v27_sleep_start(struct apple_dcp *dcp, rpc->data, iomfb_v27_sleep_done, rpc); dcp->push_out_prefill = NULL; if ((rpc->a442 || rpc->a442_key) && !rpc->oob) { - static const struct dcp_method_entry a442 = { - .name = "v27_a442", .tag = { 'A', '4', '4', '2' }, - }; + struct dcp_method_entry a442 = { .name = "v27_a442" }; u8 in[92]; + iomfb_v27_tag(dcp->v27_methods, "A442", a442.tag); + memset(in, 0xaa, sizeof(in)); memset(in, 0, 16); in[8] = rpc->a442_key ?: 0x41; @@ -1002,7 +1002,7 @@ static int iomfb_v27_rpc(struct apple_dcp *dcp, bool a500, bool on, bool flags) rpc->method = (struct dcp_method_entry) { .name = a500 ? "v27_sleep_500" : "v27_sleep_power", }; - memcpy(rpc->method.tag, a500 ? "A500" : "A484", 4); + iomfb_v27_tag(dcp->v27_methods, a500 ? "A500" : "A484", rpc->method.tag); /* * Off, before each DCP's and DCPEXT's sleep idle: A484 with the sleep's flags, then * A500's sleep form. On, after the wake: A500's wake form, then A484 with the flags. @@ -1091,7 +1091,7 @@ static int iomfb_v27_call(struct apple_dcp *dcp, const char *tag, const void *in rpc->transaction.start = iomfb_v27_sleep_start; rpc->transaction.release = iomfb_v27_sleep_release; rpc->method = (struct dcp_method_entry) { .name = "v27_display_stage" }; - memcpy(rpc->method.tag, tag, 4); + iomfb_v27_tag(dcp->v27_methods, tag, rpc->method.tag); rpc->input = in_len; rpc->output = out_len; rpc->inout = inout; From aff9b6100741329c6d46dd09abefaf03898ae328 Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Tue, 17 Nov 2026 20:16:22 -0500 Subject: [PATCH 3/3] drm/apple: the J716c's display sleep transport on firmware 27.2 too The J716c's display processors take part in a deep sleep through the firmware 27 endpoint transport, which was admitted on a 27.0 compatibility build only. On a 27.2 stub no processor registered for the sleep, and every deep sleep was refused ("display 0: no provider"). Admit 27.2.0 as well. Its endpoint transport is the 27.0 one, and the IOMFB calls the sleep makes are sent with the build's IDs. Developed with Claude Code. Signed-off-by: Erik Bourget --- drivers/gpu/drm/apple/dcp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 7cde46e009096..0b85bd658f606 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -5797,9 +5797,12 @@ static bool dcp_v27_sleep_transport_supported(struct apple_dcp *dcp) dcp->fw_compat != DCP_FIRMWARE_V_27_0) return false; - /* The enum also covers later 27.x method tables. */ + /* + * The enum also covers later 27.x method tables. 27.2 keeps the endpoint + * transport; its renumbered IOMFB calls go through iomfb_v27_tag(). + */ return dcp_read_fw_version(dev, "apple,firmware-compat", compat) >= 0 && - !strcmp(compat, "27.0.0"); + (!strcmp(compat, "27.0.0") || !strcmp(compat, "27.2.0")); } static enum dcp_firmware_version dcp_check_firmware_version(struct device *dev)