From: Chin Liang See <clsee@altera.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] usb: dwc2: Enhance interrupt handling for CONTROL transaction
Date: Tue, 5 Jan 2016 13:00:04 +0800 [thread overview]
Message-ID: <1451970004-2344-1-git-send-email-clsee@altera.com> (raw)
Per DesignWare USB OTG databook, driver should retry up to
3 times when transaction error (hcint.xacterr) happen. But
the 3 times doesn't count when the response is nack
(hcint.nak) or frame overrun (hcint.frmoverun)
This patch solved the enumeration error as spotted at socfpga
cyclone5_socdk when plugging in certain pendrive.
Signed-off-by: Chin Liang See <clsee@altera.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
Cc: Dinh Nguyen <dinh.linux@gmail.com>
Cc: Pavel Machek <pavel@denx.de>
Cc: Oleksandr Tymoshenko <gonzo@bluezbox.com>
Cc: Stephen Warren <swarren@wwwdotorg.org>
Cc: Alexander Stein <alexanders83@web.de>
Cc: Peter Griffin <peter.griffin@linaro.org>
---
drivers/usb/host/dwc2.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index 541c0f9..f00cd1b 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -786,15 +786,12 @@ int chunk_msg(struct dwc2_priv *priv, struct usb_device *dev,
uint32_t xfer_len;
uint32_t num_packets;
int stop_transfer = 0;
+ int error_retry_count = 0;
debug("%s: msg: pipe %lx pid %d in %d len %d\n", __func__, pipe, *pid,
in, len);
do {
- /* Initialize channel */
- dwc_otg_hc_init(regs, DWC2_HC_CHANNEL, dev, devnum, ep, in,
- eptype, max);
-
xfer_len = len - done;
if (xfer_len > CONFIG_DWC2_MAX_TRANSFER_SIZE)
xfer_len = CONFIG_DWC2_MAX_TRANSFER_SIZE - max + 1;
@@ -818,6 +815,14 @@ int chunk_msg(struct dwc2_priv *priv, struct usb_device *dev,
debug("%s: chunk: pid %d xfer_len %u pkts %u\n", __func__,
*pid, xfer_len, num_packets);
+ /* per DW spec, we can retry up to 3 times */
+ error_retry_count = 3;
+
+error_retry:
+ /* Initialize channel */
+ dwc_otg_hc_init(regs, DWC2_HC_CHANNEL, dev, devnum, ep, in,
+ eptype, max);
+
writel((xfer_len << DWC2_HCTSIZ_XFERSIZE_OFFSET) |
(num_packets << DWC2_HCTSIZ_PKTCNT_OFFSET) |
(*pid << DWC2_HCTSIZ_PID_OFFSET),
@@ -841,8 +846,14 @@ int chunk_msg(struct dwc2_priv *priv, struct usb_device *dev,
DWC2_HCCHAR_CHEN);
ret = wait_for_chhltd(regs, &sub, pid, ignore_ack);
- if (ret)
- break;
+ if (ret) {
+ if (ret == -EINVAL)
+ error_retry_count--;
+ if (error_retry_count)
+ goto error_retry;
+ else
+ break;
+ }
if (in) {
xfer_len -= sub;
--
1.9.2.468.g3f0c02a
next reply other threads:[~2016-01-05 5:00 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-05 5:00 Chin Liang See [this message]
2016-01-05 14:36 ` [U-Boot] [PATCH] usb: dwc2: Enhance interrupt handling for CONTROL transaction Marek Vasut
2016-01-05 15:51 ` Chin Liang See
2016-01-05 16:16 ` Marek Vasut
2016-01-13 2:58 ` Marek Vasut
2016-01-13 15:18 ` Chin Liang See
2016-01-13 15:22 ` Marek Vasut
2016-01-14 14:50 ` Chin Liang See
2016-01-14 15:20 ` Marek Vasut
2016-02-04 11:42 ` Marek Vasut
2016-02-19 9:11 ` Chin Liang See
2016-02-19 15:16 ` Marek Vasut
2016-01-10 11:56 ` [U-Boot] usb: dwc2: does not compile in 2016-rc3 when updating from -rc1 Pavel Machek
2016-01-10 12:04 ` Pavel Machek
2016-01-10 13:45 ` Marek Vasut
2016-01-10 17:50 ` Pavel Machek
2016-01-10 18:13 ` Marek Vasut
2016-01-10 18:39 ` [U-Boot] Are non-default configurations expected to work? " Pavel Machek
2016-01-10 18:42 ` Marek Vasut
2016-01-10 19:04 ` Tom Rini
2016-01-10 19:06 ` Marek Vasut
2016-01-10 19:16 ` Tom Rini
2016-01-10 19:18 ` Marek Vasut
2016-01-10 19:28 ` Tom Rini
2016-01-10 19:40 ` Marek Vasut
2016-01-10 20:11 ` Tom Rini
2016-01-10 20:18 ` Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1451970004-2344-1-git-send-email-clsee@altera.com \
--to=clsee@altera.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox