From 93a8fdc31160b077f5b516648d87489b8ea312d8 Mon Sep 17 00:00:00 2001 From: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Date: Sat, 7 Nov 2026 22:16:25 +1100 Subject: [PATCH] pmdomain: apple: wait for the T604x ANE_SYS parent on power-on On the J616s (T6040) ANE_SYS sometimes comes back from s2idle with the register at 0x0b4f: target 0xf, actual 0x4 (clock-gated) and bit 11 set, so its upstream (the SoC fabric) is not available yet. That is the condition T6000 GFX already shows on noirq resume, but T6000 GFX is the only domain that gets the separate bounded parent wait. ANE_SYS gets the plain 100 us budget, fails with PS ane_sys: Failed to reach power state 0xf (requested 0xf, now: 0xb4f) and genpd ignores the error on that path, so the ANE firmware is booted on a sys domain that is still clock-gated. In a J616s run of 80 s2idle wakes this line came right before 3 of the 10 H16 firmware startup stalls that the ANE driver then had to restart. Give ANE_SYS the same treatment as T6000 GFX: wait up to 10 ms for bit 11 to clear, then the usual 100 us for the actual state. A parent that never comes back still fails and logs. Match ANE_SYS by its label as well as its offset: 0x3c0 is also atc1_cio in another T604x PMGR block. The existing KUnit cases cover the wait itself. Signed-off-by: Ryan Murray <81541646+RyanTheTide@users.noreply.github.com> Assisted-by: LLM --- drivers/pmdomain/apple/pmgr-pwrstate.c | 29 +++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/drivers/pmdomain/apple/pmgr-pwrstate.c b/drivers/pmdomain/apple/pmgr-pwrstate.c index 59ebf701f8db0..6ee0948adee99 100644 --- a/drivers/pmdomain/apple/pmgr-pwrstate.c +++ b/drivers/pmdomain/apple/pmgr-pwrstate.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -75,7 +76,7 @@ static int apple_pmgr_ps_wait_parent(struct apple_pmgr_ps *ps, u32 *cur) { int ret, err; - /* Bit 11 reports a missing upstream power/clock on T6000 GFX. */ + /* Bit 11 reports a missing upstream power/clock (T6000 GFX, T604x ANE_SYS). */ ret = read_poll_timeout_atomic(regmap_read, err, err || !(*cur & APPLE_PMGR_BUSY), 1, APPLE_PMGR_PS_PARENT_TIMEOUT, false, @@ -83,6 +84,24 @@ static int apple_pmgr_ps_wait_parent(struct apple_pmgr_ps *ps, u32 *cur) return err ?: ret; } +/* + * Domains whose power-on can report a missing upstream power/clock (bit 11, + * actual still clock-gated) for longer than the 100 us state budget: + * - T6000 GFX: its AFR parent on noirq resume. + * - T604x ANE_SYS: the SoC fabric on resume from s2idle (0x0b4f, seen ahead + * of H16 firmware startup stalls). 0x3c0 is not unique across the T604x + * PMGR blocks, so this domain is matched by its label as well. + */ +static bool apple_pmgr_ps_has_parent_wait(struct device_node *node, u32 offset, + const char *name) +{ + if (of_device_is_compatible(node, "apple,t6000-pmgr-pwrstate")) + return offset == 0x3c0; + if (of_device_is_compatible(node, "apple,t6041-pmgr-pwrstate")) + return offset == 0x3c0 && !strcmp(name, "ane_sys"); + return false; +} + static int apple_pmgr_ps_set(struct generic_pm_domain *genpd, u32 pstate, bool auto_enable) { int ret; @@ -137,8 +156,9 @@ static int apple_pmgr_ps_set(struct generic_pm_domain *genpd, u32 pstate, bool a if (ps->wait_parent && pstate == APPLE_PMGR_PS_ACTIVE) { /* - * GFX can remain clock-gated with bit 11 set on noirq resume, - * even after genpd has powered its AFR parent on. Wait for that + * GFX and ANE_SYS can remain clock-gated with bit 11 set on + * noirq resume, even after genpd has made its parent votes + * (AFR, the SoC fabric). Wait for that * hardware dependency separately, then allow the usual 100 us * for the actual state. A missing parent must still fail. * Use delay-based polling so the wait is bounded even while @@ -573,8 +593,7 @@ static int apple_pmgr_ps_probe(struct platform_device *pdev) return ret; } - ps->wait_parent = of_device_is_compatible(node, "apple,t6000-pmgr-pwrstate") && - ps->offset == 0x3c0; + ps->wait_parent = apple_pmgr_ps_has_parent_wait(node, ps->offset, name); ps->genpd.flags |= GENPD_FLAG_IRQ_SAFE; ps->genpd.name = name;