Skip to content

Commit 4eaaa65

Browse files
clementlegerpalmer-dabbelt
authored andcommitted
riscv: misaligned: move emulated access uniformity check in a function
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 <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Charlie Jenkins <[email protected]> Tested-by: Charlie Jenkins <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 1317045 commit 4eaaa65

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

arch/riscv/kernel/traps_misaligned.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,18 @@ bool __init check_vector_unaligned_access_emulated_all_cpus(void)
645645
}
646646
#endif
647647

648+
static bool all_cpus_unaligned_scalar_access_emulated(void)
649+
{
650+
int cpu;
651+
652+
for_each_online_cpu(cpu)
653+
if (per_cpu(misaligned_access_speed, cpu) !=
654+
RISCV_HWPROBE_MISALIGNED_SCALAR_EMULATED)
655+
return false;
656+
657+
return true;
658+
}
659+
648660
#ifdef CONFIG_RISCV_SCALAR_MISALIGNED
649661

650662
static bool unaligned_ctl __read_mostly;
@@ -683,19 +695,15 @@ static int cpu_online_check_unaligned_access_emulated(unsigned int cpu)
683695

684696
bool __init check_unaligned_access_emulated_all_cpus(void)
685697
{
686-
int cpu;
687-
688698
/*
689699
* We can only support PR_UNALIGN controls if all CPUs have misaligned
690700
* accesses emulated since tasks requesting such control can run on any
691701
* CPU.
692702
*/
693703
on_each_cpu(check_unaligned_access_emulated, NULL, 1);
694704

695-
for_each_online_cpu(cpu)
696-
if (per_cpu(misaligned_access_speed, cpu)
697-
!= RISCV_HWPROBE_MISALIGNED_SCALAR_EMULATED)
698-
return false;
705+
if (!all_cpus_unaligned_scalar_access_emulated())
706+
return false;
699707

700708
unaligned_ctl = true;
701709
return true;

0 commit comments

Comments
 (0)