From decedcabf69c0ab72c768ce7a2e28c07cfea8c7b Mon Sep 17 00:00:00 2001 From: Peter Mitsis Date: Wed, 28 May 2025 15:46:24 -0700 Subject: [PATCH] arch: xtensa: Add hifi_owner for lazy switching Adds a customized _cpu_arch structure for Xtensa so that it contains a pointer to the thread that 'owns' the hifi register set for use with lazy save/restore. Signed-off-by: Peter Mitsis --- include/zephyr/arch/structs.h | 2 ++ include/zephyr/arch/xtensa/structs.h | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 include/zephyr/arch/xtensa/structs.h diff --git a/include/zephyr/arch/structs.h b/include/zephyr/arch/structs.h index dcd4406c1d8..1ea694cb4fe 100644 --- a/include/zephyr/arch/structs.h +++ b/include/zephyr/arch/structs.h @@ -31,6 +31,8 @@ #include #elif defined(CONFIG_X86) && !defined(CONFIG_X86_64) #include +#elif defined(CONFIG_XTENSA) +#include #else /* Default definitions when no architecture specific definitions exist. */ diff --git a/include/zephyr/arch/xtensa/structs.h b/include/zephyr/arch/xtensa/structs.h new file mode 100644 index 00000000000..5470c69af42 --- /dev/null +++ b/include/zephyr/arch/xtensa/structs.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_XTENSA_STRUCTS_H_ +#define ZEPHYR_INCLUDE_XTENSA_STRUCTS_H_ + +/* Per CPU architecture specifics */ +struct _cpu_arch { +#if defined(CONFIG_XTENSA_LAZY_HIFI_SHARING) + atomic_ptr_val_t hifi_owner; /* Owner of HiFi */ +#if CONFIG_MP_MAX_NUM_CPUS > 1 + atomic_ptr_val_t save_hifi; /* Save HiFi on IPI if match hifi_owner */ +#endif +#elif defined(__cplusplus) + /* Ensure this struct does not have a size of 0 which is not allowed in C++. */ + uint8_t dummy; +#endif +}; + +#endif /* ZEPHYR_INCLUDE_XTENSA_STRUCTS_H_ */