From: Michal Pecio <michal.pecio@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Pengfei Lv <lvpengfei20@huawei.com>,
gregkh@linuxfoundation.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
xuhaiyang5@hisilicon.com, xuetao09@huawei.com,
caiyadong@huawei.com, suzhuangluan@hisilicon.com
Subject: Re: [PATCH v3] usb: core: hub: Re-guess ep0 maxpacket size after reset
Date: Mon, 9 Nov 2026 21:34:37 +0100 [thread overview]
Message-ID: <20261109213437.5c693895.michal.pecio@gmail.com> (raw)
In-Reply-To: <3daf18d4-4936-4ed7-8846-b67f1664be13@rowland.harvard.edu>
On Mon, 9 Nov 2026 11:05:30 -0500, Alan Stern wrote:
> > diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> > index 199d3f535a89..d86bbba1457c 100644
> > --- a/drivers/usb/core/hub.c
> > +++ b/drivers/usb/core/hub.c
> > @@ -4969,31 +4969,29 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
> > }
> > oldspeed = udev->speed;
> >
> > - if (initial) {
> > - /* USB 2.0 section 5.5.3 talks about ep0 maxpacket ...
> > - * it's fixed size except for full speed devices.
> > + /* USB 2.0 section 5.5.3 talks about ep0 maxpacket ...
> > + * it's fixed size except for full speed devices.
> > + */
> > + switch (udev->speed) {
> > + case USB_SPEED_SUPER_PLUS:
> > + case USB_SPEED_SUPER:
> > + udev->ep0.desc.wMaxPacketSize = cpu_to_le16(512);
> > + break;
> > + case USB_SPEED_HIGH: /* fixed at 64 */
> > + udev->ep0.desc.wMaxPacketSize = cpu_to_le16(64);
> > + break;
> > + case USB_SPEED_FULL: /* 8, 16, 32, or 64 */
> > + /* to determine the ep0 maxpacket size, try to read
> > + * the device descriptor to get bMaxPacketSize0 and
> > + * then correct our initial guess.
> > */
> > - switch (udev->speed) {
> > - case USB_SPEED_SUPER_PLUS:
> > - case USB_SPEED_SUPER:
> > - udev->ep0.desc.wMaxPacketSize = cpu_to_le16(512);
> > - break;
> > - case USB_SPEED_HIGH: /* fixed at 64 */
> > - udev->ep0.desc.wMaxPacketSize = cpu_to_le16(64);
> > - break;
> > - case USB_SPEED_FULL: /* 8, 16, 32, or 64 */
> > - /* to determine the ep0 maxpacket size, try to read
> > - * the device descriptor to get bMaxPacketSize0 and
> > - * then correct our initial guess.
> > - */
> > - udev->ep0.desc.wMaxPacketSize = cpu_to_le16(64);
> > - break;
> > - case USB_SPEED_LOW: /* fixed at 8 */
> > - udev->ep0.desc.wMaxPacketSize = cpu_to_le16(8);
> > - break;
> > - default:
> > - goto fail;
> > - }
> > + udev->ep0.desc.wMaxPacketSize = cpu_to_le16(64);
> > + break;
> > + case USB_SPEED_LOW: /* fixed at 8 */
> > + udev->ep0.desc.wMaxPacketSize = cpu_to_le16(8);
> > + break;
> > + default:
> > + goto fail;
> > }
>
> The usb_ep0_reinit() call belongs here, right after
> udev->ep0.desc.wMaxPacketSize is set.
>
> >
> > speed = usb_speed_string(udev->speed);
> > @@ -5062,6 +5060,9 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
> > goto fail;
> > }
> >
> > + /* Sync the guessed ep0 maxpacket size to hardware if needed */
> > + usb_ep0_reinit(udev);
>
> Not here. And not inside the retry loop -- ep0_reinit should be
> called only once since the maxpacket value is changed only once.
Sashiko pointed out that xhci-hcd may not perform ep0_reinit() properly
until address_device() or enable_device() is called.
So it's either this kludge, or dependency on an xhci-hcd patch which
didn't exist until today:
https://lore.kernel.org/linux-usb/20261109112846.04bfeb0f.michal.pecio@gmail.com/
Regards,
Michal
prev parent reply other threads:[~2026-11-09 20:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 12:44 [PATCH] usb: core: hub: Re-guess ep0 maxpacket size on reset Pengfei Lv
2026-11-04 14:59 ` Alan Stern
2026-11-04 17:36 ` Michal Pecio
2026-11-05 5:06 ` Alan Stern
2026-11-05 12:30 ` Michal Pecio
2026-11-06 3:16 ` [PATCH v2] " Pengfei Lv
2026-11-06 7:17 ` Michal Pecio
2026-11-09 9:39 ` [PATCH v3] usb: core: hub: Re-guess ep0 maxpacket size after reset Pengfei Lv
2026-11-09 16:05 ` Alan Stern
2026-11-09 20:34 ` Michal Pecio [this message]
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=20261109213437.5c693895.michal.pecio@gmail.com \
--to=michal.pecio@gmail.com \
--cc=caiyadong@huawei.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=lvpengfei20@huawei.com \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=suzhuangluan@hisilicon.com \
--cc=xuetao09@huawei.com \
--cc=xuhaiyang5@hisilicon.com \
/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
all inboxes | Powered by JetHome®