mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
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 <jukka.laitinen@tii.ae>
This commit is contained in:
committed by
Xiang Xiao
parent
2477914ea6
commit
6b2a5dfa01
@@ -1974,6 +1974,10 @@ static int imx9_usbinterrupt(int irq, void *context, void *arg)
|
|||||||
|
|
||||||
usbtrace(TRACE_INTENTRY(IMX9_TRACEINTID_USB), 0);
|
usbtrace(TRACE_INTENTRY(IMX9_TRACEINTID_USB), 0);
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
irqstate_t flags = enter_critical_section();
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Read the interrupts and then clear them */
|
/* Read the interrupts and then clear them */
|
||||||
|
|
||||||
disr = imx9_getreg(priv, IMX9_USBDEV_USBSTS_OFFSET);
|
disr = imx9_getreg(priv, IMX9_USBDEV_USBSTS_OFFSET);
|
||||||
@@ -1985,6 +1989,10 @@ static int imx9_usbinterrupt(int irq, void *context, void *arg)
|
|||||||
|
|
||||||
imx9_usbreset(priv);
|
imx9_usbreset(priv);
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
leave_critical_section(flags);
|
||||||
|
#endif
|
||||||
|
|
||||||
usbtrace(TRACE_INTEXIT(IMX9_TRACEINTID_USB), 0);
|
usbtrace(TRACE_INTEXIT(IMX9_TRACEINTID_USB), 0);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -2153,6 +2161,10 @@ static int imx9_usbinterrupt(int irq, void *context, void *arg)
|
|||||||
imx9_putreg(priv, IMX9_USBDEV_ENDPTNAK_OFFSET, pending);
|
imx9_putreg(priv, IMX9_USBDEV_ENDPTNAK_OFFSET, pending);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_SMP
|
||||||
|
leave_critical_section(flags);
|
||||||
|
#endif
|
||||||
|
|
||||||
usbtrace(TRACE_INTEXIT(IMX9_TRACEINTID_USB), 0);
|
usbtrace(TRACE_INTEXIT(IMX9_TRACEINTID_USB), 0);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user