From 67b17cb4d781b8d19c19f76f60f48622fb157ed0 Mon Sep 17 00:00:00 2001 From: Ville Juven Date: Fri, 25 Apr 2025 13:41:26 +0300 Subject: [PATCH] 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 --- 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 c8b21b8b4b..2a6d871998 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; }