aarch64: work around QEMU 'wfi' issue

Work around an issue where the emulator ignores host OS
signals when inside a `wfi` instruction.

This should be reverted once this has been addressed in the
AARCH64 build of QEMU in the SDK.

See https://github.com/zephyrproject-rtos/sdk-ng/issues/255

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2020-09-09 10:37:50 -07:00 committed by Carles Cufí
parent 96b6da9bea
commit aebb9d8a45
3 changed files with 46 additions and 2 deletions

View File

@ -8,7 +8,6 @@ if (CONFIG_COVERAGE)
endif ()
zephyr_library_sources(
cpu_idle.S
fatal.c
irq_init.c
irq_manage.c
@ -19,6 +18,15 @@ zephyr_library_sources(
vector_table.S
)
# Workaround aarch64 QEMU not responding to host OS signals
# during 'wfi'.
# See https://github.com/zephyrproject-rtos/sdk-ng/issues/255
if (CONFIG_SOC_QEMU_CORTEX_A53)
zephyr_library_sources(cpu_idle_qemu.c)
else ()
zephyr_library_sources(cpu_idle.S)
endif ()
zephyr_library_sources_ifdef(CONFIG_GEN_SW_ISR_TABLE isr_wrapper.S)
zephyr_library_sources_ifdef(CONFIG_IRQ_OFFLOAD irq_offload.c)
zephyr_library_sources_ifdef(CONFIG_ARM_MMU arm_mmu.c)

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2020 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
*
* @brief Workaround aarch64 QEMU not responding to host OS signals
* during 'wfi'.
* See https://github.com/zephyrproject-rtos/sdk-ng/issues/255
*/
#include <arch/cpu.h>
void arch_cpu_idle(void)
{
/* Do nothing but unconditionally unlock interrupts and return to the
* caller.
*/
__asm__ volatile("msr daifclr, %0\n\t"
: : "i" (DAIFSET_IRQ)
: "memory", "cc");
}
void arch_cpu_atomic_idle(unsigned int key)
{
/* Do nothing but restore IRQ state */
arch_irq_unlock(key);
}

View File

@ -91,9 +91,13 @@
#endif
/* Cortex-M1, Nios II, and RISCV without CONFIG_RISCV_HAS_CPU_IDLE
* do have a power saving instruction, so k_cpu_idle() returns immediately
* do have a power saving instruction, so k_cpu_idle() returns immediately.
*
* Includes workaround on QEMU aarch64, see
* https://github.com/zephyrproject-rtos/sdk-ng/issues/255
*/
#if !defined(CONFIG_CPU_CORTEX_M1) && !defined(CONFIG_NIOS2) && \
!defined(CONFIG_SOC_QEMU_CORTEX_A53) && \
(!defined(CONFIG_RISCV) || defined(CONFIG_RISCV_HAS_CPU_IDLE))
#define HAS_POWERSAVE_INSTRUCTION
#endif