Skip to content

Commit d1f9c73

Browse files
ananglrlubos
authored andcommitted
[nrf fromtree] soc: nrf53: Change logging level of anomaly 160 message to DEBUG
This is a follow-up to commit fe3b97a. This message should not be a warning, as it does not actually indicate that something potentially bad happened. On the contrary, it informs that conditions in which the anomaly 160 could occur were detected and the anomaly was prevented from occurring. There is no need for this message to appear in the default configuration (INFO level). In fact, the message would undesirably flood the console in some cases (like the kernel/mem_protect/stack_random test) and sometimes it would also require enlarging the stack of the idle thread (the function is called underneath k_cpu_idle()). Therefore, the logging level of this message is changed to DEBUG. Signed-off-by: Andrzej Głąbek <[email protected]> (cherry picked from commit 7195db0)
1 parent 76acbd0 commit d1f9c73

File tree

1 file changed

+22
-11
lines changed
  • soc/arm/nordic_nrf/nrf53

1 file changed

+22
-11
lines changed

soc/arm/nordic_nrf/nrf53/soc.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,33 +125,26 @@ static void nrf53_anomaly_160_workaround(void)
125125
#endif
126126
}
127127

128-
bool z_arm_on_enter_cpu_idle(void)
128+
/* This code prevents the CPU from entering sleep again if it already
129+
* entered sleep 5 times within last 200 us.
130+
*/
131+
static bool nrf53_anomaly_160_check(void)
129132
{
130-
/* This code prevents the CPU from entering sleep again if it already
131-
* entered sleep 5 times within last 200 us.
132-
*/
133-
134133
/* System clock cycles needed to cover 200 us window. */
135134
const uint32_t window_cycles =
136135
ceiling_fraction(200 * CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC,
137136
1000000);
138137
static uint32_t timestamps[5];
139138
static bool timestamps_filled;
140-
static bool suppress_warning;
141139
static uint8_t current;
142140
uint8_t oldest = (current + 1) % ARRAY_SIZE(timestamps);
143141
uint32_t now = k_cycle_get_32();
144142

145143
if (timestamps_filled &&
146144
/* + 1 because only fully elapsed cycles need to be counted. */
147145
(now - timestamps[oldest]) < (window_cycles + 1)) {
148-
if (!suppress_warning) {
149-
LOG_WRN("Anomaly 160 trigger conditions detected.");
150-
suppress_warning = true;
151-
}
152146
return false;
153147
}
154-
suppress_warning = false;
155148

156149
/* Check if the CPU actually entered sleep since the last visit here
157150
* (WFE/WFI could return immediately if the wake-up event was already
@@ -174,6 +167,24 @@ bool z_arm_on_enter_cpu_idle(void)
174167

175168
return true;
176169
}
170+
171+
bool z_arm_on_enter_cpu_idle(void)
172+
{
173+
bool ok_to_sleep = nrf53_anomaly_160_check();
174+
175+
#if (LOG_LEVEL >= LOG_LEVEL_DBG)
176+
static bool suppress_message;
177+
178+
if (ok_to_sleep) {
179+
suppress_message = false;
180+
} else {
181+
LOG_DBG("Anomaly 160 trigger conditions detected.");
182+
suppress_message = true;
183+
}
184+
#endif
185+
186+
return ok_to_sleep;
187+
}
177188
#endif /* CONFIG_SOC_NRF53_ANOMALY_160_WORKAROUND */
178189

179190
static int nordicsemi_nrf53_init(const struct device *arg)

0 commit comments

Comments
 (0)