From 502a72ad1e32df60578a81ce55c79dafbc420c0b Mon Sep 17 00:00:00 2001 From: Bjarki Arge Andreasen Date: Tue, 5 Aug 2025 18:03:12 +0200 Subject: [PATCH 1/3] [nrf fromlist] drivers: timer: nrf_grtc_timer: support ISR_DIRECT Add support for building nrf_grtc_timer using IRQ_DIRECT_CONNECT. This allows for building the driver with no SW ISR table. Upstream PR #: 94132 Signed-off-by: Bjarki Arge Andreasen --- drivers/timer/Kconfig.nrf_grtc | 4 ++++ drivers/timer/nrf_grtc_timer.c | 27 +++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/timer/Kconfig.nrf_grtc b/drivers/timer/Kconfig.nrf_grtc index 082c15333dc..5bee0284cbd 100644 --- a/drivers/timer/Kconfig.nrf_grtc +++ b/drivers/timer/Kconfig.nrf_grtc @@ -56,4 +56,8 @@ config NRF_GRTC_TIMER_AUTO_KEEP_ALIVE This feature prevents the SYSCOUNTER from sleeping when any core is in active state. +config NRF_GRTC_TIMER_ISR_DIRECT + bool "Use direct ISR" + default y if !MULTITHREADING + endif # NRF_GRTC_TIMER diff --git a/drivers/timer/nrf_grtc_timer.c b/drivers/timer/nrf_grtc_timer.c index 2809d8b3d60..27945ca4db9 100644 --- a/drivers/timer/nrf_grtc_timer.c +++ b/drivers/timer/nrf_grtc_timer.c @@ -455,12 +455,35 @@ uint32_t sys_clock_elapsed(void) return (uint32_t)(counter_sub(counter(), last_count) / CYC_PER_TICK); } +#if CONFIG_NRF_GRTC_TIMER_ISR_DIRECT +ISR_DIRECT_DECLARE(nrf_grtc_irq_handler) +{ + nrfx_grtc_irq_handler(); +#if CONFIG_MULTITHREADING + ISR_DIRECT_PM(); + return 1; +#else + return 0; +#endif +} +#endif + static int sys_clock_driver_init(void) { nrfx_err_t err_code; - IRQ_CONNECT(DT_IRQN(GRTC_NODE), DT_IRQ(GRTC_NODE, priority), nrfx_isr, - nrfx_grtc_irq_handler, 0); +#ifdef CONFIG_NRF_GRTC_TIMER_ISR_DIRECT + IRQ_DIRECT_CONNECT(DT_IRQN(GRTC_NODE), + DT_IRQ(GRTC_NODE, priority), + nrf_grtc_irq_handler, + 0); +#else + IRQ_CONNECT(DT_IRQN(GRTC_NODE), + DT_IRQ(GRTC_NODE, priority), + nrfx_isr, + nrfx_grtc_irq_handler, + 0); +#endif #if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) && NRF_GRTC_HAS_CLKSEL #if defined(CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC) From f3a27b4111e5cec47da31df4f87e57b0f96a5019 Mon Sep 17 00:00:00 2001 From: Bjarki Arge Andreasen Date: Tue, 5 Aug 2025 19:05:28 +0200 Subject: [PATCH 2/3] [nrf fromlist] drivers: serial: uart_nrfx_uarte: Support DIRECT_ISR and nothreading Default to using DIRECT_ISR if nothreading. This allows the SW ISR table to be excluded if nothreading. This requires additional handling in the UARTE_DIRECT_ISR_DECLARE() macro to not do any multithreading work if CONFIG_MULTITHREADING=n Upstream PR #: 94132 Signed-off-by: Bjarki Arge Andreasen --- drivers/serial/Kconfig.nrfx | 1 + drivers/serial/uart_nrfx_uarte.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/serial/Kconfig.nrfx b/drivers/serial/Kconfig.nrfx index 7baa53b9c42..3897473371f 100644 --- a/drivers/serial/Kconfig.nrfx +++ b/drivers/serial/Kconfig.nrfx @@ -106,6 +106,7 @@ config UART_NRFX_UARTE_BOUNCE_BUF_SWAP_LATENCY config UART_NRFX_UARTE_DIRECT_ISR bool "Use direct ISR" + default y if !MULTITHREADING config UART_NRFX_UARTE_SPURIOUS_RXTO_WORKAROUND bool diff --git a/drivers/serial/uart_nrfx_uarte.c b/drivers/serial/uart_nrfx_uarte.c index 149a48d88b2..9b12d47fd3c 100644 --- a/drivers/serial/uart_nrfx_uarte.c +++ b/drivers/serial/uart_nrfx_uarte.c @@ -3461,9 +3461,11 @@ static int uarte_instance_init(const struct device *dev, IF_ENABLED(CONFIG_UART_NRFX_UARTE_DIRECT_ISR, ( \ ISR_DIRECT_DECLARE(uarte_##idx##_direct_isr) \ { \ - ISR_DIRECT_PM(); \ + IF_ENABLED(CONFIG_MULTITHREADING, (ISR_DIRECT_PM();)) \ UARTE_GET_ISR(idx)(DEVICE_DT_GET(UARTE(idx))); \ - return 1; \ + COND_CODE_1(CONFIG_MULTITHREADING, \ + (return 1;), \ + (return 0;)) \ } \ )) From ac7d74c3ea60d78122dd083bae4bee9ee242cdf8 Mon Sep 17 00:00:00 2001 From: Bjarki Arge Andreasen Date: Tue, 5 Aug 2025 18:39:31 +0200 Subject: [PATCH 3/3] [nrf fromlist] arch: common: fix missing _iheader from isr_tables.c Currently the isr_tables.c is not included as a zephyr library, hence it does not have --whole-archive applied to it, which prevents the build system from preserving the unreferenced _iheader structure which is required by gen_isr_tables.py This commit fixes the issue for gcc, while potentially breaking mwdt which is the reason isr_tables.c was put into a special library in the first place. Upstream PR #: 94132 Signed-off-by: Bjarki Arge Andreasen --- arch/common/CMakeLists.txt | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/arch/common/CMakeLists.txt b/arch/common/CMakeLists.txt index 6f84bb96351..ec2bf14eb19 100644 --- a/arch/common/CMakeLists.txt +++ b/arch/common/CMakeLists.txt @@ -9,6 +9,7 @@ zephyr_library_property(ALLOW_EMPTY TRUE) if(CONFIG_GEN_ISR_TABLES) zephyr_library_sources( + isr_tables.c sw_isr_common.c ) zephyr_library_sources_ifdef( @@ -96,19 +97,6 @@ if (DEFINED CONFIG_ARM OR DEFINED CONFIG_X86 OR DEFINED CONFIG_ARM64 OR DEFINED # Handled in ld.cmake endif() - -# isr_tables is a normal CMake library and not a zephyr_library because it -# should not be --whole-archive'd -if (CONFIG_GEN_ISR_TABLES) - add_library(isr_tables - isr_tables.c - ) - - add_dependencies(isr_tables zephyr_generated_headers) - target_link_libraries(isr_tables zephyr_interface) - zephyr_library_link_libraries(isr_tables) -endif() - if(CONFIG_COVERAGE) zephyr_compile_options($) zephyr_link_libraries_ifndef(CONFIG_NATIVE_LIBRARY $)