From patchwork Wed Jul 25 11:51:27 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: 10543897 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 E2F9F17FD for ; Wed, 25 Jul 2018 11:52:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D051829C7E for ; Wed, 25 Jul 2018 11:52:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C49CF29C95; Wed, 25 Jul 2018 11:52:34 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 DF7EC29C7E for ; Wed, 25 Jul 2018 11:52:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729007AbeGYNDW (ORCPT ); Wed, 25 Jul 2018 09:03:22 -0400 Received: from mail-bn3nam01on0041.outbound.protection.outlook.com ([104.47.33.41]:51362 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728899AbeGYNDU (ORCPT ); Wed, 25 Jul 2018 09:03:20 -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=kseCC0xZ7YIlqIpcH8Rvl4Lh6yI3ITlFDbRTl7l6tVo=; b=l9tXBkFNvYs13dv0Nyxa8k/Vh8rTxR5YAC4IIIlyo2R/YikOCc5Av4+l4TPmVg2LIS4hy+qquWB0evldidwIjsRlycf0lG0e5vZf3sdNCAE4l+RTn7CklqxymQqin9BvK/kB4EU9bS6xGMzaxdVrxhE0JGlvC+D1N32h4W0DsMY= Received: from MWHPR02CA0017.namprd02.prod.outlook.com (2603:10b6:300:4b::27) by BY2PR02MB1622.namprd02.prod.outlook.com (2a01:111:e400:5267::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.20; Wed, 25 Jul 2018 11:51:56 +0000 Received: from CY1NAM02FT018.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e45::206) by MWHPR02CA0017.outlook.office365.com (2603:10b6:300:4b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.995.16 via Frontend Transport; Wed, 25 Jul 2018 11:51:56 +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 CY1NAM02FT018.mail.protection.outlook.com (10.152.75.183) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.995.12 via Frontend Transport; Wed, 25 Jul 2018 11:51:55 +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 1fiIKh-0007iO-Hu; Wed, 25 Jul 2018 04:51:55 -0700 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1fiIKc-0006dG-Dk; Wed, 25 Jul 2018 04:51:50 -0700 Received: from xsj-pvapsmtp01 (maildrop.xilinx.com [149.199.38.66]) by xsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id w6PBpemF027054; Wed, 25 Jul 2018 04:51:40 -0700 Received: from [172.23.64.8] (helo=xhdvnc108.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1fiIKS-0006ZM-3a; Wed, 25 Jul 2018 04:51:40 -0700 Received: by xhdvnc108.xilinx.com (Postfix, from userid 15427) id 40DDF60505; Wed, 25 Jul 2018 17:21:39 +0530 (IST) From: Anurag Kumar Vulisha To: , CC: , , , Anurag Kumar Vulisha Subject: [PATCH 4/8] usb: dwc3: implement stream transfer timeout Date: Wed, 25 Jul 2018 17:21:27 +0530 Message-ID: <1532519491-19502-5-git-send-email-anurag.kumar.vulisha@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1532519491-19502-1-git-send-email-anurag.kumar.vulisha@xilinx.com> References: <1532519491-19502-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.83;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(39860400002)(396003)(376002)(346002)(136003)(2980300002)(438002)(189003)(199004)(126002)(63266004)(81166006)(54906003)(107886003)(39060400002)(356003)(47776003)(6266002)(110136005)(8676002)(478600001)(42186006)(36386004)(81156014)(50226002)(14444005)(51416003)(575784001)(476003)(16586007)(8936002)(2616005)(426003)(5660300001)(106002)(6666003)(11346002)(26005)(2906002)(316002)(486006)(106466001)(48376002)(186003)(50466002)(336012)(446003)(90966002)(305945005)(4326008)(76176011)(52956003)(36756003)(103686004)(107986001);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR02MB1622;H:xsj-pvapsmtpgw01;FPR:;SPF:Pass;LANG:en;PTR:unknown-60-83.xilinx.com;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;CY1NAM02FT018;1:Re1SgtBp+6mdKBj0ILiWRILravb36v9UB11nRq3D4rMgvBnAz5zZLilZA6koSnGMdvAAMFTgH25I5Lhpuj1Jz24tDnQLyXacTOLNoa23d5pbC4zB9dR7g1FjIhI1HoVx MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8386d945-5310-45e9-5f36-08d5f225059c X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600073)(711020)(4608076)(2017052603328)(7153060);SRVR:BY2PR02MB1622; X-Microsoft-Exchange-Diagnostics: 1;BY2PR02MB1622;3:cNQv5duNKLCw165FMCPhRJ/qvrh8IbZ+ZrXJKkfKpoDMlPBvzvsriGFIZs6P86Aynf7E34K5eCZhwpjilds/pO99QWPlKsDk0z/MfdDdX9NYn/sSg0EJfTXDEAx99y6l7DmQ0OcVVEvyIYhwPY8/PCdU5o4wsKmpE8CGcBfIeHfvdKHP8+5myFU0Y3bjoBX+A3t0F1ynE33oyUsCA0qydaUmVby1g/ptrfufKG7WIfurSc7410CipdBpTN9ZloxaC9l4QSqpRh/8fherSqj9HIk+ccxMIJf3TG8HkxugPyGbku6Wws7w5RSxxeFARmzL8fWALx3xUz5PNQ1RI4WGApoOrGdH8+ub8OO0JXB8p1I=;25:LSlJW5wOahDRoCQWggvU/Xs1vDAZZ1/T0PMTS2VcEHcjA1wN5W2nhqJlea+nXCqWLIITQS6W2hUTQMYs8KqixCSgpqJw3DDVfDg8zczrtYwLwNiai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, 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)(5005006)(8121501046)(10201501046)(93006095)(93004095)(3231311)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016);SRVR:BY2PR02MB1622;BCL:0;PCL:0;RULEID:;SRVR:BY2PR02MB1622; X-Microsoft-Exchange-Diagnostics: 1;BY2PR02MB1622;4:EGG41dolYvOBmLBBYmmZr+hu7+VNdc8IepQZ78n91kQKx3ttvyuX0SMFaYap8LkxZ1wF12aZZAr7VXRzgBTu6jwt5n0jGG4S9G5GQnHs2EzUJoKsMbJ6pyNqdXxDsPY3+eD+EixwPrzmLh8PhmUfUtRnTmDVgOMm5IOLwj4Lp/FCn+bKAHGRM+Ev3No6792Lx0HWG+fL4IGlLrCGtHBdkeykWLssU1S3zct/+FA/3vQB9hyS08RUGP6UOvfLrz/Xni7yaFrq/PsuBifkQzdbBennVRBNOJfvVWhSg1allPnB+ouokqoMel7MlTD5I8VG X-Forefront-PRVS: 0744CFB5E8 X-Microsoft-Exchange-Diagnostics: 1;BY2PR02MB1622;23:mlg2T+quKLR4F86zzEla0/tNjjCWS1CDgHGf0xHyVhUaqyVyws3oQgnZaqbydjPvfwMSyoRRS6x5DWkT6wWmD16IEBVA9wNjX+a4NYcRfn2eVHksC0NgNjiPjCYqpoiC4029xq+vAkI0JgGzFi3UKuCb7Nwr/oRJxkPZfcbao0vhpSblajP+ObYU62TejMIunjq7se2xOvAD9R09hp2hS3U7oiFTBbPXxEAsZPwm1X3x1UjoaxoWJ7zKw5RxI5jG1yrjVLGaBPlvdTZwHwk7G3WCZqumrBgjCo0h7xJ85zraZAm2cPX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vuZnL/Bbk1L2B1M3htt+VmznXh/MyQoQjUNowpGoZZ8u9XmhGAcaFUzOtO0cRSaX2k7RQMf8KSaxVENkHAdqOsnWMTmsU SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2018 11:51:55.9638 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8386d945-5310-45e9-5f36-08d5f225059c 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: BY2PR02MB1622 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 According to dwc3 databook when streams are used, it may be possible for the host and device become out of sync, where device may wait for host to issue prime transcation and host may wait for device to issue erdy. To avoid such deadlock, timeout needs to be implemented. After timeout occurs, device will first stop transfer and restart the transfer again. This patch does the same. Signed-off-by: Anurag Kumar Vulisha --- drivers/usb/dwc3/core.h | 7 +++++++ drivers/usb/dwc3/gadget.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 285ce0e..581f619 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -619,6 +619,11 @@ struct dwc3_event_buffer { #define DWC3_TRB_NUM 256 +/* + * Timeout value in msecs used by stream_timeout_timer when streams are enabled + */ +#define STREAM_TIMEOUT 50 + /** * struct dwc3_ep - device side endpoint representation * @endpoint: usb endpoint @@ -642,6 +647,7 @@ struct dwc3_event_buffer { * @name: a human readable name e.g. ep1out-bulk * @direction: true for TX, false for RX * @stream_capable: true when streams are enabled + * @stream_timeout_timer: timer used to aviod deadlock when streams are used */ struct dwc3_ep { struct usb_ep endpoint; @@ -691,6 +697,7 @@ struct dwc3_ep { unsigned direction:1; unsigned stream_capable:1; + struct timer_list stream_timeout_timer; }; enum dwc3_phy { diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index b3e9e7f..e2ccb55 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -254,6 +254,7 @@ int dwc3_send_gadget_generic_command(struct dwc3 *dwc, unsigned cmd, u32 param) } static int __dwc3_gadget_wakeup(struct dwc3 *dwc); +static void stream_timeout_function(struct timer_list *arg); /** * dwc3_send_gadget_ep_cmd - issue an endpoint command @@ -574,6 +575,8 @@ static int dwc3_gadget_set_ep_config(struct dwc3_ep *dep, unsigned int action) | DWC3_DEPCFG_STREAM_EVENT_EN | DWC3_DEPCFG_XFER_COMPLETE_EN; dep->stream_capable = true; + timer_setup(&dep->stream_timeout_timer, + stream_timeout_function, 0); } if (!usb_endpoint_xfer_control(desc)) @@ -730,6 +733,9 @@ static int __dwc3_gadget_ep_disable(struct dwc3_ep *dep) trace_dwc3_gadget_ep_disable(dep); + if (dep->stream_capable) + del_timer(&dep->stream_timeout_timer); + dwc3_remove_requests(dwc, dep); /* make sure HW endpoint isn't stalled */ @@ -1257,6 +1263,12 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep) return ret; } + if (starting && dep->stream_capable) { + dep->stream_timeout_timer.expires = jiffies + + msecs_to_jiffies(STREAM_TIMEOUT); + add_timer(&dep->stream_timeout_timer); + } + return 0; } @@ -2403,6 +2415,13 @@ static void dwc3_gadget_endpoint_transfer_in_progress(struct dwc3_ep *dep, stop = true; } + /* + * Delete the timer that was started in __dwc3_gadget_kick_transfer() + * for stream capable endpoints. + */ + if (dep->stream_capable) + del_timer(&dep->stream_timeout_timer); + dwc3_gadget_ep_cleanup_completed_requests(dep, event, status); if (stop) { @@ -2486,6 +2505,14 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, } break; case DWC3_DEPEVT_STREAMEVT: + switch (event->status) { + case DEPEVT_STREAMEVT_FOUND: + del_timer(&dep->stream_timeout_timer); + break; + case DEPEVT_STREAMEVT_NOTFOUND: + default: + dev_err(dwc->dev, "unable to find suitable stream"); + } case DWC3_DEPEVT_RXTXFIFOEVT: break; } @@ -2587,6 +2614,18 @@ static void dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force) } } +static void stream_timeout_function(struct timer_list *arg) +{ + struct dwc3_ep *dep = from_timer(dep, arg, stream_timeout_timer); + struct dwc3 *dwc = dep->dwc; + unsigned long flags; + + spin_lock_irqsave(&dwc->lock, flags); + dwc3_stop_active_transfer(dep, true); + __dwc3_gadget_kick_transfer(dep); + spin_unlock_irqrestore(&dwc->lock, flags); +} + static void dwc3_clear_stall_all_ep(struct dwc3 *dwc) { u32 epnum;