Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751515AbeAEKAU (ORCPT + 1 other); Fri, 5 Jan 2018 05:00:20 -0500 Received: from mail-bl2nam02on0044.outbound.protection.outlook.com ([104.47.38.44]:54087 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751476AbeAEKAM (ORCPT ); Fri, 5 Jan 2018 05:00:12 -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: Ran Wang To: Rob Herring , Mark Rutland , Russell King , Catalin Marinas , Will Deacon , Mathias Nyman , Greg Kroah-Hartman CC: Shawn Guo , Felipe Balbi , Li Yang , , , , , Ran Wang Subject: [PATCH 4/4] xHCI: Handle dwc3 erratum on USB3 HW LPM feature. Date: Fri, 5 Jan 2018 17:40:09 +0800 Message-ID: <20180105094009.22599-4-ran.wang_1@nxp.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180105094009.22599-1-ran.wang_1@nxp.com> References: <20180105094009.22599-1-ran.wang_1@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131596199834179139;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(346002)(39860400002)(39380400002)(376002)(396003)(2980300002)(1110001)(1109001)(339900001)(50944005)(199004)(189003)(81166006)(68736007)(8656006)(110136005)(50226002)(316002)(81156014)(8936002)(106466001)(54906003)(105606002)(4326008)(1076002)(51416003)(76176011)(77096006)(97736004)(86362001)(356003)(104016004)(305945005)(50466002)(36756003)(7416002)(53936002)(48376002)(498600001)(8676002)(59450400001)(47776003)(5660300001)(2950100002)(2906002)(85426001)(16586007);DIR:OUT;SFP:1101;SCL:1;SRVR:SN2PR03MB2366;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD009;1:CESpFlJIGGL+IAbf/o5Z8PIcE70XmU3xq4AC6WuIwzwvIAD7LzsBUofpxNkhcKuFUe8HOl+ueP8WrfWPgkSWHfDn7so7ZLSh9VAT0Ve1yY8XM13VUhkYxL6XfC9JHJ/p MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: caa7ad80-8140-4c04-5643-08d554230b5f X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4628075)(201703131517081)(5600026)(4604075)(2017052603307);SRVR:SN2PR03MB2366; X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB2366;3:+8sEHy5QvvBzwkEkDEFrVfFlxFaVp44vbW7o9Vl+4udMss43xFV/RiIqpdOaFgKUxV2/ittRgADQjmIyaRH3pkdbEkimk/nJVw07XJSX9v54u110Sr+JxjtmJLpafLWObWOK9I7sxzX/ufnZ7jjd152v+CaR5WdzZIppY52yycnbHsTYWnUFDejCjMp0i1ZYW7C9i/0zZqdjpLdZKNCyLZ3AEvmMREK0ACQe+4noHZvvw7LKqOw/FV9oJjiPDVhteAb57qqU0X6kusHtuibNgtokH0rlgK5yBgyFhD0w7BTMtF41jLUsYE+H3zAxb+4h0MVal5yW5x9W5i7IkbiDO4Y1cw94V4GfDXtx3E9jEIA=;25:9Xxp1aO+HJ/17+/fkvj931Uml8Fwf09BWpUEkvayxHGn2pksbuJ4W5mCdGft4uXIYvoLP4qV0Ujd68j0n5efmDnxbd7zX1IMpMZg435844Qkc3uMibZDX1dP9Fy0Tlk/9SAzNRrQzMN6A2n+l7IAI1yA0WPIhaDt4y6yyIbpbw9SiTDNpE8GVbE1LuO6BI4KdgrMDWmT/8DNdJwd+tOYrxbpf4Iw02HQxVpXALMiOUiA3vpfoT+bUTcN/TE0Vpad26hC6nH9EdVX8JMznvc1A1eD2q1iGHHQKCBAUlka7J9oCCCiuw0DQ8zJ0ow34AgZEb/fZLl6cCEhCPgThFoXzw== X-MS-TrafficTypeDiagnostic: SN2PR03MB2366: X-Microsoft-Exchange-Diagnostics: 1;SN2PR03MB2366;31:FAyxg6ErVfnRdX/Skzor4bZCrvFJ3ggQIB5f+BnWLfHpl2p0ickscss9AWj1PddCbdpXpFc+B5IPFZhElVHjMMvh/IIMGFO6Mpto+tGxXPW0Z6iTigpy3m2pLZsUSYTCz06cmYgx7Vah5pV8p0LduLCJ84g0A9E8XQj/tnxxbuMOAeuMCsVosvgXV1XJ7jwGqLF9rLecT8tKwOuelSxEFU+4kspMxh3xNHBNne6jgdI=;4:rSovD4O9F3iXIaC49D56Ec3bn5daGroOw/REFQ58ZbRyDPXUrU5FtRxZgxHqtqb7p57TA/0hFwbNtnVSKpVgZWqTS/Zstm+3vlXcBI8MqxA/p0MyGGa5Hg1nRbMZIV2oISLzNu5uwheMmtfIz6n8sefUS+/Z1nEdHdDiO7a+4cfVUozoGLjLep7WYVILUC/iMnPi05KJp/vfHLencIDo7UHr3yBjppTiNi5r5N/1YuETN7hcWNKPhNVf9NhbrW11BeMNd7QhjA8Bj5PVcvs+V25BvoZmS9e1Nwa/fsnxGOck5xk6Svt0AqZuoIjwUKKG 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)(93006095)(93001095)(10201501046)(3002001)(3231023)(944510075)(944921075)(946801075)(946901075)(6055026)(6096035)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(20161123565025)(20161123556025)(20161123561025)(20161123563025)(20161123559100)(201708071742011);SRVR:SN2PR03MB2366;BCL:0;PCL:0;RULEID:(100000803101)(100110400095)(400006);SRVR:SN2PR03MB2366; X-Forefront-PRVS: 05437568AA X-Microsoft-Exchange-Diagnostics: =?us-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QOPvIMISaLD47+wrjV77jRVO3VNAr8V00ArPd8HjuijsucZvPRlPy0KxOFwJanczRT8cIXPNRYCoyU5LUpRQRYDJ1ZZTHzgiBdKMZEcNTkWnthhDDkOtS81PrABCt1xtKD6hXoNikG1wrH10tkucjiWlP89kNH7N3JvgVAPbvjxdY0oXDuvco3TQbG572TxHMuFB0bxxtQQZPT7kH3839Si1h8 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2018 09:59:43.1839 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: caa7ad80-8140-4c04-5643-08d554230b5f 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: SN2PR03MB2366 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Synopsys STARS ticket: 90000969472(A-010131) Description: This erratum is applicable for the USB 3.0 Super Speed host mode operation. When the U2 timer expires while in U1 mode, the USB 3.0 controller completes a U1->U2 entry operation lasting three mac3_clk (24 ns). If the xHCI driver issues a U3 request during this operation, thecontroller drops this request. Impact: The controller ignores the request when the xHCI driver programs the U3 entry (PORTSC.PLS = U3). Workaround: 1. Before initiating U3 entry, save PORTPMSC. 2. Disable U2 entry by programming PORTPMSC[U2 Timeout] = h'FF. 3. After U3 entry, re-enable the U2 timer by programming PORTPMSC with the value saved in Step 1. Signed-off-by: Ran Wang --- drivers/usb/host/xhci-hub.c | 22 ++++++++++++++++++++++ drivers/usb/host/xhci-plat.c | 6 +++++- drivers/usb/host/xhci.h | 1 + 3 files changed, 28 insertions(+), 1 deletions(-) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index f070f94..a61185e 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -676,12 +676,34 @@ void xhci_set_link_state(struct xhci_hcd *xhci, __le32 __iomem **port_array, int port_id, u32 link_state) { u32 temp; + u32 portpmsc_u2_backup = 0; + + /* Backup U2 timeout info before initiating U3 entry erratum A-010131 */ + if (xhci->shared_hcd->speed >= HCD_USB3 && + link_state == USB_SS_PORT_LS_U3 && + (xhci->quirks & XHCI_DIS_U1U2_WHEN_U3)) { + portpmsc_u2_backup = readl(port_array[port_id] + PORTPMSC); + portpmsc_u2_backup &= PORT_U2_TIMEOUT_MASK; + temp = readl(port_array[port_id] + PORTPMSC); + temp |= PORT_U2_TIMEOUT_MASK; + writel(temp, port_array[port_id] + PORTPMSC); + } temp = readl(port_array[port_id]); temp = xhci_port_state_to_neutral(temp); temp &= ~PORT_PLS_MASK; temp |= PORT_LINK_STROBE | link_state; writel(temp, port_array[port_id]); + + /* Restore U2 timeout info after U3 entry complete */ + if (xhci->shared_hcd->speed >= HCD_USB3 && + link_state == USB_SS_PORT_LS_U3 && + (xhci->quirks & XHCI_DIS_U1U2_WHEN_U3)) { + temp = readl(port_array[port_id] + PORTPMSC); + temp &= ~PORT_U2_TIMEOUT_MASK; + temp |= portpmsc_u2_backup; + writel(temp, port_array[port_id] + PORTPMSC); + } } static void xhci_set_remote_wake_mask(struct xhci_hcd *xhci, diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 1969e56..616c56e 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -266,8 +266,12 @@ static int xhci_plat_probe(struct platform_device *pdev) if (device_property_read_bool(sysdev, "usb2-lpm-disable")) xhci->quirks |= XHCI_HW_LPM_DISABLE; - if (device_property_read_bool(sysdev, "usb3-lpm-capable")) + if (device_property_read_bool(sysdev, "usb3-lpm-capable")) { xhci->quirks |= XHCI_LPM_SUPPORT; + if (device_property_read_bool(sysdev, + "snps,dis-u1u2-when-u3-quirk")) + xhci->quirks |= XHCI_DIS_U1U2_WHEN_U3; + } if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped")) xhci->quirks |= XHCI_BROKEN_PORT_PED; diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index b966cd8..9704779 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1835,6 +1835,7 @@ struct xhci_hcd { /* Reserved. It was XHCI_U2_DISABLE_WAKE */ #define XHCI_ASMEDIA_MODIFY_FLOWCONTROL (1 << 28) #define XHCI_HW_LPM_DISABLE (1 << 29) +#define XHCI_DIS_U1U2_WHEN_U3 (1 << 30) unsigned int num_active_eps; unsigned int limit_active_eps; -- 1.7.1