Skip to content

Commit ae497dd

Browse files
committed
soc: apple: sleep: OR a core's start bits into the cpu-start words
After every J815 wake only the first core started in each complex came back (CPU1 = E0, CPU7 = P1); CPU2-6 and CPU8-9 timed out ("failed to come online ... unknown state 0x0"), 5 s each, 7 x 5 s added to every resume. sleep_cpu_on() wrote the SYS and cluster words plainly, so each start cleared the bits of every core already released, the boot core's SYS bit included. aura's T8142 start (smp.c) sets both bits read-modify-write, after macOS's setCoreOnline/wakeCore ("preserve other released cores"); the start now does the same. apple_sleep.cpu_start_or=0 restores the plain write for an A/B. The per-core trace (cpu_on_trace) was gated on cpu_clusters, which no SoC table sets; it now also runs where the SoC states its start stride (T8142). Not yet tested on hardware. Assisted-by: Claude Opus 5.5 Signed-off-by: Nick <[email protected]>
1 parent a3d3862 commit ae497dd

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

‎drivers/soc/apple/sleep.c‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,11 +2099,23 @@ static void sleep_cpu_start_words(struct apple_sleep *s, u32 *w)
20992099
w[3] = readl(s->cpu_start + CPU_START_CLUSTER(1));
21002100
}
21012101

2102+
/*
2103+
* apple_sleep.cpu_start_or: a core start ORs its bits into the SYS and cluster words, as aura's
2104+
* start (smp.c) and macOS's setCoreOnline/wakeCore do, so the cores already released keep
2105+
* theirs. A plain write clears them: after a J815 wake only the first core started in each
2106+
* complex came up (CPU1, CPU7), every later one timed out. N = the old plain write.
2107+
*/
2108+
static bool sleep_cpu_start_or = true;
2109+
module_param_named(cpu_start_or, sleep_cpu_start_or, bool, 0644);
2110+
MODULE_PARM_DESC(cpu_start_or, "Core start ORs into the cpu-start words, keeping running cores' bits (default Y)");
2111+
21022112
static int sleep_cpu_on(u64 mpidr)
21032113
{
21042114
struct apple_sleep *s = apple_sleep;
21052115
unsigned int cluster = sleep_cpu_cluster(s, mpidr), core = sleep_cpu_core(mpidr);
2106-
bool trace = READ_ONCE(sleep_cpu_on_trace) && s->soc->cpu_clusters >= 2;
2116+
/* Any SoC with a two-cluster start layout (T8142 states the stride, not cpu_clusters) */
2117+
bool trace = READ_ONCE(sleep_cpu_on_trace) &&
2118+
(s->soc->cpu_clusters >= 2 || s->soc->cpu_start_stride);
21072119
int cpu = get_logical_index(mpidr & MPIDR_HWID_BITMASK);
21082120
void __iomem *slot = trace ? sleep_cpu_slot_map(cpu) : NULL;
21092121
u32 before[4], after[4], ps = 0, gate = 0, edprsr = ~0U;
@@ -2116,8 +2128,16 @@ static int sleep_cpu_on(u64 mpidr)
21162128
flag0 = sleep_cpu_slot_read(slot, 8);
21172129
}
21182130

2119-
writel(sleep_cpu_start_bit(s, mpidr), s->cpu_start + CPU_START_SYS);
2120-
writel(BIT(core), s->cpu_start + CPU_START_CLUSTER(cluster));
2131+
if (READ_ONCE(sleep_cpu_start_or)) {
2132+
writel(readl(s->cpu_start + CPU_START_SYS) | sleep_cpu_start_bit(s, mpidr),
2133+
s->cpu_start + CPU_START_SYS);
2134+
writel(readl(s->cpu_start + CPU_START_CLUSTER(cluster)) | BIT(core),
2135+
s->cpu_start + CPU_START_CLUSTER(cluster));
2136+
} else {
2137+
writel(sleep_cpu_start_bit(s, mpidr), s->cpu_start + CPU_START_SYS);
2138+
writel(BIT(core), s->cpu_start + CPU_START_CLUSTER(cluster));
2139+
}
2140+
dsb(sy);
21212141

21222142
if (!trace)
21232143
return 0;

0 commit comments

Comments
 (0)