Skip to content

Commit 4d0acce

Browse files
ppryga-nordicrugeGerritsen
authored andcommitted
mpsl: init: Stop triggering sched and PM from ZLI ISRs
Zero latensy interrupt handlers are not allowed to use kernel APIs. Zephyr documentation states that use of kernel APIs must be considered as undefined behavior. The same goes for triggering kernel scheduler by `return 1;` at end of an ISR and use of PM subsystem related macros like ISR_DIRECT_PM. Signed-off-by: Piotr Pryga <[email protected]>
1 parent f6aba40 commit 4d0acce

File tree

1 file changed

+5
-32
lines changed

1 file changed

+5
-32
lines changed

subsys/mpsl/init/mpsl_init.c

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,6 @@ static void mpsl_timer0_isr_wrapper(const void *args)
222222
ARG_UNUSED(args);
223223

224224
MPSL_IRQ_TIMER0_Handler();
225-
226-
ISR_DIRECT_PM();
227225
}
228226

229227
static void mpsl_rtc0_isr_wrapper(const void *args)
@@ -236,17 +234,13 @@ static void mpsl_rtc0_isr_wrapper(const void *args)
236234
}
237235

238236
MPSL_IRQ_RTC0_Handler();
239-
240-
ISR_DIRECT_PM();
241237
}
242238

243239
static void mpsl_radio_isr_wrapper(const void *args)
244240
{
245241
ARG_UNUSED(args);
246242

247243
MPSL_IRQ_RADIO_Handler();
248-
249-
ISR_DIRECT_PM();
250244
}
251245

252246
static void mpsl_lib_irq_disable(void)
@@ -277,12 +271,7 @@ ISR_DIRECT_DECLARE(mpsl_timer0_isr_wrapper)
277271
{
278272
MPSL_IRQ_TIMER0_Handler();
279273

280-
ISR_DIRECT_PM();
281-
282-
/* We may need to reschedule in case a radio timeslot callback
283-
* accesses zephyr primitives.
284-
*/
285-
return 1;
274+
return 0;
286275
}
287276

288277
ISR_DIRECT_DECLARE(mpsl_rtc0_isr_wrapper)
@@ -293,24 +282,14 @@ ISR_DIRECT_DECLARE(mpsl_rtc0_isr_wrapper)
293282
}
294283
MPSL_IRQ_RTC0_Handler();
295284

296-
ISR_DIRECT_PM();
297-
298-
/* No need for rescheduling, because the interrupt handler
299-
* does not access zephyr primitives.
300-
*/
301285
return 0;
302286
}
303287

304288
ISR_DIRECT_DECLARE(mpsl_radio_isr_wrapper)
305289
{
306290
MPSL_IRQ_RADIO_Handler();
307291

308-
ISR_DIRECT_PM();
309-
310-
/* We may need to reschedule in case a radio timeslot callback
311-
* accesses zephyr primitives.
312-
*/
313-
return 1;
292+
return 0;
314293
}
315294
#endif /* IS_ENABLED(CONFIG_MPSL_DYNAMIC_INTERRUPTS) */
316295

@@ -492,18 +471,12 @@ static int mpsl_lib_init_sys(void)
492471
/* Ensure IRQs are disabled before attaching. */
493472
mpsl_lib_irq_disable();
494473

495-
/* We may need to reschedule in case a radio timeslot callback
496-
* accesses Zephyr primitives.
497-
* The RTC0 interrupt handler does not access zephyr primitives,
498-
* however, as this decision needs to be made during build-time,
499-
* rescheduling is performed to account for user-provided handlers.
500-
*/
501474
ARM_IRQ_DIRECT_DYNAMIC_CONNECT(MPSL_TIMER_IRQn, MPSL_HIGH_IRQ_PRIORITY, IRQ_CONNECT_FLAGS,
502-
reschedule);
475+
no_reschedule);
503476
ARM_IRQ_DIRECT_DYNAMIC_CONNECT(MPSL_RTC_IRQn, MPSL_HIGH_IRQ_PRIORITY, IRQ_CONNECT_FLAGS,
504-
reschedule);
477+
no_reschedule);
505478
ARM_IRQ_DIRECT_DYNAMIC_CONNECT(MPSL_RADIO_IRQn, MPSL_HIGH_IRQ_PRIORITY, IRQ_CONNECT_FLAGS,
506-
reschedule);
479+
no_reschedule);
507480

508481
mpsl_lib_irq_connect();
509482
#else /* !IS_ENABLED(CONFIG_MPSL_DYNAMIC_INTERRUPTS) */

0 commit comments

Comments
 (0)