UPSTREAM: usb: dwc2: host: spinlock release channel
authorGregory Herrero <gregory.herrero@intel.com>
Thu, 5 Nov 2015 08:41:41 +0000 (09:41 +0100)
committerHuang, Tao <huangtao@rock-chips.com>
Tue, 3 Jan 2017 09:50:13 +0000 (17:50 +0800)
Prevent dwc2 driver from accessing channel while it frees it.

Change-Id: Ia3c1593d84f3bb164ca165c1f35e574fd6afbb8b
Acked-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 2b046bc5aaefd4aba7195e6a73afe14f7f786692)

drivers/usb/dwc2/hcd_ddma.c

index 4801e693353a4f9220ab0e391449ea69b22bf33e..a76a58c35feabfa5ffc1a7da06b6147d50874a15 100644 (file)
@@ -360,6 +360,8 @@ err0:
  */
 void dwc2_hcd_qh_free_ddma(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
 {
+       unsigned long flags;
+
        dwc2_desc_list_free(hsotg, qh);
 
        /*
@@ -369,8 +371,10 @@ void dwc2_hcd_qh_free_ddma(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
         * when it comes here from endpoint disable routine
         * channel remains assigned.
         */
+       spin_lock_irqsave(&hsotg->lock, flags);
        if (qh->channel)
                dwc2_release_channel_ddma(hsotg, qh);
+       spin_unlock_irqrestore(&hsotg->lock, flags);
 
        if ((qh->ep_type == USB_ENDPOINT_XFER_ISOC ||
             qh->ep_type == USB_ENDPOINT_XFER_INT) &&