summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDawid Niedzwiecki <dn@semihalf.com>2021-11-24 11:15:30 +0100
committerCommit Bot <commit-bot@chromium.org>2021-11-29 22:04:39 +0000
commitbec6095ba94a83af6affda9e46a5ced4eeaaeabe (patch)
treef1765686e0a4c95fe18bb627d636b86f2d3c395d
parente744855f94f37388d4adb1f9a79077aca61ec71c (diff)
downloadchrome-ec-bec6095ba94a83af6affda9e46a5ced4eeaaeabe.tar.gz
system: change sleep_mask to atomic_t type
The sleep_mask is used only with atomic_* functions or for reading, so change to variable type to atomic_t. Do the same with idle_disabled. It shouldn't change the generated code. The only noticed change is for mchp chip. The compiler uses .w asm extension for some instructions in __idle function in clock.c file. It 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: I85d05bb911af973f030cf46d3f534c374ef76936 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3300320 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
-rw-r--r--board/zinger/runtime.c3
-rw-r--r--common/system.c4
-rw-r--r--include/system.h4
-rw-r--r--zephyr/shim/src/ztest_system.c2
4 files changed, 7 insertions, 6 deletions
diff --git a/board/zinger/runtime.c b/board/zinger/runtime.c
index 0b6f1995f5..9d27181032 100644
--- a/board/zinger/runtime.c
+++ b/board/zinger/runtime.c
@@ -4,6 +4,7 @@
*/
/* tiny substitute of the runtime layer */
+#include "atomic.h"
#include "chip/stm32/clock-f.h"
#include "clock.h"
#include "common.h"
@@ -16,7 +17,7 @@
#include "util.h"
volatile uint32_t last_event;
-uint32_t sleep_mask;
+atomic_t sleep_mask;
/* High word of the 64-bit timestamp counter */
static volatile uint32_t clksrc_high;
diff --git a/common/system.c b/common/system.c
index 5e18170b59..621ed6a99d 100644
--- a/common/system.c
+++ b/common/system.c
@@ -72,11 +72,11 @@ STATIC_IF(CONFIG_HIBERNATE) uint32_t hibernate_seconds;
STATIC_IF(CONFIG_HIBERNATE) uint32_t hibernate_microseconds;
/* On-going actions preventing going into deep-sleep mode */
-uint32_t sleep_mask;
+atomic_t sleep_mask;
#ifdef CONFIG_LOW_POWER_IDLE_LIMITED
/* Set it to prevent going into idle mode */
-uint32_t idle_disabled;
+atomic_t idle_disabled;
#endif
/* SKU ID sourced from AP */
diff --git a/include/system.h b/include/system.h
index 57592217ad..0fc0206bb3 100644
--- a/include/system.h
+++ b/include/system.h
@@ -570,7 +570,7 @@ enum {
* Current sleep mask. You may read from this variable, but must NOT
* modify it; use enable_sleep() or disable_sleep() to do that.
*/
-extern uint32_t sleep_mask;
+extern atomic_t sleep_mask;
/*
* Macros to use to get whether deep sleep is allowed or whether
@@ -613,7 +613,7 @@ static inline void disable_sleep(uint32_t mask)
* Do NOT access it directly. Use idle_is_disabled() to read it and
* enable_idle()/disable_idle() to write it.
*/
-extern uint32_t idle_disabled;
+extern atomic_t idle_disabled;
static inline uint32_t idle_is_disabled(void)
{
diff --git a/zephyr/shim/src/ztest_system.c b/zephyr/shim/src/ztest_system.c
index 580368d7f9..7da949dd84 100644
--- a/zephyr/shim/src/ztest_system.c
+++ b/zephyr/shim/src/ztest_system.c
@@ -7,7 +7,7 @@
#include "cros_version.h"
/* Ongoing actions preventing going into deep-sleep mode. */
-uint32_t sleep_mask;
+atomic_t sleep_mask;
void system_common_pre_init(void)
{