Skip to content

Commit

Permalink
hrt_ioctl: Fix issue with SMP
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pussuw authored and jlaitine committed Jan 10, 2025
1 parent a0d7d92 commit 4fc4618
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions platforms/nuttx/src/px4/common/hrt_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,16 @@ 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)) {
sq_rem(&e->list_item, &callout_queue);
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);
Expand Down

0 comments on commit 4fc4618

Please sign in to comment.