diff --git a/drivers/pmdomain/apple/pmgr-pwrstate-test.c b/drivers/pmdomain/apple/pmgr-pwrstate-test.c index b3a8cd1f5715c..67698ccfc74aa 100644 --- a/drivers/pmdomain/apple/pmgr-pwrstate-test.c +++ b/drivers/pmdomain/apple/pmgr-pwrstate-test.c @@ -296,7 +296,11 @@ static void pmgr_ps_power_on_latch_cleared_test(struct kunit *test) KUNIT_EXPECT_EQ(test, r->auto_writes, 1U); } -/* The same in the noirq phase of a system sleep, where genpd ignores errors. */ +/* + * Not in the noirq phase of a system sleep (no PS reset there: it hangs the + * T8140). The power-on fails, which genpd ignores in that phase, and the + * domain stays requested on. + */ static void pmgr_ps_power_on_latch_sleep_test(struct kunit *test) { struct pmgr_ps_test_reg *r; @@ -305,9 +309,18 @@ static void pmgr_ps_power_on_latch_sleep_test(struct kunit *test) ps = pmgr_ps_test_domain(test, APPLE_PMGR_PS_PWRGATE, true, &r); ps->system_sleep = true; r->latched = true; + KUNIT_EXPECT_EQ(test, apple_pmgr_ps_power_on(&ps->genpd), -ETIMEDOUT); + KUNIT_EXPECT_EQ(test, r->reset_writes, 0U); + KUNIT_EXPECT_FALSE(test, r->val & APPLE_PMGR_PS_RESET); + KUNIT_EXPECT_EQ(test, FIELD_GET(APPLE_PMGR_PS_TARGET, r->val), APPLE_PMGR_PS_ACTIVE); + KUNIT_EXPECT_EQ(test, FIELD_GET(APPLE_PMGR_PS_ACTUAL, r->val), APPLE_PMGR_PS_CLKGATE); + KUNIT_EXPECT_EQ(test, r->auto_writes, 0U); + + /* The same domain after the sleep: the recovery runs again. */ + ps->system_sleep = false; KUNIT_EXPECT_EQ(test, apple_pmgr_ps_power_on(&ps->genpd), 0); + KUNIT_EXPECT_EQ(test, r->reset_writes, 1U); KUNIT_EXPECT_EQ(test, FIELD_GET(APPLE_PMGR_PS_ACTUAL, r->val), APPLE_PMGR_PS_ACTIVE); - KUNIT_EXPECT_EQ(test, r->auto_writes, 0U); } /* A latch the reset does not clear still fails, and the domain is requested off. */ diff --git a/drivers/pmdomain/apple/pmgr-pwrstate.c b/drivers/pmdomain/apple/pmgr-pwrstate.c index 0c825a64b42bd..688842390a6a2 100644 --- a/drivers/pmdomain/apple/pmgr-pwrstate.c +++ b/drivers/pmdomain/apple/pmgr-pwrstate.c @@ -94,14 +94,23 @@ static int apple_pmgr_ps_wait_parent(struct apple_pmgr_ps *ps, u32 *cur) * their state there anyway), then request @reg, the on state, again. * Domains whose bit 11 means a parent that is not up yet (wait_parent) and * those with their own state contract are left alone. + * + * Never during a system sleep transition: there the power-on comes from the + * genpd noirq resume, with the DARTs and the engine of the domain still in + * their noirq phase. On the T8140 a recovery at that point hangs the machine: + * in a suspend loop on the J700, kernels with it hung on 3 of 3 boots and came + * back only through the watchdog, while kernels without it hung on none of 6, + * two of which latched ANE_SYS and carried on with the ANE quarantined. The + * power-on then fails as it did before, and genpd, which ignores errors in + * that phase, keeps the domain requested on. */ static int apple_pmgr_ps_clear_latch(struct apple_pmgr_ps *ps, u32 reg, u32 *cur) { u32 off = (reg & ~APPLE_PMGR_PS_TARGET) | APPLE_PMGR_PS_PWRGATE; int ret; - if (ps->wait_parent || ps->strict_state || ps->externally_clocked || - !(*cur & APPLE_PMGR_BUSY) || + if (ps->system_sleep || ps->wait_parent || ps->strict_state || + ps->externally_clocked || !(*cur & APPLE_PMGR_BUSY) || FIELD_GET(APPLE_PMGR_PS_ACTUAL, *cur) == APPLE_PMGR_PS_ACTIVE) return -ETIMEDOUT;