From a0bdde898484a4b4fe158d27fa6f41d1c4f7bff3 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Fri, 10 Jan 2025 15:09:16 +0200 Subject: [PATCH] hrt_ioctl: Fix issue with SMP The interrupt handler needs to take the spinlock as well, as another CPU can be futzing around with the lists when another CPU takes the HRT trap. --- platforms/nuttx/src/px4/common/hrt_ioctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platforms/nuttx/src/px4/common/hrt_ioctl.c b/platforms/nuttx/src/px4/common/hrt_ioctl.c index c0f2e9c164c8..c545f423e3c2 100644 --- a/platforms/nuttx/src/px4/common/hrt_ioctl.c +++ b/platforms/nuttx/src/px4/common/hrt_ioctl.c @@ -181,6 +181,7 @@ void hrt_usr_call(void *arg) { // This is called from hrt interrupt struct usr_hrt_call *e = (struct usr_hrt_call *)arg; + irqstate_t flags = spin_lock_irqsave_wo_note(&g_hrt_ioctl_lock); // Make sure the event is not already in flight if (!entry_inlist(&callout_inflight, (sq_entry_t *)e)) { @@ -188,6 +189,8 @@ void hrt_usr_call(void *arg) sq_addfirst(&e->list_item, &callout_inflight); px4_sem_post(e->entry.callout_sem); } + + spin_unlock_irqrestore_wo_note(&g_hrt_ioctl_lock, flags); } int hrt_ioctl(unsigned int cmd, unsigned long arg);