]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
riscv: Fix unaligned access info messages
authorAndrew Jones <ajones@ventanamicro.com>
Wed, 9 Apr 2025 15:36:51 +0000 (17:36 +0200)
committerAlexandre Ghiti <alexghiti@rivosinc.com>
Mon, 14 Apr 2025 13:07:07 +0000 (13:07 +0000)
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: aecb09e091dc ("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>
arch/riscv/kernel/unaligned_access_speed.c

index 585d2dcf2dab1ccb4e8d756437d683868ce408e2..b8ba13819d05e526ee993e289a90a53efe21b5a1 100644 (file)
@@ -439,29 +439,36 @@ static int __init check_unaligned_access_all_cpus(void)
 {
        int cpu;
 
-       if (unaligned_scalar_speed_param == RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN &&
-           !check_unaligned_access_emulated_all_cpus()) {
-               check_unaligned_access_speed_all_cpus();
-       } else {
-               pr_info("scalar unaligned access speed set to '%s' by command line\n",
-                       speed_str[unaligned_scalar_speed_param]);
+       if (unaligned_scalar_speed_param != RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN) {
+               pr_info("scalar unaligned access speed set to '%s' (%lu) by command line\n",
+                       speed_str[unaligned_scalar_speed_param], unaligned_scalar_speed_param);
                for_each_online_cpu(cpu)
                        per_cpu(misaligned_access_speed, cpu) = unaligned_scalar_speed_param;
+       } else if (!check_unaligned_access_emulated_all_cpus()) {
+               check_unaligned_access_speed_all_cpus();
+       }
+
+       if (unaligned_vector_speed_param != RISCV_HWPROBE_MISALIGNED_VECTOR_UNKNOWN) {
+               if (!has_vector() &&
+                   unaligned_vector_speed_param != RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED) {
+                       pr_warn("vector support is not available, ignoring unaligned_vector_speed=%s\n",
+                               speed_str[unaligned_vector_speed_param]);
+               } else {
+                       pr_info("vector unaligned access speed set to '%s' (%lu) by command line\n",
+                               speed_str[unaligned_vector_speed_param], unaligned_vector_speed_param);
+               }
        }
 
        if (!has_vector())
                unaligned_vector_speed_param = RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED;
 
-       if (unaligned_vector_speed_param == RISCV_HWPROBE_MISALIGNED_VECTOR_UNKNOWN &&
-           !check_vector_unaligned_access_emulated_all_cpus() &&
-           IS_ENABLED(CONFIG_RISCV_PROBE_VECTOR_UNALIGNED_ACCESS)) {
-               kthread_run(vec_check_unaligned_access_speed_all_cpus,
-                           NULL, "vec_check_unaligned_access_speed_all_cpus");
-       } else {
-               pr_info("vector unaligned access speed set to '%s' by command line\n",
-                       speed_str[unaligned_vector_speed_param]);
+       if (unaligned_vector_speed_param != RISCV_HWPROBE_MISALIGNED_VECTOR_UNKNOWN) {
                for_each_online_cpu(cpu)
                        per_cpu(vector_misaligned_access, cpu) = unaligned_vector_speed_param;
+       } else if (!check_vector_unaligned_access_emulated_all_cpus() &&
+                  IS_ENABLED(CONFIG_RISCV_PROBE_VECTOR_UNALIGNED_ACCESS)) {
+               kthread_run(vec_check_unaligned_access_speed_all_cpus,
+                           NULL, "vec_check_unaligned_access_speed_all_cpus");
        }
 
        /*