Skip to content

Multi option clocks downstream - #4456

Open
mif1-nordic wants to merge 11 commits into
nrfconnect:mainfrom
mif1-nordic:multi_option_clocks_downstream
Open

mif1-nordic wants to merge 11 commits into
nrfconnect:mainfrom
mif1-nordic:multi_option_clocks_downstream

Conversation

@mif1-nordic

Copy link
Copy Markdown
Contributor

No description provided.

@mif1-nordic
mif1-nordic force-pushed the multi_option_clocks_downstream branch from 7d9a009 to f1b081a Compare September 11, 2026 10:08
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request Sep 11, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4456

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@mif1-nordic
mif1-nordic force-pushed the multi_option_clocks_downstream branch from f1b081a to da247a1 Compare September 11, 2026 10:33
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request Sep 11, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4456

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@mif1-nordic
mif1-nordic force-pushed the multi_option_clocks_downstream branch from da247a1 to fb5b5cb Compare September 14, 2026 08:19
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request Sep 14, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4456

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@mif1-nordic
mif1-nordic force-pushed the multi_option_clocks_downstream branch from fb5b5cb to 5d1875f Compare September 14, 2026 09:53
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request Sep 14, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4456

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@mif1-nordic
mif1-nordic force-pushed the multi_option_clocks_downstream branch from 5d1875f to 10b85ef Compare September 14, 2026 11:38
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request Sep 14, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4456

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@mif1-nordic
mif1-nordic force-pushed the multi_option_clocks_downstream branch from 10b85ef to 95e4c09 Compare September 15, 2026 08:19
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request Sep 15, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4456

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
@mif1-nordic
mif1-nordic force-pushed the multi_option_clocks_downstream branch from 95e4c09 to 1dc2866 Compare September 15, 2026 13:13
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request Sep 15, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4456

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
wsipak and others added 11 commits September 17, 2026 09:03
After recent modifications to the timeout calculation in cmsdk_apb_timer,
MAX_TICKS define is no longer used. This commit removes it.

Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>

(cherry picked from commit 5949aa3)
…m-timer chosen

Instead of the vendor-specific `stm32_lp_tick_source` nodelabel, update
the STM32 LPTIM systimer driver to use the `zephyr,system-timer` chosen
as singleton instance selection.

Remove support for the old mechanism entirely, triggering instead
a build error during Kconfig parsing (to avoid unnecessary compilation).

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>

(cherry picked from commit 2ffbccc)
…ock() scheme

The driver kept a private spinlock and used the legacy sys_clock_announce()
even though the kernel already holds its timer lock across the driver's
sys_clock_set_timeout() and sys_clock_elapsed() callbacks. Take that same
lock instead: the ISR and sys_clock_idle_exit() now use sys_clock_lock()
with sys_clock_announce_locked(), and set_timeout()/elapsed() simply assert
the lock is held rather than acquiring one of their own.

This drops a redundant lock and lets the upcoming low-power idle handling
avoid any locking of its own.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>

(cherry picked from commit 7e681db)
…ppy idle centrally

The "no timeout pending, stop the clock" decision under
CONFIG_SYSTEM_CLOCK_SLOPPY_IDLE was expressed by next_timeout()
returning SYS_CLOCK_MAX_WAIT verbatim as a magic sentinel, which every
timer driver then had to recognise. Move the decision into the core and
give it an explicit, resumable interface.

Add a weak sys_clock_unused() hook (no-op default): the kernel calls it
when the timeout list is empty and sloppy idle allows uptime to drift,
in place of programming a wait. A driver may override it to actively
halt its counter; one that does not simply stops being reprogrammed and
quiesces on its own, so sloppy idle now works for every driver. Resume
is the next sys_clock_set_timeout(), exactly as before; the core keeps
no paused state.

next_timeout() no longer special-cases sloppy idle, so its empty-list
and far-timeout arms collapse to the same capped budget and
SYS_CLOCK_MAX_WAIT loses its sentinel meaning. The decision lives in
reprogram_next(), used only at the two sites where the list can drain
(abort, end of announce); the add path always has a pending timeout and
calls sys_clock_set_timeout() directly.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>

(cherry picked from commit 926f7c4)
The kernel now signals "no timeout pending, uptime may drift" by
calling sys_clock_unused() instead of passing the SYS_CLOCK_MAX_WAIT
sentinel to sys_clock_set_timeout(). Move each driver's sloppy-idle
handling out of sys_clock_set_timeout() and into a sys_clock_unused()
implementation, and drop the ticks == SYS_CLOCK_MAX_WAIT comparisons.

Drivers that actively stop the counter (cortex_m_systick, arcv2, hpet,
mcux_sysctr, mcux_lptmr, sam0, ite, infineon, mchp_xec, realtek,
stm32_lptim) do so in sys_clock_unused(). The free-running compare
timers (nrf_rtc, mcux_rtc_jdp, max32_rv32) instead follow the renesas
model and simply stop reprogramming: the last compare still catches the
counter wrap and the next real timeout re-arms them, so an explicit
maximum-length wait would only add a needless periodic wakeup. nrf_rtc
keeps a one-line sys_clock_unused() that clears the flag consumed by its
overflow-trigger path; mcux_rtc_jdp and max32_rv32 need no override at
all, like the renesas drivers.

cmsdk_apb is the exception: it is an auto-reload down-counter, so not
reprogramming would keep firing at the previous (possibly short)
interval. It programs the maximum reload instead, matching what
non-sloppy idle already does, with a note that stopping the counter
would be the better but riskier improvement.

Resume is unchanged: the next sys_clock_set_timeout() restarts the
driver.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>

(cherry picked from commit 269e2e6)
…n sys_clock_unused()

mcux_os keeps a wait_forever flag (consumed by the counter-overflow wakeup
path) that it set when sys_clock_set_timeout() was called with the
SYS_CLOCK_MAX_WAIT sentinel. The kernel no longer passes that value; the
no-deadline case now arrives via sys_clock_unused(). Set the flag there and
program the match as far out as the hardware allows; clear it on a real
sys_clock_set_timeout().

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>

(cherry picked from commit e5903e4)
…wer idle handoff

The idle argument of sys_clock_set_timeout() carries a distinct signal:
the CPU is entering low-power idle, here is its wakeup. Only the PM and
SoC power paths produce it (the timeout core always passes false), and
only a few drivers act on it to hand off to a low-power wakeup timer.

Introduce a dedicated sys_clock_idle_enter() hook for that, so the two
idle==true callers (subsys/pm and soc/nxp/rw) call it instead of
sys_clock_set_timeout(). Its weak default just programs the wakeup via
sys_clock_set_timeout(), so a driver with no low-power handling needs
nothing.

The five drivers that acted on idle (cortex_m_systick, esp32, xtensa,
mcux_os, stm32_lptim) move that handling into their own
sys_clock_idle_enter(), keeping their exact behaviour. Where the idle
path was self-contained it moves wholesale (cortex_m_systick, mcux_os,
stm32_lptim); where it shares the timeout programming, idle_enter()
calls set_timeout() first and then does its idle work (esp32), or shares
a small private helper (xtensa). set_timeout() keeps its now-unused idle
argument for the moment; nobody passes idle==true to it any more, which
lets the next change drop the argument entirely.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>

(cherry picked from commit 7d0bb85)
…et_timeout()

With low-power idle handoff now going through sys_clock_idle_enter(),
nothing passes idle == true to sys_clock_set_timeout() any more, so the
argument is dead. Drop it: sys_clock_set_timeout(uint32_t ticks) now
means exactly "program the next tick, N ticks out", nothing else.

This updates the prototype, the weak default, every in-tree timer driver
definition (including the out-of-tree-style board timer under boards/),
and the core call sites. For the five drivers with low-power behaviour
this only removes the now-unused idle argument that the previous change
left on set_timeout(); the handling itself stays in their
sys_clock_idle_enter().

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>

(cherry picked from commit fa9b836)
…_clock_set_timeout()"

This reverts commit fa9b836.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>

(cherry picked from commit 3d7be78)
Remove remaining uses of the internal __ASSERT_ON macro. Let __ASSERT()
handle disabled assertions, mark assert-only values as unused where needed,
and use CONFIG_ASSERT for assertion-only state.

Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>

(cherry picked from commit 839c682963f757a8630dd7a16d534b495d1125e7)
…ure oriented one

Replaced SOC dependent kconfigs CONFIG_SOC_SERIES_NRF54H,
CONFIG_SOC_SERIES_NRF92 with feature oriented
CONFIG_HAS_MULTI_OPTION_CLOCKS, in clock related drivers.

Signed-off-by: Michal Frankiewicz <michal.frankiewicz@nordicsemi.no>

Upstream PR #: 118713
@mif1-nordic
mif1-nordic force-pushed the multi_option_clocks_downstream branch from 1dc2866 to 5192bec Compare September 17, 2026 07:03
NordicBuilder added a commit to NordicBuilder/sdk-nrf that referenced this pull request Sep 17, 2026
Automatically created by action-manifest-pr GH action from PR:
nrfconnect/sdk-zephyr#4456

Signed-off-by: Nordic Builder <pylon@nordicsemi.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants