From patchwork Thu Sep 22 08:08:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 37218 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bmz49-00026q-OD; Thu, 22 Sep 2016 08:09:09 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.84_2/mailfrontend-8) with esmtp id 1bmz45-0004Us-lb; Thu, 22 Sep 2016 10:09:08 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752745AbcIVIJC (ORCPT + 1 other); Thu, 22 Sep 2016 04:09:02 -0400 Received: from mga05.intel.com ([192.55.52.43]:37459 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752165AbcIVIJB (ORCPT ); Thu, 22 Sep 2016 04:09:01 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP; 22 Sep 2016 01:09:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,378,1470726000"; d="asc'?scan'208";a="1034576291" Received: from pipin.fi.intel.com (HELO localhost) ([10.237.68.37]) by orsmga001.jf.intel.com with ESMTP; 22 Sep 2016 01:08:59 -0700 From: Felipe Balbi To: Bin Liu Cc: linux-usb@vger.kernel.org, linux-media@vger.kernel.org Subject: Re: g_webcam Isoch high bandwidth transfer In-Reply-To: <87oa3go065.fsf@linux.intel.com> References: <20160920170441.GA10705@uda0271908> <871t0d4r72.fsf@linux.intel.com> <20160921132702.GA18578@uda0271908> <87oa3go065.fsf@linux.intel.com> User-Agent: Notmuch/0.22.1+63~g994277e (https://notmuchmail.org) Emacs/25.1.3 (x86_64-pc-linux-gnu) Date: Thu, 22 Sep 2016 11:08:52 +0300 Message-ID: <87lgyknyp7.fsf@linux.intel.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2016.9.22.80317 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, MSGID_ADDED_BY_MTA 0.05, BODY_SIZE_6000_6999 0, BODY_SIZE_7000_LESS 0, IN_REP_TO 0, LEGITIMATE_NEGATE 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, MULTIPLE_REAL_RCPTS 0, NO_URI_HTTPS 0, REFERENCES 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __ATTACHMENT_SIZE_0_10K 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CP_URI_IN_BODY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __DATE_TZ_RU 0, __FORWARDED_MSG 0, __HAS_ATTACHMENT 0, __HAS_ATTACHMENT1 0, __HAS_ATTACHMENT2 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MIME_TEXT_P2 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __REFERENCES 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_NEGATE 0, __TO_MALFORMED_2 0, __TO_NAME 0, __TO_NAME_DIFF_FROM_ACC 0, __TO_REAL_NAMES 0, __URI_IN_BODY 0, __URI_NO_WWW 0, __URI_NS , __URI_WITH_PATH 0, __USER_AGENT 0' Hi, Felipe Balbi writes: > Bin Liu writes: >> On Wed, Sep 21, 2016 at 11:01:21AM +0300, Felipe Balbi wrote: >>> >>> Hi, >>> >>> Bin Liu writes: >>> > Hi, >>> > >>> > I am trying to check Isoch high bandwidth transfer with g_webcam.ko in >>> > high-speed connection. >>> > >>> > First I hacked webcam.c as follows to enable 640x480@30fps mode. >>> > >>> > diff --git a/drivers/usb/gadget/legacy/webcam.c b/drivers/usb/gadget/legacy/webcam.c >>> > index 72c976b..9eb315f 100644 >>> > --- a/drivers/usb/gadget/legacy/webcam.c >>> > +++ b/drivers/usb/gadget/legacy/webcam.c >>> > @@ -191,15 +191,15 @@ static const struct UVC_FRAME_UNCOMPRESSED(3) uvc_frame_yuv_360p = { >>> > .bFrameIndex = 1, >>> > .bmCapabilities = 0, >>> > .wWidth = cpu_to_le16(640), >>> > - .wHeight = cpu_to_le16(360), >>> > + .wHeight = cpu_to_le16(480), >>> > .dwMinBitRate = cpu_to_le32(18432000), >>> > .dwMaxBitRate = cpu_to_le32(55296000), >>> > - .dwMaxVideoFrameBufferSize = cpu_to_le32(460800), >>> > - .dwDefaultFrameInterval = cpu_to_le32(666666), >>> > + .dwMaxVideoFrameBufferSize = cpu_to_le32(614400), >>> > + .dwDefaultFrameInterval = cpu_to_le32(333333), >>> > .bFrameIntervalType = 3, >>> > - .dwFrameInterval[0] = cpu_to_le32(666666), >>> > - .dwFrameInterval[1] = cpu_to_le32(1000000), >>> > - .dwFrameInterval[2] = cpu_to_le32(5000000), >>> > + .dwFrameInterval[0] = cpu_to_le32(333333), >>> > + .dwFrameInterval[1] = cpu_to_le32(666666), >>> > + .dwFrameInterval[2] = cpu_to_le32(1000000), >>> > }; >>> > >>> > then loaded g_webcam.ko as >>> > >>> > # modprobe g_webcam streaming_maxpacket=3072 >>> > >>> > The endpoint descriptor showing on the host is >>> > >>> > Endpoint Descriptor: >>> > bLength 7 >>> > bDescriptorType 5 >>> > bEndpointAddress 0x8d EP 13 IN >>> > bmAttributes 5 >>> > Transfer Type Isochronous >>> > Synch Type Asynchronous >>> > Usage Type Data >>> > wMaxPacketSize 0x1400 3x 1024 bytes >>> > bInterval 1 >>> > >>> > However the usb bus trace shows only one transaction with 1024-bytes packet in >>> > every SOF. The host only sends one IN packet in every SOF, I am expecting 2~3 >>> > 1024-bytes transactions, since this would be required to transfer 640x480@30fps >>> > YUV frames in high-speed. >>> > >>> > DId I miss anything in the setup? >>> >>> MUSB or DWC3? This looks like a UDC bug to me. Can you show a screenshot >> >> Happened on both MUSB and DWC3. >> >>> of your bus analyzer? When host sends IN token, are you replying with >> >> The trace screenshot on DWC3 is attached. >> >>> DATA0, DATA1 or DATA2? >> >> Good hint! It is DATA0! > > yeah, should've been DATA2. I'll check if we're missing anything for > High Bandwidth Iso on DWC3. Can you confirm if it works of tails on > DWC3? On your follow-up mail you mentioned it's a bug in MUSB. What > about DWC3? I'm assuming DWC3 really breaks. Here's a patch for that: 8<---------------------------------- cut here ---------------------------------- From 62807011c00055785575bb39d92bfe8836817e2f Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 22 Sep 2016 11:01:01 +0300 Subject: [PATCH] usb: dwc3: gadget: set PCM1 field of isochronous-first TRBs In case of High-Speed, High-Bandwidth endpoints, we need to tell DWC3 that we have more than one packet per interval. We do that by setting PCM1 field of Isochronous-First TRB. Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/gadget.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 602f12254161..106623faf060 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -787,6 +787,9 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, unsigned length, unsigned chain, unsigned node) { struct dwc3_trb *trb; + struct dwc3 *dwc = dep->dwc; + struct usb_gadget *gadget = &dwc->gadget; + enum usb_device_speed speed = speed; dwc3_trace(trace_dwc3_gadget, "%s: req %p dma %08llx length %d%s", dep->name, req, (unsigned long long) dma, @@ -813,10 +816,17 @@ static void dwc3_prepare_one_trb(struct dwc3_ep *dep, break; case USB_ENDPOINT_XFER_ISOC: - if (!node) + if (!node) { trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS_FIRST; - else + + if (speed == USB_SPEED_HIGH) { + struct usb_endpoint *ep = &dep->endpoint; + u8 pkts = DIV_ROUNDUP(ep->maxpacket, 1024); + trb->size |= DWC3_TRB_SIZE_PCM1(pkts - 1); + } + } else { trb->ctrl = DWC3_TRBCTL_ISOCHRONOUS; + } /* always enable Interrupt on Missed ISOC */ trb->ctrl |= DWC3_TRB_CTRL_ISP_IMI;