70
70
#include "dwc_otg_hcd_if.h"
71
71
#include "dwc_otg_dbg.h"
72
72
#include "dwc_otg_driver.h"
73
+ #include "dwc_otg_hcd.h"
73
74
74
75
/**
75
76
* Gets the endpoint number from a _bEndpointAddress argument. The endpoint is
@@ -267,6 +268,7 @@ extern unsigned int g_dwc_otg_interrupt_counts[10];
267
268
static int _complete (dwc_otg_hcd_t * hcd , void * urb_handle ,
268
269
dwc_otg_hcd_urb_t * dwc_otg_urb , int32_t status )
269
270
{
271
+ uint64_t flags ;
270
272
struct urb * urb = (struct urb * )urb_handle ;
271
273
272
274
#ifdef DEBUG_SOF_FIX
@@ -356,7 +358,9 @@ static int _complete(dwc_otg_hcd_t * hcd, void *urb_handle,
356
358
#if (LINUX_VERSION_CODE < KERNEL_VERSION (2 ,6 ,30 ))
357
359
usb_hcd_giveback_urb (dwc_otg_hcd_to_hcd (hcd ), urb );
358
360
#else
361
+ DWC_SPINLOCK_IRQSAVE (hcd -> lock , & flags );
359
362
usb_hcd_unlink_urb_from_ep (dwc_otg_hcd_to_hcd (hcd ), urb );
363
+ DWC_SPINUNLOCK_IRQRESTORE (hcd -> lock , flags );
360
364
usb_hcd_giveback_urb (dwc_otg_hcd_to_hcd (hcd ), urb , status );
361
365
#endif
362
366
return 0 ;
@@ -767,6 +771,8 @@ static int urb_dequeue(struct usb_hcd *hcd, struct urb *urb)
767
771
static int urb_dequeue (struct usb_hcd * hcd , struct urb * urb , int status )
768
772
#endif
769
773
{
774
+ int rc ;
775
+ uint64_t flags ;
770
776
dwc_otg_hcd_t * dwc_otg_hcd ;
771
777
DWC_DEBUGPL (DBG_HCD , "DWC OTG HCD URB Dequeue\n" );
772
778
@@ -788,8 +794,18 @@ static int urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
788
794
#if (LINUX_VERSION_CODE < KERNEL_VERSION (2 ,6 ,30 ))
789
795
usb_hcd_giveback_urb (hcd , urb );
790
796
#else
791
- usb_hcd_unlink_urb_from_ep (hcd , urb );
792
- usb_hcd_giveback_urb (hcd , urb , status );
797
+ DWC_SPINLOCK_IRQSAVE (dwc_otg_hcd -> lock , & flags );
798
+ rc = usb_hcd_check_unlink_urb (hcd , urb , status );
799
+ if (!rc )
800
+ {
801
+ usb_hcd_unlink_urb_from_ep (hcd , urb );
802
+ }
803
+
804
+ DWC_SPINUNLOCK_IRQRESTORE (dwc_otg_hcd -> lock , flags );
805
+ if (!rc )
806
+ {
807
+ usb_hcd_giveback_urb (hcd , urb , status );
808
+ }
793
809
#endif
794
810
if (CHK_DEBUG_LEVEL (DBG_HCDV | DBG_HCD_URB )) {
795
811
DWC_PRINTF ("Called usb_hcd_giveback_urb()\n" );
0 commit comments