xiaoxiang781216 commented on code in PR #14578: URL: https://github.com/apache/nuttx/pull/14578#discussion_r1853131138
########## sched/irq/irq_csection.c: ########## @@ -232,7 +232,7 @@ irqstate_t enter_critical_section(void) DEBUGASSERT((g_cpu_irqset & (1 << cpu)) == 0); - spin_lock(&g_cpu_irqlock); + spin_lock_wo_note(&g_cpu_irqlock); Review Comment: do we need change leave_critical_section too ########## drivers/note/noterpmsg_driver.c: ########## @@ -85,6 +86,8 @@ struct noterpmsg_driver_s g_noterpmsg_driver = }, }; +volatile spinlock_t g_note_driver_lock = SP_UNLOCKED; Review Comment: remove volatile and add static ########## include/nuttx/spinlock.h: ########## @@ -528,22 +567,29 @@ static inline_function irqstate_t spin_lock_irqsave_wo_note(FAR volatile spinlock_t *lock) { irqstate_t ret; - ret = up_irq_save(); + int me; if (NULL == lock) Review Comment: let's remove NULL support in the future ########## drivers/note/noterpmsg_driver.c: ########## @@ -178,15 +181,15 @@ static bool noterpmsg_transfer(FAR struct noterpmsg_driver_s *drv, static void noterpmsg_work(FAR void *priv) { FAR struct noterpmsg_driver_s *drv = priv; - irqstate_t flags = enter_critical_section(); + irqstate_t flags = spin_lock_irqsave(&g_note_driver_lock); if (!noterpmsg_transfer(drv, false)) { work_queue(HPWORK, &drv->work, noterpmsg_work, drv, NOTE_RPMSG_WORK_DELAY); } - leave_critical_section(flags); + spin_unlock_irqrestore(&g_note_driver_lock, flags); Review Comment: ditto ########## drivers/note/noterpmsg_driver.c: ########## @@ -178,15 +181,15 @@ static bool noterpmsg_transfer(FAR struct noterpmsg_driver_s *drv, static void noterpmsg_work(FAR void *priv) { FAR struct noterpmsg_driver_s *drv = priv; - irqstate_t flags = enter_critical_section(); + irqstate_t flags = spin_lock_irqsave(&g_note_driver_lock); Review Comment: need call wo_note version ########## include/nuttx/spinlock.h: ########## @@ -515,6 +515,45 @@ static inline_function void spin_unlock(FAR volatile spinlock_t *lock) #define spin_initialize(l,s) do { SP_DMB(); *(l) = (s); } while (0) +/**************************************************************************** + * Name: spin_trylock_irqsave_wo_note + * + * Description: + * Try once to lock the spinlock. Do not wait if the spinlock is already + * locked. + * + * This implementation is the same as the above spin_trylock() except that + * it does not perform instrumentation logic. + * + * Input Parameters: + * lock - A reference to the spinlock object to lock. + * flags - flag of interrupts status + * + * Returned Value: + * SP_LOCKED - Failure, the spinlock was already locked + * SP_UNLOCKED - Success, the spinlock was successfully locked + * + * Assumptions: + * Not running at the interrupt level. + * + ****************************************************************************/ + +#ifdef CONFIG_SPINLOCK +# define spin_trylock_irqsave_wo_note(l, f) \ +({ \ Review Comment: could.we.avoid.use gcc express statement extension -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org