From patchwork Wed Sep 20 09:24:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yinbo Zhu X-Patchwork-Id: 816107 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="VGvOW4VJ"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xxvtD4QY0z9sPs for ; Wed, 20 Sep 2017 19:42:44 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=+21h6ghWYG6dntC71eUkEeJ+6sR1AAvGDiLQQhjt23s=; b=VGvOW4VJJL3Y3+ OZ8+ubeISEHY49C0xlENX4qiStnKCKk1wly9WG0zTZ9OOsAV9Iw61hgPHqunQ5skmcT3LTlkUFwC4 bghs9bMNHTCFqjz8CiBT68Q+IkH9BvzGiNh5mUjyjqHESNNefIs6+LqSrYa+dxMjcqpX+w2zjWtil kVlDJhaEadVY3g61fV3OlNeEAfybEi7yDrgg4x5ch31x3osS/VRS8bsihQXu4AdywKTpe+YQ49rqP dL1AXbEBouTFvrfhHgt0G8M4OtzD2HUJPCakB8uzkH2Fpy3bDaomQomOV8YOpgKoysTwONm6XtCvM jjrHC3noP9jL8nDV0Y1A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dubWg-0001Ow-5t; Wed, 20 Sep 2017 09:42:38 +0000 Received: from mail-by2nam01on0085.outbound.protection.outlook.com ([104.47.34.85] helo=NAM01-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dubWb-0001J3-0N for linux-arm-kernel@lists.infradead.org; Wed, 20 Sep 2017 09:42:35 +0000 Received: from BN6PR03CA0055.namprd03.prod.outlook.com (10.173.137.17) by BN6PR03MB2689.namprd03.prod.outlook.com (10.173.144.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.11; Wed, 20 Sep 2017 09:42:08 +0000 Received: from BL2FFO11FD026.protection.gbl (2a01:111:f400:7c09::155) by BN6PR03CA0055.outlook.office365.com (2603:10b6:404:4c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.8 via Frontend Transport; Wed, 20 Sep 2017 09:42:08 +0000 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; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD026.mail.protection.outlook.com (10.173.161.105) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.35.14 via Frontend Transport; Wed, 20 Sep 2017 09:42:08 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v8K9g3RH018134; Wed, 20 Sep 2017 02:42:04 -0700 From: To: , Rob Herring , Mark Rutland , Russell King , Felipe Balbi Subject: [PATCH v1] usb: host: Implement workaround for Erratum A-007463 Date: Wed, 20 Sep 2017 17:24:41 +0800 Message-ID: <20170920092441.21292-1-yinbo.zhu@nxp.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131503741286363605; (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)(7966004)(336005)(39380400002)(376002)(346002)(39860400002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(68736007)(47776003)(551934003)(105606002)(50986999)(36756003)(4326008)(77096006)(1076002)(2876002)(50226002)(189998001)(33646002)(53936002)(6666003)(2870700001)(2906002)(86152003)(81166006)(7416002)(81156014)(8676002)(8936002)(356003)(5820100001)(23676002)(305945005)(50466002)(8656003)(110136005)(5660300001)(54906003)(97736004)(316002)(498600001)(85426001)(104016004)(106466001)(86362001)(575784001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2689; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD026; 1:5ITSnHfHfN6crVJKQL1DBBz8utrI33kzS2qWDJXEojQcuYBhXRIsGwQqFyqZJoGEXpqtqEGetqdY70pUuff/qr3tf2p5ol+L0Vl2+x/isj+2SYFVeqIoMANHdYiXVPox X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6a6663fc-6342-4f2b-31d5-08d5000bdc79 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:BN6PR03MB2689; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2689; 3:7ASQFTLpvXCNXs0SLNZ17kfBgEQg4COvDCGGU0ao5+6Ua7fJ2FPy87/r477grdA2NPGIMF6iQ4Q+2eC5z1MmN7ATpikpxDxn1WrXvh7GGO5IPWCnRwF39a4w5NnJi1Ca2Js9+ZUNynCnevRp5M9eiWUXEl7xu5mV5ADoMWr2/82t5UZlgJa/GTsLaESX2rR5mubYFpcNXF0/oJsNtj8n5/232yDjv1CFDC+iBYY1TDimu1yTQ3pFCdNMgR4+WtausHoO5GnvnU5wOUfRPQvXLVghAGsP+OHkYZdC8UN/36qGNeqB32W9Bk8BsVZn8egk6HripA0TaWQLRuo3vh0UzLIuSVOTGW+kOM7iLdqN0Ys=; 25:ah8GOAcx1DyzPXKGqwmR1NWiGzi3fTTsHPVMd1EKdKy3aBQDIIRnV2rpVC5tLkAp7Q64cEfJam7wPi5X0kFHUoc2ypDfHNQ7CFH6jhraL7oQCJ5bsjP37cWyG/9QsCvetPqJ8U5lpw6qIMo26bn5FIXEm/XaSGQ3U2+krGB2VGi9MWp5NBaZVzdeXWqhrKuBqEstZYd7x3csDR3whUhWzSMtxXpI48xi5GWlwvidxPjfjQkYxEW/ljZgIS1beDPK8JqEb1Wega4JhgAdn81NNPI9WFaApZqs3HK1eI58OCD8YEe+8hhIRYFQhWWo9nrRxsYVee8WEO403NJ1XZqutw== X-MS-TrafficTypeDiagnostic: BN6PR03MB2689: X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2689; 31:Yq/jyJkZhOCqUjP1MkMqdLKHHpiersdJti2XiIVJca3fFGyIi8bYPzuSG+ZrXlA3+JNIZMhoJ9j4YkVDYaGoZInn/J1PZ5NR18GItPMrghm/k5JVyNSsqwgmEi/DaAzai4h469Bf8sCacQK80Kl4shV0E+kcOJ+mdf5SwfUQoQ6ODWgZyyZK7z14r1InANPoRPpzWdDt8+QdlBKEF238ayvg309kECjb/DA/6aCba8w=; 4:SiBUVwOLaf4O7hnxd5W52a0iDwgP6YTHJnUDEodz8ANe/52WbRs0KzuLbAMfQP89bYzm7kxOkpMP/zXl/56Dz1U3QEw0XNbneVor6tTDNcZhatMytm9ZmB9eIqt8hzETqsx6OQRK0XXizPjUk9/UGTLLGfIZWgt0tmCgkg9KsfsP0PUQUzvtA2YWU38EvTa+dNR2LflXRNsFyX+SzKwUgOvIKS0ZZly7b/94Zg+PpT5YAOayEQuRoMlJdAIBaSMqUqB2jMjiFImVArpT6Asmd1/e08QcgQcTV7eG1W7sqqSM9Hl4bLE3DmnqxTI916+DT/XydN0XKLHh+Yv+6qEcQg== X-Exchange-Antispam-Report-Test: UriScan:(20558992708506)(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(93001095)(6055026)(6096035)(20161123563025)(20161123559100)(20161123556025)(20161123561025)(20161123565025)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR03MB2689; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR03MB2689; X-Forefront-PRVS: 04362AC73B X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BBN6PR03MB2689=3B23=3Ai6pt?= =?utf-8?q?H7+xBq0mYVaF2skgELXj0B8N9Rvy+QVi9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9Tog5FmOeQIilTA/ynAyNOfm3R9atXL6Xe+OWkwXlR/NQbkPNsT9iAkc6IqNRSYm0Kihfnxu5fi6YkzG05dpIfPXpEq3d999CgaoPzpbzV+GGWxyZpvRxeOH19BTc2VRhn0YMj2iWvCcnF6qvooL23RcC0YeRrCa0GYywK5a8yHnW2G3EIfUMKZa9rUcjWKvxArU4i9Qq6n2me4x2DEfNfG5zhoGt1dTDYnz1q83o= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2017 09:42:08.4023 (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: BN6PR03MB2689 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170920_024233_215045_CC661883 X-CRM114-Status: GOOD ( 22.93 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [104.47.34.85 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [104.47.34.85 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Mathias Nyman , Greg Kroah-Hartman , "open list:DESIGNWARE USB3 DRD IP DRIVER" , open list , "moderated list:ARM PORT" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org From: "yinbo.zhu" When a transaction error (defined in Section 4.10.2.3, "USB Transaction Error" of the xHCI Specification) occurs on the USB, the host controller reports this through a transfer event with the completion code "USB Transaction Error". When this happens, the endpoint is placed in the Halted state. In response, software must issue a Reset Endpoint command to transition the endpoint to the Stopped state. In order to restart the transfer, the driver can perform either of the following: • Ring the doorbell again, which restarts the transfer from where it stopped, or • Issue a Set TR (Transfer Ring) Dequeue Pointer command for the endpoint to start the transfer from a different Transfer Ring pointer Consider the following scenario: 1. The xHCI driver prepares a control transfer read to one of the device's control endpoints; 2. During the IN data stage, a transaction error occurs on the USB, causing a transfer event with the completion code "USB Transaction Error"; 3. The driver issues a Reset Endpoint command; 4. The driver rings the doorbell of the control endpoint to resume the transfer. In this scenario, the controller may reverse the direction of the data stage from IN to OUT. Instead of sending an ACK to the endpoint to poll for read data, it sends a Data Packet (DP) to the endpoint. It fetches the data from the data stage Transfer Request Block (TRB) that is being resumed, even though the data buffer is setup to receive data and not transmit it. NOTE This issue occurs only if the transaction error happens during an IN data stage. There is no issue if the transaction error happens during an OUT data stage. Impact: When this issue occurs, the device likely responds in one of the following ways: • The device responds with a STALL because the data stage has unexpectedly changed directions. The controller then generates a Stall Error transfer event, to which software must issue a Reset Endpoint command followed by a Set TR Dequeue Pointer command pointing to a new Setup TRB to clear the STALL condition. • The device does not respond to the inverted data stage and the transaction times out. The controller generates another USB Transaction Error transfer event, to which software likely performs a USB Reset to the device because it is unresponsive. It is not expected that any of these recovery steps will cause instability in the system because this recovery is part of a standard xHCI driver and could happen regardless of the defect. Another possible system-level impact is that the controller attempts to read from the memory location pointed at by the Data Stage TRB or a Normal TRB chained to it. associated with this TRB is intended to be written by the controller, but the controller reads from it instead. Normally, this does not cause a problem. However, if the system has some type of memory protection where this unexpected read is treated as a bus error, it may cause the system to become unstable or to crash. Workaround: If a USB Transaction Error occurs during the IN data phase of a control transfer, the driver must use the Set TR Dequeue Pointer command to either restart the data phase or restart the entire control transfer from the Setup phase. Configs Affected: LS1021-20-22A-R1.0, LS1021-20-22A-R2.007463 Signed-off-by: yinbo.zhu --- arch/arm/boot/dts/ls1021a.dtsi | 1 + drivers/usb/dwc3/core.c | 2 ++ drivers/usb/dwc3/core.h | 2 ++ drivers/usb/dwc3/host.c | 2 ++ drivers/usb/host/xhci-plat.c | 3 +++ drivers/usb/host/xhci-ring.c | 28 +++++++++++++++++++++++----- drivers/usb/host/xhci.h | 3 ++- 7 files changed, 35 insertions(+), 6 deletions(-) diff --git a/arch/arm/boot/dts/ls1021a.dtsi b/arch/arm/boot/dts/ls1021a.dtsi index 7bb9df2c1460..9f76b2b82dce 100644 --- a/arch/arm/boot/dts/ls1021a.dtsi +++ b/arch/arm/boot/dts/ls1021a.dtsi @@ -683,6 +683,7 @@ dr_mode = "host"; snps,quirk-frame-length-adjustment = <0x20>; snps,dis_rxdet_inp3_quirk; + snps,quirk_reverse_in_out; }; pcie@3400000 { diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 03474d3575ab..e6a3be9280b1 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1031,6 +1031,8 @@ static void dwc3_get_properties(struct dwc3 *dwc) &hird_threshold); dwc->usb3_lpm_capable = device_property_read_bool(dev, "snps,usb3_lpm_capable"); + dwc->quirk_reverse_in_out = device_property_read_bool(dev, + "snps,quirk_reverse_in_out"); dwc->disable_scramble_quirk = device_property_read_bool(dev, "snps,disable_scramble_quirk"); diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index ea910acb4bb0..d4b5d8e87672 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -1016,6 +1016,8 @@ struct dwc3 { unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2; + unsigned quirk_reverse_in_out:1; + u16 imod_interval; }; diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index 76f0b0df37c1..1d412390b3c9 100644 --- a/drivers/usb/dwc3/host.c +++ b/drivers/usb/dwc3/host.c @@ -101,6 +101,8 @@ int dwc3_host_init(struct dwc3 *dwc) if (dwc->usb3_lpm_capable) props[prop_idx++].name = "usb3-lpm-capable"; + if (dwc->quirk_reverse_in_out) + props[prop_idx++].name = "quirk-reverse-in-out"; /** * WORKAROUND: dwc3 revisions <=3.00a have a limitation * where Port Disable command doesn't work. diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index c04144b25a67..a55dcb1a476b 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -273,6 +273,9 @@ static int xhci_plat_probe(struct platform_device *pdev) if (device_property_read_bool(&pdev->dev, "quirk-broken-port-ped")) xhci->quirks |= XHCI_BROKEN_PORT_PED; + if (device_property_read_bool(&pdev->dev, "quirk-reverse-in-out")) + xhci->quirks |= XHCI_REVERSE_IN_OUT; + hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0); if (IS_ERR(hcd->usb_phy)) { ret = PTR_ERR(hcd->usb_phy); diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index cc368ad2b51e..02505ace0a2e 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1933,11 +1933,13 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td, union xhci_trb *ep_trb, struct xhci_transfer_event *event, struct xhci_virt_ep *ep, int *status) { + struct xhci_dequeue_state deq_state; struct xhci_virt_device *xdev; struct xhci_ep_ctx *ep_ctx; struct xhci_ring *ep_ring; unsigned int slot_id; u32 trb_comp_code; + u32 remaining; int ep_index; slot_id = TRB_TO_SLOT_ID(le32_to_cpu(event->flags)); @@ -1959,14 +1961,30 @@ static int finish_td(struct xhci_hcd *xhci, struct xhci_td *td, if (trb_comp_code == COMP_STALL_ERROR || xhci_requires_manual_halt_cleanup(xhci, ep_ctx, trb_comp_code)) { - /* Issue a reset endpoint command to clear the host side - * halt, followed by a set dequeue command to move the - * dequeue pointer past the TD. - * The class driver clears the device side halt later. + /* + * A-007463: After transaction error, controller switches + * control transfer data stage from IN to OUT direction. */ - xhci_cleanup_halted_endpoint(xhci, slot_id, ep_index, + remaining = EVENT_TRB_LEN(le32_to_cpu(event->transfer_len)); + if (remaining && xhci_requires_manual_halt_cleanup(xhci, ep_ctx, + trb_comp_code) && + (xhci->quirks & XHCI_REVERSE_IN_OUT)) { + memset(&deq_state, 0, sizeof(deq_state)); + xhci_find_new_dequeue_state(xhci, slot_id, + ep_index, td->urb->stream_id, td, &deq_state); + xhci_queue_new_dequeue_state(xhci, slot_id, ep_index, + &deq_state); + xhci_ring_cmd_db(xhci); + } else { + /* Issue a reset endpoint command to clear the host side + * halt, followed by a set dequeue command to move the + * dequeue pointer past the TD. + * The class driver clears the device side halt later. + */ + xhci_cleanup_halted_endpoint(xhci, slot_id, ep_index, ep_ring->stream_id, td, ep_trb, EP_HARD_RESET); + } } else { /* Update ring dequeue pointer */ while (ep_ring->dequeue != td->last_trb) diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index e3e935291ed6..0109965616d6 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1780,7 +1780,7 @@ struct xhci_hcd { #define XHCI_STATE_DYING (1 << 0) #define XHCI_STATE_HALTED (1 << 1) #define XHCI_STATE_REMOVING (1 << 2) - unsigned int quirks; + u64 quirks; #define XHCI_LINK_TRB_QUIRK (1 << 0) #define XHCI_RESET_EP_QUIRK (1 << 1) #define XHCI_NEC_HOST (1 << 2) @@ -1821,6 +1821,7 @@ struct xhci_hcd { #define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26) #define XHCI_U2_DISABLE_WAKE (1 << 27) #define XHCI_ASMEDIA_MODIFY_FLOWCONTROL (1 << 28) +#define XHCI_REVERSE_IN_OUT (1 << 29) unsigned int num_active_eps; unsigned int limit_active_eps;