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

Minas Harutyunyan
2022-12-12T12:27:50Z

Hi Palak,

On 12/9/2022 8:51 PM, Palak SHAH wrote:
>From: Palak SHAH <palak.shah@raritan.com>
>Sent: Friday, December 9, 2022 8:51 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,
>Please find attached the logs, after I applied the patch you send.
>
>Thanks,
>Palak
>

Could you please apply below patch and send me debug log.
Also, please send me gadget trace.

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 8b15742d9e8a..fd2c821598a7 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",
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",
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,6 +2898,9 @@ static void dwc2_gadget_handle_out_token_ep_disabled(struct
dwc2_hsotg_ep *ep)
return;

if (using_desc_dma(hsotg)) {
+
+ 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;
@@ -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