This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 67b17cb4d781b8d19c19f76f60f48622fb157ed0
Author: Ville Juven <ville.ju...@unikie.com>
AuthorDate: Fri Apr 25 13:41:26 2025 +0300

    mpfs/mpfs_usb.c: Fix interrupt handling in SMP mode
    
    The interrupt handler accesses the device as well as the driver's private
    data. Thus, must take the big kernel lock in SMP mode to protect them.
    
    Signed-off-by: Jukka Laitinen <jukka.laiti...@tii.ae>
---
 arch/risc-v/src/mpfs/mpfs_usb.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/risc-v/src/mpfs/mpfs_usb.c b/arch/risc-v/src/mpfs/mpfs_usb.c
index c8b21b8b4b3..2a6d8719983 100644
--- a/arch/risc-v/src/mpfs/mpfs_usb.c
+++ b/arch/risc-v/src/mpfs/mpfs_usb.c
@@ -3430,6 +3430,10 @@ static int mpfs_usb_interrupt(int irq, void *context, 
void *arg)
   uint16_t pending_tx_ep;
   int i;
 
+#ifdef CONFIG_SMP
+  irqstate_t flags = enter_critical_section();
+#endif
+
   /* Get the device interrupts */
 
   isr = getreg8(MPFS_USB_IRQ);
@@ -3455,6 +3459,9 @@ static int mpfs_usb_interrupt(int irq, void *context, 
void *arg)
       priv->usbdev.dualspeed = 1;
 #endif
 
+#ifdef CONFIG_SMP
+      leave_critical_section(flags);
+#endif
       return OK;
     }
 
@@ -3539,6 +3546,9 @@ static int mpfs_usb_interrupt(int irq, void *context, 
void *arg)
       mpfs_resume(priv);
     }
 
+#ifdef CONFIG_SMP
+  leave_critical_section(flags);
+#endif
   return OK;
 }
 

Reply via email to