Skip to contentSkip to conversation

g_audio regression on dwc3 udc

DISCUSSION Bin Liu 1 participant 1 message Aug 13, 2018 USB

lore
Share & tools
lore

Bin Liu

author
#0 lore raw

Hi Thinh,

Quoted 82 lines · Thinh Nguyen

Hi Bin,

Quoted 13 lines · Bin Liu

Hi Felipe,

I noticed a regression on g_audio (uac2) with dwc3 udc on v4.14:

- nosound in playback
- playback can only play once, the following error happens from the 2nd playback

aplay: set_params:1361: Unable to install hw params:

A manual bisect tells the two issues are seperate and the regression happens in v4.11-rc2 with the following two patches.

Quoted 6 lines

40d829fb2ec63 ("usb: dwc3: gadget: Correct ISOC DATA PIDs for short packets")

which cases the first no-sound issue.

ep->mult is already 1 from g_audio, so mult-- leads to incorrect value. The following change solves it.

I believe v4.14.40 is missing this patch regarding that issue:
ec5bb87e4e2a ("usb: dwc3: gadget: Fix PCM1 for ISOC EP with ep->mult less than 3")

Quoted 45 lines
drivers/usb/dwc3/gadget.c +2 -2
index f92e2f2c7fbe..758cc258895c 100644
@@ -930,10 +930,10 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *trb,
                                unsigned int mult = ep->mult - 1;
                                unsigned int maxp = usb_endpoint_maxp(ep->desc);
 
-                               if (length <= (2 * maxp))
+                               if (mult && length <= (2 * maxp))
                                        mult--;
 
-                               if (length <= maxp)
+                               if (mult && length <= maxp)
                                        mult--;
 
                                trb->size |= DWC3_TRB_SIZE_PCM1(mult);

cf3113d893d4 ("usb: dwc3: gadget: properly increment dequeue pointer on ep_dequeue")

which causes the multiple playback failure. The following hack covers it.

drivers/usb/dwc3/gadget.c +2 -1
index f92e2f2c7fbe..758cc258895c 100644
@@ -1411,7 +1411,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
                if (r == req) {
                        /* wait until it is processed */
                        dwc3_stop_active_transfer(dwc, dep->number, true);
-
+#if 0
                        /*
                         * If request was already started, this means we had to
                         * stop the transfer. With that we also need to ignore
@@ -1473,6 +1473,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
                                        dwc3_ep_inc_deq(dep);
                                }
                        }
+#endif
                        goto out1;
                }
                dev_err(dwc->dev, "request %pK was not queued to %s\n",
Quoted 5 lines

With the two changes above, g_audio works fine with v4.14.40, but not with v4.18-rc7, in which the console is flooded with following message.

u_audio_iso_complete: iso_complete status(-18) 0/256

Pierre Le Magourou attempted to fix the second issue with this patch (though the patch may need rework):
https://patchwork.kernel.org/patch/10509639/

Quoted 2 lines

You can try it out. It works fine when I tested it on HAPS platform (using Felipe's next branch).

Thanks for the hints. With the two patches you pointed, g_audio works fine on v4.14.40.

Regards,
-Bin.