RE: usb: gadget: dwc2: not getting audio data

Minas Harutyunyan
2022-12-14T06:11:32Z

Hi Palak,

On 12/12/2022 11:44 PM, Palak SHAH wrote:
>From: Palak SHAH <palak.shah@raritan.com>
>Sent: Monday, December 12, 2022 11:44 PM
>To: Minas Harutyunyan <hminas@synopsys.com>; Maynard CABIENTE
><maynard.cabiente@raritan.com>
>Cc: linux-usb@vger.kernel.org
>Subject: RE: usb: gadget: dwc2: not getting audio data
>
>Hi Minas,
>I applied the patch you sent this morning and attached the logs, I have also
>attached the USB sniffer data collected using the Ellisys software. The
>previous email delivery failed because I attached the usb sniffer data (txt
>file) which was 14 MB.
>
>I am attaching the USB sniffer log file here in the .ufo format, which can
>be viewed by downloading the ellisys software.
>
>Link to download the software -
>https://urldefense.com/v3/__https://www.ellisys.com/products/usbex200/index.
>php__;!!A4F2R9G_pg!dy4zWJkC54FVl2XV1ItXNh8mqShA5i_kTiC8ZUSbap-
>7vK1yNeFrI9_cB72IdRISlzd4ajzH-a8UYdtRstfheBb1_cUR$
>
>Thanks,
>Palak
>

Please apply new patch below and test:

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 8b15742d9e8a..c88c084be189 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1355,12 +1355,16 @@ static bool dwc2_gadget_target_frame_elapsed(struct
dwc2_hsotg_ep *hs_ep)
if (hsotg->gadget.speed != USB_SPEED_HIGH)
limit >>= 3;

- if (!frame_overrun && current_frame >= target_frame)
+ if (!frame_overrun && current_frame >= target_frame) {
+ dev_dbg(hsotg->dev, "%s: target = 0x%08x current = =0x%08x\n",
__func__, target_frame, current_frame);
return true;
+ }

if (frame_overrun && current_frame >= target_frame &&
- ((current_frame - target_frame) < limit / 2))
+ ((current_frame - target_frame) < limit / 2)) {
+ dev_dbg(hsotg->dev, "%s: target = 0x%08x current = =0x%08x\n",
__func__, target_frame, current_frame);
return true;
+ }

return false;
}
@@ -2218,6 +2222,8 @@ static void dwc2_gadget_complete_isoc_request_ddma(struct
dwc2_hsotg_ep *hs_ep)

dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, 0);

+ dev_dbg(hsotg->dev, "%s: compl_desc # %d\n", __func__,
hs_ep->compl_desc);
+
hs_ep->compl_desc++;
if (hs_ep->compl_desc > (MAX_DMA_DESC_NUM_HS_ISOC - 1))
hs_ep->compl_desc = 0;
@@ -2892,11 +2898,14 @@ static void dwc2_gadget_handle_out_token_ep_disabled(struct
dwc2_hsotg_ep *ep)
return;

if (using_desc_dma(hsotg)) {
- if (ep->target_frame == TARGET_FRAME_INITIAL) {
+
+ dev_dbg(hsotg->dev, "%s: target_frame = 0x%08x\n",
__func__, ep->target_frame);
+
+// if (ep->target_frame == TARGET_FRAME_INITIAL) {
/* Start first ISO Out */
ep->target_frame = hsotg->frame_number;
dwc2_gadget_start_isoc_ddma(ep);
- }
+// }
return;
}

@@ -3159,8 +3168,12 @@ static void dwc2_hsotg_epint(struct dwc2_hsotg
*hsotg, unsigned int idx,

if (ints & DXEPINT_BNAINTR) {
dev_dbg(hsotg->dev, "%s: BNA interrupt\n", __func__);
- if (hs_ep->isochronous)
+ if (hs_ep->isochronous) {
+ dev_dbg(hsotg->dev, "%s: DxEPCTL 0x%08x\n",
__func__, dwc2_readl(hsotg, epctl_reg));
+ dev_dbg(hsotg->dev, "%s: before GRXSTSR 0x%08x\n",
__func__, dwc2_readl(hsotg, GRXSTSR));
dwc2_gadget_handle_isoc_bna(hs_ep);
+ dev_dbg(hsotg->dev, "%s: after GRXSTSR 0x%08x\n",
__func__, dwc2_readl(hsotg, GRXSTSR));
+ }
}

if (dir_in && !hs_ep->isochronous) {
@@ -4277,6 +4290,12 @@ static int dwc2_hsotg_ep_disable(struct usb_ep *ep)
hs_ep->fifo_index = 0;
hs_ep->fifo_size = 0;

+ if (using_desc_dma(hsotg) && hs_ep->isochronous) {
+ hs_ep->target_frame = TARGET_FRAME_INITIAL;
+ hs_ep->next_desc = 0;
+ hs_ep->compl_desc = 0;
+ }
+
return 0;
}

Thanks,
Minas