Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions drivers/pmdomain/apple/pmgr-pwrstate-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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. */
Expand Down
13 changes: 11 additions & 2 deletions drivers/pmdomain/apple/pmgr-pwrstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading