Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S939093AbdLSKfc (ORCPT ); Tue, 19 Dec 2017 05:35:32 -0500 Received: from mail-bn3nam01on0061.outbound.protection.outlook.com ([104.47.33.61]:55446 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934694AbdLSKfY (ORCPT ); Tue, 19 Dec 2017 05:35:24 -0500 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; From: To: Felipe Balbi , Greg Kroah-Hartman , Mathias Nyman , "open list:DESIGNWARE USB3 DRD IP DRIVER" , open list CC: , , , "yinbo . zhu" Subject: [PATCH v4 2/3] usb: host: Implement workaround for Erratum A-009611 Date: Tue, 19 Dec 2017 18:16:17 +0800 Message-ID: <20171219101618.45650-2-yinbo.zhu@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171219101618.45650-1-yinbo.zhu@nxp.com> References: <20171219101618.45650-1-yinbo.zhu@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131581533104005989;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(336005)(39860400002)(39380400002)(376002)(346002)(396003)(2980300002)(1109001)(1110001)(339900001)(199004)(189003)(50466002)(105606002)(86152003)(104016004)(4326008)(48376002)(81156014)(81166006)(305945005)(51416003)(498600001)(5660300001)(8936002)(106466001)(8676002)(8656006)(2950100002)(76176011)(53936002)(50226002)(68736007)(2906002)(1076002)(97736004)(85426001)(54906003)(110136005)(316002)(36756003)(16586007)(77096006)(59450400001)(575784001)(86362001)(47776003)(2876002)(356003);DIR:OUT;SFP:1101;SCL:1;SRVR:CO2PR03MB2359;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11OLC007;1:oWwNwsPNtPiDSEycp3EwlhD49mqzKa3nwozj7Y04ri18rIL9qltI0xTrPZwlgumRj+ZGsmYe9yfYO56HyABCbsfjfzrHtQ5IgqMeEmni2xyRkwI/DgMItFQ0pSbrvEgh MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1d994d45-32ab-48fb-6365-08d546cc2e21 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4628075)(201703131517081)(2017052603307);SRVR:CO2PR03MB2359; X-Microsoft-Exchange-Diagnostics: 1;CO2PR03MB2359;3:LX8JYXy9seA0tkDzTYTPDM9ctE9GTCb6wcBRmMV2DMGaWwphKkdj6x1XIsq38/gN0IdrrV4gicxlwyidJN7uSpIzq8Xr7HQZOoMfnq2Ap5QSDDX/9DfNaFPGn0RB596azDUWl8pDViYYEWKdHajFQ9KOyExjoDyqwWy45hZXLCBbsUxT1h80/3w96wDTS57njiwwWSEO4vNCn+EZ+Tn1rUXtPjtUexw2FwRyPxm1uUCpNJWzI80Fk335y8Ha+taHxq3JneAMlhWdFeXA5Lv/94BVYt/XyoeGeC9Mf9yg+rIt87t06uVdKXWaQRzxqcA8/Hq9xKU4K1uvgykoUQlWJRTFdi900hRWmn5ZnQ77h+Y=;25:7wHsg2H7mTiPaVZDZ4nlePL/td4voZYFeIvW8YKmrQ/yIQ0rF7N3+VXpvr8wacHu9RrXDE2LT/oVQAhxYG4pNjEHcW6OinZDZ/q5TI8nE0PVVS5nR97P8kaoHHzunny1aneuMU3oN17tqeJEpvs8c5JLVCS7sOn4ZQ9Mby+LF6sSOFUSBw6F2qP/zTCR85KMzff8ZSsB/Nhen9AU8t4xg7a2/rl7UEYk2T10qGQJME4HZXkitNCZ0LlBghtI+YmmCpP4b+RLu7N0RHhMD/9nEn9vFg/ALOqwlfcAPDAqnmLaGo38L1cfnXbIdBoUyDbvMjhyrMhcHZDsNHoNTxVKVQ== X-MS-TrafficTypeDiagnostic: CO2PR03MB2359: X-Microsoft-Exchange-Diagnostics: 1;CO2PR03MB2359;31:KDPu3+fG1K+s5jaaKHcWUK7jRnmaLV3CTw/t/0Y9BcR4cqIwFP5xjzpBu3IPQK4tCim3ASrglPA2b8SFUHNuM34wOaFMgrwJ5P1yINkiLes2fS/ttawjCABhrAdPqiSrFJhvu5v+M1uWpevRJA0V6bX3CG456Ts1pnuPM1IN4zG811dEOAYTrbD3I8ghbWGSOvuHlh2oxC94wmhtTfKE5mkUUCOvLLF4K5/Ywqs4RhI=;4:Xjb88PSgjfKBNt693B42PQL0QvVdkieQ6CNeolu9x8IyiZnYHLR1bA6j/HuMWYgVSFxc4ojW1qCblpFaM/tNXQsyAHUq/uWx9JEIcUeVysOsew0hjLfsl+FTpJaVVwac1u/GLr2yHNblb7te8pIDby/dMVNHs+SlvHuzKyHqcPE1ABBxry87d1T1QXZ0+sfsm82GZNTtv8P1EY6HeHzYmdt7NnblfeAlud3utrEnmMLF0EStZ/Y5WDaip7L8IQAprvj0d/jBQ5ueu5nnxSfZKKEaHz0L9eI8STE2tvSh7OxEbMlsZjH3EU06CfTJ/oY3 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095135)(2401047)(5005006)(8121501046)(3231023)(3002001)(10201501046)(93006095)(93001095)(6055026)(6096035)(20161123556025)(20161123561025)(20161123565025)(20161123563025)(20161123559100)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(201708071742011);SRVR:CO2PR03MB2359;BCL:0;PCL:0;RULEID:(100000803101)(100110400095)(400006);SRVR:CO2PR03MB2359; X-Forefront-PRVS: 052670E5A4 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CO2PR03MB2359;23:Ww8M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nbagurjr6Gsygb3D7ZzZyfuSEY8a+iLrGX5pXjvRb8cOLokEvsr9Fi3sKep3E5jMMzCjaiTlxT5txtpkrbj3epPrk7PjTQt410KlA/OQq/TLLyhTEwcKlrsmjidNW9ZZJkaHD4+ZsIrQhjlEPJjBGEVn8wkLgJ+scQCs/09onSVRo1nUBQ2BLP0Zzr4L64ULk4J9v+aPxeDvOUxD4V3AyO+U SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2017 10:35:10.1978 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1d994d45-32ab-48fb-6365-08d546cc2e21 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: CO2PR03MB2359 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5809 Lines: 151 From: yinbo.zhu 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 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. Configs Affected: LS1088-48A-R1.0, LS2081A-R1.1, LS2088-48A-R1.0, LS2088-48A-R1.1, LX2160-2120-2080A-R1. Signed-off-by: yinbo zhu --- Change in v4: Remove the point in "yinbo.zhu" drivers/usb/dwc3/core.c | 2 ++ drivers/usb/dwc3/core.h | 3 +++ drivers/usb/dwc3/host.c | 3 +++ drivers/usb/host/xhci-plat.c | 4 ++++ drivers/usb/host/xhci.c | 25 +++++++++++++++++++------ drivers/usb/host/xhci.h | 1 + 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 6613bc0..863f2c0 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1057,6 +1057,8 @@ static void dwc3_get_properties(struct dwc3 *dwc) "snps,tx_de_emphasis_quirk"); dwc->quirk_reverse_in_out = device_property_read_bool(dev, "snps,quirk_reverse_in_out"); + dwc->quirk_stop_transfer_in_block = device_property_read_bool(dev, + "snps,quirk_stop_transfer_in_block"); device_property_read_u8(dev, "snps,tx_de_emphasis", &tx_de_emphasis); device_property_read_string(dev, "snps,hsphy_interface", diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index a263fdc..6276678 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -858,6 +858,8 @@ struct dwc3_scratchpad_array { * 2 - No de-emphasis * 3 - Reserved * @quirk_reverse_in_out: prevent tx fifo reverse the data direction + * @quirk_stop_transfer_in_block: prevent block transmission from being + * interrupted * @imod_interval: set the interrupt moderation interval in 250ns * increments or 0 to disable. */ @@ -1011,6 +1013,7 @@ struct dwc3 { unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2; unsigned quirk_reverse_in_out:1; + unsigned quirk_stop_transfer_in_block:1; u16 imod_interval; }; diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index dab5f49..78cb7bb 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -93,6 +93,9 @@ int dwc3_host_init(struct dwc3 *dwc) if (dwc->quirk_reverse_in_out) props[prop_idx++].name = "quirk-reverse-in-out"; + if (dwc->quirk_stop_transfer_in_block) + props[prop_idx++].name = "quirk-stop-transfer-in-block"; + if (dwc->usb3_lpm_capable) props[prop_idx++].name = "usb3-lpm-capable"; diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index fe71b92..35e0fc8 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -269,6 +269,10 @@ static int xhci_plat_probe(struct platform_device *pdev) if (device_property_read_bool(&pdev->dev, "quirk-reverse-in-out")) xhci->quirks |= XHCI_REVERSE_IN_OUT; + if (device_property_read_bool(&pdev->dev, + "quirk-stop-transfer-in-block")) + xhci->quirks |= XHCI_STOP_TRANSFER_IN_BLOCK; + if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped")) xhci->quirks |= XHCI_BROKEN_PORT_PED; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 05104bd..5141856 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1501,13 +1501,26 @@ 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 + + /* + *erratum 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 && + (xhci->quirks & XHCI_STOP_TRANSFER_IN_BLOCK)) || + !(xhci->quirks & XHCI_STOP_TRANSFER_IN_BLOCK)) { + 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); + 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); diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 9f133a9..db10ee4 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1820,6 +1820,7 @@ struct xhci_hcd { #define XHCI_NO_64BIT_SUPPORT (1 << 23) #define XHCI_MISSING_CAS (1 << 24) #define XHCI_REVERSE_IN_OUT BIT(32) +#define XHCI_STOP_TRANSFER_IN_BLOCK BIT(33) /* For controller with a broken Port Disable implementation */ #define XHCI_BROKEN_PORT_PED (1 << 25) #define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26) -- 1.7.1