Skip to content

Commit 4410160

Browse files
jones-drewAlexandre Ghiti
authored andcommitted
riscv: Fix unaligned access info messages
Ensure we only print messages about command line parameters when the parameters are actually in use. Also complain about the use of the vector parameter when vector support isn't available. Fixes: aecb09e ("riscv: Add parameter for skipping access speed tests") Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> Closes: https://lore.kernel.org/all/CAMuHMdVEp2_ho51gkpLLJG2HimqZ1gZ0fa=JA4uNNZjFFqaPMg@mail.gmail.com/ Closes: https://lore.kernel.org/all/CAMuHMdWVMP0MYCLFq+b7H_uz-2omdFiDDUZq0t_gw0L9rrJtkQ@mail.gmail.com/ Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Link: https://lore.kernel.org/r/20250409153650.84433-2-ajones@ventanamicro.com Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
1 parent 70fc03c commit 4410160

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

arch/riscv/kernel/unaligned_access_speed.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -439,29 +439,36 @@ static int __init check_unaligned_access_all_cpus(void)
439439
{
440440
int cpu;
441441

442-
if (unaligned_scalar_speed_param == RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN &&
443-
!check_unaligned_access_emulated_all_cpus()) {
444-
check_unaligned_access_speed_all_cpus();
445-
} else {
446-
pr_info("scalar unaligned access speed set to '%s' by command line\n",
447-
speed_str[unaligned_scalar_speed_param]);
442+
if (unaligned_scalar_speed_param != RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN) {
443+
pr_info("scalar unaligned access speed set to '%s' (%lu) by command line\n",
444+
speed_str[unaligned_scalar_speed_param], unaligned_scalar_speed_param);
448445
for_each_online_cpu(cpu)
449446
per_cpu(misaligned_access_speed, cpu) = unaligned_scalar_speed_param;
447+
} else if (!check_unaligned_access_emulated_all_cpus()) {
448+
check_unaligned_access_speed_all_cpus();
449+
}
450+
451+
if (unaligned_vector_speed_param != RISCV_HWPROBE_MISALIGNED_VECTOR_UNKNOWN) {
452+
if (!has_vector() &&
453+
unaligned_vector_speed_param != RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED) {
454+
pr_warn("vector support is not available, ignoring unaligned_vector_speed=%s\n",
455+
speed_str[unaligned_vector_speed_param]);
456+
} else {
457+
pr_info("vector unaligned access speed set to '%s' (%lu) by command line\n",
458+
speed_str[unaligned_vector_speed_param], unaligned_vector_speed_param);
459+
}
450460
}
451461

452462
if (!has_vector())
453463
unaligned_vector_speed_param = RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED;
454464

455-
if (unaligned_vector_speed_param == RISCV_HWPROBE_MISALIGNED_VECTOR_UNKNOWN &&
456-
!check_vector_unaligned_access_emulated_all_cpus() &&
457-
IS_ENABLED(CONFIG_RISCV_PROBE_VECTOR_UNALIGNED_ACCESS)) {
458-
kthread_run(vec_check_unaligned_access_speed_all_cpus,
459-
NULL, "vec_check_unaligned_access_speed_all_cpus");
460-
} else {
461-
pr_info("vector unaligned access speed set to '%s' by command line\n",
462-
speed_str[unaligned_vector_speed_param]);
465+
if (unaligned_vector_speed_param != RISCV_HWPROBE_MISALIGNED_VECTOR_UNKNOWN) {
463466
for_each_online_cpu(cpu)
464467
per_cpu(vector_misaligned_access, cpu) = unaligned_vector_speed_param;
468+
} else if (!check_vector_unaligned_access_emulated_all_cpus() &&
469+
IS_ENABLED(CONFIG_RISCV_PROBE_VECTOR_UNALIGNED_ACCESS)) {
470+
kthread_run(vec_check_unaligned_access_speed_all_cpus,
471+
NULL, "vec_check_unaligned_access_speed_all_cpus");
465472
}
466473

467474
/*

0 commit comments

Comments
 (0)