From nobody Mon Jun 15 01:45:00 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCE86248F64 for ; Tue, 7 Apr 2026 12:06:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775563613; cv=none; b=RcNCJ/v31W7ic1+fP8qwFOUw1oCDuim1aDeW1s13esUuP6ZZ2+hgC35VnLBAgQo82pAtynWZH+q5+hjE0J5GFJqUnlAlnUYlu90s44T3DIzLVyXlxz+nAoUDQAvFUH08+VZskIiltusiuRlza/0Oj/CyrDwFrH7W2kKbgQsdlKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775563613; c=relaxed/simple; bh=m7lOt4JyKc+pf5kjlqLmstZ4kkvcESI2DKvVm4+UiYQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pr3qNR1bkEu8ysUgWYMpRJ2kJM7HDREyoNAzgLuAbR5FzJJWENokvL10dJjF8X83Cv3qW5qOpimwtZW7sVeYrZFDq/Wu0YXCL/SYqjtzNyW9Yr9rgINb1wDukUKI7spM7/e5xYyvjO1qPDnLQbzFsLB2c56nPetsaObnpxrzTxM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=JhpQpVsP; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=UCdwypNz; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="JhpQpVsP"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="UCdwypNz" From: Nam Cao DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1775563610; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1WxAkflQW4vh1CMmuU2NUC+nDRJPsXiltCCx8JFiEv0=; b=JhpQpVsPJY/J9sqDNhr1+thtc1C1kbv6il82BIGmx+3gu0qUGkmvT2b5ziCEjlDjVTzXx1 U0aXtdvJcVre4xycnlFUMz859Q8F6GsLacYjBFYRfocia7du7M+cFbNfAEBKZ9OwIMLJDx +aC2DxBgSZ9iegJ/Dv/uQlNL5gYZecoBIEligsx3VzKdTdZJl8qxXzsPGzBLgeiJbY9aqN J8opgfpLqDgBtaA9Ii4e67gctCcCmclc4TE87RIIRLvIu14+W3RR6QKAbg01C5DONzHPEE RRwDf0IB5PH0WujCt+tjvOiWqOrZN7HsqXzuxaVy9gBLeWFE6lL4CzK1MiQs6A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1775563610; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1WxAkflQW4vh1CMmuU2NUC+nDRJPsXiltCCx8JFiEv0=; b=UCdwypNzX7nOGP/gPUaP3t7JuDndj8WuReA3Or8tk6C2ya10QIVjGpqHLMXoePukRLgZoy 0Jokv89Yuw9RHcBQ== To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Nam Cao , Michael Neuling Subject: [PATCH] riscv: Fix fast_unaligned_access_speed_key not getting initialized Date: Tue, 7 Apr 2026 14:06:39 +0200 Message-ID: <20260407120639.4006031-1-namcao@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The static key fast_unaligned_access_speed_key is supposed to be initialized after check_unaligned_access_all_cpus() has been completed. However, check_unaligned_access_all_cpus() has been moved to late_initcall while setting fast_unaligned_access_speed_key still happens at arch_initcall_sync, thus the static key does not get properly initialized. fast_unaligned_access_speed_key can still be initialized in CPU hotplug events, but that cannot be relied on. Move fast_unaligned_access_speed_key's initialization into check_unaligned_access_all_cpus() to fix this issue. This also prevent someone from moving one initcall while forgetting the other in the future. Fixes: 6455c6c11827 ("riscv: Clean up & optimize unaligned scalar access pr= obe") Reported-by: Michael Neuling Closes: https://lore.kernel.org/linux-riscv/CAEjGV6y0=3DbSLp_wrS0uHFj1S2TCR= tz4GKzaU5O-L1VV-EL7Nnw@mail.gmail.com/ Signed-off-by: Nam Cao --- arch/riscv/kernel/unaligned_access_speed.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/arch/riscv/kernel/unaligned_access_speed.c b/arch/riscv/kernel= /unaligned_access_speed.c index 485ab1d105d3..11c781a4de73 100644 --- a/arch/riscv/kernel/unaligned_access_speed.c +++ b/arch/riscv/kernel/unaligned_access_speed.c @@ -235,17 +235,6 @@ static void set_unaligned_access_static_branches(void) modify_unaligned_access_branches(&fast_and_online, num_online_cpus()); } =20 -static int __init lock_and_set_unaligned_access_static_branch(void) -{ - cpus_read_lock(); - set_unaligned_access_static_branches(); - cpus_read_unlock(); - - return 0; -} - -arch_initcall_sync(lock_and_set_unaligned_access_static_branch); - static int riscv_online_cpu(unsigned int cpu) { int ret =3D cpu_online_unaligned_access_init(cpu); @@ -440,6 +429,10 @@ static int __init check_unaligned_access_all_cpus(void) cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "riscv:online", riscv_online_cpu_vec, NULL); =20 + cpus_read_lock(); + set_unaligned_access_static_branches(); + cpus_read_unlock(); + return 0; } =20 --=20 2.47.3