From a7867528605e97ec5a37ced24395c3cc5c1dfca8 Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Sat, 21 Nov 2026 19:41:33 -0500 Subject: [PATCH 01/35] 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() (and the opt-in peer setup diagnostic through peer_setup_test_store()), 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. Record every paired-mode and sleep method ID in each firmware 27 build's table (the shifted IDs on 27.2, plus the unchanged paired/DSC hand-off and sleep calls) while keeping them optional for single-engine boot admission in iomfb_v27_missing_method(). Translate each call's ID through iomfb_v27_tag(): on 27.0 (including the J714s copy) every ID is sent unchanged; on a renumbered build every ID must come from the build's table, returning -EOPNOTSUPP instead of sending an unmapped ID. Update the t6041-v27-admission host test fixture for the table helpers it extracts. Signed-off-by: Erik Bourget --- drivers/gpu/drm/apple/dcp-peer-probe-v27.inc | 9 +- .../drm/apple/dcp-peer-video-probe-v27.inc | 5 +- drivers/gpu/drm/apple/iomfb.h | 25 ++++ drivers/gpu/drm/apple/iomfb_v27.c | 111 +++++++++++++++++- .../selftests/drivers/gpu/apple-dcp/boot.py | 2 + 5 files changed, 146 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-peer-probe-v27.inc b/drivers/gpu/drm/apple/dcp-peer-probe-v27.inc index 33def11c752ea..a1c017c98e085 100644 --- a/drivers/gpu/drm/apple/dcp-peer-probe-v27.inc +++ b/drivers/gpu/drm/apple/dcp-peer-probe-v27.inc @@ -24,9 +24,7 @@ static ssize_t peer_setup_test_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - static const struct dcp_method_entry method = { - .name = "setup_peer_dcp", .tag = {'A', '3', '6', '6'}, - }; + struct dcp_method_entry method = { .name = "setup_peer_dcp" }; struct apple_dcp *dcp = dev_get_drvdata(dev); struct dcp_peer_probe_wait *wait; __le32 enabled = cpu_to_le32(1); @@ -55,6 +53,11 @@ static ssize_t peer_setup_test_store(struct device *dev, kref_put(&wait->refs, dcp_peer_probe_free); return -EBUSY; } + ret = iomfb_v27_tag(dcp->v27_methods, "A366", method.tag); + if (ret) { + kref_put(&wait->refs, dcp_peer_probe_free); + return ret; + } kref_get(&wait->refs); /* Peer-DCP setup (one bool argument): four input * bytes (boolean followed by zero padding), no output. 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..86b0f20b5823d 100644 --- a/drivers/gpu/drm/apple/dcp-peer-video-probe-v27.inc +++ b/drivers/gpu/drm/apple/dcp-peer-video-probe-v27.inc @@ -37,6 +37,10 @@ static int dcp_peer_video_call_stream(struct apple_dcp *dcp, bool independent, if (out_size > sizeof(wait->reply)) return -EINVAL; + /* The calls name 27.0 IDs: this engine's build may number them differently. */ + ret = iomfb_v27_tag(dcp->v27_methods, tag, method.tag); + if (ret) + return ret; /* An unrelated AP thread gets its own firmware stream. A369/A367/etc. * must not be mistaken for nested callbacks of the pending A413. * Stream1 (the driver's OOB context) is independent of stream0. @@ -46,7 +50,6 @@ 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)); 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..0b2c04b7c6123 100644 --- a/drivers/gpu/drm/apple/iomfb.h +++ b/drivers/gpu/drm/apple/iomfb.h @@ -198,6 +198,28 @@ enum dcpep_method { dcpep_pipe_set_476, dcpep_unnamed_500, iomfbep_set_brightness_correction, + /* + * Firmware 27.x sleep and paired-mode calls named by their 27.0 ID. + * Optional for single-engine boot (iomfb_v27_missing_method() skips + * them); iomfb_v27_tag() refuses any call missing from a renumbered + * table. + */ + dcpep_v27_sleep_a115, + dcpep_v27_wake_a442, + dcpep_v27_peer_a360, + dcpep_v27_peer_a361, + dcpep_v27_peer_a362, + dcpep_v27_peer_a364, + dcpep_v27_peer_a365, + dcpep_v27_peer_a366, + dcpep_v27_peer_a367, + dcpep_v27_peer_a368, + dcpep_v27_peer_a369, + dcpep_v27_peer_a370, + dcpep_v27_peer_a371, + dcpep_v27_peer_a372, + dcpep_v27_peer_a373, + dcpep_v27_peer_a449, dcpep_num_methods }; @@ -220,6 +242,9 @@ 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); +int iomfb_v27_tag(const struct dcp_method_entry *methods, const char *tag, char *out); +bool iomfb_v27_sleep_methods_complete(const struct dcp_method_entry *methods); 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 a7d7d6b93f341..041ce575f8823 100644 --- a/drivers/gpu/drm/apple/iomfb_v27.c +++ b/drivers/gpu/drm/apple/iomfb_v27.c @@ -164,6 +164,22 @@ static const struct dcp_method_entry dcp_methods_27_0[dcpep_num_methods] = { * the IOMFB calls around it; 27.2 moved both to A550/A551. */ IOMFB_METHOD("A500", dcpep_unnamed_500), + IOMFB_METHOD("A115", dcpep_v27_sleep_a115), + IOMFB_METHOD("A442", dcpep_v27_wake_a442), + IOMFB_METHOD("A360", dcpep_v27_peer_a360), + IOMFB_METHOD("A361", dcpep_v27_peer_a361), + IOMFB_METHOD("A362", dcpep_v27_peer_a362), + IOMFB_METHOD("A364", dcpep_v27_peer_a364), + IOMFB_METHOD("A365", dcpep_v27_peer_a365), + IOMFB_METHOD("A366", dcpep_v27_peer_a366), + IOMFB_METHOD("A367", dcpep_v27_peer_a367), + IOMFB_METHOD("A368", dcpep_v27_peer_a368), + IOMFB_METHOD("A369", dcpep_v27_peer_a369), + IOMFB_METHOD("A370", dcpep_v27_peer_a370), + IOMFB_METHOD("A371", dcpep_v27_peer_a371), + IOMFB_METHOD("A372", dcpep_v27_peer_a372), + IOMFB_METHOD("A373", dcpep_v27_peer_a373), + IOMFB_METHOD("A449", dcpep_v27_peer_a449), }; /* @@ -222,6 +238,22 @@ static const struct dcp_method_entry dcp_methods_27_2[dcpep_num_methods] = { * dispatch where 26A428's compares 'A500' (0x1df68c vs 0x1de0dc, same code). */ IOMFB_METHOD("A550", dcpep_unnamed_500), + IOMFB_METHOD("A115", dcpep_v27_sleep_a115), + IOMFB_METHOD("A492", dcpep_v27_wake_a442), + IOMFB_METHOD("A360", dcpep_v27_peer_a360), + IOMFB_METHOD("A361", dcpep_v27_peer_a361), + IOMFB_METHOD("A362", dcpep_v27_peer_a362), + IOMFB_METHOD("A364", dcpep_v27_peer_a364), + IOMFB_METHOD("A365", dcpep_v27_peer_a365), + IOMFB_METHOD("A366", dcpep_v27_peer_a366), + IOMFB_METHOD("A367", dcpep_v27_peer_a367), + IOMFB_METHOD("A368", dcpep_v27_peer_a368), + IOMFB_METHOD("A369", dcpep_v27_peer_a369), + IOMFB_METHOD("A370", dcpep_v27_peer_a370), + IOMFB_METHOD("A371", dcpep_v27_peer_a371), + IOMFB_METHOD("A372", dcpep_v27_peer_a372), + IOMFB_METHOD("A373", dcpep_v27_peer_a373), + IOMFB_METHOD("A499", dcpep_v27_peer_a449), }; /* @@ -269,6 +301,76 @@ const struct dcp_method_entry *iomfb_v27_methods(const char *compat) return NULL; } +/* + * Translate @tag, a 27.0 ID named directly by sleep or paired-mode callers, + * into the build of @methods (4 bytes in @out). On 27.0 (including the J714s + * copy) the tag is sent unchanged. On a renumbered build every ID must come + * from @methods; a missing entry returns -EOPNOTSUPP instead of sending an + * unknown tag that would panic the firmware. + */ +int iomfb_v27_tag(const struct dcp_method_entry *methods, const char *tag, char *out) +{ + unsigned int i; + char in[4]; + + if (!methods) + return -EOPNOTSUPP; + memcpy(in, tag, 4); + if (!iomfb_v27_methods_renumbered(methods)) { + memcpy(out, in, 4); + return 0; + } + for (i = 0; i < dcpep_num_methods; i++) { + if (dcp_methods_27_0[i].tag[0] && !memcmp(dcp_methods_27_0[i].tag, in, 4)) { + if (!methods[i].tag[0]) + return -EOPNOTSUPP; + memcpy(out, methods[i].tag, 4); + return 0; + } + } + return -EOPNOTSUPP; +} + +/* 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) +{ + unsigned int i; + + if (!methods || methods == dcp_methods_27_0) + return false; + for (i = 0; i < dcpep_num_methods; i++) { + if (memcmp(methods[i].tag, dcp_methods_27_0[i].tag, 4) && + !(i == dcpep_swap_submit && !memcmp(methods[i].tag, "A407", 4))) + return true; + } + return false; +} + +static const enum dcpep_method iomfb_v27_sleep_methods[] = { + dcpep_is_main_display, + dcpep_pipe_cfg_414, + dcpep_set_power_state, + dcpep_pipe_set_476, + dcpep_pipe_query_478, + dcpep_unnamed_500, + dcpep_v27_sleep_a115, + dcpep_v27_wake_a442, +}; + +/* Whether @methods names an ID for every call the firmware 27 display sleep sends. */ +bool iomfb_v27_sleep_methods_complete(const struct dcp_method_entry *methods) +{ + unsigned int i; + + if (!methods) + return false; + for (i = 0; i < ARRAY_SIZE(iomfb_v27_sleep_methods); i++) { + if (!methods[iomfb_v27_sleep_methods[i]].tag[0]) + return false; + } + return true; +} + /* * 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 @@ -309,9 +411,14 @@ const char *iomfb_v27_missing_method(const struct dcp_method_entry *methods, *count = 0; for (i = 0; i < dcpep_num_methods; i++) { - /* Only a firmware sleep sends unnamed_500, and it checks the build's table. */ + /* + * Only sleep and paired-mode paths send unnamed_500 and the + * v27-optional entries; each checks the build's table before + * sending. + */ if (!dcp_methods_27_0[i].tag[0] || methods[i].tag[0] || - i == dcpep_dfb_ready_query || i == dcpep_unnamed_500) + i == dcpep_dfb_ready_query || i == dcpep_unnamed_500 || + i >= dcpep_v27_sleep_a115) continue; if (!first) first = dcp_methods_27_0[i].name; diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py b/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py index 7a23fdb3ff45f..0f07b51a66b96 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py @@ -216,10 +216,12 @@ def _v27_prelude(root, helpers): method_table = block(dcp_c, 'static enum dcp_firmware_version dcp_v27_method_table(') return r''' #include +#include #include #include #include #include +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) typedef uint32_t u32; enum dcp_firmware_version { DCP_FIRMWARE_UNKNOWN, From 16bfcc92d90d891199340663de45361a13b5d609 Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Sat, 21 Nov 2026 19:41:33 -0500 Subject: [PATCH 02/35] drm/apple: send the firmware 27 calls named by ID in the engine's build Besides the paired video calls, the firmware 27 paths name several 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 the out-of-band wake call (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 iomfb_v27_tag() and refuse the call instead of sending it when the build's table lacks an entry. Zero the internal wake A442 payload's filler bytes on renumbered builds, where 27.2 rejects the 0xaa filler as an index count and block size. 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. Signed-off-by: Erik Bourget --- .../drm/apple/dcp-peer-modeset-probe-v27.inc | 18 ++++++++--- .../gpu/drm/apple/dcp-peer-swap-probe-v27.inc | 14 +++++++-- drivers/gpu/drm/apple/iomfb.c | 30 +++++++++++++------ 3 files changed, 47 insertions(+), 15 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..0ac6d6c344761 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,16 @@ 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]; + char peer_tag[4]; int ret; + ret = iomfb_v27_tag(dcp->v27_methods, "A484", method.tag) ?: + iomfb_v27_tag(peer->v27_methods, "A484", peer_tag); + if (ret) + return ret; + wait = kzalloc(sizeof(*wait), GFP_KERNEL); if (!wait) return -ENOMEM; @@ -134,13 +139,18 @@ 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; + char peer_tag[4]; int ret; + ret = iomfb_v27_tag(dcp->v27_methods, "A413", method.tag) ?: + iomfb_v27_tag(peer->v27_methods, "A413", peer_tag); + if (ret) + return ret; + { 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..343fa1872bada 100644 --- a/drivers/gpu/drm/apple/dcp-peer-swap-probe-v27.inc +++ b/drivers/gpu/drm/apple/dcp-peer-swap-probe-v27.inc @@ -6,6 +6,7 @@ struct dcp_peer_background { struct iomfb_transaction transaction; struct dcp_peer_video_wait *wait; struct dcp_swap_submit_req_v27 wire; + char tag[4]; bool sent; }; @@ -26,10 +27,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 }; + memcpy(method.tag, background->tag, sizeof(method.tag)); + background->sent = true; if (!dcp_present_begin_h17p(&dcp->present_state_h17p, background->wire.swap.swap_id)) { @@ -55,13 +57,18 @@ static int dcp_peer_queue_background(struct apple_dcp *dcp, struct dcp_peer_video_wait *wait) { struct dcp_peer_background *background; + char tag[4]; int ret; + ret = iomfb_v27_tag(dcp->v27_methods, "A408", tag); + if (ret) + return ret; background = kzalloc_obj(*background); if (!background) return -ENOMEM; background->wire = *wire; background->wait = wait; + memcpy(background->tag, tag, sizeof(background->tag)); kref_get(&wait->refs); background->transaction.start = dcp_peer_background_start; background->transaction.release = dcp_peer_background_release; @@ -185,6 +192,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 +353,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 1de9af271a402..0e877825b8dba 100644 --- a/drivers/gpu/drm/apple/iomfb.c +++ b/drivers/gpu/drm/apple/iomfb.c @@ -899,11 +899,14 @@ 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]; + if (iomfb_v27_tag(dcp->v27_methods, "A442", a442.tag)) { + dev_warn_once(dcp->dev, "skipping v27 wake A442: unmapped method tag\n"); + return; + } + memset(in, 0xaa, sizeof(in)); memset(in, 0, 16); in[8] = rpc->a442_key ?: 0x41; @@ -911,6 +914,9 @@ static void iomfb_v27_sleep_start(struct apple_dcp *dcp, if (rpc->a442_key) { memset(in + 80, 0, 12); in[84] = 0x20; + } else if (iomfb_v27_methods_renumbered(dcp->v27_methods)) { + /* 27.2 reads the filler as an index count and a block size. */ + memset(in + 16, 0, sizeof(in) - 16); } dcp_push(dcp, true, &a442, sizeof(in), 4100, in, iomfb_v27_a442_done, NULL); } @@ -988,6 +994,9 @@ int iomfb_v27_sleep_plain(struct apple_dcp *dcp, bool on) static int iomfb_v27_rpc(struct apple_dcp *dcp, bool a500, bool on, bool flags) { + struct dcp_method_entry method = { + .name = a500 ? "v27_sleep_500" : "v27_sleep_power", + }; struct iomfb_v27_sleep_rpc *rpc; u8 args[IOMFB_V27_SLEEP_ARGS]; int ret; @@ -998,6 +1007,9 @@ static int iomfb_v27_rpc(struct apple_dcp *dcp, bool a500, bool on, bool flags) (a500 || flags ? iomfb_v27_sleep_args(dcp, a500, args) : iomfb_v27_display_args(dcp, false, args))) return -EOPNOTSUPP; + ret = iomfb_v27_tag(dcp->v27_methods, a500 ? "A500" : "A484", method.tag); + if (ret) + return ret; rpc = kzalloc_obj(*rpc); if (!rpc) return -ENOMEM; @@ -1006,10 +1018,7 @@ static int iomfb_v27_rpc(struct apple_dcp *dcp, bool a500, bool on, bool flags) rpc->status = ~0U; rpc->transaction.start = iomfb_v27_sleep_start; rpc->transaction.release = iomfb_v27_sleep_release; - rpc->method = (struct dcp_method_entry) { - .name = a500 ? "v27_sleep_500" : "v27_sleep_power", - }; - memcpy(rpc->method.tag, a500 ? "A500" : "A484", 4); + rpc->method = method; /* * 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. @@ -1081,6 +1090,7 @@ int iomfb_v27_sleep_a115(struct apple_dcp *dcp, bool awake) static int iomfb_v27_call(struct apple_dcp *dcp, const char *tag, const void *in, u32 in_len, u32 out_len, bool inout, u8 a442_key) { + struct dcp_method_entry method = { .name = "v27_display_stage" }; struct iomfb_v27_sleep_rpc *rpc; int ret; @@ -1088,6 +1098,9 @@ static int iomfb_v27_call(struct apple_dcp *dcp, const char *tag, const void *in dcp->fw_compat != DCP_FIRMWARE_V_27_0 || in_len > sizeof(rpc->data) || (inout && out_len > sizeof(rpc->data))) return -EOPNOTSUPP; + ret = iomfb_v27_tag(dcp->v27_methods, tag, method.tag); + if (ret) + return ret; rpc = kzalloc_obj(*rpc); if (!rpc) return -ENOMEM; @@ -1097,8 +1110,7 @@ static int iomfb_v27_call(struct apple_dcp *dcp, const char *tag, const void *in rpc->any_reply = true; 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); + rpc->method = method; rpc->input = in_len; rpc->output = out_len; rpc->inout = inout; From e9c6e1178659f5e4f29b62f01ef6cd57cbe7e75f Mon Sep 17 00:00:00 2001 From: Erik Bourget Date: Sat, 21 Nov 2026 19:41:33 -0500 Subject: [PATCH 03/35] drm/apple: admit the T6050 display sleep transport by method table The T6050 display processors take part in a deep sleep through the firmware 27 endpoint transport, which previously gated on the J716c board compatible and a 27.0.0 compatibility string. On a 27.2 stub no processor registered for the sleep, and every deep sleep was refused ("display 0: no provider"). Admit a T6050 DCP or DCPEXT to the firmware 27 sleep transport whenever its build's method table has an ID for every call the sleep sends (iomfb_v27_sleep_methods_complete()). That covers 27.0 and 27.2 across T6050 boards without a board check while refusing 27.3 until its sleep methods are known. Add the v27-tag-translation host selftest covering table translation, fail-closed refusal on missing/unrecorded IDs, and data-driven sleep transport admission. Signed-off-by: Erik Bourget --- drivers/gpu/drm/apple/dcp.c | 18 +- .../selftests/drivers/gpu/apple-dcp/boot.py | 191 ++++++++++++++++++ .../selftests/drivers/gpu/apple-dcp/run.py | 1 + 3 files changed, 198 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 0666748f436d0..b23ba12367334 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -5926,31 +5926,25 @@ static bool dcp_ext26_admitted(struct device_node *np) } /* - * J716c shares the 27.0 endpoint-control wire format, not the J714s normal - * IOMFB method or panel profile. Establish this before RTKit can receive any - * application traffic, including traffic that invalidates a later inventory. + * Firmware 27 (T6050) sleep endpoint-control transport. Establish this before + * RTKit can receive any application traffic, including traffic that invalidates + * a later inventory. Admitted for a T6050 DCP/DCPEXT whose firmware 27 method + * table has an ID for every call the sleep sends. */ static bool dcp_v27_sleep_transport_supported(struct apple_dcp *dcp) { struct device *dev = dcp->dev; - char compat[DCP_FW_VERSION_STR_LEN]; if (!IS_ENABLED(CONFIG_APPLE_SOC_SLEEP)) return false; - if (dcp->v27_j714s) - return true; - if (!of_machine_is_compatible("apple,j716c") || - !of_machine_is_compatible("apple,t6050") || - !(of_device_is_compatible(dev->of_node, "apple,t6050-dcp") || + if (!(of_device_is_compatible(dev->of_node, "apple,t6050-dcp") || of_device_is_compatible(dev->of_node, "apple,t6050-dcpext")) || !dcp->hw.adopt_live_session || dcp->hw.iomfb_method_profile != DCP_IOMFB_METHODS_DEFAULT || dcp->fw_compat != DCP_FIRMWARE_V_27_0) return false; - /* The enum also covers later 27.x method tables. */ - return dcp_read_fw_version(dev, "apple,firmware-compat", compat) >= 0 && - !strcmp(compat, "27.0.0"); + return iomfb_v27_sleep_methods_complete(dcp->v27_methods); } /* diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py b/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py index 0f07b51a66b96..a4e74b38a57d9 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py @@ -557,3 +557,194 @@ def t8122_dcpext_v27_admission(root): return 0; } ''' + + +def v27_tag_translation(root): + iomfb_h = (root / 'drivers/gpu/drm/apple/iomfb.h').read_text() + methods_decl = iomfb_h[iomfb_h.index('enum dcpep_method {'): + iomfb_h.index('#define IOMFB_MAX_CB')] + v27_c = (root / 'drivers/gpu/drm/apple/iomfb_v27.c').read_text() + v27_tables = v27_c[v27_c.index('static const struct dcp_method_entry dcp_methods_27_0'): + v27_c.index('/* The template\'s calls resolve through')] + dcp_c = (root / 'drivers/gpu/drm/apple/dcp.c').read_text() + transport = block(dcp_c, 'static bool dcp_v27_sleep_transport_supported(') + return r''' +#include +#include +#include +#include +#include +#include +#include +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#define CONFIG_APPLE_SOC_SLEEP 1 +#define IS_ENABLED(option) (option) +#define GFP_KERNEL 0 +enum dcp_firmware_version { + DCP_FIRMWARE_UNKNOWN, + DCP_FIRMWARE_V_27_0, +}; +enum dcp_iomfb_method_profile { + DCP_IOMFB_METHODS_DEFAULT, + DCP_IOMFB_METHODS_H17G, +}; +struct device_node { const char *compatible; }; +struct device { struct device_node *of_node; }; +struct apple_dcp_hw_data { + bool adopt_live_session; + enum dcp_iomfb_method_profile iomfb_method_profile; +}; +struct apple_dcp { + struct device *dev; + struct apple_dcp_hw_data hw; + enum dcp_firmware_version fw_compat; + const struct dcp_method_entry *v27_methods; +}; +static int of_device_is_compatible(const struct device_node *np, const char *s) +{ + return np && np->compatible && !strcmp(np->compatible, s); +} +static void *devm_kmemdup(struct device *dev, const void *src, size_t len, unsigned int gfp) +{ + void *copy = malloc(len); + (void)dev; (void)gfp; + if (copy) + memcpy(copy, src, len); + return copy; +} +''' + methods_decl + '\n' + v27_tables + '\n' + transport + r''' +static void expect_tag(const struct dcp_method_entry *methods, const char *in, const char *want) +{ + char out[4] = { 'X', 'X', 'X', 'X' }; + assert(iomfb_v27_tag(methods, in, out) == 0); + assert(memcmp(out, want, 4) == 0); +} + +static void expect_tag_fail(const struct dcp_method_entry *methods, const char *in) +{ + char out[4] = { 'X', 'X', 'X', 'X' }; + assert(iomfb_v27_tag(methods, in, out) == -EOPNOTSUPP); + assert(memcmp(out, "XXXX", 4) == 0); +} + +int main(void) +{ + struct device_node node = { .compatible = "apple,t6050-dcp" }; + struct device dev = { .of_node = &node }; + const struct dcp_method_entry *m27_0 = iomfb_v27_methods("27.0.0"); + const struct dcp_method_entry *m27_2 = iomfb_v27_methods("27.2.0"); + const struct dcp_method_entry *m27_3 = iomfb_v27_methods("27.3.0"); + const struct dcp_method_entry *j714s = iomfb_v27_methods_j714s(&dev, m27_0); + struct dcp_method_entry partial_27_2[dcpep_num_methods]; + unsigned int missing_count; + + assert(m27_0 && m27_2 && m27_3 && j714s); + assert(!iomfb_v27_methods_renumbered(NULL)); + assert(!iomfb_v27_methods_renumbered(m27_0)); + assert(!iomfb_v27_methods_renumbered(j714s)); + assert(iomfb_v27_methods_renumbered(m27_2)); + assert(iomfb_v27_methods_renumbered(m27_3)); + + /* NULL table fails closed. */ + expect_tag_fail(NULL, "A411"); + assert(!iomfb_v27_sleep_methods_complete(NULL)); + + /* 27.0 and J714s copy keep 27.0 IDs unchanged. */ + expect_tag(m27_0, "A411", "A411"); + expect_tag(m27_0, "A484", "A484"); + expect_tag(m27_0, "A500", "A500"); + expect_tag(m27_0, "A442", "A442"); + expect_tag(m27_0, "A449", "A449"); + expect_tag(m27_0, "A115", "A115"); + expect_tag(m27_0, "A364", "A364"); + expect_tag(j714s, "A411", "A411"); + expect_tag(j714s, "A408", "A408"); + expect_tag(j714s, "A500", "A500"); + assert(iomfb_v27_sleep_methods_complete(m27_0)); + assert(iomfb_v27_sleep_methods_complete(j714s)); + assert(!iomfb_v27_missing_method(m27_0, &missing_count) && missing_count == 0); + + /* 27.2 translates every recorded shifted and unchanged paired/sleep tag. */ + const struct { const char *in, *out; } map_27_2[] = { + { "A406", "A456" }, { "A408", "A458" }, { "A411", "A461" }, { "A412", "A462" }, + { "A413", "A463" }, { "A414", "A464" }, { "A423", "A473" }, { "A428", "A478" }, + { "A442", "A492" }, { "A449", "A499" }, { "A450", "A500" }, { "A453", "A503" }, + { "A484", "A534" }, { "A487", "A537" }, { "A489", "A539" }, { "A500", "A550" }, + { "A115", "A115" }, + { "A360", "A360" }, { "A361", "A361" }, { "A362", "A362" }, { "A364", "A364" }, + { "A365", "A365" }, { "A366", "A366" }, { "A367", "A367" }, { "A368", "A368" }, + { "A369", "A369" }, { "A370", "A370" }, { "A371", "A371" }, { "A372", "A372" }, + { "A373", "A373" }, + }; + for (unsigned int i = 0; i < ARRAY_SIZE(map_27_2); i++) + expect_tag(m27_2, map_27_2[i].in, map_27_2[i].out); + assert(iomfb_v27_sleep_methods_complete(m27_2)); + assert(!iomfb_v27_missing_method(m27_2, &missing_count) && missing_count == 0); + + /* Unrecorded tags on 27.2 fail closed (no +50 arithmetic, no 27.0 fallback). */ + expect_tag_fail(m27_2, "A495"); + expect_tag_fail(m27_2, "A499"); + expect_tag_fail(m27_2, "A375"); + expect_tag_fail(m27_2, "A999"); + + /* Incomplete renumbered table (27.3) translates recorded entries and fails closed on missing ones. */ + expect_tag(m27_3, "A453", "A503"); + const char *missing_27_3[] = { + "A411", "A413", "A484", "A500", "A442", "A449", "A115", "A364", "A367", + }; + for (unsigned int i = 0; i < ARRAY_SIZE(missing_27_3); i++) + expect_tag_fail(m27_3, missing_27_3[i]); + assert(!iomfb_v27_sleep_methods_complete(m27_3)); + assert(iomfb_v27_missing_method(m27_3, &missing_count) && missing_count > 0); + + /* Dropping an optional sleep/paired entry does not block basic boot admission, + * but does mark sleep incomplete when a sleep entry is missing, and any table + * other than 27.0 or the J714s copy fails closed as renumbered. */ + memcpy(partial_27_2, m27_2, sizeof(partial_27_2)); + partial_27_2[dcpep_v27_wake_a442].tag[0] = '\0'; + assert(iomfb_v27_methods_renumbered(partial_27_2)); + expect_tag_fail(partial_27_2, "A442"); + assert(!iomfb_v27_missing_method(partial_27_2, &missing_count) && missing_count == 0); + assert(!iomfb_v27_sleep_methods_complete(partial_27_2)); + + struct dcp_method_entry future_27_x[dcpep_num_methods]; + memcpy(future_27_x, m27_0, sizeof(future_27_x)); + memcpy(future_27_x[dcpep_start_signal].tag, "A501", 4); + future_27_x[dcpep_v27_wake_a442].tag[0] = '\0'; + assert(iomfb_v27_methods_renumbered(future_27_x)); + expect_tag_fail(future_27_x, "A442"); + + /* + * Sleep transport admission keys on T6050 DCP/DCPEXT and table completeness. + * No of_machine_is_compatible() stub exists in this translation unit, enforcing + * at compile time that admission does not gate on a board model. + */ + struct apple_dcp dcp = { + .dev = &dev, + .hw = { .adopt_live_session = true, .iomfb_method_profile = DCP_IOMFB_METHODS_DEFAULT }, + .fw_compat = DCP_FIRMWARE_V_27_0, + }; + const char *t6050_compats[] = { "apple,t6050-dcp", "apple,t6050-dcpext" }; + for (unsigned int i = 0; i < ARRAY_SIZE(t6050_compats); i++) { + node.compatible = t6050_compats[i]; + dcp.v27_methods = m27_0; assert(dcp_v27_sleep_transport_supported(&dcp)); + dcp.v27_methods = j714s; assert(dcp_v27_sleep_transport_supported(&dcp)); + dcp.v27_methods = m27_2; assert(dcp_v27_sleep_transport_supported(&dcp)); + dcp.v27_methods = m27_3; assert(!dcp_v27_sleep_transport_supported(&dcp)); + dcp.v27_methods = partial_27_2; assert(!dcp_v27_sleep_transport_supported(&dcp)); + dcp.v27_methods = NULL; assert(!dcp_v27_sleep_transport_supported(&dcp)); + } + dcp.v27_methods = m27_2; + node.compatible = "apple,t6041-dcp"; assert(!dcp_v27_sleep_transport_supported(&dcp)); + node.compatible = "apple,t6050-dcp"; + dcp.hw.adopt_live_session = false; assert(!dcp_v27_sleep_transport_supported(&dcp)); + dcp.hw.adopt_live_session = true; + dcp.hw.iomfb_method_profile = DCP_IOMFB_METHODS_H17G; assert(!dcp_v27_sleep_transport_supported(&dcp)); + dcp.hw.iomfb_method_profile = DCP_IOMFB_METHODS_DEFAULT; + dcp.fw_compat = DCP_FIRMWARE_UNKNOWN; assert(!dcp_v27_sleep_transport_supported(&dcp)); + + free((void *)j714s); + puts("PASS v27 tag translation fail-closed and table-driven sleep transport admission"); + return 0; +} +''' diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/run.py b/tools/testing/selftests/drivers/gpu/apple-dcp/run.py index 87140d980dc95..f716cdbb5941b 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/run.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/run.py @@ -93,6 +93,7 @@ def main(): ('boot', 'syslog-policy', boot.syslog, ((),), ()), ('boot', 't6041-v27-admission', boot.t6041_v27_admission, ((),), ()), ('boot', 't8122-dcpext-v27-admission', boot.t8122_dcpext_v27_admission, ((),), ('-Wno-unused-function',)), + ('boot', 'v27-tag-translation', boot.v27_tag_translation, ((),), ()), ('edid', 'dpavserv-start', edid.startup, ((),), ()), ('edid', 'service-rebind', edid.rebind, ((),), ()), ('edid', 'provider-admission', edid.admission, ((),), ()), From 637f14d38b365b40aa2a19ac02e12bb4fa1fb35a Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 23 Nov 2026 15:12:06 -0700 Subject: [PATCH 04/35] soc: apple: rtkit: a mailbox named by a property of its own apple_rtkit_init() finds its mailbox in mboxes, by index or by name. The K116s's boot loader hands the display over only to a coprocessor node with a single mailbox in mboxes, so the DCP's secure port is named there by apple,secure-mbox instead. Add apple_mbox_get_prop() for a mailbox named by another property, and apple_rtkit_init_mbox_prop() on top of it. Signed-off-by: Jens Axboe --- drivers/soc/apple/mailbox.c | 10 ++++++++-- drivers/soc/apple/rtkit.c | 22 +++++++++++++++++----- include/linux/soc/apple/mailbox.h | 2 ++ include/linux/soc/apple/rtkit.h | 5 +++++ 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/drivers/soc/apple/mailbox.c b/drivers/soc/apple/mailbox.c index 5b5b69500db34..7973d07a825fd 100644 --- a/drivers/soc/apple/mailbox.c +++ b/drivers/soc/apple/mailbox.c @@ -1339,14 +1339,14 @@ static void apple_mbox_quiesce(void *data) pm_runtime_barrier(mbox->dev); } -struct apple_mbox *apple_mbox_get(struct device *dev, int index) +struct apple_mbox *apple_mbox_get_prop(struct device *dev, const char *prop, int index) { struct of_phandle_args args; struct platform_device *pdev; struct apple_mbox *mbox; int ret; - ret = of_parse_phandle_with_args(dev->of_node, "mboxes", "#mbox-cells", + ret = of_parse_phandle_with_args(dev->of_node, prop, "#mbox-cells", index, &args); if (ret || !args.np) return ERR_PTR(ret); @@ -1373,6 +1373,12 @@ struct apple_mbox *apple_mbox_get(struct device *dev, int index) return mbox; } +EXPORT_SYMBOL(apple_mbox_get_prop); + +struct apple_mbox *apple_mbox_get(struct device *dev, int index) +{ + return apple_mbox_get_prop(dev, "mboxes", index); +} EXPORT_SYMBOL(apple_mbox_get); struct apple_mbox *apple_mbox_get_byname(struct device *dev, const char *name) diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c index e516f9d6cb6a9..47440572e9d8a 100644 --- a/drivers/soc/apple/rtkit.c +++ b/drivers/soc/apple/rtkit.c @@ -2302,6 +2302,7 @@ static int apple_rtkit_inherit_buffers( } static struct apple_rtkit *__apple_rtkit_init(struct device *dev, void *cookie, + const char *mbox_prop, const char *mbox_name, int mbox_idx, const struct apple_rtkit_ops *ops, bool adopted, @@ -2366,7 +2367,9 @@ static struct apple_rtkit *__apple_rtkit_init(struct device *dev, void *cookie, set_bit(APPLE_RTKIT_EP_MGMT, rtk->endpoints); set_bit(APPLE_RTKIT_EP_MGMT, rtk->started); - if (mbox_name) + if (mbox_prop) + rtk->mbox = apple_mbox_get_prop(dev, mbox_prop, 0); + else if (mbox_name) rtk->mbox = apple_mbox_get_byname(dev, mbox_name); else rtk->mbox = apple_mbox_get(dev, mbox_idx); @@ -2414,16 +2417,25 @@ struct apple_rtkit *apple_rtkit_init(struct device *dev, void *cookie, const char *mbox_name, int mbox_idx, const struct apple_rtkit_ops *ops) { - return __apple_rtkit_init(dev, cookie, mbox_name, mbox_idx, ops, false, + return __apple_rtkit_init(dev, cookie, NULL, mbox_name, mbox_idx, ops, false, NULL, 0, false); } EXPORT_SYMBOL_GPL(apple_rtkit_init); +struct apple_rtkit *apple_rtkit_init_mbox_prop(struct device *dev, void *cookie, + const char *mbox_prop, + const struct apple_rtkit_ops *ops) +{ + return __apple_rtkit_init(dev, cookie, mbox_prop, NULL, 0, ops, false, + NULL, 0, false); +} +EXPORT_SYMBOL_GPL(apple_rtkit_init_mbox_prop); + struct apple_rtkit *apple_rtkit_init_adopted(struct device *dev, void *cookie, const char *mbox_name, int mbox_idx, const struct apple_rtkit_ops *ops) { - return __apple_rtkit_init(dev, cookie, mbox_name, mbox_idx, ops, true, + return __apple_rtkit_init(dev, cookie, NULL, mbox_name, mbox_idx, ops, true, NULL, 0, false); } EXPORT_SYMBOL_GPL(apple_rtkit_init_adopted); @@ -2482,7 +2494,7 @@ struct apple_rtkit *apple_rtkit_init_adopted_with_buffers( const struct apple_rtkit_ops *ops, const struct apple_rtkit_inherited_buffer *buffers, unsigned int count) { - return __apple_rtkit_init(dev, cookie, mbox_name, mbox_idx, ops, true, + return __apple_rtkit_init(dev, cookie, NULL, mbox_name, mbox_idx, ops, true, buffers, count, false); } EXPORT_SYMBOL_GPL(apple_rtkit_init_adopted_with_buffers); @@ -3539,7 +3551,7 @@ struct apple_rtkit *devm_apple_rtkit_init_m5_saved(struct device *dev, void *coo struct apple_rtkit *rtk; int ret; - rtk = __apple_rtkit_init(dev, cookie, mbox_name, mbox_idx, ops, false, + rtk = __apple_rtkit_init(dev, cookie, NULL, mbox_name, mbox_idx, ops, false, NULL, 0, true); if (IS_ERR(rtk)) return rtk; diff --git a/include/linux/soc/apple/mailbox.h b/include/linux/soc/apple/mailbox.h index 0159bbc356cfa..d543769a6d96a 100644 --- a/include/linux/soc/apple/mailbox.h +++ b/include/linux/soc/apple/mailbox.h @@ -96,6 +96,8 @@ struct apple_mbox { }; struct apple_mbox *apple_mbox_get(struct device *dev, int index); +/* As apple_mbox_get(), for a mailbox named by a property other than mboxes */ +struct apple_mbox *apple_mbox_get_prop(struct device *dev, const char *prop, int index); struct apple_mbox *apple_mbox_get_byname(struct device *dev, const char *name); int apple_mbox_start(struct apple_mbox *mbox); diff --git a/include/linux/soc/apple/rtkit.h b/include/linux/soc/apple/rtkit.h index c76e50bd67d59..c5cdecc34cb08 100644 --- a/include/linux/soc/apple/rtkit.h +++ b/include/linux/soc/apple/rtkit.h @@ -164,6 +164,11 @@ struct apple_rtkit *apple_rtkit_init(struct device *dev, void *cookie, const char *mbox_name, int mbox_idx, const struct apple_rtkit_ops *ops); +/* As apple_rtkit_init(), with the mailbox named by @mbox_prop instead of mboxes. */ +struct apple_rtkit *apple_rtkit_init_mbox_prop(struct device *dev, void *cookie, + const char *mbox_prop, + const struct apple_rtkit_ops *ops); + /* * Initialize an instance for a co-processor that the bootloader left running * and that cannot be reset. No HELLO/EPMAP handshake takes place: the system From 49d7003f4bf651671744903b67c923d8e9237d61 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 18 Nov 2026 06:39:39 -0700 Subject: [PATCH 05/35] soc: apple: rtkit: a step between the AP idle and the IOP idle A coprocessor with a second (secure) mailbox port takes its IOP idle only after that port's AP idle, sent between the main mailbox's AP idle and its IOP idle. The display coprocessor of T6050 firmware 27.2 is one: without it the IOP idle is never acknowledged. - apple_rtkit_v27_set_after_ap(): a callback the atomic idle runs once the AP state is acknowledged, before the IOP request. An error from it fails the idle. - apple_rtkit_v27_port_ap_idle_atomic(): a port's AP idle, sent and awaited by polling, for that callback. - apple_rtkit_idle_strict_with(): the same step for the sleeping idle, failing it the same way. No caller yet. Signed-off-by: Jens Axboe --- drivers/soc/apple/rtkit-v27-late.inc | 57 +++++++++++++++++++++++++ drivers/soc/apple/rtkit.c | 14 +++++- include/linux/soc/apple/dcp-v27-sleep.h | 2 + include/linux/soc/apple/rtkit.h | 1 + 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/drivers/soc/apple/rtkit-v27-late.inc b/drivers/soc/apple/rtkit-v27-late.inc index 6f3bfd84ab0a5..44d3b92cb27b8 100644 --- a/drivers/soc/apple/rtkit-v27-late.inc +++ b/drivers/soc/apple/rtkit-v27-late.inc @@ -7,8 +7,23 @@ struct apple_rtkit_v27_scope { DECLARE_KFIFO(deferred, struct apple_mbox_msg, 64); bool held, stopped, failed; int error; + /* + * Run once between the AP state's acknowledgment and the IOP request, interrupts off. + * An error fails the idle. + */ + int (*after_ap)(void *data); + void *after_ap_data; }; +void apple_rtkit_v27_set_after_ap(struct apple_rtkit_v27_scope *s, int (*fn)(void *), void *data) +{ + if (s) { + s->after_ap = fn; + s->after_ap_data = data; + } +} +EXPORT_SYMBOL_GPL(apple_rtkit_v27_set_after_ap); + bool apple_rtkit_v27_live(struct apple_rtkit *rtk) { return !rtk->crashed && !rtk->shutting_down && @@ -118,6 +133,43 @@ int apple_rtkit_v27_check(struct apple_rtkit_v27_scope *s) } EXPORT_SYMBOL_GPL(apple_rtkit_v27_check); +/* + * A second port's AP idle with interrupts off: sent, and its acknowledgment awaited by polling + * the port's mailbox, for at most @us. The port's tracked state is not updated. + */ +int apple_rtkit_v27_port_ap_idle_atomic(struct apple_rtkit *rtk, unsigned int us) +{ + struct apple_mbox_msg msg = { + .msg0 = FIELD_PREP(APPLE_RTKIT_MGMT_TYPE, APPLE_RTKIT_MGMT_SET_AP_PWR_STATE) | + FIELD_PREP(APPLE_RTKIT_MGMT_PWR_STATE, APPLE_RTKIT_PWR_STATE_IDLE), + .msg1 = APPLE_RTKIT_EP_MGMT, + }; + unsigned int i, n = us / 10; + int ret = -ETIMEDOUT; + + for (i = 0; i < n; i++) { + ret = apple_mbox_send_nowait(rtk->mbox, msg); + if (ret != -EAGAIN && ret != -EBUSY) + break; + udelay(10); + } + if (ret) + return ret; + for (; i < n; i++) { + struct apple_mbox_msg in; + + ret = apple_mbox_recv_nowait(rtk->mbox, &in); + if (ret < 0 && ret != -EBUSY) + return ret; + if (ret > 0 && in.msg1 == APPLE_RTKIT_EP_MGMT && + FIELD_GET(APPLE_RTKIT_MGMT_TYPE, in.msg0) == APPLE_RTKIT_MGMT_SET_AP_PWR_STATE_ACK) + return 0; + udelay(10); + } + return -ETIMEDOUT; +} +EXPORT_SYMBOL_GPL(apple_rtkit_v27_port_ap_idle_atomic); + int apple_rtkit_v27_idle_atomic(struct apple_rtkit_v27_scope *s) { struct apple_rtkit *rtk; @@ -180,6 +232,11 @@ int apple_rtkit_v27_idle_atomic(struct apple_rtkit_v27_scope *s) type == APPLE_RTKIT_MGMT_SET_AP_PWR_STATE_ACK && arg == APPLE_RTKIT_PWR_STATE_IDLE) { ap_ack = true; + if (s->after_ap) { + ret = s->after_ap(s->after_ap_data); + if (ret) + goto poison; + } } else if (msg.msg1 == APPLE_RTKIT_EP_MGMT && iop_sent && !iop_ack && type == APPLE_RTKIT_MGMT_SET_IOP_PWR_STATE_ACK && arg == APPLE_RTKIT_PWR_STATE_IDLE) { diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c index 47440572e9d8a..5080c43e2b650 100644 --- a/drivers/soc/apple/rtkit.c +++ b/drivers/soc/apple/rtkit.c @@ -2867,6 +2867,16 @@ static int apple_rtkit_strict_idle_state(struct apple_rtkit *rtk, bool ap) } int apple_rtkit_idle_strict(struct apple_rtkit *rtk) +{ + return apple_rtkit_idle_strict_with(rtk, NULL, NULL); +} +EXPORT_SYMBOL_GPL(apple_rtkit_idle_strict); + +/* + * As apple_rtkit_idle_strict(), with a step between the AP state's and the IOP state's. + * A failed step fails the idle: the IOP state is not sent. + */ +int apple_rtkit_idle_strict_with(struct apple_rtkit *rtk, int (*after_ap)(void *data), void *data) { int ret; @@ -2877,6 +2887,8 @@ int apple_rtkit_idle_strict(struct apple_rtkit *rtk) reinit_completion(&rtk->strict_idle_done); WRITE_ONCE(rtk->strict_idle_waiting, true); ret = apple_rtkit_strict_idle_state(rtk, true); + if (!ret && after_ap) + ret = after_ap(data); if (!ret) ret = apple_rtkit_strict_idle_state(rtk, false); if (!ret && !wait_for_completion_timeout(&rtk->strict_idle_done, @@ -2889,7 +2901,7 @@ int apple_rtkit_idle_strict(struct apple_rtkit *rtk) rtk->strict_idle_poisoned = true; return ret; } -EXPORT_SYMBOL_GPL(apple_rtkit_idle_strict); +EXPORT_SYMBOL_GPL(apple_rtkit_idle_strict_with); int apple_rtkit_warm_restart_strict(struct apple_rtkit *rtk) { diff --git a/include/linux/soc/apple/dcp-v27-sleep.h b/include/linux/soc/apple/dcp-v27-sleep.h index 5e56c40141903..3484c04a98c2c 100644 --- a/include/linux/soc/apple/dcp-v27-sleep.h +++ b/include/linux/soc/apple/dcp-v27-sleep.h @@ -39,6 +39,8 @@ int apple_rtkit_v27_arm(struct apple_rtkit *, struct apple_rtkit_v27_scope **); bool apple_rtkit_v27_live(struct apple_rtkit *); int apple_rtkit_v27_check(struct apple_rtkit_v27_scope *); int apple_rtkit_v27_idle_atomic(struct apple_rtkit_v27_scope *); +int apple_rtkit_v27_port_ap_idle_atomic(struct apple_rtkit *rtk, unsigned int us); +void apple_rtkit_v27_set_after_ap(struct apple_rtkit_v27_scope *s, int (*fn)(void *), void *data); int apple_rtkit_v27_disarm(struct apple_rtkit_v27_scope *, bool stopped); int apple_dart_v27_claim(struct device *provider, struct device *firmware, diff --git a/include/linux/soc/apple/rtkit.h b/include/linux/soc/apple/rtkit.h index c5cdecc34cb08..055e1424d940f 100644 --- a/include/linux/soc/apple/rtkit.h +++ b/include/linux/soc/apple/rtkit.h @@ -290,6 +290,7 @@ int apple_rtkit_idle(struct apple_rtkit *rtk); /* The mailbox's receive-enable bit (I2A_CONTROL bit 0): off once a slept firmware has answered its idle. */ void apple_rtkit_set_recv_enabled(struct apple_rtkit *rtk, bool enabled); int apple_rtkit_idle_strict(struct apple_rtkit *rtk); +int apple_rtkit_idle_strict_with(struct apple_rtkit *rtk, int (*after_ap)(void *data), void *data); int apple_rtkit_warm_restart_strict(struct apple_rtkit *rtk); int apple_rtkit_warm_restart_stopped(struct apple_rtkit *rtk); From 25787c5c696b94798265a78d5d81c7d825bcd444 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 18 Nov 2026 06:39:40 -0700 Subject: [PATCH 06/35] drm/apple: V27 sleep: the DCP's secure port (firmware 27.2) On T6050 firmware 27.2 the internal display coprocessor has a secure mailbox port (ADT /arm-io/dcp-exclave-mailbox, iop,secure-rtbuddy-proxy), as on T8140. With it unanswered the firmware acknowledges the AP idle and never the IOP idle: the sleep's late stop fails, and so does the stop and restart in the wake. - The port may be named by apple,secure-mbox where mboxes must stay the one ASC mailbox: the boot loader refuses the display handoff otherwise. The driver takes the port's mailbox from that property. - A coprocessor with the port is no longer refused the V27 sleep. Its poller stops at .prepare. - Late stop: the port's AP idle between the main mailbox's AP idle and its IOP idle, polled, interrupts off. Not acknowledged in 5 ms, it fails the stop. - Wake: the stop and restart cycle idles the port the same way and stops its poller, which otherwise reads the mailbox with the display's domain off (SError). The port is restarted before RUN and turned on after the boot. All of it follows the port's presence, not the board. Tested on a K116s: with this the IOP idle is acknowledged within 2 ms. Signed-off-by: Jens Axboe --- drivers/gpu/drm/apple/dcp-v27-sleep.inc | 81 +++++++++++++++++++++---- drivers/gpu/drm/apple/dcp.c | 27 +++++++-- 2 files changed, 91 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-v27-sleep.inc b/drivers/gpu/drm/apple/dcp-v27-sleep.inc index 027927a4ec055..acd8358d7f86b 100644 --- a/drivers/gpu/drm/apple/dcp-v27-sleep.inc +++ b/drivers/gpu/drm/apple/dcp-v27-sleep.inc @@ -250,6 +250,41 @@ static int dcp_v27_ext_cycle_ready(struct apple_dcp *dcp) return dcp->s2r_dcp_dart ? 0 : -ENODEV; } +/* + * A restart with the secure port (firmware 27.2), as dcp_s2r_warm_restart() does it: the + * port restarted before RUN, mapped between the main mailbox's IOP report and its AP on, then on. + */ +static int dcp_v27_warm_restart(struct apple_dcp *dcp, bool strict) +{ + int ret; + + if (dcp->secure_rtk && dcp->secure_answered) { + dcp_secure_poll_stop(dcp); + ret = apple_rtkit_port_restart(dcp->secure_rtk); + if (ret) + dev_warn(dcp->dev, "V27 wake: secure port restart: %d\n", ret); + } + return strict ? apple_rtkit_warm_restart_strict(dcp->rtk) : + apple_rtkit_warm_restart_stopped(dcp->rtk); +} + +static int dcp_v27_boot(struct apple_dcp *dcp) +{ + bool secure = dcp->secure_rtk && dcp->secure_answered; + int ret; + + ret = apple_rtkit_boot_with(dcp->rtk, secure ? dcp_secure_port_map : NULL, dcp); + if (ret || !secure) + return ret; + ret = dcp->secure_map_ret ?: apple_rtkit_port_on(dcp->secure_rtk, DCP_SECURE_TIMEOUT_MS); + if (ret) + dev_warn(dcp->dev, "V27 wake: secure port map %d (%lld us), on %d\n", + dcp->secure_map_ret, dcp->secure_map_us, ret); + else + dcp_secure_poll_start(dcp); + return 0; +} + /* * macOS's DCP stop/restart between its wake steps: sessions closed, AP and IOP * idle, IDLE_DONE, receive off, CPU_CONTROL RUN off; dart-dcp stopped, the display's domain off and, @@ -273,7 +308,11 @@ static int dcp_v27_rtkit_cycle(struct apple_dcp *dcp, unsigned int pause_ms) if (s && s->cycle_failed) return -ECANCELED; dcp_v27_sessions(dcp, false); - ret = apple_rtkit_idle_strict(dcp->rtk); + /* With a secure port: the IOP idle is taken only after the port's AP idle */ + if (dcp->secure_rtk && dcp->secure_answered) + ret = apple_rtkit_idle_strict_with(dcp->rtk, dcp_secure_port_idle_strict, dcp); + else + ret = apple_rtkit_idle_strict(dcp->rtk); if (ret) { dev_warn(dcp->dev, "V27 wake: RTKit cycle: idle %d\n", ret); dcp_v27_sessions(dcp, true); @@ -349,12 +388,12 @@ static int dcp_v27_rtkit_cycle(struct apple_dcp *dcp, unsigned int pause_ms) dev_warn(dcp->dev, "V27 wake: RTKit cycle: display DART rewrite %d\n", ret); } } - ret = apple_rtkit_warm_restart_strict(dcp->rtk); + ret = dcp_v27_warm_restart(dcp, true); if (!ret) { writel(readl(dcp->coproc_reg + APPLE_DCP_COPROC_CPU_CONTROL) | APPLE_DCP_COPROC_CPU_CONTROL_RUN, dcp->coproc_reg + APPLE_DCP_COPROC_CPU_CONTROL); run_status = readl(dcp->coproc_reg + APPLE_DCP_COPROC_CPU_STATUS); - ret = apple_rtkit_boot(dcp->rtk); + ret = dcp_v27_boot(dcp); } /* * An external processor that did not start is not left down: its DART, power words and @@ -373,13 +412,13 @@ static int dcp_v27_rtkit_cycle(struct apple_dcp *dcp, unsigned int pause_ms) ret = apple_dart_m5_display_cycle(dcp->s2r_dcp_dart, true); } if (!ret) - ret = apple_rtkit_warm_restart_stopped(dcp->rtk); + ret = dcp_v27_warm_restart(dcp, false); if (!ret) { writel(readl(dcp->coproc_reg + APPLE_DCP_COPROC_CPU_CONTROL) | APPLE_DCP_COPROC_CPU_CONTROL_RUN, dcp->coproc_reg + APPLE_DCP_COPROC_CPU_CONTROL); run_status = readl(dcp->coproc_reg + APPLE_DCP_COPROC_CPU_STATUS); - ret = apple_rtkit_boot(dcp->rtk); + ret = dcp_v27_boot(dcp); } } if (ret) { @@ -1258,6 +1297,8 @@ static int dcp_v27_reopen_live(struct apple_dcp *dcp) return 0; } +static int dcp_v27_secure_idle_atomic(void *data); + static int dcp_v27_late_arm(void *data) { struct dcp_v27_sleep *s = data; @@ -1287,6 +1328,8 @@ static int dcp_v27_late_arm(void *data) ret = apple_rtkit_v27_arm(dcp->rtk, &s->rx); if (ret) dev_info(dcp->dev, "V27 arm: RTKit %d\n", ret); + else + apple_rtkit_v27_set_after_ap(s->rx, dcp_v27_secure_idle_atomic, dcp); } if (ret) { if (s->display && !s->display_early) { @@ -1305,6 +1348,20 @@ static int dcp_v27_late_arm(void *data) return 0; } +/* + * With a secure port (firmware 27.2): its AP idle between the main mailbox's AP idle and + * its IOP idle, polled, as this runs with interrupts off. Not acknowledged, it fails the stop: + * the firmware would not take the IOP idle. + */ +static int dcp_v27_secure_idle_atomic(void *data) +{ + struct apple_dcp *dcp = data; + + if (!dcp->secure_rtk || !dcp->secure_answered) + return 0; + return apple_rtkit_v27_port_ap_idle_atomic(dcp->secure_rtk, 5000); +} + static int dcp_v27_late_check(void *data) { struct dcp_v27_sleep *s = data; @@ -1439,9 +1496,11 @@ static int dcp_v27_sleep_prepare(struct apple_dcp *dcp) dev_warn(dcp->dev, "V27 sleep: no sleep RPC arguments in the DT\n"); return -EOPNOTSUPP; } - if (!dcp->retain_dma || IS_ERR_OR_NULL(dcp->rtk) || !dcp->active || dcp->crashed || dcp->quiescing || - dcp->secure_rtk) - return dcp_v27_refuse(dcp, "coprocessor not live (dma, rtkit, active, crashed, quiescing, secure)"); + if (!dcp->retain_dma || IS_ERR_OR_NULL(dcp->rtk) || !dcp->active || dcp->crashed || dcp->quiescing) + return dcp_v27_refuse(dcp, "coprocessor not live (dma, rtkit, active, crashed, quiescing)"); + /* The secure port is idled from the late stop, with nothing else reading it. */ + if (dcp->secure_rtk && dcp->secure_answered) + dcp_secure_poll_stop(dcp); /* Mode-config suspend is the actual DRM scanout-owner boundary. No HPD * shortcut: external firmware still executes A484/A500/AFK and late IDLE. */ @@ -1694,7 +1753,7 @@ static int dcp_v27_sleep_restart(struct apple_dcp *dcp) if (s->phase == V27_STOPPED) { ret = apple_sleep_display_v27_power_ready(dcp->dev); if (!ret) - ret = apple_rtkit_warm_restart_strict(dcp->rtk); + ret = dcp_v27_warm_restart(dcp, true); /* * The final step stopped this CPU and it is still stopped: the firmware boots * from its reset vector next, so the state tracked before the stop does not @@ -1703,12 +1762,12 @@ static int dcp_v27_sleep_restart(struct apple_dcp *dcp) if (ret == -EUCLEAN && READ_ONCE(dcp->s2r_fw_down) && !(readl(dcp->coproc_reg + APPLE_DCP_COPROC_CPU_CONTROL) & APPLE_DCP_COPROC_CPU_CONTROL_RUN)) - ret = apple_rtkit_warm_restart_stopped(dcp->rtk); + ret = dcp_v27_warm_restart(dcp, false); if (ret) return dcp_v27_fail(s, ret); writel(readl(dcp->coproc_reg + APPLE_DCP_COPROC_CPU_CONTROL) | APPLE_DCP_COPROC_CPU_CONTROL_RUN, dcp->coproc_reg + APPLE_DCP_COPROC_CPU_CONTROL); - ret = apple_rtkit_boot(dcp->rtk); + ret = dcp_v27_boot(dcp); if (ret) return dcp_v27_fail(s, ret); } diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index b23ba12367334..cd48c2db73914 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -256,18 +256,24 @@ static void dcp_secure_port_start(struct apple_dcp *dcp) } /* Between the main mailbox's AP idle and its IOP idle. */ -static void dcp_secure_port_idle(void *data) +static int dcp_secure_port_idle_strict(void *data) { struct apple_dcp *dcp = data; int ret; if (!dcp->secure_rtk || !dcp->secure_answered) - return; + return 0; dcp_secure_poll_stop(dcp); ret = apple_rtkit_port_idle(dcp->secure_rtk, DCP_SECURE_TIMEOUT_MS); if (ret) dev_warn(dcp->dev, "secure port AP idle not acknowledged: %d\n", ret); + return ret; +} + +static void dcp_secure_port_idle(void *data) +{ + dcp_secure_port_idle_strict(data); } static void dcp_release_secure_rtkit(void *data) @@ -284,10 +290,18 @@ static int dcp_secure_port_init(struct apple_dcp *dcp) { struct device *dev = dcp->dev; - if (of_property_match_string(dev->of_node, "mbox-names", "secure") < 0) + /* + * The secure mailbox is the second of mboxes, or named by apple,secure-mbox where the + * boot loader wants mboxes to hold the one ASC mailbox (it refuses the display handoff + * otherwise). + */ + if (of_property_match_string(dev->of_node, "mbox-names", "secure") >= 0) + dcp->secure_rtk = apple_rtkit_init(dev, dcp, "secure", 0, &dcp_secure_rtkit_ops); + else if (of_property_present(dev->of_node, "apple,secure-mbox")) + dcp->secure_rtk = apple_rtkit_init_mbox_prop(dev, dcp, "apple,secure-mbox", + &dcp_secure_rtkit_ops); + else return 0; - - dcp->secure_rtk = apple_rtkit_init(dev, dcp, "secure", 0, &dcp_secure_rtkit_ops); if (IS_ERR(dcp->secure_rtk)) { int ret = PTR_ERR(dcp->secure_rtk); @@ -313,7 +327,8 @@ static void dcp_s2r_check_dt(struct apple_dcp *dcp) struct device_node *np = dcp->dev->of_node; bool power = of_property_present(np, "apple,display-power"); bool secure = dcp->hw.s2r_no_secure_port || - of_property_match_string(np, "mbox-names", "secure") >= 0; + of_property_match_string(np, "mbox-names", "secure") >= 0 || + of_property_present(np, "apple,secure-mbox"); if (dcp->hw.s2r && (!power || !secure)) { dev_info(dcp->dev, "no %s in the device tree, the firmware keeps running\n", From 3fe501cdb57bb3012692f6384217643f58f3b4c8 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 18 Nov 2026 06:39:40 -0700 Subject: [PATCH 07/35] drm/apple: V27 sleep: wait out a busy endpoint before closing it An endpoint that is still taking a message answers -EBUSY to the close for a moment, and the sleep was refused; undoing it then crashed the internal DCP. Seen on endpoint 0x31 of a K116s DCPEXT, where a service is announced late ("close-31 -16"), more often with a verbose console. Poll afk_v27_sleep_check() for up to 300 ms first, as the other steps do. Signed-off-by: Jens Axboe --- drivers/gpu/drm/apple/dcp-v27-sleep.inc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/apple/dcp-v27-sleep.inc b/drivers/gpu/drm/apple/dcp-v27-sleep.inc index acd8358d7f86b..526c0c2f27292 100644 --- a/drivers/gpu/drm/apple/dcp-v27-sleep.inc +++ b/drivers/gpu/drm/apple/dcp-v27-sleep.inc @@ -1665,7 +1665,18 @@ static int dcp_v27_sleep_prepare(struct apple_dcp *dcp) if (ret) goto uncertain; for (i = ARRAY_SIZE(v27_sleep_endpoints); i-- > 0;) { - ret = afk_v27_sleep_control(dcp->sleep_v27_ep[v27_sleep_endpoints[i] - 0x20], false); + struct apple_dcp_afkep *ep = dcp->sleep_v27_ep[v27_sleep_endpoints[i] - 0x20]; + int check; + + /* + * An endpoint still taking a message (a service announced late, seen on 0x31 of + * a K116s DCPEXT) answers -EBUSY for a moment: wait it out as the other steps do, + * rather than refuse the sleep. + */ + if (ep) + read_poll_timeout(afk_v27_sleep_check, check, check != -EBUSY, 1000, + 300 * USEC_PER_MSEC, false, ep); + ret = afk_v27_sleep_control(ep, false); if (ret) { char name[12]; From b6407ac751962803e2c48c0cf75ae354044e84a8 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 18 Nov 2026 06:39:40 -0700 Subject: [PATCH 08/35] drm/apple: V27 wake: mode set once the firmware has reported the panel After a V27 sleep the first mode set of the internal panel is kept, not sent: on the J714s (27.0) the firmware brings link and mode back once frames arrive. That mode set also comes before the firmware has announced the panel's video interface again. On firmware 27.2 it now waits for two events of the wake and is then sent: the open of the panel's video interface (up to 1.5 s) and the firmware's hotplug report that follows it (up to 250 ms). A wait that runs out is logged. On the K116s the firmware answers that the mode is already set and the link up. 27.0 keeps the mode as before. Whether 27.2 needs the mode set has not been tested separately. Signed-off-by: Jens Axboe --- drivers/gpu/drm/apple/dcp-internal.h | 4 ++++ drivers/gpu/drm/apple/dcp-v27-sleep.inc | 2 ++ drivers/gpu/drm/apple/dcp.c | 2 ++ drivers/gpu/drm/apple/epic/panelavep.c | 4 +++- drivers/gpu/drm/apple/iomfb_template.c | 15 +++++++++++++++ drivers/gpu/drm/apple/iomfb_v27.c | 3 +++ 6 files changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/apple/dcp-internal.h b/drivers/gpu/drm/apple/dcp-internal.h index f55c05d9f1793..7d8b2ccfbc408 100644 --- a/drivers/gpu/drm/apple/dcp-internal.h +++ b/drivers/gpu/drm/apple/dcp-internal.h @@ -1007,6 +1007,10 @@ struct apple_dcp { /* V27 sleep: the panel's next mode set is the mode it already has */ bool v27_keep_mode; + /* Since the V27 wake: the panel's video interface opened, firmware reported the panel */ + struct completion v27_wake_video, v27_wake_hotplug; +#define V27_WAKE_VIDEO_MS 1500 +#define V27_WAKE_HOTPLUG_MS 250 /* V27 sleep: the output area of the call being pushed holds this (an in/out word) */ const void *push_out_prefill; diff --git a/drivers/gpu/drm/apple/dcp-v27-sleep.inc b/drivers/gpu/drm/apple/dcp-v27-sleep.inc index 526c0c2f27292..f800e37f18c65 100644 --- a/drivers/gpu/drm/apple/dcp-v27-sleep.inc +++ b/drivers/gpu/drm/apple/dcp-v27-sleep.inc @@ -1252,6 +1252,8 @@ static int dcp_v27_reopen_live(struct apple_dcp *dcp) return ret; s->soft_off = false; } + reinit_completion(&dcp->v27_wake_video); + reinit_completion(&dcp->v27_wake_hotplug); WRITE_ONCE(dcp->v27_keep_mode, true); } else if (s->ext_wake) { ret = dcp_v27_ext_wake_calls(s); diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index cd48c2db73914..94b869968e2b2 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -7248,6 +7248,8 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev) INIT_LIST_HEAD(&dcp->swapped_out_fbs); mutex_init(&dcp->swapped_out_fbs_lock); + init_completion(&dcp->v27_wake_video); + init_completion(&dcp->v27_wake_hotplug); ret = dcp_backlight_init(dcp, dev); if (ret) return ret; diff --git a/drivers/gpu/drm/apple/epic/panelavep.c b/drivers/gpu/drm/apple/epic/panelavep.c index cd4507b2bf78f..6e7a0cb682bcf 100644 --- a/drivers/gpu/drm/apple/epic/panelavep.c +++ b/drivers/gpu/drm/apple/epic/panelavep.c @@ -131,9 +131,11 @@ static void panelav_open_worker(struct work_struct *work) if (ret) dev_warn(service->ep->dcp->dev, "panel AV: video interface %u OPEN failed: %d\n", service->channel, ret); - else + else { + complete(&service->ep->dcp->v27_wake_video); dev_info(service->ep->dcp->dev, "panel AV: video interface %u opened\n", service->channel); + } afk_service_put(service); kfree(w); } diff --git a/drivers/gpu/drm/apple/iomfb_template.c b/drivers/gpu/drm/apple/iomfb_template.c index 0e9064dcb289b..01c7b942709b7 100644 --- a/drivers/gpu/drm/apple/iomfb_template.c +++ b/drivers/gpu/drm/apple/iomfb_template.c @@ -4264,6 +4264,21 @@ int DCP_FW_NAME(iomfb_modeset)(struct apple_dcp *dcp, keep_mode = dcp->v27_j714s && xchg(&dcp->v27_keep_mode, false) && dcp->mode.color_mode_id == mode->color_mode_id && dcp->mode.timing_mode_id == mode->timing_mode_id; + /* + * Firmware 27.2: sent once the panel's video interface is open again and the firmware + * has reported the panel, which it does after the open. + */ + if (keep_mode && iomfb_v27_methods_renumbered(dcp->v27_methods)) { + if (!wait_for_completion_timeout(&dcp->v27_wake_video, + msecs_to_jiffies(V27_WAKE_VIDEO_MS))) + dev_warn(dcp->dev, "V27 wake: panel video interface not open after %u ms\n", + V27_WAKE_VIDEO_MS); + else if (!wait_for_completion_timeout(&dcp->v27_wake_hotplug, + msecs_to_jiffies(V27_WAKE_HOTPLUG_MS))) + dev_warn(dcp->dev, "V27 wake: no hotplug report %u ms after the panel's open\n", + V27_WAKE_HOTPLUG_MS); + keep_mode = false; + } #endif dcp->mode = (struct dcp_set_digital_out_mode_req){ .color_mode_id = mode->color_mode_id, diff --git a/drivers/gpu/drm/apple/iomfb_v27.c b/drivers/gpu/drm/apple/iomfb_v27.c index 041ce575f8823..b93bcc88885f6 100644 --- a/drivers/gpu/drm/apple/iomfb_v27.c +++ b/drivers/gpu/drm/apple/iomfb_v27.c @@ -513,6 +513,9 @@ static bool trampoline_hotplug_h17p(struct apple_dcp *dcp, int tag, if (!(request->tiled_display_null & 1)) memcpy(out, request->tiled_display, sizeof(request->tiled_display)); + /* The V27 wake's mode set waits for the firmware's report of the panel */ + if (request->connected && dcp->v27_j714s) + complete(&dcp->v27_wake_hotplug); return trampoline_hotplug(dcp, tag, out, in); } From b541c7a06e0e04fc420063d43bc9c20b73adb758 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 18 Nov 2026 06:39:40 -0700 Subject: [PATCH 09/35] soc: apple: rtkit: serve an endpoint's first buffer under the ANS hold The T6050 ANS wake holds the buffers: a request under the hold fails the wake with -EBUSY and the driver then holds all I/O. ANS on firmware 27.0 asks for none. On 27.2 it asks for its syslog buffer (endpoint 2, 0x4000 bytes) about 2.4 s into the wake, having none yet. A first buffer for an endpoint replaces nothing the hold protects: serve it. A request for an endpoint that has a buffer is refused as before. With it ANS comes back and the controller is rebuilt after a deep sleep on a K116s (27.2). Signed-off-by: Jens Axboe --- drivers/soc/apple/rtkit.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c index 5080c43e2b650..d480df4cad624 100644 --- a/drivers/soc/apple/rtkit.c +++ b/drivers/soc/apple/rtkit.c @@ -558,11 +558,9 @@ static void apple_rtkit_management_rx(struct apple_rtkit *rtk, u64 msg) } } -static int apple_rtkit_alloc_shmem(struct apple_rtkit *rtk, u8 ep, - struct apple_rtkit_shmem *buffer) +static int apple_rtkit_alloc_first_shmem(struct apple_rtkit *rtk, u8 ep, + struct apple_rtkit_shmem *buffer) { - if (READ_ONCE(rtk->ans_hold)) - return apple_rtkit_ans_fail(rtk, -EBUSY); /* The crash log's buffer is asked for only at a crash: serve it after a strict restart too. */ if (READ_ONCE(rtk->strict_retained_buffers) && ep != APPLE_RTKIT_EP_CRASHLOG) return -EPROTO; @@ -577,6 +575,14 @@ static int apple_rtkit_alloc_shmem(struct apple_rtkit *rtk, u8 ep, return buffer->buffer ? 0 : -ENOMEM; } +static int apple_rtkit_alloc_shmem(struct apple_rtkit *rtk, u8 ep, + struct apple_rtkit_shmem *buffer) +{ + if (READ_ONCE(rtk->ans_hold)) + return apple_rtkit_ans_fail(rtk, -EBUSY); + return apple_rtkit_alloc_first_shmem(rtk, ep, buffer); +} + static int apple_rtkit_common_rx_get_buffer(struct apple_rtkit *rtk, struct apple_rtkit_shmem *buffer, u8 ep, u64 msg) @@ -650,7 +656,8 @@ static int apple_rtkit_common_rx_get_buffer(struct apple_rtkit *rtk, goto error; } - err = apple_rtkit_alloc_shmem(rtk, ep, &request); + /* The endpoint has no buffer yet: a first one replaces nothing the ANS hold protects */ + err = apple_rtkit_alloc_first_shmem(rtk, ep, &request); if (err) goto error; *buffer = request; From 206b6192154f411736df59e61f68d29852933ead Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 05:27:07 -0700 Subject: [PATCH 10/35] soc: apple: sleep: tell whether a T6050 machine describes the sleep The drivers that take part in T6050's firmware-driven sleep each name the boards it has run on. Whether a board sleeps that way is in its device tree: it has an enabled apple,t6050-sleep node or it does not. Add apple_t6050_sleep_described() for that. What differs from one description to another is a property of the node, read with apple_t6050_sleep_property(). Signed-off-by: Jens Axboe --- include/linux/soc/apple/sleep.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/include/linux/soc/apple/sleep.h b/include/linux/soc/apple/sleep.h index db4337d663b81..09ec51cbf8050 100644 --- a/include/linux/soc/apple/sleep.h +++ b/include/linux/soc/apple/sleep.h @@ -9,10 +9,33 @@ #include #include #include +#include #include struct device; -struct device_node; + +/* + * A T6050 machine whose device tree describes the firmware-driven sleep. What a + * driver does for that sleep follows the description, not a list of boards. + * With @prop: the description also has that property. + */ +static inline bool apple_t6050_sleep_property(const char *prop) +{ + struct device_node *np; + bool ret; + + if (!of_machine_is_compatible("apple,t6050")) + return false; + np = of_find_compatible_node(NULL, NULL, "apple,t6050-sleep"); + ret = np && of_device_is_available(np) && (!prop || of_property_read_bool(np, prop)); + of_node_put(np); + return ret; +} + +static inline bool apple_t6050_sleep_described(void) +{ + return apple_t6050_sleep_property(NULL); +} /* The SMC's sleep messages: the pmVC value and the spacings between them, used as floors */ struct apple_sleep_smc_policy { From 0b5dc413cb88f35f45aa858d561d287e96452a3c Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 08:12:11 -0700 Subject: [PATCH 11/35] dt-bindings: soc: apple,t6050-sleep: add apple,display-method-sleep The drivers tell one T6050 sleep description from another by the board or by the node's compatible. What differs for the display coprocessors is how they take the sleep: through their firmware 27 method table, with the panel's AV and DP services, or through the sleep's endpoint transport alone. Say so in the description. Signed-off-by: Jens Axboe --- .../devicetree/bindings/soc/apple/apple,t6050-sleep.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/soc/apple/apple,t6050-sleep.yaml b/Documentation/devicetree/bindings/soc/apple/apple,t6050-sleep.yaml index c32148802bd18..7d26c0049f8ac 100644 --- a/Documentation/devicetree/bindings/soc/apple/apple,t6050-sleep.yaml +++ b/Documentation/devicetree/bindings/soc/apple/apple,t6050-sleep.yaml @@ -144,6 +144,14 @@ properties: The GFX die's wake sources left enabled for a sleep. From the ADT, set by the bootloader. + apple,display-method-sleep: + type: boolean + description: | + The display coprocessors take the sleep through their firmware 27 method + table: its sleep call and its swap, the panel's AV and DP services and the + external processors' handling around a sleep. Without it they keep the + method table they had and take the sleep's endpoint transport alone. + apple,clk-gating-boot: $ref: /schemas/types.yaml#/definitions/uint32-matrix items: From 6f51c87426946c92ff3eb7bf0c69fd4a68af851b Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 08:12:11 -0700 Subject: [PATCH 12/35] dt-bindings: mfd: apple,smc: add the wake reasons' numbering The bits of the SMC's wake record are numbered per board: the ADT's smc-pmu node gives each a name (event_name-bitN). Let the device tree carry the bits and their names. Signed-off-by: Jens Axboe --- .../devicetree/bindings/mfd/apple,smc.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/apple,smc.yaml b/Documentation/devicetree/bindings/mfd/apple,smc.yaml index c35e7d0e10faa..34416179acfa0 100644 --- a/Documentation/devicetree/bindings/mfd/apple,smc.yaml +++ b/Documentation/devicetree/bindings/mfd/apple,smc.yaml @@ -68,6 +68,22 @@ properties: hwmon: $ref: /schemas/hwmon/apple,smc-hwmon.yaml + apple,wake-reasons: + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 1 + maxItems: 64 + items: + maximum: 63 + description: | + The bits of the SMC's wake record that have a name on this board, as the + ADT's smc-pmu node numbers them (event_name-bitN). + + apple,wake-reason-names: + $ref: /schemas/types.yaml#/definitions/string-array + minItems: 1 + maxItems: 64 + description: The names of the bits in apple,wake-reasons, in the same order. + additionalProperties: false required: From 5ccf3d3ed7ccfc44f9769915b2258f4b8c13efde Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 08:12:12 -0700 Subject: [PATCH 13/35] arm64: dts: apple: t6050-j714s: the display's sleep method and the SMC's wake reasons Both were tied to the board's name in the drivers: the display coprocessors' sleep through their firmware 27 method table, and the numbering of the SMC's wake record. Describe them, the latter as the J714s ADT's smc-pmu node has it. Signed-off-by: Jens Axboe --- arch/arm64/boot/dts/apple/t6050-j714s.dts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t6050-j714s.dts b/arch/arm64/boot/dts/apple/t6050-j714s.dts index 18b7c700c8469..b36ebf840260e 100644 --- a/arch/arm64/boot/dts/apple/t6050-j714s.dts +++ b/arch/arm64/boot/dts/apple/t6050-j714s.dts @@ -792,6 +792,19 @@ #include "t6050-j714s-sleep-soc.dtsi" #include "t6050-j714s-sleep-adt.dtsi" +/* The display coprocessors take the sleep through their firmware 27 method table */ +&sleep { + apple,display-method-sleep; +}; + +/* The SMC's wake reasons (ADT smc-pmu, event_name-bitN) */ +&smc { + apple,wake-reasons = <0 8 9 11 13 35 40 41 42 43 44 45 48>; + apple,wake-reason-names = "pwrbtn", "lid", "sdconn", "charger", "wifibt", + "trackpadkeyboard", "acattach", "acdetach", "USB-C_plug", + "USB2_plug", "USB2_wake", "aupo", "rtc"; +}; + /* * Sound through the AOP, as on J813: its audio service runs the serializers, the * CS42L84 headphone jack on admac-base-ns TX2/RX2 and the six SN012776 speaker amps From e2eddb99751c6a5648f50e29ee0e768beed10883 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 05:27:21 -0700 Subject: [PATCH 14/35] soc: apple: sleep: check a profile's CPU inventory, not its board's name A profile that names a machine is refused at probe on any other board, whatever its CPUs. The node's compatible already chose the profile, and what the entry depends on is the inventory: the boot CPU's MPIDR and the CPU count. Check those alone. The K116s (16-inch M5 Pro) binds apple,t6050-sleep with the J714s's 18-core layout and sleeps with that profile. Signed-off-by: Jens Axboe --- drivers/soc/apple/sleep.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/soc/apple/sleep.c b/drivers/soc/apple/sleep.c index 9cee856626f91..4a71b157fcc30 100644 --- a/drivers/soc/apple/sleep.c +++ b/drivers/soc/apple/sleep.c @@ -1916,10 +1916,10 @@ static int apple_sleep_validate_cpu_topology(struct apple_sleep *s) soc->cpu_cores_per_cluster > 32) return dev_err_probe(s->dev, -EINVAL, "invalid CPU-start geometry\n"); - if (soc->machine && (!of_machine_is_compatible(soc->machine) || - cpu_logical_map(0) != soc->boot_mpidr || - num_possible_cpus() != soc->cpu_count)) - return dev_err_probe(s->dev, -EINVAL, "unsupported board/CPU inventory\n"); + /* The node's compatible chose the profile: its machine is where it was measured */ + if (soc->machine && (cpu_logical_map(0) != soc->boot_mpidr || + num_possible_cpus() != soc->cpu_count)) + return dev_err_probe(s->dev, -EINVAL, "unsupported CPU inventory\n"); index = of_property_match_string(np, "reg-names", "cpu-start"); if (index < 0) From cd7eb8603099dcd888a5278deb3cdb3698903680 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 05:27:46 -0700 Subject: [PATCH 15/35] irqchip/apple-aic: keep the T6050 controller where the sleep is described The save and restore for T6050's deep sleep are set up on a list of boards. Set them up wherever the device tree describes that sleep. Signed-off-by: Jens Axboe --- drivers/irqchip/irq-apple-aic.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-aic.c index 52a892164c3a4..769e4105d9ac3 100644 --- a/drivers/irqchip/irq-apple-aic.c +++ b/drivers/irqchip/irq-apple-aic.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -278,8 +279,8 @@ struct aic_info { bool vm_timer_fiq_readonly; /* A firmware-driven suspend powers the controller down: aic_syscore_ops keep it. */ bool fw_suspend; - /* If set, fw_suspend holds on these boards only */ - const char *const *fw_suspend_boards; + /* If set, fw_suspend holds only where this says the sleep is described */ + bool (*fw_suspend_described)(void); }; static const struct aic_info aic1_info __initconst = { @@ -328,12 +329,9 @@ static const struct aic_info aic3_info __initconst = { /* * The M5 Pro's sleep: the last steps mask every interrupt and acknowledge events by hand. The - * save and restore are set up on the boards with a T6050 sleep, the J714s and the J716c; + * save and restore are set up on the boards whose device tree describes a T6050 sleep; * another T6050 board is as one without them. */ -static const char *const aic3_t6050_sleep_boards[] __initconst = { - "apple,j714s", "apple,j716c", NULL -}; static const struct aic_info aic3_t6050_info __initconst = { .version = 3, @@ -341,7 +339,7 @@ static const struct aic_info aic3_t6050_info __initconst = { .fast_ipi = true, .local_fast_ipi = true, .fw_suspend = true, - .fw_suspend_boards = aic3_t6050_sleep_boards, + .fw_suspend_described = apple_t6050_sleep_described, }; static const struct aic_info aic3_t8140_info __initconst = { @@ -1298,8 +1296,7 @@ static struct syscore aic_syscore = { static void __init aic_sleep_init(struct aic_irq_chip *irqc) { if (!irqc->info.fw_suspend || - (irqc->info.fw_suspend_boards && - !of_machine_compatible_match(irqc->info.fw_suspend_boards))) + (irqc->info.fw_suspend_described && !irqc->info.fw_suspend_described())) return; aic_sleep.irq_cfg = kcalloc(irqc->nr_die * irqc->nr_irq, sizeof(u32), GFP_KERNEL); From 2fd30b341355c826c3339630f7158a569e49781d Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 05:28:30 -0700 Subject: [PATCH 16/35] mfd: macsmc: the T6050 saved-context path where the sleep is described The saved-context lane is for T6050's deep sleep and was enabled on the boards named here. Enable it wherever the device tree describes that sleep. The J714s's numbering of the wake record was a table picked by the board's name. It is the ADT's smc-pmu numbering: read it from the SMC's node (apple,wake-reasons, apple,wake-reason-names). Without them the SoC's table is used as before, and the J714s's built-in one on a J714s. The J714s's port and radio dark wake rule was keyed on that table's address. Give it a flag of its own, so the rule holds with either table. Signed-off-by: Jens Axboe --- drivers/mfd/macsmc-test.c | 7 +++++-- drivers/mfd/macsmc.c | 42 +++++++++++++++++++++++++++++++------- include/linux/mfd/macsmc.h | 1 + 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/drivers/mfd/macsmc-test.c b/drivers/mfd/macsmc-test.c index 2dec0920f982d..fc07a3eb61719 100644 --- a/drivers/mfd/macsmc-test.c +++ b/drivers/mfd/macsmc-test.c @@ -352,6 +352,9 @@ static void macsmc_lid_wake_test(struct kunit *test) static void macsmc_wake_reason_test(struct kunit *test) { + static const struct apple_smc_wake_reason j714s[] = { + { 8, "lid" }, { 9, "sdconn" }, { 13, "wifibt" }, { } + }; struct macsmc_test_context *ctx = test->priv; char names[128]; @@ -371,8 +374,8 @@ static void macsmc_wake_reason_test(struct kunit *test) KUNIT_EXPECT_EQ(test, apple_smc_wake_reason_bit(&ctx->smc, "lid"), 8); KUNIT_EXPECT_EQ(test, apple_smc_wake_reason_bit(&ctx->smc, "ipd_touch"), -1); - /* The J714s's: T8132's lid and radio bits, its SD reader at bit 9. */ - ctx->smc.wake_reasons = apple_smc_j714s_wake_reasons; + /* A device tree's own, here the J714s's: its SD reader at bit 9. */ + ctx->smc.wake_reasons = j714s; apple_smc_wake_reason_names(&ctx->smc, BIT_ULL(8) | BIT_ULL(9) | BIT_ULL(10) | BIT_ULL(13), names, sizeof(names)); KUNIT_EXPECT_STREQ(test, names, "lid sdconn wifibt"); diff --git a/drivers/mfd/macsmc.c b/drivers/mfd/macsmc.c index cb32577a3bf66..75c7ed03a72b1 100644 --- a/drivers/mfd/macsmc.c +++ b/drivers/mfd/macsmc.c @@ -635,9 +635,34 @@ static const struct apple_smc_wake_reason apple_smc_j714s_wake_reasons[] = { { 43, "USB2_plug" }, { 44, "USB2_wake" }, { 45, "aupo" }, { 48, "rtc" }, { } }; +/* A board's own numbering, from its device tree (apple,wake-reasons and their names) */ +static const struct apple_smc_wake_reason *apple_smc_dt_wake_reasons(struct device *dev) +{ + struct device_node *np = dev->of_node; + struct apple_smc_wake_reason *r; + int i, n; + + n = of_property_count_u32_elems(np, "apple,wake-reasons"); + if (n <= 0 || n != of_property_count_strings(np, "apple,wake-reason-names")) + return NULL; + r = devm_kcalloc(dev, n + 1, sizeof(*r), GFP_KERNEL); + if (!r) + return NULL; + for (i = 0; i < n; i++) { + u32 bit; + + if (of_property_read_u32_index(np, "apple,wake-reasons", i, &bit) || bit > 63 || + of_property_read_string_index(np, "apple,wake-reason-names", i, &r[i].name)) + return NULL; + r[i].bit = bit; + } + return r; +} + static int apple_smc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + const struct apple_smc_wake_reason *dt_reasons; struct apple_smc *smc; __be32 count = 0; bool t6050; @@ -646,17 +671,20 @@ static int apple_smc_probe(struct platform_device *pdev) smc = devm_kzalloc(dev, sizeof(*smc), GFP_KERNEL); if (!smc) return -ENOMEM; - smc->wake_reasons = of_device_is_compatible(dev->of_node, "apple,t8132-smc") ? - apple_smc_t8132_wake_reasons : apple_smc_t8140_wake_reasons; + dt_reasons = apple_smc_dt_wake_reasons(dev); + smc->wake_reasons = dt_reasons; + if (!smc->wake_reasons) + smc->wake_reasons = of_device_is_compatible(dev->of_node, "apple,t8132-smc") ? + apple_smc_t8132_wake_reasons : apple_smc_t8140_wake_reasons; mutex_init(&smc->mutex); spin_lock_init(&smc->lock); smc->dev = &pdev->dev; - smc->saved_enabled = of_machine_is_compatible("apple,t6050") && - (of_machine_is_compatible("apple,j714s") || - of_machine_is_compatible("apple,j716c")) && + smc->saved_enabled = apple_t6050_sleep_described() && of_device_is_compatible(dev->of_node, "apple,t6050-smc"); - if (smc->saved_enabled && of_machine_is_compatible("apple,j714s")) + smc->port_dark_wake = smc->saved_enabled && of_machine_is_compatible("apple,j714s"); + /* A J714s device tree from before apple,wake-reasons */ + if (smc->port_dark_wake && !dt_reasons) smc->wake_reasons = apple_smc_j714s_wake_reasons; /* J813's late notice needs the bounded, IRQ-independent transport too. */ if (of_machine_is_compatible("apple,j813")) @@ -1042,7 +1070,7 @@ static void apple_smc_dark_wake(struct apple_smc *smc) s64 asleep_ms; /* The J714s's rule alone: other boards with a sleep policy keep these wakes full. */ - if (smc->wake_reasons != apple_smc_j714s_wake_reasons) + if (!smc->port_dark_wake) return; /* Already dark (a port's wake with the lid closed): counted, so the re-entry waits as after ours. */ if (pm_dark_wake()) { diff --git a/include/linux/mfd/macsmc.h b/include/linux/mfd/macsmc.h index 0bfd2079d0b96..14833b8fd1cef 100644 --- a/include/linux/mfd/macsmc.h +++ b/include/linux/mfd/macsmc.h @@ -131,6 +131,7 @@ struct apple_smc { * resolve only the matching pending ID; timeout never cancels SRAM use. */ bool saved_enabled, saved_blocked, saved_scope, saved_committed; + bool port_dark_wake; bool saved_pending, saved_recovery, saved_wake; int saved_fault, saved_notice_error, saved_restore_error; /* From 8b139a051248ac2c5142c10e7ad2726168a9af1b Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 05:28:30 -0700 Subject: [PATCH 17/35] soc: apple: rtkit: acknowledge the v2 PMP's CoreAnalytics events on any board The empty CoreAnalytics event on the PMP's endpoint 7 is acknowledged on the J714s only. It is the firmware's doing, not the board's: a K116s's PMP sends it too, on the same endpoint. Acknowledge it for every registry-v2 PMP. Signed-off-by: Jens Axboe --- drivers/soc/apple/rtkit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c index d480df4cad624..a91c28d3e6db3 100644 --- a/drivers/soc/apple/rtkit.c +++ b/drivers/soc/apple/rtkit.c @@ -2360,8 +2360,7 @@ static struct apple_rtkit *__apple_rtkit_init(struct device *dev, void *cookie, goto free_rtk; rtk->pmp_registry_v2 = of_device_is_compatible(dev->of_node, "apple,t6050-pmp-v2"); - rtk->pmp_ca_event_ack = rtk->pmp_registry_v2 && - of_machine_is_compatible("apple,j714s"); + rtk->pmp_ca_event_ack = rtk->pmp_registry_v2; init_completion(&rtk->epmap_completion); init_completion(&rtk->coreanalytics_completion); From 5ee6c8347f0a8d69fde6b497ef33825d46700deb Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 05:28:30 -0700 Subject: [PATCH 18/35] dmaengine: apple-sio: the T6050 description where the sleep is described The T6050 description, which stops the SIO at the sleep's commit, was in force on the J714s by name. Follow the device tree: the boards that describe the sleep. The J716c describes it and leaves its SIO disabled, so nothing changes there. Signed-off-by: Jens Axboe --- drivers/dma/apple-sio.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/dma/apple-sio.c b/drivers/dma/apple-sio.c index cb75beb54ae99..4c5b0b1627b5e 100644 --- a/drivers/dma/apple-sio.c +++ b/drivers/dma/apple-sio.c @@ -697,12 +697,13 @@ static const struct sio_hw_data sio_hw_t6050 = { }; /* - * The T6050 description is in force on the board it has run on. On another T6050 board the - * node is taken as before: by its generic compatible. + * The T6050 description, with its stop at the sleep's commit, is in force on the boards + * that describe the sleep. On another T6050 board the node is taken as before: by its + * generic compatible. */ static bool sio_t6050_board(void) { - return of_machine_is_compatible("apple,j714s"); + return apple_t6050_sleep_described(); } static const struct of_device_id sio_of_match[] = { From 3f3c340ffebeada33ffeb1d32bb3926bc80f0a1c Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 05:28:30 -0700 Subject: [PATCH 19/35] nvme: apple: the T6050 ANS2 sleep attachment where the sleep is described The attachment was made on two boards by name. Make it wherever the device tree describes T6050's deep sleep; the node's own properties still decide the rest. Signed-off-by: Jens Axboe --- drivers/nvme/host/apple-m5-sleep.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/apple-m5-sleep.h b/drivers/nvme/host/apple-m5-sleep.h index f22d6902bf256..50bcaeabde604 100644 --- a/drivers/nvme/host/apple-m5-sleep.h +++ b/drivers/nvme/host/apple-m5-sleep.h @@ -167,10 +167,8 @@ static int apple_nvme_m5_attach(struct apple_nvme *anv) { int ret; - /* Both boards use T6050 ANS2's split NVMe/NVMMU layout and retained SART. */ - if (!of_machine_is_compatible("apple,t6050") || - (!of_machine_is_compatible("apple,j714s") && - !of_machine_is_compatible("apple,j716c"))) + /* T6050 ANS2's split NVMe/NVMMU layout and retained SART, where the sleep is described. */ + if (!apple_t6050_sleep_described()) return -EOPNOTSUPP; /* The wait before the restart after a sleep comes from the DT; without it, no sleep. */ if (of_property_read_u32(anv->dev->of_node, "apple,sleep-wake-delay-ms", From 6c9f6cb911e47044fc595dc0d5465538a8425454 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 05:28:30 -0700 Subject: [PATCH 20/35] PCI: apple: T6050: the radio host's deep sleep where the sleep is described The host registered for T6050's deep sleep on two boards by name. Register wherever the device tree describes that sleep. Signed-off-by: Jens Axboe --- drivers/pci/controller/pcie-apple.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index 8d7e9e72aabda..ab224a95ee857 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -5499,8 +5499,7 @@ static void apple_pcie_t6050_sleep_probe(struct platform_device *pdev, struct ap { struct apple_pcie_port *port; - if (pcie->managed_sids || !(of_machine_is_compatible("apple,j714s") || - of_machine_is_compatible("apple,j716c"))) + if (pcie->managed_sids || !apple_t6050_sleep_described()) return; /* The one port a boot loader trained; an endpoint Linux powers is parked instead. */ list_for_each_entry(port, &pcie->ports, entry) From 6fdd5c4cf55329d0f942c56dd4cf19b80ea94156 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 05:28:30 -0700 Subject: [PATCH 21/35] iommu/apple-dart: the T6050 sleep rules where the sleep is described The display DARTs' V27 provider was admitted on two boards by name and the ISP DART's sleep on one. Take both wherever the device tree describes T6050's deep sleep: the sleep takes the ISP DART's stream registers on any of them. Signed-off-by: Jens Axboe --- drivers/iommu/apple-dart-v27-admission.inc | 4 +--- drivers/iommu/apple-dart.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/apple-dart-v27-admission.inc b/drivers/iommu/apple-dart-v27-admission.inc index 906be5ef222ef..7b6c2be51b903 100644 --- a/drivers/iommu/apple-dart-v27-admission.inc +++ b/drivers/iommu/apple-dart-v27-admission.inc @@ -10,9 +10,7 @@ static bool apple_dart_v27_provider(struct device *dev, resource_size_t base) unsigned int i; if (!IS_ENABLED(CONFIG_APPLE_SOC_SLEEP) || - !(of_machine_is_compatible("apple,j714s") || - (of_machine_is_compatible("apple,j716c") && - of_machine_is_compatible("apple,t6050"))) || + !apple_t6050_sleep_described() || !of_device_is_compatible(dev->of_node, "apple,t6050-dart")) return false; for (i = 0; i < ARRAY_SIZE(ids); i++) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index bf7a4fc0807fa..75514098cd1a9 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -5735,7 +5735,7 @@ static int apple_dart_probe(struct platform_device *pdev) if (dart->cold_ane && !IS_BUILTIN(CONFIG_APPLE_DART)) return -EOPNOTSUPP; dart->isp_host = of_device_is_compatible(dev->of_node, "apple,t6050-isp-dart"); - dart->isp_sleep = dart->isp_host && of_machine_is_compatible("apple,j714s"); + dart->isp_sleep = dart->isp_host && apple_t6050_sleep_described(); dart->power_retained = dart->isp_host; dart->per_stream = dart->isp_host || of_device_is_compatible(dev->of_node, "apple,t8140-dart") || From 79fe9d7ac1f2d371d4d881d6095176ebb2aac431 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 05:28:31 -0700 Subject: [PATCH 22/35] phy: apple: atc-t6050: the combo PHY's deep-sleep rules where the sleep is described The rules were in force on two boards by name. Apply them wherever the device tree describes T6050's deep sleep. Signed-off-by: Jens Axboe --- drivers/phy/apple/atc-t6050-combo.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/phy/apple/atc-t6050-combo.h b/drivers/phy/apple/atc-t6050-combo.h index ae50930a7a809..83f97bc835668 100644 --- a/drivers/phy/apple/atc-t6050-combo.h +++ b/drivers/phy/apple/atc-t6050-combo.h @@ -122,13 +122,13 @@ static void combo_pipe_fault(struct t6050_dp *dp, const char *what, int ret) /* * What the combo PHY gained for a deep sleep outside its sleep callbacks (a wrapper domain * still held at a stop is released, a safe state with a domain still held is stopped again, - * the always-on domain's hold over the sleep) is in force on the boards with a T6050 sleep, - * the J714s and the J716c. On another T6050 board the stop, the safe state and the probe are + * the always-on domain's hold over the sleep) is in force on the boards whose device tree + * describes a T6050 sleep. On another T6050 board the stop, the safe state and the probe are * as before. */ static bool combo_sleep_board(void) { - return of_machine_is_compatible("apple,j714s") || of_machine_is_compatible("apple,j716c"); + return apple_t6050_sleep_described(); } static bool combo_domains_held(struct t6050_dp *dp) From 6cc4a92e966ede365726ef21012332992737caa9 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 05:28:31 -0700 Subject: [PATCH 23/35] usb: dwc3: apple: T6050's sleep lines where the sleep is described The dwc3 glue took T6050's sleep lines on the J714s and the J716c by name. Take them wherever the device tree describes T6050's sleep. The port controllers' side of this is in already: their sleep rules are asked for by the controllers' own properties. Signed-off-by: Jens Axboe --- drivers/usb/dwc3/dwc3-apple.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-apple.c b/drivers/usb/dwc3/dwc3-apple.c index c5740ee25d532..5757cf33832da 100644 --- a/drivers/usb/dwc3/dwc3-apple.c +++ b/drivers/usb/dwc3/dwc3-apple.c @@ -1109,12 +1109,12 @@ static void dwc3_apple_check_hub_later(struct dwc3_apple *appledwc) /* * Waiting for a Type-C PHY that is not started after sleep is specific to the T6050 boards - * whose port controllers take the sleep's power states (J714s, J716c). The notifier work - * and its admission rules apply to every board. + * whose port controllers take the sleep's power states: those whose device tree describes + * the sleep. The notifier work and its admission rules apply to every board. */ static bool dwc3_apple_sleep_board(void) { - return of_machine_is_compatible("apple,j714s") || of_machine_is_compatible("apple,j716c"); + return apple_t6050_sleep_described(); } /* From b45b4b232138c1c620a908cf002710ac2d1fb5f7 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 05:28:31 -0700 Subject: [PATCH 24/35] drm/asahi: g17: the M5 commit stop where the sleep is described The wrapped provider for T6050's deep sleep was used on two boards by name. Use it wherever the device tree describes that sleep. Signed-off-by: Jens Axboe --- drivers/gpu/drm/asahi/g17/sleep.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/asahi/g17/sleep.c b/drivers/gpu/drm/asahi/g17/sleep.c index 380e6662f1419..0131ace971222 100644 --- a/drivers/gpu/drm/asahi/g17/sleep.c +++ b/drivers/gpu/drm/asahi/g17/sleep.c @@ -46,14 +46,13 @@ #define ASC_CPU_CONTROL 0x44 #define ASC_CPU_CONTROL_RUN BIT(4) -/* Only the M5 boards with a deep sleep need a wrapped provider translation here: the J714s - * and the J716c. Other G17 clients retain their established direct-domain methods below. +/* Only the M5 boards with a deep sleep need a wrapped provider translation here: those whose + * device tree describes it. Other G17 clients retain their established direct-domain methods + * below. */ static bool asahi_g17_m5_provider(struct device *dev) { - return (of_machine_is_compatible("apple,j714s") || - of_machine_is_compatible("apple,j716c")) && - of_machine_is_compatible("apple,t6050") && + return apple_t6050_sleep_described() && of_device_is_compatible(dev->of_node, "apple,agx-g17s"); } From 08fba0578d9e03a6f7535d33e4dc52d82dc04e22 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 05:28:31 -0700 Subject: [PATCH 25/35] drm/apple: v27: the J714s's sleep and panel paths by the sleep's description The V27 sleep's paths for the internal panel (the 27.0 method table with the sleep call and the A407 swap, the panel's AV and DP services) and what the external processors gained around it were in force on the J714s by name. Follow the device tree: a sleep description with apple,display-method-sleep. The J716c's has none and keeps its endpoint transport. Signed-off-by: Jens Axboe --- drivers/gpu/drm/apple/dcp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 94b869968e2b2..ce08448999981 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -494,12 +494,13 @@ MODULE_PARM_DESC(t6050_ext_sleep, /* * What a T6050 external display processor gained outside the firmware 27 sleep itself (the * Type-C reconnect skipped for a crashed one, a crashed one refusing a deep sleep before - * anything is stopped, the link line) is in force on the board it has run on, the J714s. - * Elsewhere, other boards with the same SoC included, these are as before. + * anything is stopped, the link line) is in force where the sleep's description has the + * display coprocessors sleep by their method table (apple,display-method-sleep). Elsewhere, + * other boards with the same SoC included, these are as before. */ static bool dcp_j714s_ext(struct device *dev) { - return of_machine_is_compatible("apple,j714s") && + return apple_t6050_sleep_property("apple,display-method-sleep") && of_device_is_compatible(dev->of_node, "apple,t6050-dcpext"); } @@ -7257,7 +7258,7 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev) dcp->fw_compat = fw_compat; dcp->v27_j714s = fw_compat == DCP_FIRMWARE_V_27_0 && - of_machine_is_compatible("apple,j714s"); + apple_t6050_sleep_property("apple,display-method-sleep"); /* * Probe-lifetime like the desktop state: component bind opens a devres * group on this device and releases it on failure or unbind. From d59d6b8bca2d566353226d4f5277f7a1523bd058 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 18 Nov 2026 06:40:14 -0700 Subject: [PATCH 26/35] arm64: dts: apple: t6050-k116s: Add the PMU's RTC Describe the RTC of the PMU on nub-spmi0, as the J714s does: the registers are the T6041 PMU's, at the addresses this board's ADT gives. It is a second RTC beside the SMC's and the only one with an alarm. The PMU raises no alarm interrupt on this SoC, so the alarm is a wake source for a firmware sleep only. Signed-off-by: Jens Axboe --- arch/arm64/boot/dts/apple/t6050-k116s.dts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t6050-k116s.dts b/arch/arm64/boot/dts/apple/t6050-k116s.dts index f55944c0c8317..df6214b51252e 100644 --- a/arch/arm64/boot/dts/apple/t6050-k116s.dts +++ b/arch/arm64/boot/dts/apple/t6050-k116s.dts @@ -949,3 +949,19 @@ firmware-name = "apple/mesacal-k116s.bin", "apple/msrk-k116s.bin"; }; }; + +/* + * The PMU's RTC and its alarm. ADT: the PMU's info-rtc (0x2002), + * info-rtc_alarm_offset (0x2008), info-rtc_irq_mask_offset (0x200e), + * info-rtc_alarm_ctrl (0x2000) and info-rtc_scrpad (0x2100), the registers of + * the T6041 PMU. It raises no interrupt on this SoC: an armed alarm can only + * wake the machine from a firmware sleep, not from s2idle. + */ +&pmu { + pmu_rtc: rtc { + compatible = "apple,t6050-pmu-rtc", "apple,t6041-pmu-rtc"; + nvmem-cells = <&rtc_offset>; + nvmem-cell-names = "rtc_offset"; + wakeup-source; + }; +}; From eb7b172e0bd5c2c40a3b619ebf7ed3c0d5dfc775 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 18 Nov 2026 06:40:14 -0700 Subject: [PATCH 27/35] arm64: dts: apple: t6050-k116s: enable the video encoder's power states iBoot leaves VENC0_SYS on (PS word 0xf0003ff). Its node is disabled on the K116s, so nothing ever turns it off, and FAB0_SOC stays up behind it. The J714s enables these power states for its encoder. With VENC0_SYS on, the SoC does not enter the firmware-driven sleep: the whole entry runs, and the machine resets about 5 s after the commit word. macOS has VENC0_SYS off at its commit on this board (register state read with macOS as an aura guest, the commit withheld). Enable ps_fab1_piogw (firmware-owned), ps_fab0_soc (always-on) and the ps_venc0_* states as on the J714s. Unused, genpd turns them off at boot. No encoder is described yet. Tested on a K116s: venc0-sys and its children read off after boot, and the J714s commit sequence then sleeps. Signed-off-by: Jens Axboe --- arch/arm64/boot/dts/apple/t6050-k116s.dts | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t6050-k116s.dts b/arch/arm64/boot/dts/apple/t6050-k116s.dts index df6214b51252e..39b804ef48736 100644 --- a/arch/arm64/boot/dts/apple/t6050-k116s.dts +++ b/arch/arm64/boot/dts/apple/t6050-k116s.dts @@ -965,3 +965,42 @@ wakeup-source; }; }; + +/* + * The video encoder's power states, as on the J714s. iBoot leaves VENC0_SYS on, and the SoC does + * not enter the firmware-driven sleep with it on. Enabled and unused, genpd turns it off at + * boot. No encoder is described yet. + */ +&ps_fab1_piogw { + apple,firmware-owned; + status = "okay"; +}; + +&ps_fab0_soc { + apple,always-on; + status = "okay"; +}; + +&ps_venc0_sys { + status = "okay"; +}; + +&ps_venc0_dma { + status = "okay"; +}; + +&ps_venc0_pipe4 { + status = "okay"; +}; + +&ps_venc0_pipe5 { + status = "okay"; +}; + +&ps_venc0_me0 { + status = "okay"; +}; + +&ps_venc0_me1 { + status = "okay"; +}; From 00028fb5080bbe647219206a28fd0d07d9ff4134 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 18 Nov 2026 06:40:15 -0700 Subject: [PATCH 28/35] arm64: dts: apple: t6050-j714s-sleep-soc: make the CIO sleep part optional The SoC values file ends with the J714s's USB4 router sleep (acio2, its DART, the clock protection syscon), which needs nodes only t6050-max.dtsi has. A board that includes the SoC values without that router defines T6050_SLEEP_SOC_NO_CIO first. No change for the J714s. Signed-off-by: Jens Axboe --- arch/arm64/boot/dts/apple/t6050-j714s-sleep-soc.dtsi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t6050-j714s-sleep-soc.dtsi b/arch/arm64/boot/dts/apple/t6050-j714s-sleep-soc.dtsi index 9b0f2f0c3376e..5ef086dee5765 100644 --- a/arch/arm64/boot/dts/apple/t6050-j714s-sleep-soc.dtsi +++ b/arch/arm64/boot/dts/apple/t6050-j714s-sleep-soc.dtsi @@ -4576,7 +4576,11 @@ * taking that DART down and back to the live value before using it again. The router's host * also needs the port's PHY, which it stops after the router and starts before it. The left * port's router was never up in a trace: it has none of this and is powered off for a sleep. + * + * A board that includes these SoC values without that router (no acio2) defines + * T6050_SLEEP_SOC_NO_CIO first. */ +#ifndef T6050_SLEEP_SOC_NO_CIO &die0 { ps_prot: syscon@2803f0000 { compatible = "apple,t6050-ps-prot", "syscon"; @@ -4595,3 +4599,4 @@ &apciec2_dart { apple,clock-protection = <&ps_prot 31>; }; +#endif /* T6050_SLEEP_SOC_NO_CIO */ From 54fb125003c89849f18eec4b0ebf5588bb7981b7 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 18 Nov 2026 07:33:57 -0700 Subject: [PATCH 29/35] dt-bindings: mailbox: apple: add the T6050 secure RTBuddy port The internal DCP of a T6050 on firmware 27.2 has the secure port T8140's has (ADT dcp-exclave-mailbox, iop,secure-rtbuddy-proxy). Signed-off-by: Jens Axboe --- Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml b/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml index 7626c8afcedbd..e7f34eb39b152 100644 --- a/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml +++ b/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml @@ -98,6 +98,7 @@ properties: iop,secure-rtbuddy-proxy. It is polled, with no interrupts described. items: - enum: + - apple,t6050-secure-rtbuddy-proxy - apple,t8140-secure-rtbuddy-proxy - const: apple,secure-rtbuddy-proxy From 7589b52a0932641da59d85da13cba25603695fe2 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 18 Nov 2026 07:33:57 -0700 Subject: [PATCH 30/35] dt-bindings: soc: apple,t6050-sleep: allow an empty apple,pinctrl-skip-pins Without the property no pin is saved. A board whose ADT names no pin to leave alone, the K116s, has every pin saved: the property is there and empty. Signed-off-by: Jens Axboe --- .../devicetree/bindings/soc/apple/apple,t6050-sleep.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/soc/apple/apple,t6050-sleep.yaml b/Documentation/devicetree/bindings/soc/apple/apple,t6050-sleep.yaml index 7d26c0049f8ac..a8908c524d1ae 100644 --- a/Documentation/devicetree/bindings/soc/apple/apple,t6050-sleep.yaml +++ b/Documentation/devicetree/bindings/soc/apple/apple,t6050-sleep.yaml @@ -117,10 +117,12 @@ properties: description: The AP pin controller, whose pins a deep sleep resets. apple,pinctrl-skip-pins: - $ref: /schemas/types.yaml#/definitions/uint32-array + oneOf: + - $ref: /schemas/types.yaml#/definitions/uint32-array + - type: boolean description: | Pins neither saved nor restored. From the ADT, set by the bootloader; - without it no pin is saved. + without it no pin is saved. Empty where every pin is saved. apple,sleep-low-pins: $ref: /schemas/types.yaml#/definitions/uint32-array From 9c3f154f9e6ba5627fc996c690bb06601a9a2ded Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 18 Nov 2026 07:33:57 -0700 Subject: [PATCH 31/35] dt-bindings: display: apple,dcp: add apple,secure-mbox The boot loader hands the display over only to a node whose mboxes is the one ASC mailbox. A machine whose internal DCP has a secure port names it in a property of its own there, and the driver takes it as the "secure" mailbox. Signed-off-by: Jens Axboe --- Documentation/devicetree/bindings/display/apple,dcp.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/display/apple,dcp.yaml b/Documentation/devicetree/bindings/display/apple,dcp.yaml index 193ceda46427f..535eac3f1ff7f 100644 --- a/Documentation/devicetree/bindings/display/apple,dcp.yaml +++ b/Documentation/devicetree/bindings/display/apple,dcp.yaml @@ -94,6 +94,14 @@ properties: - const: mbox - const: secure + apple,secure-mbox: + $ref: /schemas/types.yaml#/definitions/phandle + description: + The coprocessor's secure RTBuddy port, on a machine whose boot loader + hands the display over only to a node with a single mailbox in mboxes. + The driver takes it as the "secure" mailbox. Elsewhere the port is the + second entry of mboxes. + iommus: maxItems: 1 From b8466385e57fbe1037f555b57a18767f68ccd3bc Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 18 Nov 2026 06:40:15 -0700 Subject: [PATCH 32/35] arm64: dts: apple: t6050-k116s: describe and enable the deep sleep The J714s's sleep controller description and SoC values on the K116s (16-inch M5 Pro, firmware 27.2), with what differs on this board: - apple,pinctrl-skip-pins is empty: the K116s ADT's gpio0 has no no-restore-gpio-pins. With the J714s's list the panel stays dark after a deep sleep. - The display coprocessor's secure mailbox (ADT dcp-exclave-mailbox), named by apple,secure-mbox so that mboxes stays the one ASC mailbox for the boot loader. - The MagSafe port's PD controller (hpm5), so that the sleep puts it in S3. - The three port controllers ask for the sleep's rules for the system power state command and for the reset on a failed probe (apple,sleep-ssps-rules, apple,reset-on-failed-probe), as the J714s's. - dcpext0 without its Type-C route, as dcpext1 to 3: the engine must bind for the sleep to stop its firmware. - apple,sram-keep <0x56000 0x9b000> for the PMP: its __DATA starts at 0x56000 on 27.2 (ADT segment-ranges). With the J714s's range the PMP does not come back from the sleep. - The four clock words are parked with 0x80100000, as macOS does on this board (J714s: 0x80100400). - apple,panel-video-open-delay-us 10000: the panel's plug takes about 2.9 ms here, and with 2500 us the open landed before the firmware's close. - No CIO sleep part: no USB4 router is described. - apple,display-method-sleep and the SMC's wake reasons, as on the J714s: the K116s ADT's smc-pmu node numbers them the same way. Needs a boot loader that hands the four DCPEXT to the kernel on 27.2 (aura with ext = true for the V27_2 images) and publishes the S2R mailbox. Tested on a K116s: sleep and wake by RTC alarm and by the lid, several cycles a boot, and one sleep of 7.7 hours; display, NVMe, Wi-Fi and Bluetooth work after the wake. The values taken from the J714s (commit schedule, SMC policy, MCC and clock sequences) have not been checked against this board one by one. Signed-off-by: Jens Axboe --- .../boot/dts/apple/t6050-k116s-sleep.dtsi | 285 ++++++++++++++++++ arch/arm64/boot/dts/apple/t6050-k116s.dts | 49 +++ 2 files changed, 334 insertions(+) create mode 100644 arch/arm64/boot/dts/apple/t6050-k116s-sleep.dtsi diff --git a/arch/arm64/boot/dts/apple/t6050-k116s-sleep.dtsi b/arch/arm64/boot/dts/apple/t6050-k116s-sleep.dtsi new file mode 100644 index 0000000000000..040cee8bae63b --- /dev/null +++ b/arch/arm64/boot/dts/apple/t6050-k116s-sleep.dtsi @@ -0,0 +1,285 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * Deep sleep (suspend to RAM) on the K116s: the J714s description with this board's differences + * (the pins, the display coprocessor's secure mailbox, dcpext0). The sleep controller and what + * it needs from the rest of the tree. + */ + +/ { + aliases { + /* The boot loader finds the SIO by this alias */ + sio = &sio; + }; + + sleep: sleep-controller@280600000 { + compatible = "apple,t6050-sleep"; + reg = <0x2 0x80600000 0x0 0x4000>, + <0x2 0x80900000 0x0 0x4000>, + <0x2 0x88300000 0x0 0xc000>, + <0x23 0x00e80000 0x0 0x4000>, + <0x23 0x80600000 0x0 0xc000>, + <0x23 0x88300000 0x0 0x4000>, + <0x2 0x80760000 0x0 0x10000>, + <0x2 0x807d4000 0x0 0x4000>, + <0x2 0x80930000 0x0 0x4000>, + <0x23 0x00e90000 0x0 0x4000>, + <0x23 0x80760000 0x0 0x10000>, + <0x2 0x80700000 0x0 0x20000>, + <0x23 0x80700000 0x0 0x14000>, + <0x2 0x807ec000 0x0 0x4000>, + <0x2 0x80950000 0x0 0x4000>, + <0x23 0x807dc000 0x0 0x4000>, + <0x2 0x80620000 0x0 0x4000>, + <0x2 0x8062c000 0x0 0x4000>, + <0x2 0x80688000 0x0 0x4000>, + <0x2 0x88f04000 0x0 0x4000>, + <0x2 0x8836c000 0x0 0x4000>, + <0x2 0x88330000 0x0 0x4000>, + <0x2 0x80920000 0x0 0x4000>, + <0x2 0x8a014000 0x0 0x4000>, + <0x2 0x86700000 0x0 0x14000>, + <0x2 0x86806000 0x0 0x3000>, + <0x2 0x84240000 0x0 0x20000>, + <0x2 0x803f0000 0x0 0x4000>, + <0x2 0x88370000 0x0 0x4000>, + <0x23 0x88370000 0x0 0x4000>, + <0x2 0x10e40000 0x0 0x10000>, + <0x2 0x11e40000 0x0 0x10000>, + <0x2 0x12e40000 0x0 0x10000>, + <0x4 0x17020000 0x0 0x4000>, + <0x4 0x17980000 0x0 0x4000>, + <0x2 0x80000000 0x0 0x4000>, + <0x2 0x80078000 0x0 0x4000>, + <0x23 0x80078000 0x0 0x4000>, + <0x22 0x20200000 0x0 0x8000>, + <0x22 0x20400000 0x0 0x8000>, + <0x22 0x20600000 0x0 0x8000>, + <0x22 0x20800000 0x0 0x8000>, + <0x22 0x22200000 0x0 0x8000>, + <0x2 0x88004000 0x0 0x4000>, + <0x23 0x88004000 0x0 0x4000>, + <0x23 0x80400000 0x0 0x4000>; + reg-names = "ps0", "ps1", "ps-aon", "ps-gpx", "ps-media", "ps-gfx-aon", + "clk", "clk-soc", "clk1", "afr-clk", "media-clk", + "perf", "media-perf", "table0", "table1", "media-table", + "cluster", "pwrgate", "cpu-start", "commit", "wdt", "wdt-aux", + "disp-gate", "spmi", "pmc-voters", "pmc-rails", "ptd", "gapf", + "aon-clk", "media-aon-clk", "cpm0", "cpm1", "cpm2", + "storage-phy", "storage-phy-ip", + "clkgen", "clkgen-78", "media-clkgen-78", + "mcc22", "mcc23", "mcc24", "mcc25", "mcc26", + "wake", "wake-gfx", "aic-gfx"; + apple,display-coprocessors = <&dcp>, <&dcpext0>, <&dcpext1>, <&dcpext2>, <&dcpext3>; + apple,spmi-buses = <&nub_spmi_a0>, <&nub_spmi2>, <&nub_spmi_a1>, <&nub_spmi3>, + <&aop_spmi0>; + /* SEP's, PMP0's, SIO's and the DCP's DART, stopped in the sleep's last steps */ + apple,sleep-darts = <&sep_dart>, <&pmp0_dart>, <&sio_dart>, <&dcp_dart>; + /* The N1's host: its link is shut down for the sleep and brought back after it */ + apple,radio-pcie = <&pcie0>; + apple,pinctrl = <&pinctrl_ap>; + /* The display coprocessors take the sleep through their firmware 27 method table */ + apple,display-method-sleep; + }; +}; + +/* The SMC's wake reasons (ADT smc-pmu, event_name-bitN) */ +&smc { + apple,wake-reasons = <0 8 9 11 13 35 40 41 42 43 44 45 48>; + apple,wake-reason-names = "pwrbtn", "lid", "sdconn", "charger", "wifibt", + "trackpadkeyboard", "acattach", "acdetach", "USB-C_plug", + "USB2_plug", "USB2_wake", "aupo", "rtc"; +}; + +/* + * The N1's warm reset (ADT pci-bridge0 function-warm_reset: the SMC, key 'bpli'). The N1's + * firmware does not survive a sleep; the host resets the N1 after the wake, before its link + * trains. The writes that give the reset are the boot loader's to add (see the binding). + */ +&port00 { + apple,function-warm-reset = <&smc 0x62706c69 0x1000000>; +}; + +/* On through the commit: the sleep stops their users in its last steps. */ +&ps_pmp { + apple,always-on; +}; + +&ps_pms_sram { + apple,always-on; +}; + +&ps_gfx { + apple,always-on; +}; + +&ps_spi_p { + apple,always-on; +}; + +&ps_atc3_usb_aon { + apple,always-on; +}; + +&ps_sio { + apple,always-on; + status = "okay"; +}; + +&ps_sio_cpu { + apple,always-on; + status = "okay"; +}; + +/* The port controllers put in system power state S3 before the commit, then SLEEP */ +&hpm1 { + apple,sleep-ssps; + apple,sleep-ssps-rules; + apple,reset-on-failed-probe; +}; + +&hpm2 { + apple,sleep-ssps; + apple,sleep-ssps-rules; + apple,reset-on-failed-probe; +}; + +/* + * The MagSafe port's PD controller (ADT hpm5, nub-spmi-a0 0x08), described as + * on the J714s so that the sleep puts it in S3 with the others. + */ +&nub_spmi_a0 { + hpm5: usb-pd@8 { + compatible = "apple,sn201202x"; + reg = <0x8 SPMI_USID>; + apple,no-liquid-detection; + apple,sleep-ssps; + apple,sleep-ssps-rules; + apple,reset-on-failed-probe; + }; +}; + +&{/soc@200000000} { + /* + * The cores' power-gate enables, /arm-io/pmgr reg[0] + 0x2c000, one word per core: the + * boot loader leaves core 0's (the boot core's) and core 12's clear. Without them the + * boot cluster never powers down, and the sleep never gets past its first sequence. + */ + cluster_pwrgate: power-gate@28062c000 { + compatible = "apple,t6050-cluster-pwrgate", "apple,cluster-pwrgate"; + reg = <0x2 0x8062c000 0x0 0x4>, + <0x2 0x8062c0c0 0x0 0x4>; + }; +}; + +/* AOP2, running until the commit: its ASC mailbox at the AOP2 ASC + 0x8000 */ +&{/soc@200000000} { + aop2_mbox: mailbox@291608000 { + compatible = "apple,t6050-asc-mailbox", "apple,asc-mailbox-v4"; + reg = <0x2 0x91608000 0x0 0x4000>; + interrupts = , + , + , + ; + interrupt-names = "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells = <0>; + }; +}; + +&aop2 { + reg = <0x2 0x91600000 0x0 0x4000>; + reg-names = "asc"; + /delete-property/ interrupts; + mboxes = <&aop2_mbox>; + mbox-names = "mbox"; + apple,dma-range = <0x110 0x0 0x10 0x0>; + status = "okay"; +}; + +/* + * The SIO, running until the sleep's own stop: its ASC bank split around its mailbox. The boot + * loader enables it with its firmware and tables. + */ +/delete-node/ &sio; + +&{/soc@200000000} { + sio_mbox: mailbox@505e08000 { + compatible = "apple,t6050-asc-mailbox", "apple,asc-mailbox-v4"; + reg = <0x5 0x5e08000 0x0 0x4000>; + interrupts = , + , + , + ; + interrupt-names = "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + power-domains = <&ps_sio_cpu>; + #mbox-cells = <0>; + }; + + sio: dma-controller@505e00000 { + compatible = "apple,t6050-sio", "apple,sio"; + reg = <0x5 0x5e00000 0x0 0x8000>, + <0x5 0x5850000 0x0 0x4000>, + <0x5 0x5e0c000 0x0 0x7c000>; + reg-names = "asc", "auxiliary", "asc-tail"; + #dma-cells = <1>; + dma-channels = <128>; + mboxes = <&sio_mbox>; + iommus = <&sio_dart 0>; + power-domains = <&ps_sio_cpu>; + clocks = <&peripheral_clocks 359>, <&peripheral_clocks 358>; + status = "disabled"; + }; +}; + +&sio_dart { + power-domains = <&ps_sio_cpu>; + status = "okay"; +}; + +/* + * The AP pins a deep sleep neither saves nor restores: none. The K116s ADT's gpio0 has no + * no-restore-gpio-pins (the J714s's has 5 6 7 112 141), and with those skipped the panel stayed + * dark after a deep sleep. Without the property no pin is saved at all. + */ +&sleep { + apple,pinctrl-skip-pins = <>; +}; + +/* + * The display coprocessor's secure mailbox (ADT /arm-io/dcp-exclave-mailbox, + * iop,secure-rtbuddy-proxy, reg 0x4cae7c000). Firmware 27.2 acknowledges no IOP power state + * while nothing answers it, as on T8140. + */ +&{/soc@200000000} { + dcp_secure_mbox: mailbox@4cae7c000 { + compatible = "apple,t6050-secure-rtbuddy-proxy", "apple,secure-rtbuddy-proxy"; + reg = <0x4 0xcae7c000 0x0 0x4000>; + #mbox-cells = <0>; + }; +}; + +/* + * Not in mboxes: the boot loader hands the display over only to a node whose mboxes is the one + * ASC mailbox. The driver adds it to the live tree at probe. + */ +&dcp { + apple,secure-mbox = <&dcp_secure_mbox>; +}; + +/* + * dcpext0 without its Type-C route, as dcpext1 to 3 are here. Its PHY's DP side + * is not described on this board, and the engine's probe waits for it and gives the engine + * up; a deep sleep needs the engine bound, to stop its firmware. + */ +&dcpext0 { + /delete-property/ apple,connector-type; + /delete-property/ apple,dptx-die; + /delete-property/ apple,typec-dptx-phys; + /delete-property/ apple,typec-mux-indices; + /delete-property/ phys; + /delete-property/ phy-names; + /delete-property/ mux-controls; + /delete-property/ mux-control-names; + /delete-node/ typec-routes; +}; diff --git a/arch/arm64/boot/dts/apple/t6050-k116s.dts b/arch/arm64/boot/dts/apple/t6050-k116s.dts index 39b804ef48736..ce2dbbf489ea3 100644 --- a/arch/arm64/boot/dts/apple/t6050-k116s.dts +++ b/arch/arm64/boot/dts/apple/t6050-k116s.dts @@ -1004,3 +1004,52 @@ &ps_venc0_me1 { status = "okay"; }; + +/* + * Deep sleep: the sleep controller's description and the J714s's SoC values, then what differs + * on this board (firmware 27.2). + */ +#include "t6050-k116s-sleep.dtsi" +/* No USB4 router is described on this board: without the J714s's CIO sleep part. */ +#define T6050_SLEEP_SOC_NO_CIO +#include "t6050-j714s-sleep-soc.dtsi" + +/* + * macOS on this board parks the four clock words with 0x80100000 in the last 0.5 ms before its + * commit (traced as an aura guest); the J714s's values have bit 10 set. + */ +&sleep { + apple,seq-commit-sio = + <0x0 17 0x290 0x400024f>, + <0x0 17 0x2a0 0x400024f>, + <0x1 51 0xa0 0x0>, + <0x0 51 0xa0 0x80100000>, + <0x1 51 0xa0 0x0>, + <0x1 51 0xa4 0x0>, + <0x0 51 0xa4 0x80100000>, + <0x1 51 0xa4 0x0>, + <0x1 51 0x94 0x0>, + <0x0 51 0x94 0x80100000>, + <0x1 51 0x94 0x0>, + <0x1 51 0x90 0x0>, + <0x0 51 0x90 0x80100000>, + <0x1 51 0x90 0x0>; +}; + +/* + * The PMP firmware's __DATA starts at 0x56000 on 27.2 (ADT pmp0 segment-ranges: __TEXT 0x56000 + * bytes, __DATA 0x9b000 bytes), not at the J714s's 0x58000. With the wrong range kept over the + * sleep the PMP does not come back (endpoint discovery -62). + */ +&pmp0 { + apple,sram-keep = <0x56000 0x9b000>; +}; + +/* + * The panel's plug takes about 2.9 ms here from the video interface's announcement to the + * firmware's "ioav i/f is now closed", and the next round of reports follows about 33 ms later. + * With the J714s's 2500 us the open landed 25 us before the close. + */ +&dcp { + apple,panel-video-open-delay-us = <10000>; +}; From b242dd2c9d7213d6e92baa6f875d8a32b3e1df79 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 09:54:29 -0700 Subject: [PATCH 33/35] dt-bindings: display: apple,dcp: add apple,merged-mode-limit The platform's limit on merged modes belongs to the external display coprocessors of a machine, not to its sleep. Give it a property of their nodes. Signed-off-by: Jens Axboe --- Documentation/devicetree/bindings/display/apple,dcp.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/display/apple,dcp.yaml b/Documentation/devicetree/bindings/display/apple,dcp.yaml index 535eac3f1ff7f..4ee47fdea867c 100644 --- a/Documentation/devicetree/bindings/display/apple,dcp.yaml +++ b/Documentation/devicetree/bindings/display/apple,dcp.yaml @@ -102,6 +102,13 @@ properties: The driver takes it as the "secure" mailbox. Elsewhere the port is the second entry of mboxes. + apple,merged-mode-limit: + type: boolean + description: + The platform's limit on merged modes applies to this external display + coprocessor. A display takes a second coprocessor as its pair only + while one is left for every external display that is present. + iommus: maxItems: 1 From caaf017accf757f5239377e26c97448e6808624a Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 09:54:29 -0700 Subject: [PATCH 34/35] arm64: dts: apple: t6050-j714s: the merged-mode limit of the external display coprocessors The driver applies the limit on the J714s. Say so on its four external display coprocessors, for the driver to read. Signed-off-by: Jens Axboe --- arch/arm64/boot/dts/apple/t6050-j714s.dts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t6050-j714s.dts b/arch/arm64/boot/dts/apple/t6050-j714s.dts index b36ebf840260e..0b83928178a4b 100644 --- a/arch/arm64/boot/dts/apple/t6050-j714s.dts +++ b/arch/arm64/boot/dts/apple/t6050-j714s.dts @@ -792,6 +792,23 @@ #include "t6050-j714s-sleep-soc.dtsi" #include "t6050-j714s-sleep-adt.dtsi" +/* A merged mode's pair is given only while every external display has an engine */ +&dcpext0 { + apple,merged-mode-limit; +}; + +&dcpext1 { + apple,merged-mode-limit; +}; + +&dcpext2 { + apple,merged-mode-limit; +}; + +&dcpext3 { + apple,merged-mode-limit; +}; + /* The display coprocessors take the sleep through their firmware 27 method table */ &sleep { apple,display-method-sleep; From ecf92666148508b92937164a18823f3556fea410 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 Nov 2026 09:54:29 -0700 Subject: [PATCH 35/35] drm/apple: v27: the merged-mode limit by the coprocessor's own property dcp_peer_limit_applies() rode on dcp_j714s_ext(), which follows the sleep's description now. The limit is of the display engines, not of the sleep: read apple,merged-mode-limit from the coprocessor's node. The J714s sets it, so nothing changes there, and no other board takes the limit. Signed-off-by: Jens Axboe --- drivers/gpu/drm/apple/dcp-peer-v27.inc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/apple/dcp-peer-v27.inc b/drivers/gpu/drm/apple/dcp-peer-v27.inc index a824ab7e99265..34ee3e472d3ef 100644 --- a/drivers/gpu/drm/apple/dcp-peer-v27.inc +++ b/drivers/gpu/drm/apple/dcp-peer-v27.inc @@ -8,12 +8,14 @@ module_param(peer_allocation_probe, bool, 0444); MODULE_PARM_DESC(peer_allocation_probe, "Firmware27 logical peer allocation for merged modes (default: on)"); /* - * The platform limit on merged modes (dcp_fabric_merged_fits()) holds on the - * board it has run on, for the J714s's T6050 external display processors. + * The platform limit on merged modes (dcp_fabric_merged_fits()) holds for the + * external display processors whose node says so (apple,merged-mode-limit). */ static bool dcp_peer_limit_applies(struct apple_dcp *dcp) { - return dcp->fw_compat == DCP_FIRMWARE_V_27_0 && dcp_j714s_ext(dcp->dev); + return dcp->fw_compat == DCP_FIRMWARE_V_27_0 && + of_device_is_compatible(dcp->dev->of_node, "apple,t6050-dcpext") && + of_property_read_bool(dcp->dev->of_node, "apple,merged-mode-limit"); } /* @@ -68,8 +70,7 @@ void dcp_peer_limit_update_v27(struct drm_device *drm) unsigned int n = 0, i; struct drm_crtc *crtc; - /* Neither a board without the limit nor a device without CRTCs. */ - if (!of_machine_is_compatible("apple,j714s") || !drm->mode_config.num_crtc) + if (!drm->mode_config.num_crtc) return; scoped_guard(mutex, &dcp_peer_lock) { drm_for_each_crtc(crtc, drm) {