Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1967831imu; Sat, 8 Dec 2018 11:07:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/UnbDaVQq6K0LmE7rPkE6p1WdJOGz52i4LQPu1ocOhBRKkODcmAfK89O+SeN7nn/2MkpBv0 X-Received: by 2002:a65:47ca:: with SMTP id f10mr6072066pgs.166.1544296045604; Sat, 08 Dec 2018 11:07:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544296045; cv=none; d=google.com; s=arc-20160816; b=mXSA2+sT6NVXIVos0q9B8W1lQMxFlSjJrdgZ+OPztZz9eGyn5tnzyWro0VYaBYNyLo TGX2xbT3yBtHlZB4YTNL9sOHss86lRxG14VbxRpm/5gvglQrWtAOMo4hOJYrNoZpa9Oy WriJMTgMu1uYfW+2l4rpuyIOdfdkLnPYIErgkSnNap4IFi57/eUC9To5/DFFZI+cg8Xn Pi8miOhzBnrAiGOv4LMhOHwNTbQy0Bc/MfXIw7DUuGyMhe+J41OviLIQDsPQG6Jo5C3o oa5OV8Qqr6yE5CkUEM6DCx9CoRQ9Skc2amq5FL4JwYXboBvMD+H9t2R30tjkhhAOfpTA U5aQ== 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 :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=0DDJhNUDFJbh6F5L0isJpCx94Qf/XGjPOc4j39dZ85I=; b=SUjGaMM5Sdm8YrjrEml8Aujrl7NtwX9g84XrLIKUHOvAcjQfgXwUeF6CAipWsDY+4y 4zRMD/cVEghOAp6MOvQC3B8ZqBYVvn14OjQr4XFGwdXZQ9CK9gipSu76YB/gowdyxKDr xfp5jFpOaiS8iyHIkcu5mDPaXSNkK3dWeTuNfuoH0/maETWsie51+WOPsrkcP31cnBNG wQ2PbblBIj6euwcS1R+CD1a/fcvSVTK5S9x337+82vRSrp++0B28h1GUCuztScAPoqxr okfphXS8VcegPnW8/s2RD5L4Sw9trxxvZONTCjPe5EkBOL746ySNuzunHmf4ojEHRxAP Dm3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xilinx.onmicrosoft.com header.s=selector1-xilinx-com header.b=zRKtUr9m; 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 s125si6732023pfc.60.2018.12.08.11.07.08; Sat, 08 Dec 2018 11:07:25 -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 header.i=@xilinx.onmicrosoft.com header.s=selector1-xilinx-com header.b=zRKtUr9m; 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 S1726197AbeLHTGb (ORCPT + 99 others); Sat, 8 Dec 2018 14:06:31 -0500 Received: from mail-eopbgr790089.outbound.protection.outlook.com ([40.107.79.89]:49410 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726177AbeLHTGa (ORCPT ); Sat, 8 Dec 2018 14:06:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0DDJhNUDFJbh6F5L0isJpCx94Qf/XGjPOc4j39dZ85I=; b=zRKtUr9mxAc0qlPgevvoeKJEVDSPX0ehAwS/sELVYEHuCCbkDufXch3z7Kk1V1YKfi3c5qscEGIBumU+0w6zAsm9odjqDLi1Dw322fwt0IclivOoU2HAoPk1Dl9csuXqjStH8OWZfUFRv3wFruZEtFt16//5RLo4l9mwXYzqgKs= Received: from BL0PR02MB5633.namprd02.prod.outlook.com (20.177.241.80) by BL0PR02MB5460.namprd02.prod.outlook.com (20.177.240.215) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.22; Sat, 8 Dec 2018 19:03:33 +0000 Received: from BL0PR02MB5633.namprd02.prod.outlook.com ([fe80::68ed:9ca9:c7da:d76d]) by BL0PR02MB5633.namprd02.prod.outlook.com ([fe80::68ed:9ca9:c7da:d76d%2]) with mapi id 15.20.1404.023; Sat, 8 Dec 2018 19:03:33 +0000 From: Anurag Kumar Vulisha To: Felipe Balbi , Greg Kroah-Hartman , Shuah Khan , Alan Stern , Johan Hovold , Jaejoong Kim , Benjamin Herrenschmidt , Roger Quadros , Manu Gautam , "martin.petersen@oracle.com" , Bart Van Assche , Mike Christie , Matthew Wilcox , Colin Ian King CC: "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "v.anuragkumar@gmail.com" , Thinh Nguyen , Tejas Joglekar , Ajay Yugalkishore Pandey Subject: RE: [PATCH v7 09/10] usb: dwc3: Check for IOC/LST bit in both event->status and TRB->ctrl fields Thread-Topic: [PATCH v7 09/10] usb: dwc3: Check for IOC/LST bit in both event->status and TRB->ctrl fields Thread-Index: AQHUiWbqDI9WfI74TEmPyd+V2NlqDqVv4SkAgACgrWCAAlLUgIACXYXw Date: Sat, 8 Dec 2018 19:03:33 +0000 Message-ID: References: <1543662811-5194-1-git-send-email-anurag.kumar.vulisha@xilinx.com> <1543662811-5194-10-git-send-email-anurag.kumar.vulisha@xilinx.com> <875zw82vfj.fsf@linux.intel.com> <874lbpx3vg.fsf@linux.intel.com> In-Reply-To: <874lbpx3vg.fsf@linux.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=anuragku@xilinx.com; x-originating-ip: [182.18.177.170] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BL0PR02MB5460;6:/om0ml0EFaXfxFJiaXEgywGwwiLffTg6zzZVsVGCIp+Mk8XwMlOvfzbZ741hl3/URwpNoE+hLRUMEj6hw7jNZn0D3kUVy4vA3rovwLy4Hr+JsB97bDu9Z/TMhNKAMKuM6IKvjHpkfg2vkfgIAaSXFr7qFqpp51DNRrjfG0DY3qHnV1yUVxny2FBmW8f1EqXIEMT7xeEe5NoGyolOo4P2h7evq+OYwBZnnSRqXp4co7+UN/FXQG2aFXgeF59MtyqVFsivCyFXr7YgnLTWNuVZ4g7dNMBvXDIRWKCajnwngKupXCHiaEINe6HWnr8CQNwc6r5wyS1wiVfyrcP0SpQgiWExH6ED1Efk7njLFrLoXY92aNT2cLR/sQPU7CNTyut63q3TFy8+tWtIEsCZQnlG/3KcnlnGwlN9oJHxtwXcZLVyrMtqesEK6gVMBdYD3O/sgPGT1G0nRJNQtB5GmgaMdA==;5:Wh6NqtIWproQ7uSgwPvHLkVZ+JEG0pNYyJDoRZNv/RF6Ml5kRGjLNKXD96tzpEW5nSJVJvFsJFCtLNMqASxcJCSUuISpdCiOErDLfkK30Zckozv0G48VymKA/1cfIespqsL6eciw4X8L6oUqIVjUOf0qTI716djKCXh61wwgQeY=;7:fSkYESxU4BrLWNvS4sSNiRCcYKJ6+kzYwBHkPxy2KRTpaEPXH/qFgPDuQThPkHuar2uHJjKzoY7/2AK/NM2Kf90c0AnCvUeqEq4IwmB3SHWSnTJA0eAaV/6t3TOjTbrpoOQ/MGS9U+B51TaJqxZ0nA== x-ms-office365-filtering-correlation-id: 9fa792ad-1cb2-4cfd-fe7d-08d65d3fd9bc x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:BL0PR02MB5460; x-ms-traffictypediagnostic: BL0PR02MB5460: x-ld-processed: 657af505-d5df-48d0-8300-c31994686c5c,ExtAddr x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231455)(999002)(944501520)(52105112)(93006095)(93001095)(3002001)(10201501046)(6055026)(148016)(149066)(150057)(6041310)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:BL0PR02MB5460;BCL:0;PCL:0;RULEID:;SRVR:BL0PR02MB5460; x-forefront-prvs: 0880FB6EC1 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(39860400002)(396003)(346002)(366004)(136003)(376002)(13464003)(189003)(199004)(26005)(256004)(14444005)(4326008)(186003)(86362001)(3846002)(6116002)(97736004)(71200400001)(53936002)(55016002)(33656002)(93886005)(14454004)(9686003)(71190400001)(6506007)(102836004)(39060400002)(106356001)(105586002)(2171002)(6246003)(54906003)(316002)(110136005)(7416002)(107886003)(68736007)(478600001)(229853002)(8676002)(74316002)(305945005)(81156014)(81166006)(99286004)(486006)(8936002)(476003)(446003)(11346002)(7696005)(5660300001)(76176011)(25786009)(6436002)(66066001)(7736002)(2906002)(2501003)(921003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:BL0PR02MB5460;H:BL0PR02MB5633.namprd02.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: xilinx.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: WNjZdJWlQd18DzIbghLzquO/tURcJY8XGEAxfgEDiK0GLtLLJzx0RE9w+CoWsUtNvR5U2cgY19xdMwth8sqehaZc42GGskbBW4C4kegRJOrfgsBzb/pc/4B8/NHLuGSWDbCfZBUtIuHFuvQ4BrqW8GlhxQDniAUSBOZSzQVhzqqbThpNg3QQSB7YbCVZ5o4zgGMGff1SufiZpf2rVE2KgajTdjJsqizpB503nPClaxjCLqkCr8eHleW6IFtRFLiL77uR1nq//vF+kAkpxTtkgFCKjS/VnRbB3aoh8p9r8G0tR5nut1ogYM7wdI1rgnCjwevBfACx/lQ2wKvBhFW27J5ZzMm6wKzZoAZGgB/PFHI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9fa792ad-1cb2-4cfd-fe7d-08d65d3fd9bc X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Dec 2018 19:03:33.4817 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR02MB5460 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org HI Felipe, >-----Original Message----- >From: Felipe Balbi [mailto:balbi@kernel.org] >Sent: Friday, December 07, 2018 11:42 AM >To: Anurag Kumar Vulisha ; Greg Kroah-Hartman >; Shuah Khan ; Alan Stern >; Johan Hovold ; Jaejoong Kim >; Benjamin Herrenschmidt = ; >Roger Quadros ; Manu Gautam ; >martin.petersen@oracle.com; Bart Van Assche ; Mike >Christie ; Matthew Wilcox ; Coli= n Ian >King >Cc: linux-usb@vger.kernel.org; linux-kernel@vger.kernel.org; >v.anuragkumar@gmail.com; Thinh Nguyen ; Tejas Jogleka= r >; Ajay Yugalkishore Pandey >Subject: RE: [PATCH v7 09/10] usb: dwc3: Check for IOC/LST bit in both eve= nt->status >and TRB->ctrl fields > > >Hi, > >Anurag Kumar Vulisha writes: >>>> @@ -2286,7 +2286,12 @@ static int >>>dwc3_gadget_ep_reclaim_completed_trb(struct dwc3_ep *dep, >>>> if (event->status & DEPEVT_STATUS_SHORT && !chain) >>>> return 1; >>>> >>>> - if (event->status & (DEPEVT_STATUS_IOC | DEPEVT_STATUS_LST)) >>>> + if ((event->status & DEPEVT_STATUS_IOC) && >>>> + (trb->ctrl & DWC3_TRB_CTRL_IOC)) >>>> + return 1; >>> >>>this shouldn't be necessary. According to databook, event->status >>>contains the bits from the completed TRB. Which means that >>>event->status & IOC will always be equal to trb->ctrl & IOC. >>> >> Thanks for reviewing this patch. Lets consider an example where a >> request has num_sgs > 0 and each sg is mapped to a TRB and the last >> TRB has the IOC bit set. Once the controller is done with the >> transfer, it generates XferInProgress for the last TRB (since IOC bit >> is set). As a part of trb reclaim process >> dwc3_gadget_ep_reclaim_trb_sg() calls >> dwc3_gadget_ep_reclaim_completed_trb() for req->num_sgs times. Since >> the event already has the IOC bit set, the loop is exited from the >> loop at the very first TRB and the remaining TRBs (mapped to the sglist)= are left >unhandled. >> To avoid this we modified the code to exit only if both TRB & event >> has the IOC bit set. > >Seems like IOC case should just test for chain flag as well: > Okay. Along with this logic the code for updating chain bit should also be = modified I guess. Since the IOC bit is also set when there are not enough TRBs available, the= code should be modified to not set DWC3_TRB_CTRL_CHN bit when the IOC bit is set. I will u= pdate below changes along with your suggestions and resend the patches. @@ -998,7 +998,7 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep *dep,= struct dwc3_trb *trb, (dwc3_calc_trbs_left(dep) =3D=3D 1)) trb->ctrl |=3D DWC3_TRB_CTRL_IOC; =20 - if (chain) + if (chain && !(trb->ctrl & DWC3_TRB_CTRL_IOC)) trb->ctrl |=3D DWC3_TRB_CTRL_CHN; =20 if (usb_endpoint_xfer_bulk(dep->endpoint.desc) && dep->stream_capab= le) @@ -2372,7 +2372,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(struc= t dwc3_ep *dep, if (event->status & DEPEVT_STATUS_SHORT && !chain) return 1; =20 - if (event->status & DEPEVT_STATUS_IOC) + if (event->status & DEPEVT_STATUS_IOC && !chain) return 1; =20 return 0; @@ -2399,7 +2399,7 @@ static int dwc3_gadget_ep_reclaim_trb_sg(struct dwc3_= ep *dep, req->num_pending_sgs--; =20 ret =3D dwc3_gadget_ep_reclaim_completed_trb(dep, req, - trb, event, status, true); + trb, event, status, (trb & DWC3_TRB_CTRL_CH= N)); if (ret) break; } Thanks, Anurag Kumar Vulisha >modified drivers/usb/dwc3/gadget.c >@@ -2372,7 +2372,7 @@ static int dwc3_gadget_ep_reclaim_completed_trb(stru= ct >dwc3_ep *dep, > if (event->status & DEPEVT_STATUS_SHORT && !chain) > return 1; > >- if (event->status & DEPEVT_STATUS_IOC) >+ if (event->status & DEPEVT_STATUS_IOC && !chain) > return 1; > > return 0; > >-- >balbi