Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1792938imm; Fri, 7 Sep 2018 06:18:40 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaYCAn9JAIps2O/sw/nmBoeuQWquhhPgdmC1DEQJbi41YD1osgPO5vt1BTu6DD0NPWbKibt X-Received: by 2002:a62:8186:: with SMTP id t128-v6mr8289663pfd.192.1536326319907; Fri, 07 Sep 2018 06:18:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536326319; cv=none; d=google.com; s=arc-20160816; b=hdYjcSAEGreHwKV61yQAO/z5pB0Df2uzIIbv6pQRZbHf6Jfjn5qifGN4ReSpKuOGEA zVL/8mkXdH6dXONNQgjzHDhbvT3ksaN4qO4ZFdGhSmyABjoxSjTd2oz4SzNpesd8mYV0 C8MUtnxe6/i/mAE0LHmRTbZtle0aZMHmYhEnp8008CvyU0gTbOv80JI1mPzIK26cUJiL 5XKS8RoRUpzPiTBnsS8cw/Ut8u1YxldBi+/nEH9qoJkIEVg2unSI09ubTnMMqOtBJ3CH KUF5JS004oqSWDJknBFR0NJ68g7UsrLQc61oxjYRt34nmXa0c0aIMCN00kcgoTpTnBJi X6zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yunVzcyw+srTsSotZNAFuedem7YsFjztCVDhgC/jEFg=; b=ShKdFGGdqsKuxNvAqlMwZfL5HR3HsSLDD+QfLFM8uc6YQ3G/hs0Zxvqrd4ZrQMOVlM 6IF2vJlasWIQJXl1PhfPPisiTq3Mc85QyOrmhojxhJxU9mgA9BZHFfcc67nogsSGz5wJ BfPHixwecvrrC+wpntH6oDyCSzNmmMAYn8K/yUVZeege2uMPTgyKk8ayNfMvMy79ug8S U7xTTXx2wq9z97jWZWTgYngtd9XeJnkXl24gdIj/d5Y02NEpSgdUDWVWAmMrdDKwBqyf vQV8+9fMmaNbAFBRLm2GIrKSlE7qcfrJBkNpRGVUOI+Y0u4DIBI7mYvD47xkxVwA2D7p Jgqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xilinx.onmicrosoft.com header.s=selector1-xilinx-com header.b=5Y0Nd+JD; 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 i6-v6si8485822pfg.175.2018.09.07.06.18.24; Fri, 07 Sep 2018 06:18:39 -0700 (PDT) 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=5Y0Nd+JD; 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 S1729434AbeIGRz0 (ORCPT + 99 others); Fri, 7 Sep 2018 13:55:26 -0400 Received: from mail-eopbgr720063.outbound.protection.outlook.com ([40.107.72.63]:27072 "EHLO NAM05-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728322AbeIGRzY (ORCPT ); Fri, 7 Sep 2018 13:55:24 -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=yunVzcyw+srTsSotZNAFuedem7YsFjztCVDhgC/jEFg=; b=5Y0Nd+JDf41yXxHMNk6gGObWDk1wnGFPvq1yfWRHOOrZ7n6mQwmev59QN8VKqgCNQTbjA9Theglw1MZm4qCKgHVSwTmudFE4Vg7Y6OBazvyLxWiXq+l96u5PPVH7rPM52tm8bWJvyq17G5w/vNOL33I4WS4LmsvhTNxifi37nkk= Received: from BYAPR02CA0057.namprd02.prod.outlook.com (2603:10b6:a03:54::34) by SN6PR02MB4943.namprd02.prod.outlook.com (2603:10b6:805:99::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Fri, 7 Sep 2018 13:14:22 +0000 Received: from BL2NAM02FT062.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::208) by BYAPR02CA0057.outlook.office365.com (2603:10b6:a03:54::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1122.16 via Frontend Transport; Fri, 7 Sep 2018 13:14:22 +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 BL2NAM02FT062.mail.protection.outlook.com (10.152.77.57) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.1122.15 via Frontend Transport; Fri, 7 Sep 2018 13:14:20 +0000 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:46050 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1fyGaZ-0000Wh-Ql; Fri, 07 Sep 2018 06:14:19 -0700 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1fyGaU-0005mb-MU; Fri, 07 Sep 2018 06:14:14 -0700 Received: from xsj-pvapsmtp01 (xsj-mail.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id w87DE7ux019599; Fri, 7 Sep 2018 06:14:07 -0700 Received: from [172.23.64.8] (helo=xhdvnc108.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1fyGaM-0005le-JK; Fri, 07 Sep 2018 06:14:07 -0700 Received: by xhdvnc108.xilinx.com (Postfix, from userid 15427) id C3A0F604DB; Fri, 7 Sep 2018 18:44:05 +0530 (IST) From: Anurag Kumar Vulisha To: , CC: , , , , Anurag Kumar Vulisha Subject: [PATCH v3 4/8] usb: dwc3: implement stream transfer timeout Date: Fri, 7 Sep 2018 18:43:45 +0530 Message-ID: <1536326029-16327-5-git-send-email-anurag.kumar.vulisha@xilinx.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1536326029-16327-1-git-send-email-anurag.kumar.vulisha@xilinx.com> References: <1536326029-16327-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)(346002)(376002)(39860400002)(396003)(2980300002)(438002)(199004)(189003)(107886003)(90966002)(39060400002)(426003)(6266002)(106466001)(47776003)(50466002)(316002)(36386004)(486006)(48376002)(5660300001)(446003)(76176011)(2616005)(51416003)(476003)(478600001)(11346002)(54906003)(42186006)(110136005)(2906002)(16586007)(103686004)(8936002)(50226002)(106002)(97736004)(81166006)(356003)(26005)(186003)(81156014)(8676002)(126002)(63266004)(53936002)(6666003)(336012)(52956003)(14444005)(305945005)(36756003)(4326008)(107986001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN6PR02MB4943;H:xsj-pvapsmtpgw02;FPR:;SPF:Pass;LANG:en;PTR:ErrorRetry;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;BL2NAM02FT062;1:GUj5A/NvYwSunMZXgPXrLVAUCKCbUbHacpFvwyu8pSxbKSIIm/nfEQHC0B/idvjHCyQ5c6+XXkMGWW8RhLawYTC7EWba1daBJOqvnKsTSlXNzuPUr3/a5qkcPGLvwOmp MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ff7fedbe-3dea-4de7-b862-08d614c3d2c6 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:SN6PR02MB4943; X-Microsoft-Exchange-Diagnostics: 1;SN6PR02MB4943;3:WLgM98oYauNtGvjRcdBp5CfSpOM/+8O8lrrb3lghDTc2AEjr4WGAAtbpGS4mEhkES3cflsYsJBLukKceQfO6zFhohtY+BbtEBaBXsYPunqsYFdYDpbW/8+BG5j238eyTgJ4RWPT0IWBtKUJaKIUCuvRCxhzMRc/iBx+FFUgPsp68/XRXsrRs/7T5FgRUk1/p4YF7+BUew5IR7Vp6ZFnc0KbCapHdvWkGjqmYKC8esM3lmSSDCM6TzRKb9VG+3WVBJo2oYTLQmytHQDSfdw2kn6KH91lfEx6eZthr0nII5Y8+lc0Cqb4O3YjO+ifB4389gGyLDGuOsrk9s+jHfhyaTpLeky8BMvdTTV4FPkNlGXw=;25:oSOI4MeiXD66nvIFWIzqYBT7QqjxlPvCMUUAjcE2sSIXT2zpeUSI5tHWApZROEYLHA2ZeHYgjB7upmSny2HmzTfaifIKXNXLxZKN9bmVelSgztLHHs+vs2idLfrNWyX1CF0AWLK07uM7Z3TjdC+thGjN+QT1pUVhFYHYjBO77kHJVt0b8yGWuasi/MIUicDWCqaCgmcfNuVv0Z59/vSA8Bvxf6d6rOpVx12Ti6uAuDQ9nIbRBzh+OZmQ836dasY4cyJtwpBh0qH2geN8yixZApcPB0VIMaGRPYQNTVnihd22DA6hgbc8L+xG+BPZI/+Q6q4tO/kHNok8oCeoXNaHvw== X-MS-TrafficTypeDiagnostic: SN6PR02MB4943: X-Microsoft-Exchange-Diagnostics: 1;SN6PR02MB4943;31:2LJa4iOWcRt2HLD8iuhYb0oLtCOtYzzfoaJnGEBwo8OE5iCVi9KpIfa+z/7tOz64a6jxqmkBumgUFn+F7boOuJcoT62KaId/nDUyo1hONeNQkifXudFwFLgrlO4annhdgaRzN8zEzChhd+0kEaCbcEvgCqE/qQrVftejg491kDRObjLCyXZgLuSWDAUg/GqFePZW6SauMI+JVQQti/5+O21xCr+cWq00CFp60wiR/Ps=;20:wJx11feS90kJZ5EvDYCwK6pqKeVQEyyYjI+oUUSTv1wH7tnhS7p7v/nJYWeHnDxcn8GvaE7VCnCjJOjhMxaH9ZV1skRl/Rqe1PyTH98IcjZ01wPj53DSjMF6dcX9ekxm5qayuVl7WzGScV/scjETziOFTSHZrmisV7PUFQ410Nsnd+oaRfysCda+XUtj0VvBF9Nwznu/Owx3zsjdFFV5V5zWTZeERP3okG3pfWs/bbIHZofrtvgJ7hBArBQ0EGJY4zkKs/MDCxA1sH/xc1u5Rq8HJYi1oOO02y85tk6YC+6F4MruNNvgMPUyGQk7ZMoZl+EF8Z+r0QA+MokMLV1D7so3tdxMDz6EnDMlc4kTHEG7F8P4ANzzhmZmNStFWTeiC56P/7WJFvASj0pE6xslq3KJe1JeO7rXVbeIZe5TrEgT9CpJfQl1har1RCdD2xQ343pXiFuZ4NqpIheCnUoMxQ+sDdWc0jrattjSMWvub2Y+6tnfMaXejZVDAkkS0HKs 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)(93006095)(93004095)(3231311)(944501410)(52105095)(10201501046)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699050);SRVR:SN6PR02MB4943;BCL:0;PCL:0;RULEID:;SRVR:SN6PR02MB4943; X-Microsoft-Exchange-Diagnostics: 1;SN6PR02MB4943;4:Ww0vtOsz6mG7euHmb3HRc7Lr84kwKu4vMfviVMepwIT/gjIWtkn87zpXPPo2aUv9Y74EPUQaLWxm4S0S9Z5tIcwqJ8eq9QbWSBhcnFQUJMJFOPLAjwPOi1XuHVNeZcgu06ixo79ypgfk6X2psjv6hegPurQj/m/R2x9XfoyIPxox2gkLaGTs3ZB1S5gajjTjNfJ/Fh3kZdZW6JUc72qDwap94tVqeC4c6rMRj1B5v+lj23bEebbkY2r3L5kid9b8XyYfJ2OwjAHCdaOPB9i/mapB3Z/SLfPkzixjBnIPjqfvTi8CxNHcwwASeiV/NvY5 X-Forefront-PRVS: 07880C4932 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN6PR02MB4943;23:4FKDSMXXBGAYMGv3Rc5zhzK2UOQwbw5AlqG5vpvgE?= =?us-ascii?Q?imYnEpOtNFl2+2YqZ/B98wmriHyS1HRRF0eFmkPqhK8StPOst4p5z1bAttcQ?= =?us-ascii?Q?2CVcSxgx17VVnTa9aA3OFBhPzk3yo/qGAHajWjuywr1W+jxHMDSL7N10f6Ob?= =?us-ascii?Q?4VIOfbwjSi8jT4EF+vsSvf8uWkJ5iW107A9PgwPVAOW6vK/X4ebnmONI1r0R?= =?us-ascii?Q?/UbZsZxXRjui+bWn488I7vPyzL7rshTQFRYNG7Fx2oKe6QmsXK8haPollF4i?= =?us-ascii?Q?kJzhTEhuNBwz4KX8hq7jx8Y7SMSItZi1Mt1qjI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X7AnMaZll5Mnw/DT2a+0Uk4Bn0B+BvNm+ZTsGuaBGnvSYBKZv0RFRVe/E4Mjk2QfrpzC1gcNA=;7:+AmxzE4JA+DyGwXSVbb+QrmFDYxsulrbLpRLz4mAYZfz+6uwLMMp+FyTLgyBpkr99HGSTwchhNUcKwAuYgI/XYEai/qVLJvLKKQ6wdSuH759H+tWcuEyGX9AdickOCioDsos5RnKyFGJVcijC4Dx88uxnbqJMP1aQVfKmlFvUZEwp9Cw5gugG7D0UUVYHfw/CDy/XcQRXq28YbjZWY+pQzbHoJUJgN1nKAUaKOS8KvDQNfI6iH7pKJX4Fkkkd7Xs SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2018 13:14:20.4420 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ff7fedbe-3dea-4de7-b862-08d614c3d2c6 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: SN6PR02MB4943 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Thinh Nguyen --- Changes in v3: 1. Added the changes suggested by "Thinh Nguyen" 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 | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 5bfb625..0b255e97 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -633,6 +633,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 @@ -656,6 +661,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; @@ -705,6 +711,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 13ea282..98e5f39 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) { @@ -2487,6 +2506,11 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc, } break; case DWC3_DEPEVT_STREAMEVT: + if (event->status == DEPEVT_STREAMEVT_FOUND) + del_timer(&dep->stream_timeout_timer); + else + dev_dbg(dwc->dev, "unable to find suitable stream"); + break; case DWC3_DEPEVT_RXTXFIFOEVT: break; } @@ -2588,6 +2612,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; -- 2.1.1