From 90ae60078effc2a38a91e44bbbc77bfb279183c8 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Thu, 19 Jan 2023 09:25:27 -0500 Subject: [PATCH] ztest: make the FPU flush workaround more generic In addition to ARM64, it must apply to RISC-V too now. Signed-off-by: Nicolas Pitre --- subsys/testsuite/ztest/src/ztest.c | 5 ++--- subsys/testsuite/ztest/src/ztest_new.c | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/subsys/testsuite/ztest/src/ztest.c b/subsys/testsuite/ztest/src/ztest.c index ce5bcb86530..cbb22559d51 100644 --- a/subsys/testsuite/ztest/src/ztest.c +++ b/subsys/testsuite/ztest/src/ztest.c @@ -107,15 +107,14 @@ static void cpu_hold(void *arg1, void *arg2, void *arg3) k_sem_give(&cpuhold_sem); -#if defined(CONFIG_ARM64) && defined(CONFIG_FPU_SHARING) +#if (defined(CONFIG_ARM64) || defined(CONFIG_RISCV)) && defined(CONFIG_FPU_SHARING) /* * We'll be spinning with IRQs disabled. The flush-your-FPU request * IPI will never be serviced during that time. Therefore we flush * the FPU preemptively here to prevent any other CPU waiting after * this CPU forever and deadlock the system. */ - extern void z_arm64_flush_local_fpu(void); - z_arm64_flush_local_fpu(); + k_float_disable(_current_cpu->arch.fpu_owner); #endif while (cpuhold_active) { diff --git a/subsys/testsuite/ztest/src/ztest_new.c b/subsys/testsuite/ztest/src/ztest_new.c index 36809480639..1589681d28f 100644 --- a/subsys/testsuite/ztest/src/ztest_new.c +++ b/subsys/testsuite/ztest/src/ztest_new.c @@ -132,15 +132,14 @@ static void cpu_hold(void *arg1, void *arg2, void *arg3) k_sem_give(&cpuhold_sem); -#if defined(CONFIG_ARM64) && defined(CONFIG_FPU_SHARING) +#if (defined(CONFIG_ARM64) || defined(CONFIG_RISCV)) && defined(CONFIG_FPU_SHARING) /* * We'll be spinning with IRQs disabled. The flush-your-FPU request * IPI will never be serviced during that time. Therefore we flush * the FPU preemptively here to prevent any other CPU waiting after * this CPU forever and deadlock the system. */ - extern void z_arm64_flush_local_fpu(void); - z_arm64_flush_local_fpu(); + k_float_disable(_current_cpu->arch.fpu_owner); #endif while (cpuhold_active) {