From patchwork Sat Dec 1 11:13:21 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: 10707619 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 D1D7314BD for ; Sat, 1 Dec 2018 11:14:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0A4C2E65F for ; Sat, 1 Dec 2018 11:14:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4F8A2E666; Sat, 1 Dec 2018 11:14:31 +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 30F472E65F for ; Sat, 1 Dec 2018 11:14:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727038AbeLAW0r (ORCPT ); Sat, 1 Dec 2018 17:26:47 -0500 Received: from mail-eopbgr780080.outbound.protection.outlook.com ([40.107.78.80]:42176 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726708AbeLAW0J (ORCPT ); Sat, 1 Dec 2018 17:26:09 -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=hWqCA3lOXEItm038LpdbUJ6wLH4VhiDpOSgNvBvECZY=; b=UF0YUbqhi4f9YKpTDQLCIal3WziatP+4qaGbkGYiU6MpJEYUBigCdd7CaFSx6+E8FcXbZBcMVyfn1QfPNoqv3IT3NxegMj6LK061DPsSsPwtEVB/g9XH0P+DChkeFqbWpkKarMJUsIehwX/T7It1leKgVbT3pQ+8P8r52ab33Jk= Received: from SN4PR0201CA0063.namprd02.prod.outlook.com (2603:10b6:803:20::25) by SN6PR02MB4334.namprd02.prod.outlook.com (2603:10b6:805:a4::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1382.22; Sat, 1 Dec 2018 11:13:45 +0000 Received: from SN1NAM02FT046.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::205) by SN4PR0201CA0063.outlook.office365.com (2603:10b6:803:20::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1382.21 via Frontend Transport; Sat, 1 Dec 2018 11:13:45 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) 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.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by SN1NAM02FT046.mail.protection.outlook.com (10.152.72.191) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1382.18 via Frontend Transport; Sat, 1 Dec 2018 11:13:44 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1gT3DU-0002W2-2e; Sat, 01 Dec 2018 03:13:44 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1gT3DO-0001kp-Vb; Sat, 01 Dec 2018 03:13:39 -0800 Received: from xsj-pvapsmtp01 (mailman.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id wB1BDX76003399; Sat, 1 Dec 2018 03:13:33 -0800 Received: from [172.23.64.8] (helo=xhdvnc108.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1gT3DJ-0001ji-2x; Sat, 01 Dec 2018 03:13:33 -0800 Received: by xhdvnc108.xilinx.com (Postfix, from userid 15427) id 413D5604D5; Sat, 1 Dec 2018 16:43:32 +0530 (IST) From: Anurag Kumar Vulisha To: Felipe Balbi , Greg Kroah-Hartman , Shuah Khan , Alan Stern , Johan Hovold , Jaejoong Kim , Benjamin Herrenschmidt , Roger Quadros , Manu Gautam , , Bart Van Assche , Mike Christie , Matthew Wilcox , Colin Ian King CC: , , , Thinh Nguyen , Tejas Joglekar , Ajay Yugalkishore Pandey , Anurag Kumar Vulisha Subject: [PATCH v7 00/10] usb: dwc3: Fix broken BULK stream support to dwc3 gadget driver Date: Sat, 1 Dec 2018 16:43:21 +0530 Message-ID: <1543662811-5194-1-git-send-email-anurag.kumar.vulisha@xilinx.com> X-Mailer: git-send-email 2.1.1 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.83;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(396003)(136003)(39850400004)(376002)(346002)(2980300002)(199004)(189003)(51416003)(356004)(186003)(551934003)(478600001)(6666004)(2906002)(48376002)(476003)(305945005)(486006)(50226002)(2616005)(126002)(36386004)(26005)(8676002)(426003)(4326008)(316002)(42186006)(107886003)(106466001)(36756003)(54906003)(81156014)(336012)(39060400002)(16586007)(106002)(90966002)(8936002)(110136005)(81166006)(63266004)(7416002)(103686004)(2171002)(5660300001)(14444005)(6266002)(47776003)(52956003)(50466002)(107986001)(921003)(83996005)(2101003)(1121003);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR02MB4334;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;LANG:en;PTR:unknown-60-83.xilinx.com;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;SN1NAM02FT046;1:MHU83GkrStIsasJE27XCvWINZ/TitfaSRZkBd1K4ubqjBabVyqD7z0UyuTkthzEbEc1udWap4g3O/zyw5DPjsRmvZIqmDIKfo2fLr6Sa1FPp1HVdT3yFA8BDaTYp7sNM MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9577a908-b197-47cc-990c-08d6577e0f40 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:SN6PR02MB4334; X-Microsoft-Exchange-Diagnostics: 1;SN6PR02MB4334;3:SjsSSvaFbAsBUCGzIjY2iNDeYlDOWHcQD1pmG7Xs77CtTdOrnSRabb5Q4u9H2/8yDxdLNbAqGnCiPKJf423GDKEwP9vTNKKlvaFs3EsmI3p+ngv/00Y45JwbsbtvCWBjJPr3aIikDAM3bZ3w7SrZN+Jk/+4Q9JeEiMCnDuP3JpSRbypNjx3PX0AXDW1ROMwGs9+xn3mbrAec9pBRf18RdVN00rYTpVNxqv+JjYVgItS502DCoOp7cdTDnkkdtsKBPFWEWoZstEJX9S60vn98YWmC7G5IFYUq1oStZOfQvqof9NqTsZbybor9omSpkqXlBTC7+w7kg1bRinUVE3WJBk3YY09lz9RWKdPfEobhsJk=;25:T5Z+9TGcsSrdWPZ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BnQ8r52nbS5kIut/Gx86duEd2s97e4hAs5V36O0cDLfPHJD3WCRfmbqR3eEe X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply 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)(10201501046)(3002001)(3231454)(999002)(944501475)(52105112)(93006095)(93004095)(6055026)(148016)(149066)(150057)(6041310)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095);SRVR:SN6PR02MB4334;BCL:0;PCL:0;RULEID:;SRVR:SN6PR02MB4334; X-Microsoft-Exchange-Diagnostics: 1;SN6PR02MB4334;4:qFxURIjnkHhtVqFc6Z5zQp8RHyb9iFyazrIkTd45UsKfKWD05Kyw/YJWZKhmON626ZH2KKxPVzRav6joCPE6lrn6tyffm3SbJczMohYVkhOlsS+1WaP3i1f9CB+30KJqtR0Q4zKyloYz2pt6LyuFrULFkKeuvAQv046LVf2izwzUlS7ak9c0fDX9I+IoFa1pPl390cp7iTqan+trkeNEEviDDav6Q5bYz0q+aFzZHsM6XGdR43dYolTLXT/3WFQ4tQKFJd/DTCq3kL/HHGGKzA== X-Forefront-PRVS: 087396016C X-Microsoft-Exchange-Diagnostics: 1;SN6PR02MB4334;23:4kZ15Pgcb9dC7Ql9EMmeGPGZ1HqLhGwUx9dxGK9T12g2VVUMtY101AF1oIQbVwTekGPLlWuRur8XNP89pCp8DzX6dlc8kUKOb8AvVyd1uYV8angb6inhz5jn7HhS7qcNIFSPuMbbW4S1y/AmeR96GXBafJ8sEV8RclJjrWisuQSo80Hz1ldvPLXMe6AjuYltf6fQVtNq58PYSrDiqYs1lq6yqQRH4Szha/riqqJpCKKcLkCli6OEhezEpEzg+qCqklCsHaDTv5FsBVqF7la3tWLsMD8TmzIs9HNx8FRFPdahgKdSybT6Q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BP2CpVBqykNyIV+923KBfjuKy+g== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2018 11:13:44.5391 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9577a908-b197-47cc-990c-08d6577e0f40 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.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR02MB4334 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 This patch series fixes the broken BULK streaming support in dwc3 gadget driver and also adds timers in udc/core.c for the endpoints which may go out of sync with host and enter into deadlock. For example when bulk streams are enabled for an endpoint, there can be a condition where the gadget controller waits for the host to issue prime transaction and the host controller waits for the gadget to issue ERDY. This condition could create a deadlock. To avoid such potential deadlocks, a timer is started after queuing any request for the endpoint in usb_ep_queue(). The gadget driver is expected to stop the timer if a valid event is found (ex: stream event for stream capable endpoints). If no valid event is found, the timer expires after the programmed timeout value and a timeout callback function registered would be called. This callback function dequeues the request and re-queues it again, doing so makes the controller restart the transfer, thus avoiding deadlocks. This kind of behaviour is observed in dwc3 controller and expected to be generic issue with other controllers supporting bulk streams. Changes in v7: 1. Added timer timeout handler into udc/core.c 2. Started timer per request instead of per endpoint as suggested by "Felipe Balbi" 3. Added usb_ep_dequeue() & usb_ep_queue() logic into timeout handler as suggested by "Felipe Balbi" Changes in v6: 1. Added timer into udc/core.c for stream capable endpoint as suggested by "Felipe Balbi" Changes in v5: 1. Removed the dev_dbg prints as suggested bt "Thinh Nguyen" Changes in v4: 1. Corrected the commit message and stream timeout description as suggested by "Thinh Nguyen" Changes in v3: 1. Added the changes suggested by "Thinh Nguyen" Changes in v2: 1. Added "usb: dwc3:" in subject heading Anurag Kumar Vulisha (10): usb: gadget: udc: Add timer support for usb requests usb: gadget: function: tcm: Add timeout for stream capable endpoints usb: dwc3: gadget: handle stream events usb: dwc3: update stream id in depcmd usb: dwc3: make controller clear transfer resources after complete usb: dwc3: don't issue no-op trb for stream capable endpoints usb: dwc3: check for requests in started list for stream capable endpoints usb: dwc3: Correct the logic for checking TRB full in __dwc3_prepare_one_trb() usb: dwc3: Check for IOC/LST bit in both event->status and TRB->ctrl fields usb: dwc3: Check MISSED ISOC bit only for ISOC endpoints drivers/usb/dwc3/gadget.c | 67 +++++++++++++++++--- drivers/usb/gadget/function/f_tcm.c | 25 +++++--- drivers/usb/gadget/udc/core.c | 119 +++++++++++++++++++++++++++++++----- include/linux/usb/gadget.h | 15 +++++ 4 files changed, 197 insertions(+), 29 deletions(-)