]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
usb: dwc3: Remove DWC3 locking during gadget suspend/resume
authorWesley Cheng <quic_wcheng@quicinc.com>
Thu, 1 Sep 2022 19:36:22 +0000 (12:36 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:22:58 +0000 (16:22 +0200)
commit 5265397f94424eaea596026fd34dc7acf474dcec upstream.

Remove the need for making dwc3_gadget_suspend() and dwc3_gadget_resume()
to be called in a spinlock, as dwc3_gadget_run_stop() could potentially
take some time to complete.

Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
Link: https://lore.kernel.org/r/20220901193625.8727-3-quic_wcheng@quicinc.com
Signed-off-by: Selvarasu Ganesan <selvarasu.g@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc3/core.c
drivers/usb/dwc3/gadget.c

index 1264683d45f20bfe32c36db980d167b4773a79de..9988424aa91f7d7acf1ed04c9934c3cf3f460bd8 100644 (file)
@@ -1742,9 +1742,7 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg)
        case DWC3_GCTL_PRTCAP_DEVICE:
                if (pm_runtime_suspended(dwc->dev))
                        break;
-               spin_lock_irqsave(&dwc->lock, flags);
                dwc3_gadget_suspend(dwc);
-               spin_unlock_irqrestore(&dwc->lock, flags);
                synchronize_irq(dwc->irq_gadget);
                dwc3_core_exit(dwc);
                break;
@@ -1805,9 +1803,7 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg)
                        return ret;
 
                dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE);
-               spin_lock_irqsave(&dwc->lock, flags);
                dwc3_gadget_resume(dwc);
-               spin_unlock_irqrestore(&dwc->lock, flags);
                break;
        case DWC3_GCTL_PRTCAP_HOST:
                if (!PMSG_IS_AUTO(msg)) {
index 8809c0f84af080fdae40c915636c6aedf2dbcfe1..a2aa37ca6ad2cadeb2fedf1b0f87c56edbb40fe2 100644 (file)
@@ -4115,12 +4115,17 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
 
 int dwc3_gadget_suspend(struct dwc3 *dwc)
 {
+       unsigned long flags;
+
        if (!dwc->gadget_driver)
                return 0;
 
        dwc3_gadget_run_stop(dwc, false, false);
+
+       spin_lock_irqsave(&dwc->lock, flags);
        dwc3_disconnect_gadget(dwc);
        __dwc3_gadget_stop(dwc);
+       spin_unlock_irqrestore(&dwc->lock, flags);
 
        return 0;
 }