Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.4 YOPAN-165 and YOPAN-168 #1958

Conversation

ankuns
Copy link
Contributor

@ankuns ankuns commented Aug 19, 2024

This PR brings in workaround against anomaly 165 and 168 for the nRF5430 SoC.

KRKNWK-19361

Introduce a new API for barrier operations starting with a general
skeleton and the implementation for barrier_data_memory_fence_full().

Select a built-in or an arch-based implementation according to new
Kconfig symbols CONFIG_BARRIER_OPERATIONS_BUILTIN and
CONFIG_BARRIER_OPERATIONS_ARCH.

The built-in implementation falls back on the compiler built-in
function using __ATOMIC_SEQ_CST as it is done for the atomic APIs
already.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
(cherry picked from commit 74a942e)
@ankuns ankuns force-pushed the KRKNWK-19361_v2.4-branch_yoda_fixes branch from a39cd10 to c7cf54c Compare August 19, 2024 11:11
@ankuns ankuns force-pushed the KRKNWK-19361_v2.4-branch_yoda_fixes branch 2 times, most recently from 547cc00 to eb28481 Compare August 19, 2024 11:23
@shanthanordic shanthanordic requested review from ioannisg, martintv and gmarull and removed request for ioannisg August 19, 2024 11:40
Copy link
Member

@gmarull gmarull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some fromlists should be fromtrees as they’re already merged

@ankuns ankuns force-pushed the KRKNWK-19361_v2.4-branch_yoda_fixes branch from eb28481 to d82c0ef Compare August 19, 2024 12:16
@ankuns
Copy link
Contributor Author

ankuns commented Aug 19, 2024

Some fromlists should be fromtrees as they’re already merged

Fixed, there are now [nrf fromtree]

@gmarull
Copy link
Member

gmarull commented Aug 19, 2024

Some fromlists should be fromtrees as they’re already merged

Fixed, there are now [nrf fromtree]

Some cherry-picks contain two lines for "cherry picked from", should only be one

ankuns and others added 8 commits August 19, 2024 15:51
…prepare() hook

Introduce an optional hook to be called when the CPU is made idle.
If needed, this hook can be used to prepare data for upcoming
call to z_arm_on_enter_cpu_idle(). The main difference is that
z_arm_on_enter_cpu_idle_prepare() hook is called before interrupts
are disabled.

Signed-off-by: Andrzej Kuros <andrzej.kuros@nordicsemi.no>
(cherry picked from commit 3d89d58)
Add RTC pretick option that triggers HW activity one tick before and
RTC event that leads to the interrupt. Option is active only on nrf53
network core.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
(cherry picked from commit 31eaffd)
…st one CC

The nrf53 pretick can be used with non-zero
`NRF_RTC_TIMER_USER_CHAN_COUNT` Kconfig option.

The nrf53 pretick requires just one RTC1 CC channel.

The nrf53 pretick handles also RTC1 and RTC0 both CCs and OVERFLOW
events by examination of events scheduled on them. The pretick is set
based on number of ticks to the closest event scheduled that can trigger
an interrupt.

Because the operation in `z_arm_on_enter_cpu_idle` hook would
take too much time with interrupts disabled, the
`z_arm_on_enter_cpu_idle_prepare` hook enabled by Kconfig option
`ARM_ON_ENTER_CPU_IDLE_PREPARE_HOOK` is used. It performs RTC0 and RTC1
examination, and sets pretick without interrupts being blocked.

The LDREX/STREX are leveraged to detect if exception took place
between start of `z_arm_on_enter_cpu_idle_prepare` and
`z_arm_on_enter_cpu_idle`. If exception has not been taken, the pretick
calculation can be trusted because source data could not changed and
too much time could not pass. Otherwise the sleep attempt is disallowed,
the idle will loop again and try later.

Prompt for `SOC_NRF53_RTC_PRETICK` Kconfig option allows to control
this option by an user and turn the feature off if necessary.

Signed-off-by: Andrzej Kuros <andrzej.kuros@nordicsemi.no>
(cherry picked from commit e03d5d4)
The `SOC_NRF53_RTC_PRETICK` option is now allowed to be used with
`NRF_802154_RADIO_DRIVER`.

Signed-off-by: Andrzej Kuros <andrzej.kuros@nordicsemi.no>
(cherry picked from commit d44e96e)
…nterrupts

It might happen that while some interrupt handler other than for RTC0
or RTC1 (e.g. for RADIO) is executed, the scheduled pretick CC triggers.
This starts pretick pulses due to the loop through IPC. The change
in pretick schedule did not stop the pretick pulses going through IPC
loop, what caused heavy increase in power consumption.

This commit fixes this behavior.
Added also clarifications for Kconfig option `SOC_NRF53_RTC_PRETICK`.

Signed-off-by: Andrzej Kuros <andrzej.kuros@nordicsemi.no>
(cherry picked from commit fe1202d)
Coupling in code between workarounds for anomaly 160 and anomaly 165
(pretick) is decreased.

Signed-off-by: Andrzej Kuros <andrzej.kuros@nordicsemi.no>
(cherry picked from commit 1d4a51c)
The cherry-picked workaround against nRF53 anomaly 165, the "pretick"
is based on nrfx 3.0.0. The added code introduces missing definitions
to the soc.c file which are missing in nrfx 2.11.0.

Signed-off-by: Andrzej Kuros <andrzej.kuros@nordicsemi.no>
…ly 168

Use the already available in the tree mechanism of adding assembly
instructions right after WFI/WFE to implement the workaround for
nRF5340 anomaly 168 (replace the 4 NOP solution used on the network
core as it turned out to be insufficient) and provide two related
Kconfig options so that users are able to adjust the workaround to
their actual needs (disable it entirely or use it in the extended
version).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
(cherry picked from commit 23e15c4)
@ankuns ankuns force-pushed the KRKNWK-19361_v2.4-branch_yoda_fixes branch from fd7f713 to 7300d9e Compare August 19, 2024 13:53
@ankuns
Copy link
Contributor Author

ankuns commented Aug 19, 2024

Some cherry-picks contain two lines for "cherry picked from", should only be one

fixed

The function `z_nrf_rtc_timer_exact_set` is added to allow
setting compare channel without possible creeping of cc val.

Signed-off-by: Andrzej Kuros <andrzej.kuros@nordicsemi.no>
(cherry picked from commit a6615ac)
@ankuns ankuns force-pushed the KRKNWK-19361_v2.4-branch_yoda_fixes branch from 7300d9e to 0ad2a2a Compare August 19, 2024 14:10
With GCC 12.3 and binutils 2.40, the build fails with:

<...>/zephyr/arch/arm/core/cortex_m/cpu_idle.S: Assembler messages:
<...>/zephyr/arch/arm/core/cortex_m/cpu_idle.S:51: Error: junk at end of line, first unrecognized character is `n'
<...>/zephyr/arch/arm/core/cortex_m/cpu_idle.S:133:   Info: macro invoked from here

Because the SOC_ON_EXIT_CPU_IDLE macro puts all the statements on a
single line, there must be a semicolon after .rept

Signed-off-by: Ben Wolsieffer <benwolsieffer@gmail.com>
(cherry picked from commit 37352d3)
@ankuns ankuns force-pushed the KRKNWK-19361_v2.4-branch_yoda_fixes branch from 7d3d1ed to 40681cf Compare August 20, 2024 06:56
@gmarull gmarull merged commit c0aa4d2 into nrfconnect:v3.3.99-ncs1-branch Aug 20, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants