From 258d596303e483702caa87a0015ae545c4ce482d Mon Sep 17 00:00:00 2001 From: Rahix <rahix@rahix.de> Date: Thu, 4 Jul 2019 12:30:23 +0200 Subject: [PATCH] fix(epicardium): Reenable preemption This commit changes the tickless idle behaviour. Instead of keeping interrupts off during sleep, they are enabled because preemption somehow prevents them from triggering with WFE. This might have unintended sideeffects and needs further verification. Signed-off-by: Rahix <rahix@rahix.de> --- epicardium/FreeRTOSConfig.h | 3 +-- epicardium/main.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/epicardium/FreeRTOSConfig.h b/epicardium/FreeRTOSConfig.h index 76ae165a9..95ddf835d 100644 --- a/epicardium/FreeRTOSConfig.h +++ b/epicardium/FreeRTOSConfig.h @@ -25,8 +25,7 @@ #define configMAX_SYSCALL_INTERRUPT_PRIORITY ( ( unsigned char ) 5 << ( 8 - configPRIO_BITS) ) /* We want to use preemption to easier integrate components */ -/* TODO: Figure out why turning this on does not work ... */ -#define configUSE_PREEMPTION 0 +#define configUSE_PREEMPTION 1 /* * Tickless idle from the FreeRTOS port + our own hooks (defined further down in diff --git a/epicardium/main.c b/epicardium/main.c index cc2d0a4f3..deda39b8b 100644 --- a/epicardium/main.c +++ b/epicardium/main.c @@ -31,8 +31,19 @@ void pre_idle_sleep(TickType_t xExpectedIdleTime) * WFE because the other core should be able to notify * epicardium if it wants to issue an API call. */ + + /* + * TODO: Ensure this is actually correct and does not have any + * race conditions. + */ + __asm volatile( "cpsie i" ::: "memory" ); __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); __asm volatile( "wfe" ); + __asm volatile( "dsb" ::: "memory" ); + __asm volatile( "isb" ); + __asm volatile( "cpsid i" ::: "memory" ); + __asm volatile( "dsb" ); __asm volatile( "isb" ); } } -- GitLab