All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lothar Waßmann" <LW@KARO-electronics.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 03/16] usb: Remove unnecessary work in usb_setup_descriptor()
Date: Fri, 30 Jun 2017 08:15:53 +0200	[thread overview]
Message-ID: <20170630081553.352a1635@karo-electronics.de> (raw)
In-Reply-To: <CAEUhbmUnEO92wmkpN52mh-vn5tU2_8qpV2rvieYH8s0aNUe1Tg@mail.gmail.com>

Hi,

On Fri, 30 Jun 2017 11:49:56 +0800 Bin Meng wrote:
> Hi,
> 
> On Fri, Jun 23, 2017 at 5:54 PM, Bin Meng <bmeng.cn@gmail.com> wrote:
> > The only work we need do in usb_setup_descriptor() is to initialize
> > dev->descriptor.bMaxPacketSize0, when do_read is false. Other steps
> > are the same as do_read being true.
> >
> > While we are here, update the comment block to be within 80 cols.
> >
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > ---
> >
> >  common/usb.c | 40 ++++++++++++++++++----------------------
> >  1 file changed, 18 insertions(+), 22 deletions(-)
> >
> > diff --git a/common/usb.c b/common/usb.c
> > index 15e1e4c..293d968 100644
> > --- a/common/usb.c
> > +++ b/common/usb.c
> > @@ -962,37 +962,33 @@ static int usb_setup_descriptor(struct usb_device *dev, bool do_read)
> >          * some more, or keeps on retransmitting the 8 byte header.
> >          */
> >
> > -       if (dev->speed == USB_SPEED_LOW) {
> > -               dev->descriptor.bMaxPacketSize0 = 8;
> > -               dev->maxpacketsize = PACKET_SIZE_8;
> > -       } else {
> > -               dev->descriptor.bMaxPacketSize0 = 64;
> > -               dev->maxpacketsize = PACKET_SIZE_64;
> > -       }
> > -       dev->epmaxpacketin[0] = dev->descriptor.bMaxPacketSize0;
> > -       dev->epmaxpacketout[0] = dev->descriptor.bMaxPacketSize0;
> > -
> >         if (do_read) {
> >                 int err;
> >
> >                 /*
> > -                * Validate we've received only at least 8 bytes, not that we've
> > -                * received the entire descriptor. The reasoning is:
> > -                * - The code only uses fields in the first 8 bytes, so that's all we
> > -                *   need to have fetched at this stage.
> > -                * - The smallest maxpacket size is 8 bytes. Before we know the actual
> > -                *   maxpacket the device uses, the USB controller may only accept a
> > -                *   single packet. Consequently we are only guaranteed to receive 1
> > -                *   packet (at least 8 bytes) even in a non-error case.
> > +                * Validate we've received only at least 8 bytes, not that
> > +                * we've received the entire descriptor. The reasoning is:
> > +                * - The code only uses fields in the first 8 bytes, so that's
> > +                *   all we need to have fetched at this stage.
> > +                * - The smallest maxpacket size is 8 bytes. Before we know
> > +                *   the actual maxpacket the device uses, the USB controller
> > +                *   may only accept a single packet. Consequently we are only
> > +                *   guaranteed to receive 1 packet (at least 8 bytes) even in
> > +                *   a non-error case.
> >                  *
> > -                * At least the DWC2 controller needs to be programmed with the number
> > -                * of packets in addition to the number of bytes. A request for 64
> > -                * bytes of data with the maxpacket guessed as 64 (above) yields a
> > -                * request for 1 packet.
> > +                * At least the DWC2 controller needs to be programmed with
> > +                * the number of packets in addition to the number of bytes.
> > +                * A request for 64 bytes of data with the maxpacket guessed
> > +                * as 64 (above) yields a request for 1 packet.
> >                  */
> >                 err = get_descriptor_len(dev, 64, 8);
> >                 if (err)
> >                         return err;
> > +       } else {
> > +               if (dev->speed == USB_SPEED_LOW)
> > +                       dev->descriptor.bMaxPacketSize0 = 8;
> > +               else
> > +                       dev->descriptor.bMaxPacketSize0 = 64;
> >         }
> >
> >         dev->epmaxpacketin[0] = dev->descriptor.bMaxPacketSize0;
> > --
> 
> For some reason that I don't understand, this patch breaks EHCI.
> dev->maxpacketsize is equal to zero with this patch, which leads to a
> 'divide error' exception in ehci_submit_async(). Not sure if anyone
> has some hints?
> 
In the do_read case the dev->descriptor.bMaxPacketSize0 is not set up.


Lothar Waßmann

  reply	other threads:[~2017-06-30  6:15 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-23  9:54 [U-Boot] [PATCH 00/16] usb: hub: Support USB 3.0 hubs Bin Meng
2017-06-23  9:54 ` [U-Boot] [PATCH 01/16] usb: xhci-pci: Drop non-DM version of xhci-pci driver Bin Meng
2017-06-23 17:51   ` Marek Vasut
2017-07-06  4:49   ` Simon Glass
2017-06-23  9:54 ` [U-Boot] [PATCH 02/16] usb: xhci-pci: Clean up the driver a little bit Bin Meng
2017-06-23 17:52   ` Marek Vasut
2017-07-06  4:49     ` Simon Glass
2017-06-23  9:54 ` [U-Boot] [PATCH 03/16] usb: Remove unnecessary work in usb_setup_descriptor() Bin Meng
2017-06-30  3:49   ` Bin Meng
2017-06-30  6:15     ` Lothar Waßmann [this message]
2017-06-30  6:19       ` Bin Meng
2017-07-01 17:29     ` stefan.bruens at rwth-aachen.de
2017-07-03  1:20       ` Bin Meng
2017-06-23  9:54 ` [U-Boot] [PATCH 04/16] usb: hub: Use 'struct usb_hub_device' as hub device's uclass_priv Bin Meng
2017-06-23 17:54   ` Marek Vasut
2017-07-06  4:49   ` Simon Glass
2017-06-23  9:54 ` [U-Boot] [PATCH 05/16] usb: hub: Add a new API to test if a hub device is root hub Bin Meng
2017-06-23 17:55   ` Marek Vasut
2017-06-28  8:27     ` Bin Meng
2017-06-23 17:57   ` Marek Vasut
2017-06-24  1:41     ` Bin Meng
2017-06-26 18:05       ` Marek Vasut
2017-06-23  9:54 ` [U-Boot] [PATCH 06/16] usb: xhci: Change to use usb_hub_is_root_hub() API Bin Meng
2017-07-06  4:49   ` Simon Glass
2017-06-23  9:54 ` [U-Boot] [PATCH 07/16] usb: hub: Translate USB 3.0 hub port status into old version Bin Meng
2017-06-23 17:59   ` Marek Vasut
2017-06-24  1:53     ` Bin Meng
2017-06-26 18:06       ` Marek Vasut
2017-06-26 23:57         ` Bin Meng
2017-06-28  8:28           ` Bin Meng
2017-06-28 17:25             ` Marek Vasut
2017-07-06  5:56               ` Bin Meng
2017-07-07  3:57                 ` Simon Glass
2017-06-23  9:54 ` [U-Boot] [PATCH 08/16] usb: hub: Support 'set hub depth' request for USB 3.0 hubs Bin Meng
2017-07-06  4:49   ` Simon Glass
2017-06-23  9:54 ` [U-Boot] [PATCH 09/16] usb: xhci: Change xhci_setup_addressable_virt_dev() signature Bin Meng
2017-07-06  4:49   ` Simon Glass
2017-06-23  9:54 ` [U-Boot] [PATCH 10/16] usb: xhci: Program 'route string' in the input slot context Bin Meng
2017-06-23 18:02   ` Marek Vasut
2017-06-24  1:57     ` Bin Meng
2017-06-26 18:07       ` Marek Vasut
2017-06-27  0:01         ` Bin Meng
2017-06-27  5:23           ` Stefan Roese
2017-06-27  8:27             ` Bin Meng
2017-06-27  8:39               ` Marek Vasut
2017-06-28 11:28               ` Stefan Roese
2017-06-28 12:27                 ` Bin Meng
2017-06-28 23:00                   ` Bin Meng
2017-06-29  5:29                     ` Stefan Roese
2017-06-29  5:42                       ` Bin Meng
2017-06-29  5:46                         ` Stefan Roese
2017-06-27  9:31             ` Marek Vasut
2017-06-27 23:22               ` Bin Meng
2017-07-07  3:57               ` Simon Glass
2017-06-23  9:54 ` [U-Boot] [PATCH 11/16] usb: hub: Parse and save TT details from device descriptor Bin Meng
2017-07-06  4:49   ` Simon Glass
2017-06-23  9:54 ` [U-Boot] [PATCH 12/16] dm: usb: Add a new USB controller operation 'update_hub_device' Bin Meng
2017-07-06  4:49   ` Simon Glass
2017-06-23  9:54 ` [U-Boot] [PATCH 13/16] usb: hub: Call usb_update_hub_device() after hub descriptor is fetched Bin Meng
2017-07-06  4:49   ` Simon Glass
2017-06-23  9:54 ` [U-Boot] [PATCH 14/16] usb: xhci: Implement update_hub_device() operation Bin Meng
2017-07-06  4:50   ` Simon Glass
2017-06-23  9:54 ` [U-Boot] [PATCH 15/16] usb: xhci: Correct TT_SLOT and TT_PORT macros Bin Meng
2017-07-06  4:50   ` Simon Glass
2017-06-23  9:54 ` [U-Boot] [PATCH 16/16] usb: xhci: Enable TT to support LS/FS devices behind a HS hub Bin Meng
2017-07-06  4:50   ` Simon Glass

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=20170630081553.352a1635@karo-electronics.de \
    --to=lw@karo-electronics.de \
    --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.