Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp271843ybz; Fri, 24 Apr 2020 15:53:01 -0700 (PDT) X-Google-Smtp-Source: APiQypJc3fglr59n2JE89S3zJk+SzDsQrMTYe/83P54VBMsceq8zQz4+3Vniy0x6VC4fGtLEbjPD X-Received: by 2002:a05:6402:286:: with SMTP id l6mr9673164edv.134.1587768781475; Fri, 24 Apr 2020 15:53:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587768781; cv=none; d=google.com; s=arc-20160816; b=zrTWLIj0xPOSX8i69DN2AT3drZEDZrk82T92NNC5iA8CiHlLj/HrllfELxd9Xkbc/l /0BdJaCw55ZTQVbB7+gt6yoYYZKPOEHDJw8i0kPtYJE9v1KixBEFB5sAOOtPEpMo3tQY +QkNVK8NXefKFCjUIJUOxosSYrecfHxk+WnQkZ5E/Yw12voqk4+EW6BqtZBBDQJHA7wS TwqHX/DBR6F9oNQxqnhElVgkHKwoEeAhUkd1O9rNEoww7DPy8ctDxZs3PuZka8aTYoYK kr2yCAUkYJixjan51nQirYWniYvzWPJwdZlr3kVc2Sn1+BriHDMu2SVhJq9LyrilXiKB nJ9Q== 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:cc :to:from:date:dmarc-filter:dkim-signature; bh=FU5XkGQPbB1A0pLWx0Yc91zreZZRuFBUjh0H32lUTWI=; b=qwQH0blVEyT5JV1jzbpVO2sGhirM+8BZ2ZonrlFUF1Xcj1w5ICpmCIs4HWVw5mk9Ze uT9CcPilrXGtPmg1K5tbIXICIfGycF/QdkxIecZZnc0/h1j24BPFGZms+mqByruzCN/m HO2Gndoaw9FmDYK8qZfFSRxgOeD7wwN+h5YjqnooQ0WHPzr5caLHotxeS/1r1YtXu7Wh Z4RuCiuuqcVba1mnTsIkMjRX/O/qB6pcNyICCfjENEzLjGDwUIhpS2R3+HrkBLQWur6P MHa2UhHjhAsHJz/1CPZRSQYwirB2BALhe5AdqvV26xsnQYr7EkxRuMNugZS+0Ty3K7us SwoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=MHIkv1YG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z3si3986758edp.327.2020.04.24.15.52.38; Fri, 24 Apr 2020 15:53:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=MHIkv1YG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726062AbgDXWtH (ORCPT + 99 others); Fri, 24 Apr 2020 18:49:07 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:17757 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbgDXWtG (ORCPT ); Fri, 24 Apr 2020 18:49:06 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1587768546; h=In-Reply-To: Content-Type: MIME-Version: References: Message-ID: Subject: Cc: To: From: Date: Sender; bh=FU5XkGQPbB1A0pLWx0Yc91zreZZRuFBUjh0H32lUTWI=; b=MHIkv1YGqIlog9ptzjNdlt4tafMdbO76n2s6dzxLm7Vd9/+lHLuEq7AW50m+NeuiRzYc5GfA wPwcsxAxkiKLaZXM8qHFm/SowCt/nkgAmt+avMUzMByXAXPAqOfArP1AbI0qREnMr1o7fhHI 6vS0667PO68d3lm1O22cQ+JY5bo= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5ea36cd0.7fa74d5c8730-smtp-out-n02; Fri, 24 Apr 2020 22:48:48 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id CC946C4478C; Fri, 24 Apr 2020 22:48:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from jackp-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jackp) by smtp.codeaurora.org (Postfix) with ESMTPSA id 39E0EC433D2; Fri, 24 Apr 2020 22:48:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 39E0EC433D2 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=jackp@codeaurora.org Date: Fri, 24 Apr 2020 15:48:43 -0700 From: Jack Pham To: John Stultz Cc: Felipe Balbi , Josh Gao , YongQin Liu , Anurag Kumar Vulisha , Yang Fei , Thinh Nguyen , Tejas Joglekar , Andrzej Pietrasiewicz , Todd Kjos , Greg KH , Linux USB List , lkml Subject: Re: More dwc3 gadget issues with adb Message-ID: <20200424224843.GB20167@jackp-linux.qualcomm.com> References: <877dyfsv00.fsf@kernel.org> <20200424171247.GA20167@jackp-linux.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi John, On Fri, Apr 24, 2020 at 11:36:24AM -0700, John Stultz wrote: > On Fri, Apr 24, 2020 at 10:12 AM Jack Pham wrote: > > On Tue, Apr 21, 2020 at 10:09:27PM -0700, John Stultz wrote: > > > Does something like this make sense? It's not causing trouble on > > > db845c either so far in my testing. > > > > Ok I'll bite... > > > > I'm now curious why it hasn't been a problem with the Qualcomm HW. Do > > you mind please capturing a similar trace log on the db845c? Would be > > good to see a side-by-side comparison and see if, first of all, whether > > the same S/G path is getting exercised (i.e. 16KiB OUT requests from ADB > > userspace using AIO which then get broken up into 4K chunks by f_fs), > > and what the behaviors of the reclaim_trb and giveback are when the > > transfer is completed. > > > > Preferably if you could get a trace without your patch applied that > > would be great. And maybe also one after your patch just to see if the > > traces are truly identical or not. > > Sure. I've captured logs in the same manner with and without on db845c > (against 5.7-rc2). See attached. Thank you! > I suspect the difference is the db845c is using an iommu (I don't > think it will boot without it) where hikey960 isn't, but I'll let you > take a look. Yes I think that's exactly what's happening. Those 16KiB requests on ep1out would normally be passed as 4x4KiB sglists from f_fs.c but after the call to usb_gadget_map_request() the IOMMU is coalescing them back into a single entry, so for each of those requests we end up preparing just a single unchained TRB. UsbFfs-worker-532 [007] d..1 96.025897: dwc3_alloc_request: ep1out: req 0000000075c0b6d7 length 0/0 zsI ==> 0 UsbFfs-worker-532 [007] d..2 96.025898: dwc3_ep_queue: ep1out: req 0000000075c0b6d7 length 0/16384 zsI ==> -115 UsbFfs-worker-532 [007] d..2 96.025908: dwc3_prepare_trb: ep1out: trb 00000000c0c9cf9f (E217:D209) buf 00000000ff930000 size 16384 ctrl 00000819 (HlcS:sC:normal) ^^^^^^^^^^^^^^^^ -> trb c0c9cf9f enqueued at position 216 in the ring (enqueue pointer 217) We can see the pointer to the DMA address and it's 16KiB, and the chain bit is off. UsbFfs-worker-532 [007] d..2 96.025912: dwc3_readl: addr 00000000ab36a89f value 00002400 UsbFfs-worker-532 [007] d..2 96.025915: dwc3_writel: addr 00000000057ac193 value 00000000 UsbFfs-worker-532 [007] d..2 96.025917: dwc3_writel: addr 000000009c937859 value 00000000 UsbFfs-worker-532 [007] d..2 96.025919: dwc3_writel: addr 00000000a91887be value 00000000 UsbFfs-worker-532 [007] d..2 96.025922: dwc3_writel: addr 00000000679c8ad6 value 00020007 UsbFfs-worker-532 [007] d..2 96.025924: dwc3_readl: addr 00000000679c8ad6 value 00020007 UsbFfs-worker-532 [007] d..2 96.025925: dwc3_gadget_ep_cmd: ep1out: cmd 'Update Transfer' [20007] params 00000000 00000000 00000000 --> status: Successful ... irq/142-dwc3-529 [000] d..1 96.027952: dwc3_event: event (00006084): ep1out: Transfer In Progress [0] (SIm) irq/142-dwc3-529 [000] d..1 96.027955: dwc3_complete_trb: ep1out: trb 00000000c0c9cf9f (E224:D217) buf 00000000ff930000 size 16360 ctrl 00000818 (hlcS:sC:normal) ^^^^^^^^^^^^^^^^ irq/142-dwc3-529 [000] d..1 96.027965: dwc3_gadget_giveback: ep1out: req 0000000075c0b6d7 length 24/16384 zsI ==> 0 That same trb c0c9cf9f is completed, 24 (16384 - 16360) bytes were transferred, and dwc3 gives back the request to the function driver. TRB dequeue pointer advanced by one to position 217. irq/142-dwc3-529 [000] d..1 96.027970: dwc3_readl: addr 0000000054b9cc02 value 80001000 irq/142-dwc3-529 [000] d..1 96.027971: dwc3_writel: addr 0000000054b9cc02 value 00001000 irq/142-dwc3-529 [000] d..1 96.027974: dwc3_writel: addr 00000000e4e556e6 value 80000000 irq/142-dwc3-529 [000] d..1 96.027976: dwc3_writel: addr 000000001139226c value 00000001 So it's interesting that with IOMMU always enabled on the db845c we don't hit the bug as we avoid preparing an SG/chained TRB list. Thanks, Jack -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project