diff options
author | Dawid Niedzwiecki <dn@semihalf.com> | 2021-11-25 14:40:48 +0100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-12-07 08:50:15 +0000 |
commit | 1b1214d973aa2d092301d8a5973b47e7c261e578 (patch) | |
tree | dea9e96dd9198ee978374d45b0968fd47de78a44 /core | |
parent | bb4c47af02a21be2cc9205adc8bae83862de780a (diff) | |
download | chrome-ec-1b1214d973aa2d092301d8a5973b47e7c261e578.tar.gz |
task: use atomic_t for some variables
Use the atomic_t variable type for tasks_ready, tasks_enabled and
waiters in struct mutex.
The generated asm code is different around the line:
char is_ready = ((uint32_t)tasks_ready & BIT(i)) ? 'R' : ' ';
for all cores, so cast tasks_ready to an unsigned variable to make sure
is works as intended regardless of architecture.
The change will be useful for incoming commits related to modifying
atomic_t caused by a change in Zephyr upstream (atomic_t from int to
long).
BUG=b:207082842
TEST=make buildall && zmake testall
BRANCH=main
Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com>
Change-Id: I0a55c71947401e4137b30fc62adba84d867f56f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3301710
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Reviewed-by: Keith Short <keithshort@chromium.org>
Commit-Queue: Dawid Niedzwiecki <dawidn@google.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/cortex-m/task.c | 6 | ||||
-rw-r--r-- | core/cortex-m0/task.c | 6 | ||||
-rw-r--r-- | core/minute-ia/task.c | 8 | ||||
-rw-r--r-- | core/nds32/task.c | 6 | ||||
-rw-r--r-- | core/riscv-rv32i/task.c | 6 |
5 files changed, 16 insertions, 16 deletions
diff --git a/core/cortex-m/task.c b/core/cortex-m/task.c index 09e13f445d..61c180330f 100644 --- a/core/cortex-m/task.c +++ b/core/cortex-m/task.c @@ -202,13 +202,13 @@ static int need_resched_or_profiling; * can do their init within a task switching context. The hooks task will then * make a call to enable all tasks. */ -static uint32_t tasks_ready = BIT(TASK_ID_HOOKS); +static atomic_t tasks_ready = BIT(TASK_ID_HOOKS); /* * Initially allow only the HOOKS and IDLE task to run, regardless of ready * status, in order for HOOK_INIT to complete before other tasks. * task_enable_all_tasks() will open the flood gates. */ -static uint32_t tasks_enabled = BIT(TASK_ID_HOOKS) | BIT(TASK_ID_IDLE); +static atomic_t tasks_enabled = BIT(TASK_ID_HOOKS) | BIT(TASK_ID_IDLE); static int start_called; /* Has task swapping started */ @@ -952,7 +952,7 @@ void task_print_list(void) ccputs("Task Ready Name Events Time (s) StkUsed\n"); for (i = 0; i < TASK_ID_COUNT; i++) { - char is_ready = (tasks_ready & (1<<i)) ? 'R' : ' '; + char is_ready = ((uint32_t)tasks_ready & BIT(i)) ? 'R' : ' '; uint32_t *sp; int stackused = tasks_init[i].stack_size; diff --git a/core/cortex-m0/task.c b/core/cortex-m0/task.c index ab13a7a172..6996ad133c 100644 --- a/core/cortex-m0/task.c +++ b/core/cortex-m0/task.c @@ -136,13 +136,13 @@ task_ *current_task = (task_ *)scratchpad; * can do their init within a task switching context. The hooks task will then * make a call to enable all tasks. */ -static uint32_t tasks_ready = BIT(TASK_ID_HOOKS); +static atomic_t tasks_ready = BIT(TASK_ID_HOOKS); /* * Initially allow only the HOOKS and IDLE task to run, regardless of ready * status, in order for HOOK_INIT to complete before other tasks. * task_enable_all_tasks() will open the flood gates. */ -static uint32_t tasks_enabled = BIT(TASK_ID_HOOKS) | BIT(TASK_ID_IDLE); +static atomic_t tasks_enabled = BIT(TASK_ID_HOOKS) | BIT(TASK_ID_IDLE); static int start_called; /* Has task swapping started */ @@ -569,7 +569,7 @@ void task_print_list(void) ccputs("Task Ready Name Events Time (s) StkUsed\n"); for (i = 0; i < TASK_ID_COUNT; i++) { - char is_ready = (tasks_ready & (1<<i)) ? 'R' : ' '; + char is_ready = ((uint32_t)tasks_ready & BIT(i)) ? 'R' : ' '; uint32_t *sp; int stackused = tasks_init[i].stack_size; diff --git a/core/minute-ia/task.c b/core/minute-ia/task.c index 91807c8c14..6ad7e8046e 100644 --- a/core/minute-ia/task.c +++ b/core/minute-ia/task.c @@ -60,7 +60,7 @@ static uint64_t task_start_time; /* Time task scheduling started */ static uint32_t exc_start_time; /* Time of task->exception transition */ static uint32_t exc_end_time; /* Time of exception->task transition */ static uint64_t exc_total_time; /* Total time in exceptions */ -static uint32_t svc_calls; /* Number of service calls */ +static atomic_t svc_calls; /* Number of service calls */ static uint32_t task_switches; /* Number of times active task changed */ static uint32_t irq_dist[CONFIG_IRQ_COUNT]; /* Distribution of IRQ calls */ #endif @@ -143,13 +143,13 @@ task_ *current_task, *next_task; * can do their init within a task switching context. The hooks task will then * make a call to enable all tasks. */ -static uint32_t tasks_ready = BIT(TASK_ID_HOOKS); +static atomic_t tasks_ready = BIT(TASK_ID_HOOKS); /* * Initially allow only the HOOKS and IDLE task to run, regardless of ready * status, in order for HOOK_INIT to complete before other tasks. * task_enable_all_tasks() will open the flood gates. */ -static uint32_t tasks_enabled = BIT(TASK_ID_HOOKS) | BIT(TASK_ID_IDLE); +static atomic_t tasks_enabled = BIT(TASK_ID_HOOKS) | BIT(TASK_ID_IDLE); static int start_called; /* Has task swapping started */ @@ -521,7 +521,7 @@ void task_print_list(void) "StkUsed\n"); for (i = 0; i < TASK_ID_COUNT; i++) { - char is_ready = (tasks_ready & (1<<i)) ? 'R' : ' '; + char is_ready = ((uint32_t)tasks_ready & BIT(i)) ? 'R' : ' '; uint32_t *sp; int stackused = tasks_init[i].stack_size; diff --git a/core/nds32/task.c b/core/nds32/task.c index 376ba08ad7..0503495f17 100644 --- a/core/nds32/task.c +++ b/core/nds32/task.c @@ -159,13 +159,13 @@ int need_resched; * can do their init within a task switching context. The hooks task will then * make a call to enable all tasks. */ -static uint32_t tasks_ready = BIT(TASK_ID_HOOKS); +static atomic_t tasks_ready = BIT(TASK_ID_HOOKS); /* * Initially allow only the HOOKS and IDLE task to run, regardless of ready * status, in order for HOOK_INIT to complete before other tasks. * task_enable_all_tasks() will open the flood gates. */ -static uint32_t tasks_enabled = BIT(TASK_ID_HOOKS) | BIT(TASK_ID_IDLE); +static atomic_t tasks_enabled = BIT(TASK_ID_HOOKS) | BIT(TASK_ID_IDLE); int start_called; /* Has task swapping started */ @@ -670,7 +670,7 @@ void task_print_list(void) ccputs("Task Ready Name Events Time (s) StkUsed\n"); for (i = 0; i < TASK_ID_COUNT; i++) { - char is_ready = (tasks_ready & (1<<i)) ? 'R' : ' '; + char is_ready = ((uint32_t)tasks_ready & BIT(i)) ? 'R' : ' '; uint32_t *sp; int stackused = tasks_init[i].stack_size; diff --git a/core/riscv-rv32i/task.c b/core/riscv-rv32i/task.c index b2fda7c6fb..b9b126c1fd 100644 --- a/core/riscv-rv32i/task.c +++ b/core/riscv-rv32i/task.c @@ -154,13 +154,13 @@ int need_resched; * can do their init within a task switching context. The hooks task will then * make a call to enable all tasks. */ -static uint32_t tasks_ready = BIT(TASK_ID_HOOKS); +static atomic_t tasks_ready = BIT(TASK_ID_HOOKS); /* * Initially allow only the HOOKS and IDLE task to run, regardless of ready * status, in order for HOOK_INIT to complete before other tasks. * task_enable_all_tasks() will open the flood gates. */ -static uint32_t tasks_enabled = BIT(TASK_ID_HOOKS) | BIT(TASK_ID_IDLE); +static atomic_t tasks_enabled = BIT(TASK_ID_HOOKS) | BIT(TASK_ID_IDLE); int start_called; /* Has task swapping started */ @@ -603,7 +603,7 @@ void task_print_list(void) ccputs("Task Ready Name Events Time (s) StkUsed\n"); for (i = 0; i < TASK_ID_COUNT; i++) { - char is_ready = (tasks_ready & (1<<i)) ? 'R' : ' '; + char is_ready = ((uint32_t)tasks_ready & BIT(i)) ? 'R' : ' '; uint32_t *sp; int stackused = tasks_init[i].stack_size; |