Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp191955imu; Thu, 10 Jan 2019 21:41:17 -0800 (PST) X-Google-Smtp-Source: ALg8bN77J34s79utliYnF/cYxT788z6xtctpc5r/XD7prOotQT08VUapoESbMh3W6uo/LoF+obBr X-Received: by 2002:a62:1289:: with SMTP id 9mr13340387pfs.102.1547185277338; Thu, 10 Jan 2019 21:41:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547185277; cv=none; d=google.com; s=arc-20160816; b=gz5qxqW/Y9j6nBu+Tx2lCXSW61gpOmHbcgoBRSyV+Q93R55geTFT6LJjflAHGbJmNj FS6tWrxm7g21rtjN/ieFRMo/LmwVSliWgmI+T+jB+5KiMjsYiDdTUtwLHqx2mIFiGjbT +cVorh5hX4cQgRr6Jt9uPkI1pfuvOLfgvn2wv6mHDgPbT5F4sE04SJkpP4BCaO3nw2qR msic1ZaFQYbqow2Z5KM8b8I8EAeFMuyV4skF6mmGBcIPKk8pYYd77ytmz/0NJr1BCd67 vFNqnx3ELKCCfZZ9NfrIHWxUvJ1jvtUxMCeAADr96H/yRPHUvYJY7M1jGffZ/naemjku RAYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:to :from:date:dkim-signature; bh=F3n7lLWPGkUj4zPrINa98+s1VkkwCdIO73f7j5pJV+g=; b=lB1Cz+loSD5jmLGPPQnAJPPGTa5IZVkrldD+ZNIg1OOIZngj31aL8vYzQiiSHrZsVT t2liPfrvImZmsompAylipO5jCwRyv712cZqFVn1BsSNtOcoVhhELnS340JOCIPpkLl3H xPN5LceiQB/AiSOw5MG5TVL75l7jXc7yaGwAoqIBMZX6ejDF3rq3CKDzNAiOOcW7L/bt /7us5ddMaKSJCQvZv9AlEwwUI5fd1WZQbNfHdHaCv12S7uwvLM/zPVcPD8LMYdOv6q3R EwhwXENcxDXTbjRXhMD3weOCgS0raCkeI3uVogkH/nzx4wZKv8Y9c3fStKhf6QV2PXnD G7UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=seUU0+8i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bg9si11297939plb.317.2019.01.10.21.41.02; Thu, 10 Jan 2019 21:41:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=seUU0+8i; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729961AbfAKFcK (ORCPT + 99 others); Fri, 11 Jan 2019 00:32:10 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:56794 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725769AbfAKFcJ (ORCPT ); Fri, 11 Jan 2019 00:32:09 -0500 Received: from localhost.localdomain (unknown [96.44.9.117]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C6BFB547; Fri, 11 Jan 2019 06:32:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1547184727; bh=zZWhcZaFDqdCn/J3pF4ZQ+Rvq6k8QPOcP6iSqJktypA=; h=Date:From:To:Subject:References:In-Reply-To:From; b=seUU0+8iipVNF9wvBD2ofs6QORnbDde3doduSZiMeGXws9nF6PnvAzHMbSt6fKfYk 2Pz6M/fJrQdDF/U7xXP7T4kVJrsWcJZDb1v8HDKoZ0m1LaNI/Z5GZiR7ZSATzmldMG j638sq/Ad3hBy9A3ivsfsPq4YVdwo60ftatmX+c0= Date: Fri, 11 Jan 2019 00:31:59 -0500 From: Paul Elder To: Bin Liu , laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com, drinkcat@chromium.org, balbi@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] usb: gadget: musb: fix short isoc packets with inventra dma Message-ID: <20190111053159.GA32268@localhost.localdomain> References: <20190109071009.27625-1-paul.elder@ideasonboard.com> <20190109150215.GJ25910@uda0271908> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190109150215.GJ25910@uda0271908> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bin, On Wed, Jan 09, 2019 at 09:02:15AM -0600, Bin Liu wrote: > Hi Paul, > > On Wed, Jan 09, 2019 at 02:10:09AM -0500, Paul Elder wrote: > > Handling short packets (length < max packet size) in the Inventra DMA > > engine in the MUSB driver causes the MUSB DMA controller to hang. An > > example of a problem that is caused by this problem is when streaming > > video out of a UVC gadget, only the first video frame is transferred. > > > > For short packets (mode-0 or mode-1 DMA), MUSB_TXCSR_TXPKTRDY must be > > set manually by the driver. This was previously done in musb_g_tx > > (musb_gadget.c), but incorrectly (all csr flags were cleared, and only > > MUSB_TXCSR_MODE and MUSB_TXCSR_TXPKTRDY were set). Fixing that problem > > allows some requests to be transferred correctly, but multiple requests > > were often put together in one USB packet, and caused problems if the > > packet size was not a multiple of 4. Instead, set MUSB_TXCSR_TXPKTRDY > > in dma_controller_irq (musbhsdma.c), just like host mode transfers. > > > > This topic was originally tackled by Nicolas Boichat [0] [1] and is > > discussed further at [2] as part of his GSoC project [3]. > > > > [0] https://groups.google.com/forum/?hl=en#!topic/beagleboard-gsoc/k8Azwfp75CU > > [1] https://gitorious.org/beagleboard-usbsniffer/beagleboard-usbsniffer-kernel/commit/b0be3b6cc195ba732189b04f1d43ec843c3e54c9?p=beagleboard-usbsniffer:beagleboard-usbsniffer-kernel.git;a=patch;h=b0be3b6cc195ba732189b04f1d43ec843c3e54c9 > > [2] http://beagleboard-usbsniffer.blogspot.com/2010/07/musb-isochronous-transfers-fixed.html > > [3] http://elinux.org/BeagleBoard/GSoC/USBSniffer > > > > Signed-off-by: Paul Elder > > --- > > Changes in v2: > > > > - no more flushing FIFO > > - greatly simplified short packet if guard in musb_g_tx, and removed > > unnecessary variables > > - minor indentation and wording changes > > > > drivers/usb/musb/musb_gadget.c | 19 +++++-------------- > > drivers/usb/musb/musbhsdma.c | 21 +++++++++++---------- > > 2 files changed, 16 insertions(+), 24 deletions(-) > > > > diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c > > index eae8b1b1b45b..496643f54faa 100644 > > --- a/drivers/usb/musb/musb_gadget.c > > +++ b/drivers/usb/musb/musb_gadget.c > > @@ -452,13 +452,10 @@ void musb_g_tx(struct musb *musb, u8 epnum) > > } > > > > if (request) { > > - u8 is_dma = 0; > > - bool short_packet = false; > > > > trace_musb_req_tx(req); > > > > if (dma && (csr & MUSB_TXCSR_DMAENAB)) { > > - is_dma = 1; > > csr |= MUSB_TXCSR_P_WZC_BITS; > > csr &= ~(MUSB_TXCSR_DMAENAB | MUSB_TXCSR_P_UNDERRUN | > > MUSB_TXCSR_TXPKTRDY | MUSB_TXCSR_AUTOSET); > > @@ -476,16 +473,8 @@ void musb_g_tx(struct musb *musb, u8 epnum) > > */ > > if ((request->zero && request->length) > > && (request->length % musb_ep->packet_sz == 0) > > - && (request->actual == request->length)) > > - short_packet = true; > > + && (request->actual == request->length)) { > > > > - if ((musb_dma_inventra(musb) || musb_dma_ux500(musb)) && > > - (is_dma && (!dma->desired_mode || > > - (request->actual & > > - (musb_ep->packet_sz - 1))))) > > - short_packet = true; > > - > > - if (short_packet) { > > /* > > * On DMA completion, FIFO may not be > > * available yet... > > @@ -493,8 +482,10 @@ void musb_g_tx(struct musb *musb, u8 epnum) > > if (csr & MUSB_TXCSR_TXPKTRDY) > > return; > > > > - musb_writew(epio, MUSB_TXCSR, MUSB_TXCSR_MODE > > - | MUSB_TXCSR_TXPKTRDY); > > + musb_dbg(musb, "sending short pkt (zero=%d, length=%d, actual=%d, dma->desired_mode=%d)\n", > > + request->zero, request->length, request->actual, > > + dma->desired_mode); > > + musb_writew(epio, MUSB_TXCSR, csr | MUSB_TXCSR_TXPKTRDY); > > Sorry I didn't catch this in the last review, but this change seems not > required, isn't it? In the first version of the patch, the code is > 'returned' in the 'if (musb_dma_inventra())' branch above, doesn't reach > here. Do you mean change compared to the last version of the patch, or this last chunk of the diff? I guess I did also remove the return when I removed the 'if (musb_dma_inventra())' block that had the FLUSHFIFIO, but when I tested it it still worked. In fact, I reverted this last diff chunk and it still worked. Paul