CONFIG_ZERO_LATENCY_IRQS and kernel services

Hello !

I can use ZERO latency IRQ with both methods of define interrupts :

IRQ_DIRECT_CONNECT(TIMER2_IRQn, CONFIG_TIMER_IRQ_PRIORITY,
timer2_isr_wrapper,
IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS) ?
IRQ_ZERO_LATENCY : 0);
 
or 
IRQ_CONNECT(TIMER2_IRQn, CONFIG_TIMER_IRQ_PRIORITY, TIMER2_IRQHandler, NULL,
IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS) ? IRQ_ZERO_LATENCY : 0);
And it is mentioned that not all services can be used in ISR :
"
Since Zero-latency ISRs will run in the same priority or possibly at higher priority than the rest of the kernel they cannot use any kernel functionality.
"

What services they talking about ?

Can I use k_sem_give() for example ?

I can see all ZERO latency interrupts have priority 0.

I have try to define CONFIG_ZERO_LATENCY_LEVELS=2 or 3 but there some compilation errors.


Regards,
Eugene



Parents
  • Hi,

    "
    Since Zero-latency ISRs will run in the same priority or possibly at higher priority than the rest of the kernel they cannot use any kernel functionality.
    "

    Here is a list over kernel serices, https://docs.zephyrproject.org/3.1.0/kernel/services/index.html

    semaphores, and the use of k_sem_give() is a kernel service.

  • Hi Sigurd !

    So I can think like this

    IRQ_DIRECT_CONNECT have better latency than IRQ_CONNECT and adding IRQ_ZERO_LATENCY improve both ways of interrupt registration. But in case of IRQ_ZERO_LATENCY flag I can't use semaphores and other kernel services.

    I hope I can use in any ZERO_LATENCY ISR APIs for manipulate with other ZERO_LATENCY ISR.

    irq_disable()/irq_enable();
    nrf_radio_int_disable(NRF_RADIO, ~((uint32_t)0));
    NRFX_IRQ_PENDING_CLEAR(RADIO_IRQn);

    May be I can schedule/trigger other interrupt ( like SW one) if I need to force some thread to run.

    Or what is common technique for workaround in case of semaphore usage from Zero interrupts ?

    Regards,

    Eugene

  • Hi Sigurd !

    Yes you can 

    But if you set 

    CONFIG_ZERO_LATENCY_LEVELS=2 or 3,
    some gpio component complain about build error.
    Most probably not all components are updated.
    And only ztest
    /home/user/ncs/v2.3.0/zephyr/tests/arch/arm/arm_irq_zero_latency_levels/prj.conf
    try to use it, others stay with defaults.

    CONFIG_ZERO_LATENCY_IRQS=y
    CONFIG_ZERO_LATENCY_LEVELS=2

    you will see

    from /home/user/ncs/v2.3.0/zephyr/drivers/gpio/gpio_nrfx.c:8:
    /home/user/ncs/v2.3.0/zephyr/drivers/gpio/gpio_nrfx.c: In function 'gpio_nrfx_init':
    /home/user/ncs/v2.3.0/zephyr/include/zephyr/toolchain/gcc.h:78:36: error: static assertion failed: "Invalid interrupt priority. Values must not exceed IRQ_PRIO_LOWEST"
    78 | #define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG)
    | ^~~~~~~~~~~~~~
    /home/user/ncs/v2.3.0/zephyr/include/zephyr/arch/arm/aarch32/irq.h:105:9: note: in expansion of macro 'BUILD_ASSERT'
    105 | BUILD_ASSERT(((flags_p & IRQ_ZERO_LATENCY) && \
    | ^~~~~~~~~~~~
    /home/user/ncs/v2.3.0/zephyr/include/zephyr/arch/arm/aarch32/irq.h:128:9: note: in expansion of macro '_CHECK_PRIO'
    128 | _CHECK_PRIO(priority_p, flags_p) \
    | ^~~~~~~~~~~
    /home/user/ncs/v2.3.0/zephyr/include/zephyr/irq.h:49:9: note: in expansion of macro 'ARCH_IRQ_CONNECT'
    49 | ARCH_IRQ_CONNECT(irq_p, priority_p, isr_p, isr_param_p, flags_p)
    | ^~~~~~~~~~~~~~~~
    /home/user/ncs/v2.3.0/zephyr/drivers/gpio/gpio_nrfx.c:378:9: note: in expansion of macro 'IRQ_CONNECT'
    378 | IRQ_CONNECT(DT_IRQN(GPIOTE_NODE), DT_IRQ(GPIOTE_NODE, priority),
    | ^~~~~~~~~~~
    [127/192] Building C object zephyr/drivers/mbox/CMakeFiles/drivers__mbox.dir/mbox_nrfx_ipc.c.obj
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: /home/user/ncs/toolchains/v2.3.0/usr/local/bin/cmake --build /home/user/nsctest/timeslot/build

    br, Eugene
  • Hi,

    You might need to increase it further, try e.g. 10

  • Hi !

    Build error vanish at 

    CONFIG_ZERO_LATENCY_LEVELS=7
    but we have 7 as max level in ARM
    But Image is not boot up to main().
    I mean assert in gpio_nrfx.c bug or feature ?
    Some fix need to be done or not ?
    Regards, Eugene
  • Hiihtaja said:
    CONFIG_ZERO_LATENCY_LEVELS=7
    but we have 7 as max level in ARM
    But Image is not boot up to main().

    It boots fine to main() here when I set it to 10. What samples did you test this on?

Reply Children
Related