Skip to content

Commit 6b2a5df

Browse files
jlaitinexiaoxiang781216
authored andcommitted
imx9/imx9_usbdev.c: Fix interrupt handling in SMP mode
The interrupt handler accesses the device as well as the driver's private data. Use critical_section for mutual exclusion with drivers/usbdev, which also protects the same data with critical_section. Signed-off-by: Jukka Laitinen <[email protected]>
1 parent 2477914 commit 6b2a5df

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

arch/arm64/src/imx9/imx9_usbdev.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,10 @@ static int imx9_usbinterrupt(int irq, void *context, void *arg)
19741974

19751975
usbtrace(TRACE_INTENTRY(IMX9_TRACEINTID_USB), 0);
19761976

1977+
#ifdef CONFIG_SMP
1978+
irqstate_t flags = enter_critical_section();
1979+
#endif
1980+
19771981
/* Read the interrupts and then clear them */
19781982

19791983
disr = imx9_getreg(priv, IMX9_USBDEV_USBSTS_OFFSET);
@@ -1985,6 +1989,10 @@ static int imx9_usbinterrupt(int irq, void *context, void *arg)
19851989

19861990
imx9_usbreset(priv);
19871991

1992+
#ifdef CONFIG_SMP
1993+
leave_critical_section(flags);
1994+
#endif
1995+
19881996
usbtrace(TRACE_INTEXIT(IMX9_TRACEINTID_USB), 0);
19891997
return OK;
19901998
}
@@ -2153,6 +2161,10 @@ static int imx9_usbinterrupt(int irq, void *context, void *arg)
21532161
imx9_putreg(priv, IMX9_USBDEV_ENDPTNAK_OFFSET, pending);
21542162
}
21552163

2164+
#ifdef CONFIG_SMP
2165+
leave_critical_section(flags);
2166+
#endif
2167+
21562168
usbtrace(TRACE_INTEXIT(IMX9_TRACEINTID_USB), 0);
21572169
return OK;
21582170
}

0 commit comments

Comments
 (0)