{"id":814934,"url":"http://patchwork.ozlabs.org/api/patches/814934/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/1505742050-5697-7-git-send-email-bmeng.cn@gmail.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1505742050-5697-7-git-send-email-bmeng.cn@gmail.com>","list_archive_url":null,"date":"2017-09-18T13:40:42","name":"[U-Boot,06/14] usb: Only get 64 bytes device descriptor for full speed devices","commit_ref":"c008faa77358bb5b313696dd1d5bb8afa03a6ca2","pull_url":null,"state":"accepted","archived":false,"hash":"48a713bc170017f7e1ee45df06a60c4f430a1630","submitter":{"id":64981,"url":"http://patchwork.ozlabs.org/api/people/64981/?format=json","name":"Bin Meng","email":"bmeng.cn@gmail.com"},"delegate":{"id":1699,"url":"http://patchwork.ozlabs.org/api/users/1699/?format=json","username":"marex","first_name":"Marek","last_name":"Vasut","email":"marek.vasut@gmail.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/1505742050-5697-7-git-send-email-bmeng.cn@gmail.com/mbox/","series":[{"id":3647,"url":"http://patchwork.ozlabs.org/api/series/3647/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=3647","date":"2017-09-18T13:40:36","name":"usb: xhci: Add interrupt transfer support and full speed device support","version":1,"mbox":"http://patchwork.ozlabs.org/series/3647/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/814934/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/814934/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"YzYp2xb0\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwnKK3NHgz9s4s\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 23:43:49 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 4066DC21E76; Mon, 18 Sep 2017 13:40:04 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 20AD0C21F4B;\n\tMon, 18 Sep 2017 13:37:38 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 120D2C21F34; Mon, 18 Sep 2017 13:36:40 +0000 (UTC)","from mail-it0-f65.google.com (mail-it0-f65.google.com\n\t[209.85.214.65])\n\tby lists.denx.de (Postfix) with ESMTPS id 60B5CC21F39\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 13:36:37 +0000 (UTC)","by mail-it0-f65.google.com with SMTP id u2so544143itb.2\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 06:36:37 -0700 (PDT)","from ala-d2121-lx1.wrs.com (unknown-156-139.windriver.com.\n\t[147.11.156.139]) by smtp.gmail.com with ESMTPSA id\n\t193sm2528740ion.83.2017.09.18.06.36.34\n\t(version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tMon, 18 Sep 2017 06:36:35 -0700 (PDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.0 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=3FUFFFO7oo3ARqJCKdq4Tt1iq1WXnp6uJt/TFBE50dk=;\n\tb=YzYp2xb0O1iWa0JMQxngUc4bKrmA4vS8TYzt0cChvYWpNbOxraWxUaozWn8eKCLDLS\n\t20xpOyhoPtvtv4wwmM3Ak5aVm/1V1a1+Z1LS4kL/UPsDOvgcBm6k3E2KheSPy3xZDBzx\n\tNgIs2z+Ttgl3RRxiN+KG3K1tCHupHK9YW9bnsYOUHN4zy9+FJvl80x5DDOh0Fo58eX9y\n\tmfuX17TKO3H/YnVSgi0AmBJB7USTlI9TqrS7MdWwTq+Z45ami0Wz+hYM8A9wVLk5VOQS\n\tM5bGZXr1PlbtqhqssPEFKFQ/x954t3ZfnKeCylG+rKZV8lcYxcnfC4LgAq6WELu8tnFe\n\ttDow==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=3FUFFFO7oo3ARqJCKdq4Tt1iq1WXnp6uJt/TFBE50dk=;\n\tb=jl/9gShNRcy9aPI8P80Gp8xPHO4Y/dDOC9m1nIIb4F5qDUf3H4B4kJTRNmYOmpwxkb\n\t8VWqOPKPWj1urSKmTeeUugkwMoFskxGRL0ZsHZFFje0SKZUo929ZusBld44azkY1yV7e\n\t/z+lZyc0ljLSGZe357QUwgxKlDmFhWGrs1v0ecG0ohmzurkcuAA5Jchx7kZJUPT0lhMo\n\thnZh/RwZ/DG5FyB6koqrcGcWSRl6bnKMwVlrQygsaXYtHyenQLzToS0clyYQmzTtfZ6m\n\tn5VizDs0ODcFmV4jIq8guagH5seSLytoWMJPe9UxMRQpGsw/MWix64ksxm4gLpxLQj87\n\tf0hQ==","X-Gm-Message-State":"AHPjjUie+ZlOYtw7Yp80wVi8eLjCDAhVTcHG5VLkjEXdgPfG68RpxF3/\n\t4A8bQeKFUp5yI4sAMGyZ3BAn3w==","X-Google-Smtp-Source":"AOwi7QACp2UYgPkBrdhUK0XuvWJRRXpzVPuIORcLgv92It4mVKJd6yWbkMW31nB4fLLlJuR9aLANVQ==","X-Received":"by 10.36.81.71 with SMTP id s68mr15314736ita.90.1505741796289;\n\tMon, 18 Sep 2017 06:36:36 -0700 (PDT)","From":"Bin Meng <bmeng.cn@gmail.com>","To":"Marek Vasut <marex@denx.de>, U-Boot Mailing List <u-boot@lists.denx.de>","Date":"Mon, 18 Sep 2017 06:40:42 -0700","Message-Id":"<1505742050-5697-7-git-send-email-bmeng.cn@gmail.com>","X-Mailer":"git-send-email 1.7.9.5","In-Reply-To":"<1505742050-5697-1-git-send-email-bmeng.cn@gmail.com>","References":"<1505742050-5697-1-git-send-email-bmeng.cn@gmail.com>","Cc":"Stefan Roese <sr@denx.de>","Subject":"[U-Boot] [PATCH 06/14] usb: Only get 64 bytes device descriptor for\n\tfull speed devices","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"Full speed device endpoint 0 can have 8/16/32/64 bMaxPacketSize0.\nOther speed devices report fixed value per USB spec. So it only\nmakes sense if we send a get device descriptor with 64 bytes to\nfull speed devices.\n\nWhile we are here, update the comment block to be within 80 cols.\n\nSigned-off-by: Bin Meng <bmeng.cn@gmail.com>\n---\n\n common/usb.c | 29 +++++++++++++++--------------\n 1 file changed, 15 insertions(+), 14 deletions(-)","diff":"diff --git a/common/usb.c b/common/usb.c\nindex 6cb92ef..88cee81 100644\n--- a/common/usb.c\n+++ b/common/usb.c\n@@ -970,23 +970,24 @@ static int usb_setup_descriptor(struct usb_device *dev, bool do_read)\n \tdev->epmaxpacketin[0] = dev->descriptor.bMaxPacketSize0;\n \tdev->epmaxpacketout[0] = dev->descriptor.bMaxPacketSize0;\n \n-\tif (do_read) {\n+\tif (do_read && dev->speed == USB_SPEED_FULL) {\n \t\tint err;\n \n \t\t/*\n-\t\t * Validate we've received only at least 8 bytes, not that we've\n-\t\t * received the entire descriptor. The reasoning is:\n-\t\t * - The code only uses fields in the first 8 bytes, so that's all we\n-\t\t *   need to have fetched at this stage.\n-\t\t * - The smallest maxpacket size is 8 bytes. Before we know the actual\n-\t\t *   maxpacket the device uses, the USB controller may only accept a\n-\t\t *   single packet. Consequently we are only guaranteed to receive 1\n-\t\t *   packet (at least 8 bytes) even in a non-error case.\n+\t\t * Validate we've received only at least 8 bytes, not that\n+\t\t * we've received the entire descriptor. The reasoning is:\n+\t\t * - The code only uses fields in the first 8 bytes, so\n+\t\t *   that's all we need to have fetched at this stage.\n+\t\t * - The smallest maxpacket size is 8 bytes. Before we know\n+\t\t *   the actual maxpacket the device uses, the USB controller\n+\t\t *   may only accept a single packet. Consequently we are only\n+\t\t *   guaranteed to receive 1 packet (at least 8 bytes) even in\n+\t\t *   a non-error case.\n \t\t *\n-\t\t * At least the DWC2 controller needs to be programmed with the number\n-\t\t * of packets in addition to the number of bytes. A request for 64\n-\t\t * bytes of data with the maxpacket guessed as 64 (above) yields a\n-\t\t * request for 1 packet.\n+\t\t * At least the DWC2 controller needs to be programmed with\n+\t\t * the number of packets in addition to the number of bytes.\n+\t\t * A request for 64 bytes of data with the maxpacket guessed\n+\t\t * as 64 (above) yields a request for 1 packet.\n \t\t */\n \t\terr = get_descriptor_len(dev, 64, 8);\n \t\tif (err)\n@@ -1009,7 +1010,7 @@ static int usb_setup_descriptor(struct usb_device *dev, bool do_read)\n \t\tdev->maxpacketsize = PACKET_SIZE_64;\n \t\tbreak;\n \tdefault:\n-\t\tprintf(\"usb_new_device: invalid max packet size\\n\");\n+\t\tprintf(\"%s: invalid max packet size\\n\", __func__);\n \t\treturn -EIO;\n \t}\n \n","prefixes":["U-Boot","06/14"]}