Re: g_audio breaks with dwc3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Felipe,

On 30/10/2019 13:26, Felipe Balbi wrote:

Hi,

Roger Quadros <rogerq@xxxxxx> writes:
      irq/170-dwc3-1240  [000] d...    85.450564: dwc3_gadget_giveback: ep1out: req ee75d6ac length 0/256 zsI ==> -108
      irq/170-dwc3-1240  [000] d...    85.450566: dwc3_gadget_giveback: ep1out: req c26c10a3 length 0/256 zsI ==> -108
      irq/170-dwc3-1240  [000] d...    85.450567: dwc3_gadget_giveback: : req d4301893 length 0/0 zsI ==> 0

Giveback happens on above two reqs after they are already freed. Could
it be due to f_uac2 / u_audio.c performing usb_ep_free_request()
immediately after usb_ep_dequeue() without waiting for completion?

this could be a race condition. Add a trace_printk() at the cancelation,
see if the request is moved to cancelled list.

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 86dc1db788a9..affc2f7a929d 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1513,6 +1513,7 @@ static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep)
   	struct dwc3_request		*tmp;
list_for_each_entry_safe(req, tmp, &dep->cancelled_list, list) {
+		trace_printk("---> completing cancellation of req %p\n", req);
   		dwc3_gadget_ep_skip_trbs(dep, req);
   		dwc3_gadget_giveback(dep, req, -ECONNRESET);
   	}
@@ -1551,6 +1552,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
   			if (!r->trb)
   				goto out0;
+ trace_printk("---> req %p moved to cancelled\n", req);
   			dwc3_gadget_move_cancelled_request(req);
   			if (dep->flags & DWC3_EP_TRANSFER_STARTED)
   				goto out0;



Below is trace with above debug patch applied.

Did it fail the same way? It doesn't look like in the trace.

Does this help?

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 86dc1db788a9..a9aba716bf80 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -707,6 +707,12 @@ static void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep)
dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
  	}
+
+	while (!list_empty(&dep->cancelled_list)) {
+		req = next_request(&dep->cancelled_list);
+
+		dwc3_gadget_giveback(dep, req, -ESHUTDOWN);
+	}
  }
/**


Yes, this fixes the issue.
I'm able to use aplay/arecord as well. Thanks!

cheers,
-roger
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux