From patchwork Fri Aug 17 12:24:51 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: 10568707 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 37BBD14BD for ; Fri, 17 Aug 2018 12:25:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 242D22B020 for ; Fri, 17 Aug 2018 12:25:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17DAA2B400; Fri, 17 Aug 2018 12:25:26 +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 7B2BA2B020 for ; Fri, 17 Aug 2018 12:25:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727484AbeHQP23 (ORCPT ); Fri, 17 Aug 2018 11:28:29 -0400 Received: from mail-eopbgr730078.outbound.protection.outlook.com ([40.107.73.78]:1584 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726795AbeHQP22 (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=kdx9OIFGBN8hg2SN0GaRDQsgf+nUyqA+bZSU7irLA0A=; b=PITN4PNItWuaZGWuxCb3vmAECZnc5FHtDYnKy9Q7asfN7cyWLsMmstb48zbR/CzDNtrVObRUUDoRX3Hwuq7XpBMsCC+pYUDlWWpEtvr2qMGvzWCbjJN2URuoPzp/2s7L3mwRyVpxYFhh8kMSuPcxT2qgo7Bm5B1VXHHfEfozJv8= Received: from BN7PR02CA0016.namprd02.prod.outlook.com (2603:10b6:408:20::29) by DM6PR02MB4460.namprd02.prod.outlook.com (2603:10b6:5:29::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1059.20; Fri, 17 Aug 2018 12:25:06 +0000 Received: from BL2NAM02FT054.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::207) by BN7PR02CA0016.outlook.office365.com (2603:10b6:408:20::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1059.21 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 BL2NAM02FT054.mail.protection.outlook.com (10.152.77.107) 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:05 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:42351 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1fqdoP-0008VN-CX; 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-Bq; Fri, 17 Aug 2018 05:25:00 -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 w7HCOwnZ019095; Fri, 17 Aug 2018 05:24:58 -0700 Received: from [172.23.64.8] (helo=xhdvnc108.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1fqdoH-0000TW-Vs; Fri, 17 Aug 2018 05:24:58 -0700 Received: by xhdvnc108.xilinx.com (Postfix, from userid 15427) id 1A1226050B; Fri, 17 Aug 2018 17:54:57 +0530 (IST) From: Anurag Kumar Vulisha To: , CC: , , , Anurag Kumar Vulisha Subject: [PATCH v2 4/8] usb: dwc3: implement stream transfer timeout Date: Fri, 17 Aug 2018 17:54:51 +0530 Message-ID: <1534508695-12642-5-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)(396003)(376002)(346002)(39850400004)(2980300002)(438002)(199004)(189003)(52956003)(8936002)(36386004)(47776003)(2616005)(126002)(486006)(14444005)(336012)(26005)(476003)(81156014)(6266002)(81166006)(36756003)(575784001)(63266004)(186003)(6666003)(8676002)(51416003)(356003)(107886003)(5660300001)(305945005)(110136005)(39060400002)(54906003)(106002)(426003)(2906002)(42186006)(90966002)(103686004)(16586007)(106466001)(50226002)(11346002)(478600001)(446003)(50466002)(316002)(4326008)(76176011)(48376002)(107986001)(5001870100001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR02MB4460;H:xsj-pvapsmtpgw02;FPR:;SPF:Pass;LANG:en;PTR:xapps1.xilinx.com,unknown-60-100.xilinx.com;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;BL2NAM02FT054;1:hQa38XuJNznv814CAq+RqmSqDnRIdUzv20S2/kb6N03NNoaaeFqGW8YQdbTO01HqXz+jybgNL66aSKyoERbdQ7r+zWaJD4GXyWb1TKY9Ej+ACf5prZVzcSdc6+pjSXVN MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e6dc72b-dd1e-4017-28f5-08d6043c7719 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:DM6PR02MB4460; X-Microsoft-Exchange-Diagnostics: 1;DM6PR02MB4460;3:2DOE4OkZln0LIp+UNF9aRuWF1oU1C08MXYSUICSjgAh3aK4EzuHojFs+wdgPS4UT9fpRc9W/Zg6NhJNR8kMCCKHlcywLn3YjmVWddeIFDPVIYwxsC9z9rqOIM8xxbJOPtnVxE0ngKu5I/+F4jikb2kHOW3n6nHyQ8AprgBw05FFLbwxu4CFb43RX67bozUHorArNilDQ3oQAgy9XZmpPGrE1llp2fx5a3uWkNxyVo4/sAsAAub7PoK8Oef7Yn04+fkZBPw3Od0DPQT9thQuEU06ATzTMOsntxdFx8xB3YDFYjjGBvGcHB4Xtf6MmXBCe+C74Zn/tN3BJC6s3+4qRo7LgSl4kYzIEsEsjTALwb2w=;25:0iCiSil3QvNndn/c6yJNF7nex+Qdq3vzObAFoOyFB7LqNBcpQozcSF9oi3gBqWyW2iCdJJuNRJ+OihbD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i2aTrne 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)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93004095)(3231311)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(201708071742011)(7699016);SRVR:DM6PR02MB4460;BCL:0;PCL:0;RULEID:;SRVR:DM6PR02MB4460; X-Microsoft-Exchange-Diagnostics: 1;DM6PR02MB4460;4:C5IfWaYyxqQGrdd2Hl7v7z3hVxDWPdJCIklD1JhHs1bnp+LB6eh7F5wZhkD3v1p+Y63NyXzY0dX3rfBf0oyG4mNXmS4XkOp8IwGvMw4xODlZw953C0lIppE5Xk2DyKIk+E3tAOPlyMTfAAJjGPBY1T+Di0NCq5zKl7V5QDIDBcd304KBN5/YEL0rpn1bPuwQYLyJ76VlU82jZIgHdW9qHViczP+2lKcvd/59tnQIbWIORAgvln8BCtaq8e2dT2koF36t3ERYAgKNB/MDUOJzZblkFFJzVQtNxEdRnEtCQ6EiCtJsVPVNkwdM2UG5d/84 X-Forefront-PRVS: 076777155F X-Microsoft-Exchange-Diagnostics: 1;DM6PR02MB4460;23:v7JMbswzyVJ1rQBJil5FXSWSYRfbU5zHG2jak8krJ3CqToKh2f61BU59znw5bP8vAHw6yQv+xMselA5hvbyygz08njKpi+whwChdnx/mGT3pKlBI2oxLmOxV2DH9zGG708eQDppSzFLZ7XJnOQTkzkZTDED/ei3wB+HHEeA3s3WXIUL9eoXpkWJyu5FmApBVqnDuRAQG6MLGyrpwTqyGVsfleEcc5arTY6EC4ikECbgCN7LboI07inJV1LwOR9z6KKkmfg/kYvKw71dB/1IQNPtOleipvFc/OaE4TOEAxwq4sp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MDW2BjjXB7lzTzX27VHKjs7XaiZaVe3glYmoeMECrJkTGhfWa+nOpF4Pn6dJwouxPT0TKa954OoxhNUG26iXySNmLh2LPSEMdXhXb0q+6+I2QzlnYhT82qX3ngfX0TraptHobjeCmBcEAW6ftOaF SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2018 12:25:05.9534 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e6dc72b-dd1e-4017-28f5-08d6043c7719 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: DM6PR02MB4460 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 --- Changes in v2: 1. Changed STREAM_TIMEOUT to STREAM_TIMEOUT_MS as suggested by Andy Shevchenko --- 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..f58640f 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_MS 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..8cef488 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_MS); + 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;