Skip to content

Commit e6d0adf

Browse files
jones-drewAlexandre Ghiti
authored andcommitted
riscv: Fix check_unaligned_access_all_cpus
check_vector_unaligned_access_emulated_all_cpus(), like its name suggests, will return true when all cpus emulate unaligned vector accesses. If the function returned false it may have been because vector isn't supported at all (!has_vector()) or because at least one cpu doesn't emulate unaligned vector accesses. Since false may be returned for two cases, checking for it isn't sufficient when attempting to determine if we should proceed with the vector speed check. Move the !has_vector() functionality to check_unaligned_access_all_cpus() in order for check_vector_unaligned_access_emulated_all_cpus() to return false for a single case. Fixes: e7c9d66 ("RISC-V: Report vector unaligned access speed hwprobe") Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Link: https://lore.kernel.org/r/20250304120014.143628-13-ajones@ventanamicro.com Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
1 parent 5af72a8 commit e6d0adf

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

arch/riscv/kernel/traps_misaligned.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -609,12 +609,6 @@ bool __init check_vector_unaligned_access_emulated_all_cpus(void)
609609
{
610610
int cpu;
611611

612-
if (!has_vector()) {
613-
for_each_online_cpu(cpu)
614-
per_cpu(vector_misaligned_access, cpu) = RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED;
615-
return false;
616-
}
617-
618612
schedule_on_each_cpu(check_vector_unaligned_access_emulated);
619613

620614
for_each_online_cpu(cpu)

arch/riscv/kernel/unaligned_access_speed.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,16 @@ static int __init vec_check_unaligned_access_speed_all_cpus(void *unused __alway
403403

404404
static int __init check_unaligned_access_all_cpus(void)
405405
{
406-
bool all_cpus_emulated, all_cpus_vec_unsupported;
406+
bool all_cpus_emulated;
407+
int cpu;
407408

408409
all_cpus_emulated = check_unaligned_access_emulated_all_cpus();
409-
all_cpus_vec_unsupported = check_vector_unaligned_access_emulated_all_cpus();
410410

411-
if (!all_cpus_vec_unsupported &&
412-
IS_ENABLED(CONFIG_RISCV_PROBE_VECTOR_UNALIGNED_ACCESS)) {
411+
if (!has_vector()) {
412+
for_each_online_cpu(cpu)
413+
per_cpu(vector_misaligned_access, cpu) = RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED;
414+
} else if (!check_vector_unaligned_access_emulated_all_cpus() &&
415+
IS_ENABLED(CONFIG_RISCV_PROBE_VECTOR_UNALIGNED_ACCESS)) {
413416
kthread_run(vec_check_unaligned_access_speed_all_cpus,
414417
NULL, "vec_check_unaligned_access_speed_all_cpus");
415418
}

0 commit comments

Comments
 (0)