Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3395078imm; Tue, 4 Sep 2018 22:35:07 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYUbJXvTGKhOIT4yyZaMnRBHzfgwdMjLAORweYvJY/D8sDNPkcmji3D61zI48k4qWw8Aq7x X-Received: by 2002:a63:2d05:: with SMTP id t5-v6mr34665299pgt.403.1536125707396; Tue, 04 Sep 2018 22:35:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536125707; cv=none; d=google.com; s=arc-20160816; b=wRNBw+623Zk+ZFLukbC/uan/iVjuELLLGLttfQ1sZmh5JCxOfI3qGSGvYJYHKu82UY 91VOuxU6PQyWiJA9Ha8/XgjM+qCfs0rs1e734MwSKO3LCTtg7C+1KUwonRYVFHomZxMv TajU7LA9zlTZUblchRYt+MoLDIZvsWV+ylOmPoN+xb3Qa722mXwp0XLhLpCgsokDjwrS W2axNtk8u+KwV4M8NZNGgxei6xbMK1pC/ipkPEknJeXQlCOn5sZicmzOPTDU3q0vgFA0 neNOy6EBD8WpN/vjlRvTOrNzQXJDA80N8TV4UMqDBPckWg9SX3epaFExwe3JKAAo41UZ /h5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:references:message-id:date :thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=zUep4rrR1+DypnT3fm7+g9utCCjOxe35oHOxP5dqxjk=; b=FQY57qUgAwbcffXxR42pdElON4Ak1OEFAqafCP/RzbBkuiPtOGwkka4OiC2YsxlStV snnK/KLe4AYyy7spoTCnq6GswKPzsZt+w7ZRp1kzSITun7cIilqKm/4TWcZdf8YP0CEu 7Qif1B/ILbz6/8bfl+IOp1z/dYMe5bRDUbRM+ZDvecSmi1eAIiY9lnGA9n+LPyltOgfc kc+szzl5LjjbTGRDhbRwDS9ZYkFXisHFzSpAidxHgh30+e+Bo9rTZaRTfWJAJ5BNy1Ei wCfpwUnZ7SZZVhrnKII6AzPpmk09k7viCr1D8hyXUMw5hHsrJyqaFK0j9Q/WID5G/aMc FNJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=RAeP6UL5; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t9-v6si956302pgr.244.2018.09.04.22.34.52; Tue, 04 Sep 2018 22:35:07 -0700 (PDT) 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 header.i=@synopsys.com header.s=mail header.b=RAeP6UL5; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727640AbeIEKCH (ORCPT + 99 others); Wed, 5 Sep 2018 06:02:07 -0400 Received: from smtprelay4.synopsys.com ([198.182.47.9]:35242 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727580AbeIEKCH (ORCPT ); Wed, 5 Sep 2018 06:02:07 -0400 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id DBB3924E0691; Tue, 4 Sep 2018 22:33:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1536125619; bh=c7EtLAb92J0LGi/FBVcTkCghg+Xo9oymN8ajVVX02Zg=; h=From:To:CC:Subject:Date:References:From; b=RAeP6UL5Z4gN9opBwTMXiWS0NGlctxQoxkhD2x4XITBbRCm0ltCB7y0RiGBVlxULY 0+ndtZO81JghT5a79dmLTMoiE97nNej54xNGA2r3S6x2q3/XNgzbnPf+9CJV66Imqu NluLEilSnM/AXf0qOG05OlMPO8hJezmIpJ+HQmt0JAEAqfKG7q/kclH791kfeohFQk NzGhB2urzAH7RYMT/fb1XW1dBm/LuKpoDRQN5FyUx3iRVU9Vwjxkx883gAcVBN8QK5 fHnZ/rggtkXgw3Lwd8GZrskDfVdshsOY+4rFFpKCRPPwCFzyOj81MCnSTF40fOIoUS I0D3VUlxJrBAg== Received: from us01wehtc1.internal.synopsys.com (us01wehtc1-vip.internal.synopsys.com [10.12.239.236]) by mailhost.synopsys.com (Postfix) with ESMTP id BFE573D6D; Tue, 4 Sep 2018 22:33:39 -0700 (PDT) Received: from us01wembx1.internal.synopsys.com ([169.254.1.253]) by us01wehtc1.internal.synopsys.com ([::1]) with mapi id 14.03.0361.001; Tue, 4 Sep 2018 22:33:39 -0700 From: Thinh Nguyen To: Anurag Kumar Vulisha , "balbi@kernel.org" , "gregkh@linuxfoundation.org" CC: "v.anuragkumar@gmail.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 1/8] usb: dwc3: Correct the logic for checking TRB full in __dwc3_prepare_one_trb() Thread-Topic: [PATCH v2 1/8] usb: dwc3: Correct the logic for checking TRB full in __dwc3_prepare_one_trb() Thread-Index: AQHUNiVe6PVhPxbQeEm3tnXrG8X9Mg== Date: Wed, 5 Sep 2018 05:33:39 +0000 Message-ID: <30102591E157244384E984126FC3CB4F544AB897@us01wembx1.internal.synopsys.com> References: <1534508695-12642-1-git-send-email-anurag.kumar.vulisha@xilinx.com> <1534508695-12642-2-git-send-email-anurag.kumar.vulisha@xilinx.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.13.184.20] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Anurag,=0A= =0A= On 8/17/2018 5:25 AM, Anurag Kumar Vulisha wrote:=0A= > Availability of TRB's are calculated using dwc3_calc_trbs_left(), which= =0A= > determines available TRB's based on the HWO bit set in a TRB.=0A= >=0A= > __dwc3_prepare_one_trb() is called with a TRB which needs to be prepared= =0A= > for transfer. This __dwc3_prepare_one_trb() calls dwc3_calc_trbs_left()= =0A= > to determine total available TRBs and set IOC bit if the total available= =0A= > TRBs are zero. Since the present working TRB(which is passed as an=0A= > argument to __dwc3_prepare_one_trb() ) doesn't have HWO bit already set,= =0A= > there are chances where dwc3_calc_trbs_left() wrongly calculates this=0A= > present working TRB as free(since the HWO bit is not yet set). This could= =0A= > be a problem. This patch correct this issue by setting HWO bit before=0A= > calling dwc3_calc_trbs_left()=0A= >=0A= > Signed-off-by: Anurag Kumar Vulisha =0A= > ---=0A= > Changes in v2:=0A= > 1. Changed the commit message=0A= > ---=0A= > drivers/usb/dwc3/gadget.c | 4 ++--=0A= > 1 file changed, 2 insertions(+), 2 deletions(-)=0A= >=0A= > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c=0A= > index 69bf137..f73d219 100644=0A= > --- a/drivers/usb/dwc3/gadget.c=0A= > +++ b/drivers/usb/dwc3/gadget.c=0A= > @@ -990,6 +990,8 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep *de= p, struct dwc3_trb *trb,=0A= > trb->ctrl |=3D DWC3_TRB_CTRL_ISP_IMI;=0A= > }=0A= > =0A= > + trb->ctrl |=3D DWC3_TRB_CTRL_HWO;=0A= > +=0A= > if ((!no_interrupt && !chain) ||=0A= > (dwc3_calc_trbs_left(dep) =3D=3D 0))=0A= > trb->ctrl |=3D DWC3_TRB_CTRL_IOC;=0A= > @@ -1000,8 +1002,6 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep *= dep, struct dwc3_trb *trb,=0A= > if (usb_endpoint_xfer_bulk(dep->endpoint.desc) && dep->stream_capable)= =0A= > trb->ctrl |=3D DWC3_TRB_CTRL_SID_SOFN(stream_id);=0A= > =0A= > - trb->ctrl |=3D DWC3_TRB_CTRL_HWO;=0A= > -=0A= > trace_dwc3_prepare_trb(dep, trb);=0A= > }=0A= > =0A= How do you reproduce this issue? We should not set HWO before setting=0A= other trb->ctrl bits. Can you provide a driver tracepoint? If there's an=0A= issue with the check if ((!no_interrupt && !chain) ||=0A= dwc3_calc_trbs_left =3D=3D 0), then we may need to fix the check there.=0A= =0A= BR,=0A= Thinh=0A=