From 2df85e70d49c3e48f1a1fbf599c4214fbe1620c6 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 13 Nov 2026 16:14:23 +0700 Subject: [PATCH 1/2] soc: apple: rtkit: Echo OSLOG counters on T8142 J815's first deep-sleep attempts (kernel pm_test "platform", then a real one) failed at .prepare: the MTP took no AP idle notice ("AP power notice (idle) not answered: -62"). The "devices" step just before had its notice answered, and the MTP logged after that step's resume. As on T8140 (d9b438c4ca41), an RTKit firmware holds its next OSLOG counter until the last is echoed and takes no AP power notice while one is outstanding. T8142 still dropped them (the no-ACK policy kept for Neo/M5 before T8140's sleep work). Echo them on T8142 too, as macOS does. With this, the J815 pm_test steps devices, platform, processors and core all pass, with the MTP answering every notice. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick --- drivers/soc/apple/rtkit.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c index a0f5e46a6087d..ac30118e9791c 100644 --- a/drivers/soc/apple/rtkit.c +++ b/drivers/soc/apple/rtkit.c @@ -1832,8 +1832,14 @@ static struct apple_rtkit *__apple_rtkit_init(struct device *dev, void *cookie, rtk->handshake_timeout_ms = APPLE_RTKIT_HANDSHAKE_TIMEOUT_MS; rtk->sync_syslog_ack = of_property_read_bool(dev->of_node, "apple,sync-syslog-ack"); - /* As macOS does; a driver whose firmware shouldn't get them turns it off. */ - rtk->oslog_echo = of_machine_is_compatible("apple,t8140"); + /* + * As macOS does; a driver whose firmware shouldn't get them turns it off. T8142 too: + * its MTP left a counter unechoed after the first sleep's resume, then took no AP + * idle notice for the next one (J815, -ETIME at prepare) and asserted on the one + * after ("Invalid AP power"). + */ + rtk->oslog_echo = of_machine_is_compatible("apple,t8140") || + of_machine_is_compatible("apple,t8142"); INIT_KFIFO(rtk->sync_ack_fifo); INIT_WORK(&rtk->sync_ack_work, apple_rtkit_sync_ack_work); From 983f9c65513de775fe1ce7d8f66768ee020493d7 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 13 Nov 2026 16:14:23 +0700 Subject: [PATCH 2/2] soc: apple: rtkit-helper: Never stack an unanswered AP idle notice When an AP idle notice was never answered, the next sleep sent a second one, and T8142's MTP firmware asserted on it ("Invalid AP power: 8"), taking the keyboard and trackpad with it until a reboot. Keep an idle notice that still had no answer when its sleep ended as pending. The next sleep looks again: if the answer came since, it sends the skipped AP on first; if not, it refuses the sleep (-EBUSY) instead of sending a second notice. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick --- drivers/soc/apple/rtkit-helper.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/soc/apple/rtkit-helper.c b/drivers/soc/apple/rtkit-helper.c index 7c4521ef6783b..8c518ef4349e9 100644 --- a/drivers/soc/apple/rtkit-helper.c +++ b/drivers/soc/apple/rtkit-helper.c @@ -44,6 +44,8 @@ struct apple_rtkit_helper { bool ap_idle; /* It was told, gave no answer, and wasn't told otherwise. */ bool idle_unanswered; + /* An idle notice that still had no answer when its sleep ended. */ + bool idle_pending; /* Ends a sleep whose .prepare failed, which gets no .complete. */ struct notifier_block pm_nb; @@ -414,6 +416,25 @@ static int apple_rtkit_helper_ap_idle(struct apple_rtkit_helper *helper) if (helper->ap_idle) return 0; + /* + * A firmware that never answered the last idle notice still holds it: T8142's MTP + * asserts on a second ("Invalid AP power") and takes the keyboard and trackpad with + * it. Refuse this sleep instead, unless the answer has come since; then the AP on + * the last sleep's end skipped goes first. + */ + if (helper->idle_pending) { + if (apple_rtkit_is_running(helper->rtk)) { + dev_err(helper->dev, "the last AP idle notice is still unanswered: no sleep\n"); + return -EBUSY; + } + helper->idle_pending = false; + dev_info(helper->dev, "the last AP idle notice was answered late, sending AP on first\n"); + if (apple_rtkit_ap_power(helper->rtk, true)) { + dev_err(helper->dev, "AP on after the late answer not answered: no sleep\n"); + helper->idle_pending = true; + return -EBUSY; + } + } ret = apple_rtkit_helper_ap_power(helper, false); if (ret) return ret; @@ -452,6 +473,8 @@ static void apple_rtkit_helper_sleep_end(struct apple_rtkit_helper *helper) late ? "its answer came late, sending AP on" : "still no answer, nothing sent"); helper->ap_idle = late; + /* Its answer may still come: the next sleep looks again before sending another. */ + helper->idle_pending = !late; } apple_rtkit_helper_ap_on(helper); }