Skip to content

Commit 2744ec4

Browse files
jones-drewAlexandre Ghiti
authored andcommitted
riscv: Fix set up of vector cpu hotplug callback
Whether or not we have RISCV_PROBE_VECTOR_UNALIGNED_ACCESS we need to set up a cpu hotplug callback to check if we have vector at all, since, when we don't have vector, we need to set vector_misaligned_access to unsupported rather than leave it the default of unknown. 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-16-ajones@ventanamicro.com Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
1 parent 05ee21f commit 2744ec4

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

arch/riscv/kernel/unaligned_access_speed.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -356,34 +356,37 @@ static void check_vector_unaligned_access(struct work_struct *work __always_unus
356356
per_cpu(vector_misaligned_access, cpu) = speed;
357357
}
358358

359+
/* Measure unaligned access speed on all CPUs present at boot in parallel. */
360+
static int __init vec_check_unaligned_access_speed_all_cpus(void *unused __always_unused)
361+
{
362+
schedule_on_each_cpu(check_vector_unaligned_access);
363+
364+
return 0;
365+
}
366+
#else /* CONFIG_RISCV_PROBE_VECTOR_UNALIGNED_ACCESS */
367+
static int __init vec_check_unaligned_access_speed_all_cpus(void *unused __always_unused)
368+
{
369+
return 0;
370+
}
371+
#endif
372+
359373
static int riscv_online_cpu_vec(unsigned int cpu)
360374
{
361375
if (!has_vector()) {
362376
per_cpu(vector_misaligned_access, cpu) = RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED;
363377
return 0;
364378
}
365379

380+
#ifdef CONFIG_RISCV_PROBE_VECTOR_UNALIGNED_ACCESS
366381
if (per_cpu(vector_misaligned_access, cpu) != RISCV_HWPROBE_MISALIGNED_VECTOR_UNKNOWN)
367382
return 0;
368383

369384
check_vector_unaligned_access_emulated(NULL);
370385
check_vector_unaligned_access(NULL);
371-
return 0;
372-
}
373-
374-
/* Measure unaligned access speed on all CPUs present at boot in parallel. */
375-
static int __init vec_check_unaligned_access_speed_all_cpus(void *unused __always_unused)
376-
{
377-
schedule_on_each_cpu(check_vector_unaligned_access);
386+
#endif
378387

379388
return 0;
380389
}
381-
#else /* CONFIG_RISCV_PROBE_VECTOR_UNALIGNED_ACCESS */
382-
static int __init vec_check_unaligned_access_speed_all_cpus(void *unused __always_unused)
383-
{
384-
return 0;
385-
}
386-
#endif
387390

388391
static int __init check_unaligned_access_all_cpus(void)
389392
{
@@ -409,10 +412,8 @@ static int __init check_unaligned_access_all_cpus(void)
409412
cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "riscv:online",
410413
riscv_online_cpu, riscv_offline_cpu);
411414
#endif
412-
#ifdef CONFIG_RISCV_PROBE_VECTOR_UNALIGNED_ACCESS
413415
cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "riscv:online",
414416
riscv_online_cpu_vec, NULL);
415-
#endif
416417

417418
return 0;
418419
}

0 commit comments

Comments
 (0)