Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751424AbdIKJ6v (ORCPT ); Mon, 11 Sep 2017 05:58:51 -0400 Received: from mail-by2nam01on0086.outbound.protection.outlook.com ([104.47.34.86]:23328 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751253AbdIKJ6t (ORCPT ); Mon, 11 Sep 2017 05:58:49 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=fail action=none header.from=nxp.com; From: To: CC: Mathias Nyman , Greg Kroah-Hartman , "open list:USB XHCI DRIVER" , open list Subject: [PATCH 1/2] usb: host: Implement workaround for Erratum A-009611 Date: Mon, 11 Sep 2017 17:41:32 +0800 Message-ID: <20170911094132.38456-1-yinbo.zhu@nxp.com> X-Mailer: git-send-email 2.14.1 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131495975271007140;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(336005)(39380400002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(50944005)(81156014)(81166006)(47776003)(8676002)(8936002)(77096006)(33646002)(53936002)(86152003)(54906002)(106466001)(2351001)(105606002)(4326008)(50986999)(50466002)(48376002)(104016004)(7049001)(36756003)(5003940100001)(50226002)(6916009)(68736007)(305945005)(189998001)(110136004)(1076002)(85426001)(97736004)(6666003)(5660300001)(356003)(8656003)(498600001)(2876002)(2906002)(6200100001)(86362001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR03MB3315;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD046;1:nOv520dVux9SpjMVT1Z1yqTNHFqszkcAuPlMT1YqVDKW5JfJK31tp6hdnwe4Dc9sMIl7TUrOjo0sHHk/wrnwh8mTfKWmnYhqNQwHvu4nQKT1RnJ90VaNXF6Kc14pZys/ MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2da3bef4-945e-4048-03a4-08d4f8fbb1e3 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BN6PR03MB3315; X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB3315;3:sprpoaFEVyMz3+kngN4QP/sUgHpYN3Z5Vg7oPv4rrTpKzcDXrnnLWnKSr3Sn7N2IvtkNowyV3jHJ6paX1X3FwgoDwJhMelc2bQ2PWxPXw34d7h35t5yFqlabvTHzLh6fJH8ghVhwCxpn4yYQPlu93uozFTYqP7U++j3f1mR1e6CbV5VvsEIu9rICn1EcNrjpHc2Jr3/GlFftTIMUobwJEru5VNOcRKlM+qnIJNUa9qsJNzknhq5crU2rgwr5EASuS2mgKl+oBoLxUJACm/EXV7kZTQyEt1X0YlFsLQVPi4K9d/QKGzD0ojS5ccUxbti4TgbvCopZQyTanNBU/nBoAzbGI6sexpQUJM0G1ARjZNM=;25:DxKkKY1GOOrx76Ji0HWLb7E5KYMBgaW/GW0UaFSCPDEYCGwqubv9Z1heXjMA/x5FNOdgKDzTLeIIQRDr7i08/EJGmz7O5+YJrWXBRMkI0DwgGErFvFYZtkn3VCXQ92q7vjzEeY+r9HVR6uSU0HqrvKGojPrQmq+B91lhnIjfHhyimUrWjvzSxgzJfHI8+sdxx35AfKG+K6gndGMGtXNA63YkDkBlfWlcK7PxNf+nS5TEtBjRy/pZvdlEpKmfZ/6apzM0zJiYUTlWrjOBTcOR+S+iHypwdtz78GR5b8dXyMxNtRlUy8v+noCTEJIS3W3PEIrLk+93BwtNx8oerhPL4Q== X-MS-TrafficTypeDiagnostic: BN6PR03MB3315: X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB3315;31:caEt2C201fvvoHc3MXU0f50kib/U7Tv8jkKjOQG1fS9kdh9aFXBTA5F86XxTjqOwONegkS0ABug4HIy/iXhEN8JF0EzhwlG+EBbLSMP/aJvjuIBEE5ZzR6sTPYmJphCEovkPyj27bGlVKttH9y1fl5o4eToZ2dgPpJMKC2WEzxZkhipIK4yCyJgUo9xe9dL/CEqw+W7aLs0qG+ccc2KllmjrON7hFYExHacghv85J3M=;4:YdmSMGZ3xkJBZ5gIbKLFkyuiIFMopcG3lkWkd+Sm3+lN8VzZbwIOMpweSyLW+Qyl/5LVH2v9CiNsw6VwA40PJ8u8b0PVKjmW8eGaHon5hMQwW14AyoQIa0GDPrTqgO/lgVdLRM966a4EkZGlTgKqjwuBzn/E4onDvxo2a7tHXRGqtNG4/hFICJhXwVcbwNNbiju68cAx3jfEI/cgPQyL4NFfi1kgYYkulxijjizv4Qih/jrOa9q32Sa58yINZlCqnRr49Nw5S6hXUqt2D2VuQIBIEe1E74Br2Wyc+kkpdxM= X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(6096035)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(201703151042153)(20161123565025)(20161123561025)(20161123556025)(20161123563025)(20161123559100)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN6PR03MB3315;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN6PR03MB3315; X-Forefront-PRVS: 04270EF89C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN6PR03MB3315;23:0I5QH7WgkP4mwGkq4NFqkXh7IE+0CsAJkAuPmtXJK?= =?us-ascii?Q?mBsh+/tvAqMSYfOEqf4rwjW1KGyeU3N2dpSM1giiohrXchLxc/bJY4mKWBtz?= =?us-ascii?Q?pp9EvRYxgq3FQQCJhEvAyPJa8LD6lJGRmGjcGBpAQARc/gPPYTsj2rlZIsXC?= =?us-ascii?Q?rd9PvLmivtS+tu9+fJMreWC69qfqLM7qd+YCTjzSulowTk+maO/n45bhwQCA?= =?us-ascii?Q?j3Qoz58+tjjqNtTU6vBQGFwkU1RlsjrnBa7+O12TPIN6PmL4gKi7KMDy/U6M?= =?us-ascii?Q?nrILzRe6rgfKmikhgavszRQEf73JqJ381rlVemShDVlePV/jQVxFWDV7aoNv?= =?us-ascii?Q?eA/lnLr5WsdCmjkvoHrtnyjEYGRxVxfiX7R9JvdspsOjkc9R5Corcmrm/+Gr?= =?us-ascii?Q?y2SAcyTPCTzJjoDLstUCHtxYTIlNzrZCvd9iYzoSKeJCrAPJAjlCKdSAzvJN?= =?us-ascii?Q?8g0A83/6cAM8hcnQLocbl1ef0mGx9wbfLpH+hYue9PIrAl8bfQ9jQokvExJl?= =?us-ascii?Q?aABUpODFehqnJHfBr5UskjfaC3FGhb7nHSbsH27F96v4S4AX+ob/X9U+BOay?= =?us-ascii?Q?aIUQE9S48f8Yrr0DgMOzKCYs/JMZWmPawm97nrJHTsYNU3spJyPfv8CHuv+E?= =?us-ascii?Q?bVI4lh9KJMYyikvQrAai/B/tNnM86yqavyOWVS5N+8Zz44ooRJnt4/UOgUaq?= =?us-ascii?Q?p/15J50RS0DY1FHGjS+zqFsgL5wkmROby5sYN2qyPulRiZWsXFA7aN/Jv3jN?= =?us-ascii?Q?Uq4ZFCyTCq0PwsPm217JT8nxD5w7vVjQDSq6eqBjoCbN/ij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25kbiO82nrlCWfDGmylq/TVTZb053A1pyRo9WY7ugZT3ONrujlS4sN3d3uQt+NioEUoVSTGc=;7:1LWp6zbWsSgpgycpwhWTmdOFkH0uMjeROqWDjBnFZT0ORnbJ3ZDnDDli7yb5iuqeatzDg3IcrT34+qmoQkWbkRgLM6KfpGOtSTAWp4pK9VJzu8OsMOtqvLSwjU5KxkJP9Y2931DWPjF26ZMksofm9iAabs+Gsw07hudnJ9eZrkkUSj1Xb9Ot/ITDQpttn9N5NUF1uMalPd2yPRI7evRRBPBDh49QoFU22HsiAcLu70c= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2017 09:58:46.8979 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB3315 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2394 Lines: 61 From: "yinbo.zhu" Description: This is a occasional problem where the software issues an End Transfer command while a USB transfer is in progress, resulting in the TxFIFO being flushed when the lower layer is waiting for data,causing the super speed (SS) transmit to get blocked. If the End Transfer command is issued on an IN endpoint to flush out the pending transfers when the same IN endpoint is doing transfers on the USB, then depending upon the timing of the End Transfer (and the resulting internal FIFO flush),the lower layer (U3PTL/U3MAC) could get stuck waiting for data indefinitely. This blocks the transmission path on the SS, and no DP/ACK/ERDY/DEVNOTIF packets can be sent from the device. Impact: If this issue happens and the transmission gets blocked, then the USB host aborts and resets/re-enumerates the device. This unblocks the transmitt engine and the device functions normally. Workaround: Software must wait for all existing TRBs to complete before issuing End transfer command. Signed-off-by: yinbo.zhu --- drivers/usb/host/xhci.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 2d6a98c1dc12..35f7821bc8b2 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1501,13 +1501,22 @@ static int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) ret = -ENOMEM; goto done; } - ep->ep_state |= EP_STOP_CMD_PENDING; - ep->stop_cmd_timer.expires = jiffies + - XHCI_STOP_EP_CMD_TIMEOUT * HZ; - add_timer(&ep->stop_cmd_timer); - xhci_queue_stop_endpoint(xhci, command, urb->dev->slot_id, - ep_index, 0); - xhci_ring_cmd_db(xhci); + + /* + *A-009611: Issuing an End Transfer command on an IN endpoint. + *when a transfer is in progress on USB blocks the transmission + *Workaround: Software must wait for all existing TRBs to + *complete before issuing End transfer command. + */ + if (ep_ring->enqueue == ep_ring->dequeue) { + ep->ep_state |= EP_STOP_CMD_PENDING; + ep->stop_cmd_timer.expires = jiffies + + XHCI_STOP_EP_CMD_TIMEOUT * HZ; + add_timer(&ep->stop_cmd_timer); + xhci_queue_stop_endpoint(xhci, command, + urb->dev->slot_id, ep_index, 0); + xhci_ring_cmd_db(xhci); + } } done: spin_unlock_irqrestore(&xhci->lock, flags); -- 2.14.1