Skip to contentSkip to conversation

usb: dwc3: imx: avoid calling imx suspend/resume callbacks twice

PATCH In review Xu Yang 2 participants 2 messages Mar 17 – Mar 18

Subsystems (3)
lore
Share & tools
lore

Xu Yang

author
#0 lore raw

PATCH 1/1 usb: dwc3: imx: avoid calling imx suspend/resume callbacks twice

If a runtime suspend is executed followed by a system suspend, the driver may invoke dwc3_imx_suspend() twice, which causes enable_irq() to be called twice as well. This leads to an unbalanced IRQ state and may trigger warnings or malfunction. Prevent this by checking the pm_suspended flag before running the imx suspend/resume path.

Fixes 76fc9452a6bf ("usb: dwc3: introduce flatten model driver of i.MX Soc")
---
 drivers/usb/dwc3/dwc3-imx.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/usb/dwc3/dwc3-imx.c +6 -0
index 303708f7d79a..973a486b544d 100644
@@ -288,6 +288,9 @@ static void dwc3_imx_remove(struct platform_device *pdev)
 
 static void dwc3_imx_suspend(struct dwc3_imx *dwc_imx, pm_message_t msg)
 {
+	if (dwc_imx->pm_suspended)
+		return;
+
 	if (PMSG_IS_AUTO(msg) || device_may_wakeup(dwc_imx->dev))
 		dwc3_imx_wakeup_enable(dwc_imx, msg);
 
@@ -299,6 +302,9 @@ static void dwc3_imx_resume(struct dwc3_imx *dwc_imx, pm_message_t msg)
 {
 	struct dwc3	*dwc = &dwc_imx->dwc;
 
+	if (!dwc_imx->pm_suspended)
+		return;
+
 	dwc_imx->pm_suspended = false;
 	if (!dwc_imx->wakeup_pending)
 		disable_irq_nosync(dwc_imx->irq);
Signature · 1 line
2.34.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 40 lines · Xu Yang

If a runtime suspend is executed followed by a system suspend, the driver may invoke dwc3_imx_suspend() twice, which causes enable_irq() to be called twice as well. This leads to an unbalanced IRQ state and may trigger warnings or malfunction. Prevent this by checking the pm_suspended flag before running the imx suspend/resume path.

Fixes 76fc9452a6bf ("usb: dwc3: introduce flatten model driver of i.MX Soc")
---
 drivers/usb/dwc3/dwc3-imx.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/usb/dwc3/dwc3-imx.c +6 -0
index 303708f7d79a..973a486b544d 100644
@@ -288,6 +288,9 @@ static void dwc3_imx_remove(struct platform_device *pdev)
 
 static void dwc3_imx_suspend(struct dwc3_imx *dwc_imx, pm_message_t msg)
 {
+	if (dwc_imx->pm_suspended)
+		return;
+
 	if (PMSG_IS_AUTO(msg) || device_may_wakeup(dwc_imx->dev))
 		dwc3_imx_wakeup_enable(dwc_imx, msg);
 
@@ -299,6 +302,9 @@ static void dwc3_imx_resume(struct dwc3_imx *dwc_imx, pm_message_t msg)
 {
 	struct dwc3	*dwc = &dwc_imx->dwc;
 
+	if (!dwc_imx->pm_suspended)
+		return;
+
 	dwc_imx->pm_suspended = false;
 	if (!dwc_imx->wakeup_pending)
 		disable_irq_nosync(dwc_imx->irq);
Signature · 1 line
2.34.1

BR,
Thinh