From 0c2dfd6e8c6e880bb3c4b8bb9f1147034b849fc0 Mon Sep 17 00:00:00 2001 From: Diljit Singh Date: Thu, 19 Nov 2026 16:16:44 -0500 Subject: [PATCH] drm/asahi: g17: raise the GPU's domain at the commit only on T8142 and T6050 Commit f5b80629ce25 ("drm/asahi: g17: Raise the GPU's domain before stopping it at the commit") made the common commit stop raise the GPU's power domain to full before the RTKit idle poll, for the J815 (T8142). That stop is shared with the T8140 (J700, MacBook Neo), where the raise breaks every firmware-backed deep sleep. At the commit the J700's GPU domain reads 0x1000230f: target on, nothing powered, under automatic power. The raise from there times out (-110) and leaves BUSY latched. The PMP then answers its AP IDLE with a message on its crash log endpoint instead of the echo ("RTKit: AP IDLE not echoed (-110, AP 32): 1 received, last ep 0x1"), its stop fails, the sleep driver finds power word 0x1f0 off with BUSY latched and takes the deep path. After the wake the PMP and the GPU firmware don't come back (ETIME, GPU device lost), the radios are gone and Bluetooth reports a terminal transport fault. Raise only on the SoCs the raise was made for, by the GPU's compatible: apple,agx-t8142 and apple,agx-g17s. Everywhere else the stop goes straight to the idle poll and takes the word to restore after the idle, as before f5b80629ce25. The "GPU domain at the commit stop" line is printed only where the raise ran. Fixes: f5b80629ce25 ("drm/asahi: g17: Raise the GPU's domain before stopping it at the commit") Signed-off-by: Diljit Singh --- drivers/gpu/drm/asahi/g17/sleep.c | 53 ++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/asahi/g17/sleep.c b/drivers/gpu/drm/asahi/g17/sleep.c index 917965e36014..3a29524ca144 100644 --- a/drivers/gpu/drm/asahi/g17/sleep.c +++ b/drivers/gpu/drm/asahi/g17/sleep.c @@ -363,8 +363,25 @@ struct asahi_g17_commit { /* The domain at the start of the stop, and the raise to full power before any ASC access */ u32 entry; int raise_ret; + /* Whether the stop raises the domain first (asahi_g17_commit_raises()) */ + bool raise; }; +/* + * Whether the commit's stop raises the GPU's domain before it touches the coprocessor: on the + * SoCs the raise was made for, the T8142 (J815: the GPU gates itself between frames and its + * registers may not answer below full power) and the T6050. Elsewhere the stop goes straight + * to the idle poll, as before the raise. On the T8140 (J700) the domain reads its target on + * and nothing powered under automatic power at the commit (0x1000230f); a raise from there + * times out with BUSY latched, the PMP's AP IDLE then goes unanswered, the sleep takes the + * deep path and the PMP and GPU firmware don't come back from it. + */ +static bool asahi_g17_commit_raises(struct device *dev) +{ + return of_device_is_compatible(dev->of_node, "apple,agx-t8142") || + of_device_is_compatible(dev->of_node, "apple,agx-g17s"); +} + /* * down() at the commit, every refusal behind it: both instances idled by polling, mailboxes * and run bits off, the gating hold, the PMP request withdrawn while the PMP still runs, then @@ -384,15 +401,18 @@ static int asahi_g17_commit_stop(void *data) * domain read 0x244 (actual 4, J815 boot 12505746): its coprocessor's and mailbox's * registers may not answer there, and with interrupts off a stalled read ends at WD2 (J815 * boot 3c93d5a2: PMU note 0x44, the first commit stop). Bring it to full power first, as - * asahi_g17_power_raise() does, and keep the word from before for the resume. + * asahi_g17_power_raise() does, and keep the word from before for the resume. Only where + * asahi_g17_commit_raises() says so. */ - c->entry = readl(c->ps); - c->saved = c->entry; - if (FIELD_GET(PS_ACTUAL, c->entry) != PS_ACTIVE) { - writel(asahi_g17_ps_on(c->dev, c->entry, c->entry), c->ps); - c->raise_ret = readl_poll_timeout_atomic(c->ps, val, - FIELD_GET(PS_ACTUAL, val) == PS_ACTIVE, - 10, PS_TIMEOUT_US); + if (c->raise) { + c->entry = readl(c->ps); + c->saved = c->entry; + if (FIELD_GET(PS_ACTUAL, c->entry) != PS_ACTIVE) { + writel(asahi_g17_ps_on(c->dev, c->entry, c->entry), c->ps); + c->raise_ret = readl_poll_timeout_atomic(c->ps, val, + FIELD_GET(PS_ACTUAL, val) == + PS_ACTIVE, 10, PS_TIMEOUT_US); + } } apple_sleep_note_sub(2); if (c->raise_ret) { @@ -417,8 +437,14 @@ static int asahi_g17_commit_stop(void *data) c->request_ret = c->request ? apple_pmp_report_entry_withdraw_polled(c->request) : 0; apple_sleep_note_sub(5); - /* Off automatic management, still at full power, for the bridge. */ - writel(readl(c->ps) & ~(PS_AUTO_ENABLE | PS_BUSY | PS_FLAGS), c->ps); + /* + * Off automatic management, for the bridge (still at full power after a raise). Without + * the raise, the word for the resume is the one found here, after the idle. + */ + val = readl(c->ps); + if (!c->raise) + c->saved = val; + writel(val & ~(PS_AUTO_ENABLE | PS_BUSY | PS_FLAGS), c->ps); if (c->bridge) { for (i = 0; i < SGX_BRIDGE_WORDS; i++) c->words[i] = readl(c->bridge + 4 * i); @@ -574,6 +600,7 @@ struct asahi_g17_commit *asahi_g17_commit_prepare(struct device *dev, c->rtk[1] = secondary_rtk; c->mbox[1] = secondary_mbox; c->count = secondary_rtk ? 2 : 1; + c->raise = asahi_g17_commit_raises(dev); ret = -EOPNOTSUPP; for (i = 0; i < c->count; i++) { @@ -663,6 +690,7 @@ struct asahi_g17_commit *asahi_g16_commit_prepare(struct device *dev, struct app c->dev = dev; c->rtk[0] = rtk; c->count = 1; + c->raise = asahi_g17_commit_raises(dev); ret = -ENODEV; c->cpu[0] = asahi_g17_map(dev->of_node, "asc", 0, ASC_CPU_CONTROL, 8); @@ -704,8 +732,9 @@ bool asahi_g17_commit_finish(struct asahi_g17_commit *c, u32 *saved) c->idle_us[0], c->idle_us[1], c->status[0], c->status[1]); dev_dbg(c->dev, "GPU at the commit: bridge %#x %#x gating %#x, domain %#x now %#x\n", c->words[0], c->words[1], c->words[2], c->saved, c->lowered); - dev_info(c->dev, "GPU domain at the commit stop: %#x, raise to full %d\n", - c->entry, c->raise_ret); + if (c->raise) + dev_info(c->dev, "GPU domain at the commit stop: %#x, raise to full %d\n", + c->entry, c->raise_ret); *saved = c->saved; } asahi_g17_commit_free(c);