]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
riscv: misaligned: move emulated access uniformity check in a function
authorClément Léger <cleger@rivosinc.com>
Fri, 23 May 2025 10:19:26 +0000 (12:19 +0200)
committerPalmer Dabbelt <palmer@dabbelt.com>
Wed, 4 Jun 2025 22:11:06 +0000 (15:11 -0700)
Split the code that check for the uniformity of misaligned accesses
performance on all cpus from check_unaligned_access_emulated_all_cpus()
to its own function which will be used for delegation check. No
functional changes intended.

Signed-off-by: Clément Léger <cleger@rivosinc.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>
Tested-by: Charlie Jenkins <charlie@rivosinc.com>
Link: https://lore.kernel.org/r/20250523101932.1594077-10-cleger@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
arch/riscv/kernel/traps_misaligned.c

index f1b2af51559232491d2a608f36e7ac92282d80d7..7ecaa8103fe7486d0531be2cf82340647087ec5c 100644 (file)
@@ -645,6 +645,18 @@ bool __init check_vector_unaligned_access_emulated_all_cpus(void)
 }
 #endif
 
+static bool all_cpus_unaligned_scalar_access_emulated(void)
+{
+       int cpu;
+
+       for_each_online_cpu(cpu)
+               if (per_cpu(misaligned_access_speed, cpu) !=
+                   RISCV_HWPROBE_MISALIGNED_SCALAR_EMULATED)
+                       return false;
+
+       return true;
+}
+
 #ifdef CONFIG_RISCV_SCALAR_MISALIGNED
 
 static bool unaligned_ctl __read_mostly;
@@ -683,8 +695,6 @@ static int cpu_online_check_unaligned_access_emulated(unsigned int cpu)
 
 bool __init check_unaligned_access_emulated_all_cpus(void)
 {
-       int cpu;
-
        /*
         * We can only support PR_UNALIGN controls if all CPUs have misaligned
         * accesses emulated since tasks requesting such control can run on any
@@ -692,10 +702,8 @@ bool __init check_unaligned_access_emulated_all_cpus(void)
         */
        on_each_cpu(check_unaligned_access_emulated, NULL, 1);
 
-       for_each_online_cpu(cpu)
-               if (per_cpu(misaligned_access_speed, cpu)
-                   != RISCV_HWPROBE_MISALIGNED_SCALAR_EMULATED)
-                       return false;
+       if (!all_cpus_unaligned_scalar_access_emulated())
+               return false;
 
        unaligned_ctl = true;
        return true;