Skip to content

Commit 6505cf2

Browse files
peter-mitsiscfriedt
authored andcommitted
arch: xtensa: Carve space for saved HiFi regs
As the BSA can not be used when lazy HiFi context switching is used, a more permanent and predictable location in which to store the registers is required. To this end ... 1. reserve some space in the arch-specific portion of the k_thread structure for those registers. 2. clear that region when the thread is created. Signed-off-by: Peter Mitsis <[email protected]>
1 parent cd35120 commit 6505cf2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

arch/xtensa/core/thread.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
120120
{
121121
thread->switch_handle = init_stack(thread, (int *)stack_ptr, entry,
122122
p1, p2, p3);
123+
#ifdef CONFIG_XTENSA_LAZY_HIFI_SHARING
124+
memset(thread->arch.hifi_regs, 0, sizeof(thread->arch.hifi_regs));
125+
#endif /* CONFIG_XTENSA_LAZY_HIFI_SHARING */
126+
123127
#ifdef CONFIG_KERNEL_COHERENCE
124128
__ASSERT((((size_t)stack) % XCHAL_DCACHE_LINESIZE) == 0, "");
125129
__ASSERT((((size_t)stack_ptr) % XCHAL_DCACHE_LINESIZE) == 0, "");

include/zephyr/arch/xtensa/thread.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#include <zephyr/arch/xtensa/mpu.h>
1515
#endif
1616

17+
#ifdef CONFIG_XTENSA_LAZY_HIFI_SHARING
18+
#include <xtensa/config/tie.h>
19+
#endif
20+
1721
/* Xtensa doesn't use these structs, but Zephyr core requires they be
1822
* defined so they can be included in struct _thread_base. Dummy
1923
* field exists for sizeof compatibility with C++.
@@ -48,6 +52,11 @@ struct _thread_arch {
4852
*/
4953
uint32_t return_ps;
5054
#endif
55+
56+
#ifdef CONFIG_XTENSA_LAZY_HIFI_SHARING
57+
/* A non-BSA region is required for lazy save/restore */
58+
uint8_t hifi_regs[XCHAL_CP1_SA_SIZE] __aligned(XCHAL_CP1_SA_ALIGN);
59+
#endif
5160
};
5261

5362
typedef struct _thread_arch _thread_arch_t;

0 commit comments

Comments
 (0)