Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752270AbdLKIpG (ORCPT ); Mon, 11 Dec 2017 03:45:06 -0500 Received: from mail-eopbgr00058.outbound.protection.outlook.com ([40.107.0.58]:39282 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751307AbdLKIpA (ORCPT ); Mon, 11 Dec 2017 03:45:00 -0500 From: Yinbo Zhu To: Greg Kroah-Hartman CC: Felipe Balbi , Mathias Nyman , "open list:DESIGNWARE USB3 DRD IP DRIVER" , "open list:DESIGNWARE USB3 DRD IP DRIVER" , open list , Xiaobo Xie , Jerry Huang , Ran Wang Subject: RE: [PATCH v2] usb: host: Implement workaround for Erratum A-009611 Thread-Topic: [PATCH v2] usb: host: Implement workaround for Erratum A-009611 Thread-Index: AQHTcAyGjgXsnJgVWUy1+tsNjEwqHqM5PHCAgASXr2A= Date: Mon, 11 Dec 2017 08:44:55 +0000 Message-ID: References: <20171208094942.46748-1-yinbo.zhu@nxp.com> <20171208094942.46748-2-yinbo.zhu@nxp.com> <20171208102111.GA16245@kroah.com> In-Reply-To: <20171208102111.GA16245@kroah.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=yinbo.zhu@nxp.com; x-originating-ip: [192.158.241.86] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR04MB1501;6:HnFlhWkIK6F9ClhUSjqmkj/0m4fOMijTMvfIA1viOF/NWw563JCJHauLNBQcjpo7ifOwaqEE6Qa9U1uoPVjT04YOBgA4fK6/fQqagABLE3X7ZYkHOa7P4sF7AY3zGhlKPsnzPlRo8s4/EfHYnLx79op7EN1GiZRRPmm00z7yk0LPcD/wj2gRoLTjBJlbqmqM2AQXoRi9KWHYehIFW2vdc9YW4XlV7uQIM+h0mKOCwB2beGYz7h+RSN3OJoxEAVajcniouhmlvwVmPqzUO5BISGXxzC+t6y48ijcJqt3XpdUMRqH2DcNaQSmi/IgevOkB2SESScqKAui6w49ZYImCKuZrx7EBThaRuPTtNntYXHU=;5:II/0LMqXPRfOgmR4bQbV043mitbXOEoJU9FxRY87s8VAKVlPl30xlsblr/Vv8ZeW75FmYlLIbkJm67unS9gVZMUcPwSHHJdjNZa+Z8T3K53+r7s+rPhwm8n6nfWCg9FmcSvqbZHDaTmtJyt8aSjQiUY3ExaUD4C8L+BOIOSequk=;24:rlpUtiwjm4j/QJuJ+oJwTGyvXSPZg8tSQb9dFlvMacVZnTeSRRSqDbq45MhctOb+RE00Xj7E7FSUdVbBxMnuBqngR1suAijK6t+3CQ9EfSY=;7:wp2dmWz2P3DJAaNKZZo3YkThpBKRVVZg9nDSS9Md3zKDNsspaBlh3DhiN2qRPbOH/JRTitfMdMOj6+Bp67cpBgQ/x9oNrE3XZuBB74hkI1cdpvdIYbP+3aN5OJtBmrjD78YJTXxCqZSycsMl+BgYMUXkKeC6SAbuG96sFTkKdaV6cPo60QHQX3YowJONiVq+/+9Zx4l6VGtoeh5acLncDzNnQryMZhuHxrR0GfewA1+7xn+7lqzqBp3KY2r33roU x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10009020)(376002)(39860400002)(366004)(346002)(199004)(189003)(13464003)(50944005)(24454002)(25786009)(6916009)(102836003)(3280700002)(97736004)(53546010)(81156014)(55016002)(99286004)(305945005)(8676002)(575784001)(86362001)(2950100002)(81166006)(3846002)(2900100001)(2906002)(105586002)(68736007)(9686003)(4326008)(229853002)(478600001)(53936002)(6506006)(3660700001)(106356001)(5250100002)(33656002)(6436002)(74316002)(6116002)(316002)(66066001)(54906003)(6246003)(5660300001)(8936002)(7696005)(14454004)(59450400001)(7736002)(76176011);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB1501;H:VI1PR04MB1262.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 9a7f57e6-855e-4116-6893-08d54073744f x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307);SRVR:VI1PR04MB1501; x-ms-traffictypediagnostic: VI1PR04MB1501: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(31051911155226)(9452136761055)(185117386973197)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3231022)(3002001)(6055026)(6041248)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123558100)(20161123564025)(20161123560025)(6072148)(201708071742011);SRVR:VI1PR04MB1501;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:VI1PR04MB1501; x-forefront-prvs: 0518EEFB48 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9a7f57e6-855e-4116-6893-08d54073744f X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Dec 2017 08:44:55.8321 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB1501 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id vBB8jBqo030853 Content-Length: 7407 Lines: 183 -----Original Message----- From: Greg Kroah-Hartman [mailto:gregkh@linuxfoundation.org] Sent: Friday, December 08, 2017 6:21 PM To: Yinbo Zhu Cc: Felipe Balbi ; Mathias Nyman ; open list:DESIGNWARE USB3 DRD IP DRIVER ; open list:DESIGNWARE USB3 DRD IP DRIVER ; open list ; Xiaobo Xie ; Jerry Huang ; Ran Wang Subject: Re: [PATCH v2] usb: host: Implement workaround for Erratum A-009611 On Fri, Dec 08, 2017 at 05:49:41PM +0800, yinbo.zhu@nxp.com wrote: > From: "yinbo.zhu" > > Description: This is a occasional problem where the software >No need for a "Description:" word. That's just assumed here, right? > 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. > > Configs Affected: > LS1088-48A-R1.0, LS2081A-R1.1, LS2088-48A-R1.0, LS2088-48A-R1.1, > LX2160-2120-2080A-R1. What are these Configs? That doesn't seem to match up with anything that is in the kernel tree that I can see. > > Signed-off-by: yinbo.zhu > --- > drivers/usb/dwc3/core.c | 3 +++ > drivers/usb/dwc3/core.h | 3 +++ > drivers/usb/dwc3/host.c | 3 +++ > drivers/usb/host/xhci-plat.c | 4 ++++ > drivers/usb/host/xhci.c | 24 ++++++++++++++++++------ > 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 > 5cb3f6795b0b..071e7cea8cbb 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -1106,6 +1106,9 @@ static void dwc3_get_properties(struct dwc3 > *dwc) > > 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"); >Have you documented this new DT value somewhere? I had add some description in drivers/usb/dwc3/core.h. Is it okay? " + * @quirk_stop_transfer_in_block: prevent block transmission from being + * interrupted." > + > dwc->needs_fifo_resize = of_property_read_bool(node, > "tx-fifo-resize"); > > dwc->configure_gfladj = > diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index > 6c530cbedf49..b2425799ecb6 100644 > --- a/drivers/usb/dwc3/core.h > +++ b/drivers/usb/dwc3/core.h > @@ -900,6 +900,8 @@ struct dwc3_scratchpad_array { > * 3 - Reserved > * @disable_devinit_u1u2_quirk: disable device-initiated U1/U2 request. > * @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. > */ > @@ -1063,6 +1065,7 @@ struct dwc3 { > unsigned tx_de_emphasis:2; > unsigned disable_devinit_u1u2_quirk:1; > 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 > 2cd48633d3fa..a9ccbf1b9871 100644 > --- a/drivers/usb/dwc3/host.c > +++ b/drivers/usb/dwc3/host.c > @@ -110,6 +110,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 d1c1e882e6d7..5721d4ece625 100644 > --- a/drivers/usb/host/xhci-plat.c > +++ b/drivers/usb/host/xhci-plat.c > @@ -272,6 +272,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 > 21dd1d98508f..925c8d171c0b 100644 > --- a/drivers/usb/host/xhci.c > +++ b/drivers/usb/host/xhci.c > @@ -1515,13 +1515,25 @@ 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 + > + /* > + *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. >What is "A-009611:" mean? >Also please properly format your comments (look at other ones for examples of how to do it.) A-009611 is erratum name, about the comments that I will had a change. Thanks. > + */ > + 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 > 78d14ff0b811..bff47d6582a8 100644 > --- a/drivers/usb/host/xhci.h > +++ b/drivers/usb/host/xhci.h > @@ -1836,6 +1836,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_STOP_TRANSFER_IN_BLOCK (1 << 30) >Meta-comment, why are these not using the BIT() macro? >thanks, >greg k-h Okay , I will use the BIT() . Thanks yinbo