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
27 changes: 26 additions & 1 deletion arch/arm64/kernel/cpufeature.c
Original file line number Diff line number Diff line change
Expand Up @@ -2625,6 +2625,31 @@ test_has_gicv5_legacy(const struct arm64_cpu_capabilities *entry, int scope)
return !!(read_sysreg_s(SYS_ICC_IDR0_EL1) & ICC_IDR0_EL1_GCIE_LEGACY);
}

/*
* Apple T8152 (M6) cores clear architectural state across WFIT, the FP/SIMD
* registers included. __delay() would execute it from any context, including
* the cpufreq transition polling that load-driven governors run on a CPU
* whose current task still has live FP/SIMD state: on J873 (M6) 25-56% of
* SHA-256 runs gave wrong results under schedutil. Treat WFxT as absent
* there, as arm64.nowfxt does, so __delay() uses WFE. T8142 (M5) was not
* measured; it is included because apple_m5_needs_wait_save() groups its
* cores with T8152 for this state loss.
*/
static bool has_wfxt(const struct arm64_cpu_capabilities *entry, int scope)
{
static const struct midr_range apple_wfxt_loses_state[] = {
MIDR_ALL_VERSIONS(MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, 0x062)),
MIDR_ALL_VERSIONS(MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, 0x063)),
MIDR_ALL_VERSIONS(MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, 0x072)),
MIDR_ALL_VERSIONS(MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, 0x073)),
{}
};

if (is_midr_in_range_list(apple_wfxt_loses_state))
return false;
return has_cpuid_feature(entry, scope);
}

static const struct arm64_cpu_capabilities arm64_features[] = {
#ifdef CONFIG_ARM64_USER4K_EXPERIMENTAL
{
Expand Down Expand Up @@ -3129,7 +3154,7 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
.desc = "WFx with timeout",
.capability = ARM64_HAS_WFXT,
.type = ARM64_CPUCAP_SYSTEM_FEATURE,
.matches = has_cpuid_feature,
.matches = has_wfxt,
ARM64_CPUID_FIELDS(ID_AA64ISAR2_EL1, WFxT, IMP)
},
{
Expand Down
12 changes: 12 additions & 0 deletions arch/arm64/kernel/idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,22 @@ static bool apple_wfi_loses_regs __ro_after_init;

void __init apple_wfi_quirk_init(void)
{
u32 model = read_cpuid_id() & MIDR_CPU_MODEL_MASK;

if (midr_is_apple_m4_or_later(read_cpuid_id())) {
apple_wfi_loses_regs = true;
pr_info("Apple: preserving registers across WFI\n");
}
/*
* aura passes idle=nop on M5 for kernels without this quirk. Spinning
* idle keeps all ten cores busy (cpuidle's WFI state spins too), and
* the SoC sits near 90 C and throttles; WFI is safe here.
*/
if (idle == ARM64_IDLE_NOP &&
(model == MIDR_APPLE_T8142_E || model == MIDR_APPLE_T8142_P)) {
idle = ARM64_IDLE_WFI;
pr_info("Apple: T8142 idles in WFI, ignoring idle=nop\n");
}
}

static __always_inline bool apple_wfi_needs_save(void)
Expand Down