From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 3/3] usb: Early failure when the first descriptor read fails or is invalid
Date: Tue, 07 Apr 2015 23:07:05 -0600 [thread overview]
Message-ID: <5524B779.5090308@wwwdotorg.org> (raw)
In-Reply-To: <1428153149-3738-3-git-send-email-contact@paulk.fr>
On 04/04/2015 07:12 AM, Paul Kocialkowski wrote:
> This may happen when using an USB1 device on a controller that only supports
> USB2 (e.g. EHCI). Reading the first descriptor will fail (read 0 byte), so we
> can abort the process at this point instead of failing later and wasting time.
FYI, this patch breaks USB keyboard (or perhaps any USB 1.x device)
support on the RPi.
> diff --git a/common/usb.c b/common/usb.c
> @@ -956,7 +956,7 @@ int usb_new_device(struct usb_device *dev)
> */
> #ifndef CONFIG_USB_XHCI
> err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, desc, 64);
> - if (err < 0) {
> + if (err < sizeof(struct usb_device_descriptor)) {
> debug("usb_new_device: usb_get_descriptor() failed\n");
> return -EIO;
> }
The value returned here is 8 not 18 (the sizeof the descriptor), so the
code bails out with an error.
Given the description of what this patch is attempting to achieve,
shouldn't the replacement check be:
if (err <= 0) {
My guess for why the value 8 is returned is because the device's
maxpacket is 8, and the DWC2 driver only attempts to transfer 1 packet
because the requested transfer size is 64, and the default packet size
is 64, which means 1 packet. Note that DWC2 HW (perhaps unlike e.g.
EHCI) requires the driver to specify the number of packets transferred,
not a byte count. However, I haven't validated that yet. My device is a
USB 1.x FS keyboard.
next prev parent reply other threads:[~2015-04-08 5:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-04 13:12 [U-Boot] [PATCH v3 1/3] usb: usb_new_device return codes consistency Paul Kocialkowski
2015-04-04 13:12 ` [U-Boot] [PATCH v3 2/3] usb: Check usb_new_device for failure Paul Kocialkowski
2015-04-04 13:12 ` [U-Boot] [PATCH v3 3/3] usb: Early failure when the first descriptor read fails or is invalid Paul Kocialkowski
2015-04-08 5:07 ` Stephen Warren [this message]
2015-04-08 5:41 ` Stephen Warren
2015-04-08 20:59 ` Paul Kocialkowski
2015-04-06 15:05 ` [U-Boot] [PATCH v3 1/3] usb: usb_new_device return codes consistency 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=5524B779.5090308@wwwdotorg.org \
--to=swarren@wwwdotorg.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.