From patchwork Fri Aug 17 12:24:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anurag Kumar Vulisha X-Patchwork-Id: 10568705 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27F5414BD for ; Fri, 17 Aug 2018 12:25:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 159822B019 for ; Fri, 17 Aug 2018 12:25:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07CA42B29B; Fri, 17 Aug 2018 12:25:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E5D32B019 for ; Fri, 17 Aug 2018 12:25:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727509AbeHQP2a (ORCPT ); Fri, 17 Aug 2018 11:28:30 -0400 Received: from mail-eopbgr690068.outbound.protection.outlook.com ([40.107.69.68]:37216 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726800AbeHQP22 (ORCPT ); Fri, 17 Aug 2018 11:28:28 -0400 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=9oUcBefZZDizQhh5U50j4/ut2w/sXtUKikIytlt+zvk=; b=W8jVO12RELlTcIsiinsALM70Z7ld2VkqrT1sxoWaIi14DJ62CbeIm3jDXY+FhOsW64DJITaxAdN9e91OOf0wPEeALr3yGGCcUJf+o5MkLGamJzi7a9fvFVmYLzgQC6OFJsesYC/McBZM66pBWTclYVXk7DQL8FglIDlSvnkB6WY= Received: from BLUPR0201CA0030.namprd02.prod.outlook.com (2a01:111:e400:52e7::40) by BYAPR02MB4326.namprd02.prod.outlook.com (2603:10b6:a03:56::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.25; Fri, 17 Aug 2018 12:25:07 +0000 Received: from BL2NAM02FT007.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::200) by BLUPR0201CA0030.outlook.office365.com (2a01:111:e400:52e7::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1059.20 via Frontend Transport; Fri, 17 Aug 2018 12:25:06 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.100 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.100; helo=xsj-pvapsmtpgw02; Received: from xsj-pvapsmtpgw02 (149.199.60.100) by BL2NAM02FT007.mail.protection.outlook.com (10.152.77.46) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1059.14 via Frontend Transport; Fri, 17 Aug 2018 12:25:06 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:42365 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1fqdoP-0008VO-HZ; Fri, 17 Aug 2018 05:25:05 -0700 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1fqdoK-0000U3-HB; Fri, 17 Aug 2018 05:25:00 -0700 Received: from xsj-pvapsmtp01 (xsj-smtp.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id w7HCOvRx019091; Fri, 17 Aug 2018 05:24:57 -0700 Received: from [172.23.64.8] (helo=xhdvnc108.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1fqdoH-0000TQ-B4; Fri, 17 Aug 2018 05:24:57 -0700 Received: by xhdvnc108.xilinx.com (Postfix, from userid 15427) id 6140160508; Fri, 17 Aug 2018 17:54:56 +0530 (IST) From: Anurag Kumar Vulisha To: , CC: , , , Anurag Kumar Vulisha Subject: [PATCH v2 1/8] usb: dwc3: Correct the logic for checking TRB full in __dwc3_prepare_one_trb() Date: Fri, 17 Aug 2018 17:54:48 +0530 Message-ID: <1534508695-12642-2-git-send-email-anurag.kumar.vulisha@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1534508695-12642-1-git-send-email-anurag.kumar.vulisha@xilinx.com> References: <1534508695-12642-1-git-send-email-anurag.kumar.vulisha@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.100;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(136003)(376002)(39850400004)(396003)(346002)(2980300002)(438002)(189003)(199004)(305945005)(6666003)(76176011)(51416003)(186003)(26005)(90966002)(50466002)(48376002)(39060400002)(110136005)(54906003)(103686004)(47776003)(316002)(4326008)(16586007)(106002)(42186006)(36756003)(50226002)(8936002)(15760500003)(106466001)(107886003)(63266004)(6266002)(356003)(478600001)(486006)(476003)(2616005)(126002)(36386004)(52956003)(2906002)(8676002)(336012)(5660300001)(446003)(11346002)(81166006)(426003)(81156014)(107986001)(5001870100001);DIR:OUT;SFP:1101;SCL:1;SRVR:BYAPR02MB4326;H:xsj-pvapsmtpgw02;FPR:;SPF:Pass;LANG:en;PTR:unknown-60-100.xilinx.com,xapps1.xilinx.com;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;BL2NAM02FT007;1:CiudDmc2Z/dATSP+1ojfLhQUwHM4t0anuif4Ikd8bHbRkbNLRcE21BHBBkSZVHlOOROOVTo9RwwMiobmbXbhH8NtXivsuQV1ifOQ+Y4uBDiYwsViNfxDk5/llHZMXd// MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 084ef1ed-40e7-46e3-37d8-08d6043c7728 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:BYAPR02MB4326; X-Microsoft-Exchange-Diagnostics: 1;BYAPR02MB4326;3:FsU5/sQuUQhRp5mtD9E/eHAjeDNXuK48sFSSlRDXM+8CFmfHo0SOyU+Gp9sQMauyNMhe1ZU6KY/vILGvubGiRVRDo1XA1utIAgDS0wYANsCN13teq9JvJlz3MdIqQoeRUB8v9Evd4nkN9c35qk348njyFLoLS7HJEuphuS+Hp195u5zyYJrkbsMCVINWQh+g2U7U9JThkRPyFN8vh24IIIPBrwolUTmUHJ7tMxXD393pvfqnWF4WPStDXyks1F1MnvqZ8OriC+3bJWHsWlgqx/jDCSLx8K9zY0FtY2N9hERaHXHVCduDBLIBs4LN+63sQ++oH2TD9u1siEKpFU8zbUy4ZBd0dHu5inlSBOer2lM=;25:ajV6Tc8axJTWktG8bZDk/PeTVg59an3MZVD4wbzPOq/0ssDu+Oh/m/2cMIiSXpBLfud8dA6fxrB8XUc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zJQ X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(93006095)(93004095)(10201501046)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016);SRVR:BYAPR02MB4326;BCL:0;PCL:0;RULEID:;SRVR:BYAPR02MB4326; X-Microsoft-Exchange-Diagnostics: 1;BYAPR02MB4326;4:3rK/U51LeIaEgz0VSVZeDELTotv0Jb7quLd/Ao2MTc2btglbCfS8prOqNZRm4k54ichTc6XICAIOm5tpDaLkFifCfy+Yc+wm2NJzdxbaXpqwcUkwgu/I2WSIn3lsd0ujP7HFR2LmFMqmXpGzNvpQKhO+TqNMxpNYV/gk8iYov72Ew7ys0+EjSMi1l/McCshT6DqTd9fjjp/GILAJUzxSER+SO9nXVQDYJ2SVfURTeUBB0mmbleTcyoZfXO/NIrKr7tGBfqGY8Mg9t8upg1q5P2o7I3YgLXjr/a2A6pgxEbJFp7Iam+wQuZj9j6xb/cLh X-Forefront-PRVS: 076777155F X-Microsoft-Exchange-Diagnostics: 1;BYAPR02MB4326;23:f/mjmHBVd4Ez+OO1+x6+sGXVdVTUhsRs4OWEOxjG3W4GUjFITROxtmB/7zLLwo9ZqIKezNB4vx2l+Bo+E0klG0ZMxDZR8yiOuFP/UfbZTpp+X4ODljZy/u3rvBA7ev6K8UF5eElvCT+Vwb/I2UYbvk4sEC2kxPtEOwBG7vznCq8oQHXAGIFGcrVEWpH5HpRIt1a2UKBkqa808+sx+ZKPZO94aU426+1pMwk+MJXBKGVxpCc0lIV7U9LctZd0UYFHx335eu/rTtN5oYQ4/ntQ3oFoutFLhA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o4x9mYzG9PfdB5CjJ4wph6W+0SnsWzGiAw6Sy64Izqa0OKZ1XTpLRBsJR6/jGBqNLaZz7tcBfmC+G9qmsFCF9uJrzI93L/KmYRez+rDfAM+F5JJtE68r6/tSQZA40jN+bTeK SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2018 12:25:06.1302 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 084ef1ed-40e7-46e3-37d8-08d6043c7728 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.100];Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR02MB4326 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Availability of TRB's are calculated using dwc3_calc_trbs_left(), which determines available TRB's based on the HWO bit set in a TRB. __dwc3_prepare_one_trb() is called with a TRB which needs to be prepared for transfer. This __dwc3_prepare_one_trb() calls dwc3_calc_trbs_left() to determine total available TRBs and set IOC bit if the total available TRBs are zero. Since the present working TRB(which is passed as an argument to __dwc3_prepare_one_trb() ) doesn't have HWO bit already set, there are chances where dwc3_calc_trbs_left() wrongly calculates this present working TRB as free(since the HWO bit is not yet set). This could be a problem. This patch correct this issue by setting HWO bit before calling dwc3_calc_trbs_left() Signed-off-by: Anurag Kumar Vulisha Reviewed-by: Thinh Nguyen --- Changes in v2: 1. Changed the commit message --- drivers/usb/dwc3/gadget.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 69bf137..f73d219 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -990,6 +990,8 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *trb, trb->ctrl |= DWC3_TRB_CTRL_ISP_IMI; } + trb->ctrl |= DWC3_TRB_CTRL_HWO; + if ((!no_interrupt && !chain) || (dwc3_calc_trbs_left(dep) == 0)) trb->ctrl |= DWC3_TRB_CTRL_IOC; @@ -1000,8 +1002,6 @@ static void __dwc3_prepare_one_trb(struct dwc3_ep *dep, struct dwc3_trb *trb, if (usb_endpoint_xfer_bulk(dep->endpoint.desc) && dep->stream_capable) trb->ctrl |= DWC3_TRB_CTRL_SID_SOFN(stream_id); - trb->ctrl |= DWC3_TRB_CTRL_HWO; - trace_dwc3_prepare_trb(dep, trb); }